POST stats to DiscordBotList using axios

Free lines JavaScript 1 revisions 783 2 years ago 2 years 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}`,

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.