From 5ed18c160fa3cb528cda4de05f6592362531f563 Mon Sep 17 00:00:00 2001 From: dragonfire535 Date: Mon, 16 Oct 2017 15:32:17 -0400 Subject: [PATCH] Remove Guild Pruning --- XiaoBot.js | 4 +--- structures/CommandoClient.js | 35 +---------------------------------- 2 files changed, 2 insertions(+), 37 deletions(-) diff --git a/XiaoBot.js b/XiaoBot.js index 697b3255..fc822fac 100644 --- a/XiaoBot.js +++ b/XiaoBot.js @@ -11,9 +11,7 @@ const client = new CommandoClient({ messageCacheLifetime: 600, messageSweepInterval: 120, dBotsToken: DBOTS_KEY, - dBotsOrgToken: DBOTSORG_KEY, - guildWhitelist: ['110373943822540800', '264445053596991498'], - guildPruneLevel: 25 + dBotsOrgToken: DBOTSORG_KEY }); client.registry diff --git a/structures/CommandoClient.js b/structures/CommandoClient.js index f6999e86..982ae247 100644 --- a/structures/CommandoClient.js +++ b/structures/CommandoClient.js @@ -1,18 +1,14 @@ const { Client } = require('discord.js-commando'); const snekfetch = require('snekfetch'); -const { Collection } = require('discord.js'); class CommandoClient extends Client { constructor(options) { super(options); - if (typeof this.options.guildPruneLevel === 'undefined') this.options.guildPruneLevel = Infinity; - if (typeof this.options.guildWhitelist === 'undefined') this.options.guildWhitelist = []; Object.defineProperty(this, 'dBotsToken', { value: options.dBotsToken }); Object.defineProperty(this, 'dBotsOrgToken', { value: options.dBotsOrgToken }); - this.on('guildCreate', guild => { - this.pruneGuilds(guild); + this.on('guildCreate', () => { this.dBots(); this.dBotsOrg(); }); @@ -20,7 +16,6 @@ class CommandoClient extends Client { this.dBots(); this.dBotsOrg(); }); - this.setInterval(() => this.pruneGuilds(), 600000); } async dBots() { @@ -58,34 +53,6 @@ class CommandoClient extends Client { return null; } } - - async pruneGuilds(guild) { - let guilds = new Collection(); - if (typeof guild === 'undefined') { - for (const g of this.guilds.values()) { - if (this.options.guildWhitelist.includes(g.id)) continue; - if (g.members.filter(member => member.user.bot).size > this.options.guildPruneLevel) { - try { - guilds.set(g.id, g); - await g.leave(); - } catch (err) { - this.emit('error', `Failed to leave guild ${g.name}. (${g.id})`, err); - } - } - } - } else { - if (this.options.guildWhitelist.includes(guild.id)) return guilds; - if (guild.members.filter(member => member.user.bot).size > this.options.guildPruneLevel) { - try { - guilds.set(guild.id, guild); - await guild.leave(); - } catch (err) { - this.emit('error', `Failed to leave guild ${g.name}. (${g.id})`, err); - } - } - } - return guilds; - } } module.exports = CommandoClient;