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