0

POST stats to DiscordBotList using axios

Free lines JavaScript 1 revisions 65 a month ago a month ago
// Let's assume `bot` is a djs thing

console.log('Updating DBL stats');

axios.post(`https://discordbotlist.com/api/bots/${process.env.BOT_ID}/stats`, {
    shard_id: 0,
    guilds: bot.guilds.size,
    users: bot.users.size,
    voice_connections: bot.voiceConnections.size,
}, {
    headers: {
        Authorization: `Bot ${process.env.DBL_TOKEN}`,
    }
}).catch(console.error);

This is an example of how to POST statistics to DiscordBotList. It uses axios to make the HTTP request.

It assumes DBL_TOKEN is an environment variable which is the token provided from DiscordBotList, and BOT_ID being the bot ID provided by Discord itself.