1 |
import readline from "readline"; |
2 |
import DiscordClient from "../../client/Client"; |
3 |
import BannedGuild from "../../models/BannedGuild"; |
4 |
import BaseCLICommand from "../../utils/structures/BaseCLICommand"; |
5 |
|
6 |
export default class GuildPurgeCommand extends BaseCLICommand { |
7 |
constructor() { |
8 |
super('guildpurge', 'guild'); |
9 |
} |
10 |
|
11 |
async run(client: DiscordClient, argv: string[], args: string[]) { |
12 |
for (const guild of client.guilds.cache.toJSON()) { |
13 |
if (!client.config.props[guild.id]) { |
14 |
const io = await readline.createInterface({ |
15 |
input: process.stdin, |
16 |
output: process.stdout, |
17 |
}); |
18 |
|
19 |
await io.question(`Found an unauthorized guild: ${guild.name} (${guild.id}), please type 'yes' / 'y' confirm the bot to leave.\n`, async input => { |
20 |
if (input.toLowerCase() === 'y' || input.toLowerCase() === 'yes') { |
21 |
await guild.leave(); |
22 |
await console.log(`Left guild: ${guild.name} (${guild.id})`); |
23 |
} |
24 |
else { |
25 |
await console.log('Operation canceled.'); |
26 |
} |
27 |
|
28 |
await io.close(); |
29 |
}); |
30 |
} |
31 |
} |
32 |
} |
33 |
} |