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
BOTS_GG_TOKEN=
DISCORDBOTLIST_TOKEN=
# Redis info
REDIS_HOST=
+5 -1
View File
@@ -184,7 +184,11 @@ client.on('ready', async () => {
// Post bot list stats
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 => {
+22 -4
View File
@@ -20,7 +20,8 @@ const {
XIAO_WEBHOOK_TOKEN,
REPORT_CHANNEL_ID,
JOIN_LEAVE_CHANNEL_ID,
BOTS_GG_TOKEN
BOTS_GG_TOKEN,
DISCORDBOTLIST_TOKEN
} = process.env;
module.exports = class XiaoClient extends CommandoClient {
@@ -64,9 +65,13 @@ module.exports = class XiaoClient extends CommandoClient {
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 });
.post(`https://discordbotlist.com/api/v1/bots/${this.user.id}/stats`)
.set({ Authorization: DISCORDBOTLIST_TOKEN })
.send({
guilds: this.guilds.size,
users: this.users.size,
voice_connections: this.dispatchers.size
});
this.logger.info('[BOTS.GG] Posted stats.');
return body;
} 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() {
const read = fs.readFileSync(path.join(__dirname, '..', 'blacklist.json'), { encoding: 'utf8' });
const file = JSON.parse(read);