Script to update bots.gg stats

This commit is contained in:
Supositware 2022-10-10 20:18:14 +02:00
parent 118954f795
commit 0ae54bbbca
2 changed files with 33 additions and 1 deletions

View file

@ -10,4 +10,6 @@ twiConsumerSecret=TwitterConsumerSecretToken
twiToken=TwitterToken twiToken=TwitterToken
twiTokenSecret=TwitterSecretToken twiTokenSecret=TwitterSecretToken
twiChannel=ChannelWhereJustTheTwitterLinkAreSent twiChannel=ChannelWhereJustTheTwitterLinkAreSent
twiLogChannel=ChannelWhereTheDetailedInfoOfTheCommandIsSent twiLogChannel=ChannelWhereTheDetailedInfoOfTheCommandIsSent
botsggToken=APITokenForBots.gg
botsggEndpoint=https://discord.bots.gg/api/v1

View file

@ -0,0 +1,30 @@
import dotenv from 'dotenv';
import fetch from 'node-fetch';
import { Client, GatewayIntentBits } from 'discord.js';
dotenv.config();
const { botsggToken, botsggEndpoint, token } = process.env;
const client = new Client({
intents: [GatewayIntentBits.Guilds],
});
await client.login(token);
const body = {
guildCount: client.guilds.cache.size,
};
console.log(body);
const response = await fetch(`${botsggEndpoint}/bots/${client.user.id}/stats`, {
method: 'post',
body: JSON.stringify(body),
headers: { 'Authorization': botsggToken, 'Content-Type': 'application/json' },
});
const data = await response.json();
console.log(data);
process.exit();