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
|
import { Command } from 'discord-akairo';
import { Message } from 'discord.js';
export default class KickMod extends Command {
public constructor() {
super('kick', {
aliases: ['kick'],
category: 'moderation',
description: {
content: 'Kick a specified user from the server.',
usage: '[user] [reason(s)]',
examples: [
'@fun#1337',
'@fun#1337 too cool'
]
},
ratelimit: 3,
channel: 'guild',
clientPermissions: ['KICK_MEMBERS'],
userPermissions: ['KICK_MEMBERS'],
args: [
{
id: 'user',
type: 'string',
prompt: {
start: 'Which user would you like to kick?',
retry: 'That doesn\'t seem to be a user, please try again!'
}
},
{
id: 'reason',
type: 'string',
prompt: {
start: 'For what reason would you like to kick this user?',
optional: true
},
match: 'rest'
}
]
});
}
public async exec(msg: Message, { user, reason }): Promise<Message> {
if (msg.mentions.members.first()) user = msg.mentions.members.first().id;
if (user === this.client.user.id) return msg.channel.send('You can\'t kick me!');
if (!reason) reason = 'No reason has been specified.';
if (user === msg.author.id) return msg.channel.send('You can\'t kick yourself!');
user = msg.guild.members.cache.get(user);
await user.send(`You have been kick from **${msg.guild.name}** for the following reason(s): "**${reason}**".`)
.catch(() => console.log('[ERROR] Could not send message to this user.'));
// TODO: fix reason showing up as [Object object]
return user.kick({ reason: `Kicked by: ${msg.author.username} for the following reason(s): ${reason}.`})
.then(() => msg.reply(`${user.user.username} was successfully kick with the following reason(s): "**${reason}**".`))
.catch(err => console.error(err));
}
}
|