diff --git a/.env.example b/.env.example index 23280dce..46f8022a 100644 --- a/.env.example +++ b/.env.example @@ -14,6 +14,7 @@ JOIN_LEAVE_CHANNEL_ID= APRIL_FOOLS= # Bot list tokens +TOP_GG_TOKEN= BOTS_GG_TOKEN= DISCORDBOTLIST_TOKEN= diff --git a/Xiao.js b/Xiao.js index 401fca85..e23fdd74 100644 --- a/Xiao.js +++ b/Xiao.js @@ -183,9 +183,11 @@ client.on('ready', async () => { } // Post bot list stats + await client.postTopGGStats(); await client.postBotsGGStats(); await client.postDiscordBotListStats(); setInterval(() => { + client.postTopGGStats(); client.postBotsGGStats(); client.postDiscordBotListStats(); }, 1.8e+6); diff --git a/structures/Client.js b/structures/Client.js index edbb110a..fdb1801b 100644 --- a/structures/Client.js +++ b/structures/Client.js @@ -20,6 +20,7 @@ const { XIAO_WEBHOOK_TOKEN, REPORT_CHANNEL_ID, JOIN_LEAVE_CHANNEL_ID, + TOP_GG_TOKEN, BOTS_GG_TOKEN, DISCORDBOTLIST_TOKEN } = process.env; @@ -62,7 +63,23 @@ module.exports = class XiaoClient extends CommandoClient { return this.fonts; } + async postTopGGStats() { + if (!TOP_GG_TOKEN) return null; + try { + const { body } = await request + .post(`https://top.gg/api/bots/${this.user.id}/stats`) + .set({ Authorization: TOP_GG_TOKEN }) + .send({ server_count: this.guilds.cache.size }); + this.logger.info('[TOP.GG] Posted stats.'); + return body; + } catch (err) { + this.logger.error(`[TOP.GG] Failed to post stats:\n${err.stack}`); + return err; + } + } + async postBotsGGStats() { + if (!BOTS_GG_TOKEN) return null; try { const { body } = await request .post(`https://discord.bots.gg/api/bots/${this.user.id}/stats`) @@ -77,6 +94,7 @@ module.exports = class XiaoClient extends CommandoClient { } async postDiscordBotListStats() { + if (!DISCORDBOTLIST_TOKEN) return null; try { const { body } = await request .post(`https://discordbotlist.com/api/v1/bots/${this.user.id}/stats`)