#Accessing bot statistics or information through an external site
15 messages · Page 1 of 1 (latest)
• What's your exact discord.js npm list discord.js and node node -v version?
• Post the full error stack trace, not just the top part!
• Show your code!
• Explain what exactly your issue is.
• Not a discord.js issue? Check out #useful-servers.
node version: >=16.6.0"
djs version: 13.3.1
<Client>.guilds.cache.size exists, yes
I mean from outside of the bot. I have an api endpoint set up on an external site, is there a way for me to access my bot and it's information from an external api endpoint?
Like, an app that isn't the one running the bot
you can start another bot
and get the info you want
if you really don't want to access the bot
Or write your own API that you can query inside your bot’s code
^^
just create the front end in your bots current work directory ez
Reading the docs and my own source code i see that we use @discordjs/rest and execute rest.put to deploy the commands to discord. isn't there a rest.get command i could use for getting my bot's information?
Not really… and you‘d need to put your bot‘s token into your API for that to work. And then you could also just login to the bot from there directly…
For anyone who happens to get stuck with this issue:
After digging through the rest api docs i was able to call the api and access the user data of my bot by supplying it's token in the auth header.
E.g.
await fetch('https://discord.com/api/v10/users/@me/guilds',
{
method: 'GET',
Authorization: `Bot ${BOT_TOKEN}`
} );
Not sure if this is the best way to go about it, but it worked for me