diff --git a/.env.example b/.env.example index 4ec6a556..0f49aeb1 100644 --- a/.env.example +++ b/.env.example @@ -10,6 +10,9 @@ XIAO_WEBHOOK_TOKEN= REPORT_CHANNEL_ID= JOIN_LEAVE_CHANNEL_ID= +# Bot list tokens +BOTS_GG_TOKEN= + # Redis info REDIS_HOST= REDIS_PASS= diff --git a/Xiao.js b/Xiao.js index 2b530a1e..00c2f211 100644 --- a/Xiao.js +++ b/Xiao.js @@ -147,6 +147,10 @@ client.on('ready', async () => { } catch (err) { client.logger.error(`[ADULT SITES] Failed to fetch list\n${err.stack}`); } + + // Post bot list stats + await client.postBotsGGStats(); + setInterval(() => client.postBotsGGStats(), 1.8e+6); }); client.on('message', async msg => { diff --git a/commands/util-public/info.js b/commands/util-public/info.js index 3d454ee3..93fffd0f 100644 --- a/commands/util-public/info.js +++ b/commands/util-public/info.js @@ -33,7 +33,8 @@ module.exports = class InfoCommand extends Command { .addField('❯ Home Server', this.client.options.invite ? embedURL('Invite', this.client.options.invite) : 'None', true) .addField('❯ Invite', embedURL('Add Me', invite), true) - .addField('❯ Top.gg', embedURL('Vote!', `https://top.gg/bot/${this.client.user.id}`), true) + .addField('❯ Bot List', + embedURL('discord.bots.gg', `https://discord.bots.gg/bots/${this.client.user.id}`), true) .addField('❯ Memory Usage', `${Math.round(process.memoryUsage().heapUsed / 1024 / 1024)}MB`, true) .addField('❯ Uptime', moment.duration(this.client.uptime).format('d:hh:mm:ss'), true) .addField('❯ Version', `v${version}`, true) diff --git a/structures/Client.js b/structures/Client.js index 5311053f..27033951 100644 --- a/structures/Client.js +++ b/structures/Client.js @@ -17,7 +17,8 @@ const { XIAO_WEBHOOK_ID, XIAO_WEBHOOK_TOKEN, REPORT_CHANNEL_ID, - JOIN_LEAVE_CHANNEL_ID + JOIN_LEAVE_CHANNEL_ID, + BOTS_GG_TOKEN } = process.env; module.exports = class XiaoClient extends CommandoClient { @@ -57,6 +58,19 @@ module.exports = class XiaoClient extends CommandoClient { return this.fonts; } + async postBotsGGStats() { + try { + const { body } = await request + .post(`https://discord.bots.gg/api/bots/${this.user.id}/stats`) + .set({ Authorization: BOTS_GG_TOKEN }) + .send({ guildCount: this.guilds.size }); + this.logger.info('[BOTS.GG] Posted stats.'); + return body; + } catch (err) { + this.logger.error(`[BOTS.GG] Failed to post stats:\n${err.stack}`); + } + } + importBlacklist() { const read = fs.readFileSync(path.join(__dirname, '..', 'blacklist.json'), { encoding: 'utf8' }); const file = JSON.parse(read);