1

Post Discord bot status to discordbotlist.com

Free lines JavaScript 1 revisions 143 2 months ago 2 months ago
    const request = require('node-superfetch');
    try {
      console.log('Updating discordbotlist.com stats')

      await request
        .post(`https://discordbotlist.com/api/bots/${this.client.user.id}/stats`)
        .set("Authorization", `Bot ${process.env.DBLORGTOKEN}`)
        .send({
            shard_id: 0,
            guilds: this.client.guilds.size,
            users: this.client.users.size,
            voice_connections: this.client.voice.connections.size
        })

      console.log('Updated discordbotlist.com stats')
    } catch(O_o) {
      console.error(O_o)
    }

This is a code snippet to be used in the ready event for your Discord.JS bot. Rather than using snekfetch, it uses node-superfetch, a module that is not deprecated.

Unless you use an event handler, change every this.client to the bot variable. Replace process.env.DBLORGTOKEN with your DiscordBotList.com token

If you don't use Discord.js v12, replace this.client.voice.connections.size with this.client.voiceConnections.size

Credits to NightYoshi370 who made this and Dragon_Fire for making node-superfetch and helping me