add purge command
This commit is contained in:
parent
f16563c301
commit
79cd4e8935
1 changed files with 22 additions and 0 deletions
22
cmd/perm.js
22
cmd/perm.js
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue