-1
I’m trying to make a ban command for my Discord.js bot, but he says I don’t have permission, even though I’m one of the server administrators (even the guy with Ownership can’t do it).
if(comando === "ban") {
if(!message.member.roles.some(r=>["Administrator"].includes(r.name)) )
return message.reply("Você não tem permissões para usar este comando.");
let member = message.mentions.members.first();
if(!member)
return message.reply("Por favor, mencione um usuário válido.");
if(!member.bannable)
return message.reply("Eu não posso banir este usuário! Ele pode ter um
cargo maior que o meu, ou eu não tenha permissão pra banir!");
let reason = args.slice(1).join(' ');
if(!reason) reason = "Forneça uma razão à esse banimento.";
await member.ban(reason)
.catch(error => message.reply("Desculpe ${message.author} não consegui banir o membro devido ao : ${error}"));
message.reply("${member.user.tag} foi banido por ${message.author.tag} pelo motivo de: ${reason}`);
}
But the [Administrator] is already marked in this code: if(!message.member.roles.some(r=>["Administrator"].includes(r.name)) ), where should I put it, then?
– dxmxged
My Discord is in English, and it says "Administrator" on the roles part.
– dxmxged
Try creating a new role with a different name to test and see the result. Here, the same code works perfectly.
– Guilherme Carvalho Lithg
I did that, I created a role called Administrator, and it worked. But I wanted to know if it is possible to schedule so that all the positions that had the admin permission could run the ban.
– dxmxged