-
Notifications
You must be signed in to change notification settings - Fork 244
Expand file tree
/
Copy pathban.js
More file actions
96 lines (79 loc) · 3.45 KB
/
Copy pathban.js
File metadata and controls
96 lines (79 loc) · 3.45 KB
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
const { MessageEmbed } = require("discord.js");
const { stripIndents } = require("common-tags");
const { promptMessage } = require("../../functions.js");
module.exports = {
name: "ban",
category: "moderation",
description: "bans the member",
usage: "<id | mention>",
run: async (client, message, args) => {
const logChannel = message.guild.channels.cache.find(c => c.name === "logs") || message.channel;
if (message.deletable) message.delete();
// No args
if (!args[0]) {
return message.reply("Please provide a person to ban.")
.then(m => m.delete(5000));
}
// No reason
if (!args[1]) {
return message.reply("Please provide a reason to ban.")
.then(m => m.delete(5000));
}
// No author permissions
if (!message.member.hasPermission("BAN_MEMBERS")) {
return message.reply("❌ You do not have permissions to ban members. Please contact a staff member")
.then(m => m.delete(5000));
}
// No bot permissions
if (!message.guild.me.hasPermission("BAN_MEMBERS")) {
return message.reply("❌ I do not have permissions to ban members. Please contact a staff member")
.then(m => m.delete(5000));
}
const toBan = message.mentions.members.first() || message.guild.members.cache.get(args[0]);
// No member found
if (!toBan) {
return message.reply("Couldn't find that member, try again")
.then(m => m.delete(5000));
}
// Can't ban urself
if (toBan.id === message.author.id) {
return message.reply("You can't ban yourself...")
.then(m => m.delete(5000));
}
// Check if the user's banable
if (!toBan.bannable) {
return message.reply("I can't ban that person due to role hierarchy, I suppose.")
.then(m => m.delete(5000));
}
const embed = new MessageEmbed()
.setColor("#ff0000")
.setThumbnail(toBan.user.displayAvatarURL())
.setFooter(message.member.displayName, message.author.displayAvatarURL())
.setTimestamp()
.setDescription(stripIndents`**- baned member:** ${toBan} (${toBan.id})
**- baned by:** ${message.member} (${message.member.id})
**- Reason:** ${args.slice(1).join(" ")}`);
const promptEmbed = new MessageEmbed()
.setColor("GREEN")
.setAuthor(`This verification becomes invalid after 30s.`)
.setDescription(`Do you want to ban ${toBan}?`)
// Send the message
await message.channel.send(promptEmbed).then(async msg => {
// Await the reactions and the reactioncollector
const emoji = await promptMessage(msg, message.author, 30, ["✅", "❌"]);
// Verification stuffs
if (emoji === "✅") {
msg.delete();
toBan.ban(args.slice(1).join(" "))
.catch(err => {
if (err) return message.channel.send(`Well.... the ban didn't work out. Here's the error ${err}`)
});
logChannel.send(embed);
} else if (emoji === "❌") {
msg.delete();
message.reply(`ban canceled.`)
.then(m => m.delete(10000));
}
});
}
};