Post Discord bot status to discordbotlist.com

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

      await request
        .set("Authorization", `Bot ${process.env.DBLORGTOKEN}`)
            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) {

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