1 |
const MessageEmbed = require("../src/MessageEmbed"); |
2 |
|
3 |
module.exports = { |
4 |
async handle(msg, cm) { |
5 |
if (typeof cm.args[0] === 'undefined') { |
6 |
await msg.reply({ |
7 |
embeds: [ |
8 |
new MessageEmbed() |
9 |
.setColor('#f14a60') |
10 |
.setDescription(`This command requires at least one argument.`) |
11 |
] |
12 |
}); |
13 |
|
14 |
return; |
15 |
} |
16 |
|
17 |
var user = await msg.mentions.members.first(); |
18 |
let reason = {}; |
19 |
|
20 |
if (typeof cm.args[1] !== 'undefined') { |
21 |
let args = [...cm.args]; |
22 |
args.shift(); |
23 |
|
24 |
await (reason.reason = args.join(' ')); |
25 |
} |
26 |
|
27 |
if (typeof user !== 'object') { |
28 |
try { |
29 |
user = await msg.guild.members.fetch(cm.args[0]); |
30 |
} |
31 |
catch(e) { |
32 |
|
33 |
} |
34 |
} |
35 |
|
36 |
if (typeof user !== 'object') { |
37 |
await msg.reply({ |
38 |
embeds: [ |
39 |
new MessageEmbed() |
40 |
.setColor('#f14a60') |
41 |
.setDescription(`Invalid user given.`) |
42 |
] |
43 |
}); |
44 |
|
45 |
return; |
46 |
} |
47 |
|
48 |
try { |
49 |
if (typeof user.kickable === 'boolean' && user.kickable === false) { |
50 |
await msg.reply({ |
51 |
embeds: [ |
52 |
new MessageEmbed() |
53 |
.setColor('#f14a60') |
54 |
.setDescription(`This user isn't kickable.`) |
55 |
] |
56 |
}); |
57 |
|
58 |
return; |
59 |
} |
60 |
|
61 |
await user.kick(reason); |
62 |
} |
63 |
catch(e) { |
64 |
console.log(e); |
65 |
|
66 |
await msg.reply({ |
67 |
embeds: [ |
68 |
new MessageEmbed() |
69 |
.setColor('#f14a60') |
70 |
.setDescription(`I don't have enough permission to kick this user.`) |
71 |
] |
72 |
}); |
73 |
|
74 |
return; |
75 |
} |
76 |
|
77 |
await msg.reply({ |
78 |
embeds: [ |
79 |
new MessageEmbed() |
80 |
.setDescription(`The user ${user.user.tag} has been kicked`) |
81 |
.addFields([ |
82 |
{ |
83 |
name: "Reason", |
84 |
value: typeof reason.reason === 'undefined' ? '*No reason provided*' : reason.reason |
85 |
} |
86 |
]) |
87 |
] |
88 |
}); |
89 |
} |
90 |
}; |