Je fais mon propre bot de discordance parce que je ne fais pas confiance aux plus gros (Dyno, Hime, Nosobot, etc.) et mon bot est à peu près fait. Le seul problème est que mon code permet à tous les membres d'utiliser ces commandes. Je veux seulement que les gens puissent utiliser les fonctions qu'ils ont des autorisations. Le code fonctionne, mais comment puis-je le faire autoriser uniquement les personnes ayant la permission de frapper/interdiction?
if (msg.content.startsWith("$kick ")) {
if (msg.mentions.members.first()) {
msg.mentions.members.first.kick().then((member) => {
msg.channel.send(":wave: " + member.displayName + " has been successfully kicked :point_right: ");
}).catch(() => {
msg.channel.send("I do not have permissions to do this");
});
}
}else if (msg.content.startsWith("$ban ")) {
if (!message.member.hasPermission("MANAGE_MESSAGES")) return;
if (msg.mentions.members.first()) {
msg.mentions.members.first.ban().then((member) => {
msg.channel.send(":wave: " + member.displayName + " has been successfully banned :point_right: ");
}).catch(() => {
msg.channel.send("I do not have permissions to do this");
});
}
}
if (message.content.startWith(`${prefix}ban`)){
let buser = message.guild.member(message.mentions.users.first() || message.guild.members.get(args[0]));
if (!buser) return message.channel.send("Please provid a user to ban")
let reason = args.join(" ").slice(22)
if (!reason) return message.channel.send("Please provide a reason")
if(!message.member.hasPermission("BAN_MEMBERS")) return message.channel.send("You don't have acces to this command")
if (buser.hasPermission("BAN_MEMBERS")) return message.channel.send("This user has the perm ban user")
let embed = new Discord.RichEmbed()
buser.ban()
.setAuthor("Ban")
.setDescription(`The user ${buser} has been ban for: ${reason}\n by the admin ${message.author.tag}`)
bot.channels.get("an channel id").send(embed);
}