Home > front end >  How to connect a discord bot to a website
How to connect a discord bot to a website

Time:10-21

Hey i am new to web development i have a question how i can connect my discord bot to my html website i dont need dashboard i just need to show many server my bot is in, in my website how i can do this and which backend language i should use? and can anyone say which is the beast backend language for web development i am new to this stuff. Thanks in advance happy coding

my html

<!DOCTYPE html>
<html>
   <head>
      <div class="topnav">
         <a class="active" href="#home">Home</a>
         <a href="#news">News</a>
         <a href="#contact">Contact</a>
         <a href="#about">About</a>
       </div>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="style.css">
      <title>Beast Bot</title>
   </head>  
   <body>
      <div class="container">
        <div class="title">
           <P>Beast Bot :)</P>

              <img class="img" src="images/kisspng-portable-network-graphics-computer-icons-transpare-braingoodgames-5c9d9c5093e378.8617067815538330406058.png">

        </div>

    </div>
      </div>

   </body>  
</html>

CodePudding user response:

I would use client.guilds.size to get the amount of servers it's in. Assuming the web server and the bot are on the same server then, I would write the raw count of the amount of servers it's in to a file that the public can access from a browser.

Using JQuery (by adding <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script> to your head) you can do a GET request to the publicly accessible URL that has that number, like this:

$.get("/path/to/data", data => {
  // your code here to display it, the data var will have the page's content
})

CodePudding user response:

You can use an API to fetch data from your bot's backend. Frameworks like express.js are great for making a REST API from scratch.

  • Related