add purge command

This commit is contained in:
jane 2020-11-21 20:14:11 -05:00
parent f16563c301
commit 79cd4e8935

View file

@ -69,4 +69,26 @@ class WhitelistGuild extends Command {
initializer.addCommand(new WhitelistGuild());
class Purge extends Command {
name = 'purge';
whitelist = true;
func = async function (msg, args, ctx) {
let guilds = await ctx.bot.guilds;
let whitelist = ctx.whitelist.guild;
let purged = 0;
guilds.forEach((guild) => {
if (!whitelist(guild)) {
this.log.info(`purging guild ${guild.name} (${guild.id})`);
guild.leave();
purged++;
} else {
this.log.info(`keeping guild ${guild.name} (${guild.id})`);
}
});
msg.channel.createMessage(`purged ${purged} guilds.`);
};
}
initializer.addCommand(new Purge());
export default initializer;