From ae496db91138d5b58ab98937c7bb0c61dfbfdc1c Mon Sep 17 00:00:00 2001 From: Abheek Dhawan Date: Mon, 28 Jun 2021 17:59:23 -0500 Subject: [PATCH] Attempt to update Top.gg server count on guild join and remove --- bot/awesomescibo.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/bot/awesomescibo.js b/bot/awesomescibo.js index 3ccb950..f04cdea 100755 --- a/bot/awesomescibo.js +++ b/bot/awesomescibo.js @@ -12,6 +12,7 @@ const userScore = require("./mongooseModels/mongooseUserScoreModel.js"); const generatedRound = require("./mongooseModels/mongooseGeneratedRoundModel.js"); const mongoose = require("mongoose"); const gitlog = require("gitlog").default; +const config = require("./config.json"); const helpMessage = "AwesomeSciBo has migrated to using slash commands! You can take a look at the different commands by typing `/` and clicking on the AwesomeSciBo icon." @@ -114,6 +115,12 @@ client.once("ready", () => { }); client.on("guildCreate", (guild) => { + const topggAuthHeader = { + headers: { + 'Authorization': config.topggauth + } + }; + axios.post(`https://top.gg/api/bots/${client.user.id}/stats`, { server_count: client.guilds.cache.size }, topggAuthHeader); //guild.commands.set(slashCommands); const welcomeChannel = guild.channels.cache .find( @@ -127,6 +134,15 @@ client.on("guildCreate", (guild) => { } }); +client.on("guildDelete", guild => { + const topggAuthHeader = { + headers: { + 'Authorization': config.topggauth + } + }; + axios.post(`https://top.gg/api/bots/${client.user.id}/stats`, { server_count: client.guilds.cache.size }, topggAuthHeader); +}); + async function updateScore(isCorrect, score, authorId) { if (!isCorrect) { return `Nice try! Your score is still ${score}.`;