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