/[sudobot]/trunk/src/cli-commands/guild/GuildPurgeCommand.ts
ViewVC logotype

Annotation of /trunk/src/cli-commands/guild/GuildPurgeCommand.ts

Parent Directory Parent Directory | Revision Log Revision Log


Revision 329 - (hide annotations)
Mon Jul 29 17:29:34 2024 UTC (8 months, 1 week ago) by rakin
File MIME type: application/typescript
File size: 1313 byte(s)
refactor(cli): remove bannedguild model
1 rakin 77 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 rakin 81 super('guildpurge', 'guild');
8 rakin 77 }
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     }

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26