/[sudobot]/branches/2.x/src/cli-commands/guild/GuildPurgeCommand.ts
ViewVC logotype

Annotation of /branches/2.x/src/cli-commands/guild/GuildPurgeCommand.ts

Parent Directory Parent Directory | Revision Log Revision Log


Revision 577 - (hide annotations)
Mon Jul 29 18:52:37 2024 UTC (8 months ago) by rakinar2
File MIME type: application/typescript
File size: 1365 byte(s)
chore: add old version archive branches (2.x to 9.x-dev)
1 rakinar2 577 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     }

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26