From ad855b3f29454ad49435507c39e4b8bcf801c430 Mon Sep 17 00:00:00 2001 From: Dragon Fire Date: Fri, 23 Apr 2021 12:45:00 -0400 Subject: [PATCH] Add Blist Stats --- .env.example | 1 + structures/Client.js | 18 +++++++++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/.env.example b/.env.example index 2905fc33..b80efbc6 100644 --- a/.env.example +++ b/.env.example @@ -18,6 +18,7 @@ TOP_GG_TOKEN= BOTS_GG_TOKEN= DISCORDBOTLIST_TOKEN= CARBON_TOKEN= +BLIST_TOKEN= # Redis info REDIS_HOST= diff --git a/structures/Client.js b/structures/Client.js index 8388d5a6..9c0f0c28 100644 --- a/structures/Client.js +++ b/structures/Client.js @@ -23,7 +23,8 @@ const { TOP_GG_TOKEN, BOTS_GG_TOKEN, DISCORDBOTLIST_TOKEN, - CARBON_TOKEN + CARBON_TOKEN, + BLIST_TOKEN } = process.env; module.exports = class XiaoClient extends CommandoClient { @@ -131,6 +132,21 @@ module.exports = class XiaoClient extends CommandoClient { } } + async postBlistStats() { + if (!BLIST_TOKEN) return null; + try { + const { body } = await request + .patch(`https://blist.xyz/api/v2/bot/${this.user.id}/stats/`) + .set({ Authorization: BLIST_TOKEN }) + .send({ server_count: this.guilds.cache.size }); + this.logger.info('[BLIST] Posted stats.'); + return body; + } catch (err) { + this.logger.error(`[BLIST] Failed to post stats:\n${err.stack}`); + return err; + } + } + importBlacklist() { const read = fs.readFileSync(path.join(__dirname, '..', 'blacklist.json'), { encoding: 'utf8' }); const file = JSON.parse(read);