Add DiscordBotList Stats

This commit is contained in:
Dragon Fire
2021-04-16 07:18:19 -04:00
parent eaa9b89235
commit 0fb0901053
3 changed files with 28 additions and 5 deletions
+1
View File
@@ -15,6 +15,7 @@ APRIL_FOOLS=
# Bot list tokens # Bot list tokens
BOTS_GG_TOKEN= BOTS_GG_TOKEN=
DISCORDBOTLIST_TOKEN=
# Redis info # Redis info
REDIS_HOST= REDIS_HOST=
+5 -1
View File
@@ -184,7 +184,11 @@ client.on('ready', async () => {
// Post bot list stats // Post bot list stats
await client.postBotsGGStats(); await client.postBotsGGStats();
setInterval(() => client.postBotsGGStats(), 1.8e+6); await client.postDiscordBotListStats();
setInterval(() => {
client.postBotsGGStats();
client.postDiscordBotListStats();
}, 1.8e+6);
}); });
client.on('message', async msg => { client.on('message', async msg => {
+22 -4
View File
@@ -20,7 +20,8 @@ const {
XIAO_WEBHOOK_TOKEN, XIAO_WEBHOOK_TOKEN,
REPORT_CHANNEL_ID, REPORT_CHANNEL_ID,
JOIN_LEAVE_CHANNEL_ID, JOIN_LEAVE_CHANNEL_ID,
BOTS_GG_TOKEN BOTS_GG_TOKEN,
DISCORDBOTLIST_TOKEN
} = process.env; } = process.env;
module.exports = class XiaoClient extends CommandoClient { module.exports = class XiaoClient extends CommandoClient {
@@ -64,9 +65,13 @@ module.exports = class XiaoClient extends CommandoClient {
async postBotsGGStats() { async postBotsGGStats() {
try { try {
const { body } = await request const { body } = await request
.post(`https://discord.bots.gg/api/bots/${this.user.id}/stats`) .post(`https://discordbotlist.com/api/v1/bots/${this.user.id}/stats`)
.set({ Authorization: BOTS_GG_TOKEN }) .set({ Authorization: DISCORDBOTLIST_TOKEN })
.send({ guildCount: this.guilds.size }); .send({
guilds: this.guilds.size,
users: this.users.size,
voice_connections: this.dispatchers.size
});
this.logger.info('[BOTS.GG] Posted stats.'); this.logger.info('[BOTS.GG] Posted stats.');
return body; return body;
} catch (err) { } catch (err) {
@@ -75,6 +80,19 @@ module.exports = class XiaoClient extends CommandoClient {
} }
} }
async postDiscordBotListStats() {
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('[DISCORDBOTLIST] Posted stats.');
} catch (err) {
this.logger.error(`[DISCORDBOTLIST] Failed to post stats:\n${err.stack}`);
return err;
}
}
importBlacklist() { importBlacklist() {
const read = fs.readFileSync(path.join(__dirname, '..', 'blacklist.json'), { encoding: 'utf8' }); const read = fs.readFileSync(path.join(__dirname, '..', 'blacklist.json'), { encoding: 'utf8' });
const file = JSON.parse(read); const file = JSON.parse(read);