Discord server count on my website

I have 2 projects one for my discord bot and another for my website here.
I want to get my server count on my website and i don’t know how, i think it need to be used with post or get methods but i don’t know how to use them at all.
as well i can’t get package.json on my website project because i’m a noob when it comes to what needs to be written there.

at a high level what it sound like you’ll want to do is:

  1. add something like discord.js to your package.json
  2. in your server.js file use/modify the instructions on https://discord.js.org to get your user count
  3. in your server.js use express to render a template view, passing that user count as a variable to the template (there’s lots of examples on glitch of projects using handlebars, etc.)
  4. then in your template file, print the variable you’ve passed in

There are a lot of great tutorials and answers on google and stack overflow that’ll run you through the specifics of things like rendering views with express. Good luck! And feel free to post followup questions

I created you a simple bot which should do exactly what you want. All you have to do is send a GET request to the domain and it will return a .JSON object that should tell you the amount of servers the bot is in. Sorry for the messy code, take a look at it here.

1 Like