Make sure bot is not in any blacklisted guilds on start-up

This commit is contained in:
Dragon Fire
2021-02-14 20:22:57 -05:00
parent 55a9ffff03
commit 5f46f14c1b
+25
View File
@@ -94,6 +94,31 @@ client.on('ready', async () => {
client.logger.error(`[BLACKLIST] Could not parse blacklist.json:\n${err.stack}`);
}
// Make sure bot is not in any blacklisted guilds
for (const id of client.blacklist.guild) {
try {
const guild = await this.client.guilds.fetch(id, false);
await guild.leave();
client.logger.info(`[BLACKLIST] Left blacklisted guild ${id}.`);
} catch {
client.logger.info(`[BLACKLIST] Failed to leave blacklisted guild ${id}.`);
}
}
// Make sure bot is not in any guilds owned by a blacklisted user
let guildsLeft = 0;
for (const guild of this.client.guilds.cache.values()) {
if (client.blacklist.user.includes(guild.ownerID)) {
try {
await guild.leave();
guildsLeft++;
} catch {
client.logger.info(`[BLACKLIST] Failed to leave blacklisted guild ${guild.id}.`);
}
}
}
client.logger.info(`[BLACKLIST] Left ${guildsLeft} guilds owned by blacklisted users.`);
// Import command-leaderboard.json
try {
const results = client.importCommandLeaderboard();