aboutsummaryrefslogtreecommitdiff
path: root/src/commands/moderation/kick.ts
blob: f8bb5a15b7ed8fb66df998d28f252859d5d6ae59 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
import { GuildMember, Message } from 'discord.js';
import { BushCommand } from '../../lib/extensions/discord-akairo/BushCommand';

export default class KickCommand extends BushCommand {
	public constructor() {
		super('kick', {
			aliases: ['kick'],
			category: 'moderation',
			args: [
				{
					id: 'user',
					type: 'member',
					prompt: {
						start: 'What user would you like to kick?',
						retry: '{error} Choose a valid user to kick.'
					}
				},
				{
					id: 'reason',
					type: 'string',
					match: 'restContent',
					prompt: {
						start: 'Why would you like to kick this user?',
						retry: '{error} Choose a valid user to kick.',
						optional: true
					}
				}
			],
			clientPermissions: ['KICK_MEMBERS'],
			userPermissions: ['KICK_MEMBERS'],
			description: {
				content: 'Kick a member from the server.',
				usage: 'kick <member> <reason>',
				examples: ['kick @user bad']
			},
			slashOptions: [
				{
					type: 'USER',
					name: 'user',
					description: 'What user would you like to kick?',
					required: true
				},
				{
					type: 'STRING',
					name: 'reason',
					description: 'Why would you like to kick this user?',
					required: false
				}
			],
			slash: true
		});
	}

	// private async *genResponses(
	// 	message: Message | CommandInteraction,
	// 	user: GuildMember,
	// 	reason?: string
	// ): AsyncIterable<string> {
	// 	let modlogEnry: ModLog;
	// 	// Create guild entry so postgres doesn't get mad when I try and add a modlog entry
	// 	await Guild.findOrCreate({
	// 		where: {
	// 			id: message.guild.id
	// 		},
	// 		defaults: {
	// 			id: message.guild.id
	// 		}
	// 	});
	// 	try {
	// 		modlogEnry = ModLog.build({
	// 			user: user.id,
	// 			guild: message.guild.id,
	// 			moderator: message instanceof Message ? message.author.id : message.user.id,
	// 			type: ModLogType.KICK,
	// 			reason
	// 		});
	// 		await modlogEnry.save();
	// 	} catch (e) {
	// 		this.client.console.error(`KickCommand`, `Error saving to database. ${e?.stack || e}`);
	// 		yield `${this.client.util.emojis.error} Error saving to database. Please report this to a developer.`;
	// 		return;
	// 	}
	// 	try {
	// 		await user.send(`You were kicked in ${message.guild.name} with reason \`${reason || 'No reason given'}\``);
	// 	} catch {
	// 		yield `${this.client.util.emojis.warn} Unable to dm user`;
	// 	}
	// 	try {
	// 		await user.kick(
	// 			`Kicked by ${message instanceof Message ? message.author.tag : message.user.tag} with ${
	// 				reason ? `reason ${reason}` : 'no reason'
	// 			}`
	// 		);
	// 	} catch {
	// 		yield `${this.client.util.emojis.error} Error kicking :/`;
	// 		await modlogEnry.destroy();
	// 		return;
	// 	}
	// 	yield `${this.client.util.emojis.success} Kicked <@!${user.id}> with reason \`${reason || 'No reason given'}\``;
	// }

	async exec(message: Message, { user, reason }: { user: GuildMember; reason?: string }): Promise<unknown> {
		return message.util.reply(`${this.client.util.emojis.error} This command is not finished.`);

		// for await (const response of this.genResponses(message, user, reason)) {
		// 	await message.util.send(response);
		// }
	}
}