D
D
dayniel2022-01-27 02:39:57
Node.js
dayniel, 2022-01-27 02:39:57

How to give access to a command of a certain role?

Is it possible to give access to my team to only 1 or a couple of roles? For example, only Glav.Adminu.

function правила(robot, mess, args) {
  const exampleEmbed = new MessageEmbed()
  .setColor('#4C50BE')
  .setTitle('правила')
  .setDescription('правила')
  .setFooter({ text: '12.01.2022'});
  mess.author.send({ embeds: [exampleEmbed] });
}


I tried to search on the Internet, but I did not find a working option.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander, 2022-01-27
@dayniel

First, get the desired role:

let adminRole = mess.guild.roles.cache.get("ID_роли");
// или //
let adminRole = mess.guild.roles.cache.find(role => role.name === "название_роли");

after that, check if the author of the command has this role:
if (!mess.member.roles.cache.has(adminRole)) return "у пользователя отсутствует роль."

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question