xxxxxxxxxx
if (msg.member.hasPermission("BAN_MEMBERS")) {
if (msg.members.mentions.first()) {
try {
msg.members.mentions.first().ban();
} catch {
msg.reply("I do not have permissions to ban" + msg.members.mentions.first());
}
} else {
msg.reply("You do not have permissions to ban" + msg.members.mentions.first());
}
}
xxxxxxxxxx
if (msg.member.hasPermission("KICK_MEMBERS")) {
if (msg.members.mentions.first()) {
try {
msg.members.mentions.first().kick();
} catch {
msg.reply("I do not have permissions to kick " + msg.members.mentions.first());
}
} else {
msg.reply("You do not have permissions to kick " + msg.members.mentions.first());
}
}
xxxxxxxxxx
let member = message.mentions.members.first();
if(!member) return message.reply("Please mention a valid member of this server");
if(!member.bannable) return message.reply("I cannot ban this member!");
member.ban(); //.ban(reason) if you would to put in the reason through arguments
xxxxxxxxxx
/*
Need more help? Add me on discord: Dwagon#0069
Discord.js ^13.8.1
*/
/*
With interaction
*/
if (interaction.member.permissions.has("BAN_MEMBERS")) {
const user = interaction.options.getUser("user")
const member = interaction.guild.members.cache.get(user.id) || await interaction.guild.members.fetch(user.id).catch(err => { })
switch (member.id) {
case (!member):
return interaction.reply({
content: "ERROR: Cannot find this user!",
ephemeral: true
})
case (interaction.member.id):
return interaction.reply({
content: "ERROR: You cannot ban yourself!",
ephemeral: true
})
case (bot.user.id):
return interaction.reply({
content: "ERROR: You cannot ban me!",
ephemeral: true
})
case (member.roles.highest.position >= interaction.member.roles.highest.position):
return interaction.reply({
content: "ERROR: I can't ban this user, because he's higher than you!",
ephemeral: true
})
case (!member.bannable):
return interaction.reply({
content: "ERROR: I can't ban this user!",
ephemeral: true
})
default:
const reason = interaction.options.getString("reason");
const admin = interaction.user.tag;
await interaction.reply({
content: ["``" + member.user.tag + "`` has been banned from the server for ``" + reason + "``"],
ephemeral: true
})
await member.ban({ reason: [reason + " | " + admin] });
break;
}
} else {
// If doesn't have permission to ban
return interaction.reply({
content: "ERROR: You cannot execute this command!",
ephemeral: true
})
}
}
};
xxxxxxxxxx
code: //https://github.com/NekoYasuii/discord-template-with-slash/blob/master/src/commands/moderation/ban.js
xxxxxxxxxx
//This is the command but you need the kcik command
if (message.content.startsWith("d!kick")) {if (message.member.hasPermission("KICK_MEMBERS")) {
let member = message.mentions.members.first()
if (!member) message.channel.send("Please mention someone")
else {member.kick().then(mem => {message.channel.send(`Kicked ${mem.user.username}!`)
})}} else {message.reply("You don't have the permission to do that...")}} if (message.content.startsWith('d!ban')) {if(message.member.hasPermission("BAN_MEMBERS")) {const user = message.mentions.users.first(); if (user) {const member = message.guild.member(user);if (member) {
member