/[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 148 - (hide annotations)
Mon Jul 29 17:28:47 2024 UTC (8 months, 1 week ago) by rakin
File MIME type: application/typescript
File size: 1365 byte(s)
chore: commit changes
1 rakin 77 import readline from "readline";
2     import DiscordClient from "../../client/Client";
3 rakin 148 import BannedGuild from "../../models/BannedGuild";
4 rakin 77 import BaseCLICommand from "../../utils/structures/BaseCLICommand";
5    
6     export default class GuildPurgeCommand extends BaseCLICommand {
7     constructor() {
8 rakin 81 super('guildpurge', 'guild');
9 rakin 77 }
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     }

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26