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
|
import { Command } from 'discord-akairo';
import { Message } from 'discord.js';
export default class BanMod extends Command {
public constructor() {
super('ban', {
aliases: ['ban', 'banish'],
category: 'moderation',
description: {
content: 'Ban a specified user from the server.',
usage: '[user] [reason(s)]',
examples: [
'@fun#1337',
'@fun#1337 too cool'
]
},
ratelimit: 3,
channel: 'guild',
clientPermissions: ['BAN_MEMBERS'],
userPermissions: ['BAN_MEMBERS'],
args: [
{
id: 'user',
type: 'string',
prompt: {
start: 'Which user would you like to ban?',
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 ban 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 ban me!');
if (!reason) reason = 'No reason has been specified.';
if (user === msg.author.id) return msg.channel.send('You can\'t ban yourself!');
if (msg.mentions.members.first()) {
user = msg.mentions.members.first();
await user.send(`You have been banned from **${msg.guild.name}** for the following reason(s): "**${reason}**".`)
.catch(() => console.log('[ERROR] Could not send message to this user.'));
return user.ban({ reason: `Banned by: ${msg.author.username} for the following reason(s): ${reason}.`})
.then(() => msg.reply(`${user.user.username} was successfully banned with the following reason(s): "**${reason}**".`))
.catch(err => console.error(err));
} else {
msg.guild.members.ban(user, { reason: `Banned by: ${msg.author.username} for the following reason(s): ${reason}.`})
.then(() => msg.reply(`User ID ${user} was successfully banned with the following reason(s): "**${reason}**".`))
.catch(err => console.error(err));
}
}
}
|