1 |
import { exit } from "process"; |
2 |
import DiscordClient from "../../client/Client"; |
3 |
import BannedGuild from "../../models/BannedGuild"; |
4 |
import BaseCLICommand from "../../utils/structures/BaseCLICommand"; |
5 |
|
6 |
export default class BanGuildCommand extends BaseCLICommand { |
7 |
requiredArgs = 1; |
8 |
|
9 |
constructor() { |
10 |
super('banguild', 'guild'); |
11 |
} |
12 |
|
13 |
async run(client: DiscordClient, argv: string[], args: string[]) { |
14 |
const guild_id = args.shift()!; |
15 |
let reason: string | null = null; |
16 |
|
17 |
if (args.length > 0) |
18 |
reason = args.join(' '); |
19 |
|
20 |
const guild = await client.guilds.cache.get(guild_id); |
21 |
|
22 |
if (!guild) { |
23 |
console.error("Failed to find a guild with ID " + guild_id); |
24 |
exit(-1); |
25 |
} |
26 |
|
27 |
await BannedGuild.create({ |
28 |
guild_id, |
29 |
reason |
30 |
}); |
31 |
|
32 |
await guild.leave(); |
33 |
|
34 |
console.log(`Succesfully banned and left guild: ${guild.name} (${guild.id})`); |
35 |
|
36 |
await exit(0); |
37 |
} |
38 |
} |