mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-03 15:07:42 +02:00
Add DiscordBotList Stats
This commit is contained in:
@@ -15,6 +15,7 @@ APRIL_FOOLS=
|
||||
|
||||
# Bot list tokens
|
||||
BOTS_GG_TOKEN=
|
||||
DISCORDBOTLIST_TOKEN=
|
||||
|
||||
# Redis info
|
||||
REDIS_HOST=
|
||||
|
||||
@@ -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
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user