V
V
Vladimir Kuchma2020-08-01 14:36:52
Node.js
Vladimir Kuchma, 2020-08-01 14:36:52

How to issue a role or if with a role if there is then execute discord.js?

Help please or throw a link to the article

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Anastasia Eliseeva, 2020-08-01
@perpeto

if (message.member.roles.has("735180265005121697")) {
^
TypeError: message.member.roles.has is not a function

If using Discord.js version 12+, then use cache in roles, users, channels, etc , namely
if (message.member.roles .cache .has("735180265005121697")) {
// if there is a role
} else {
// if there is no role
}

A
Alexander, 2020-08-01
@Alexandre888

if (message.member.roles.has("id_роли")) {
    // . . .
} else {
   // . . .
}

give role:
var role = message.guild.roles.cache.find(role => role.name === "название_роли");
message.member.roles.add(role);

V
Vladimir Kuchma, 2020-08-01
@perpeto

if (message.member.roles.has("735180265005121697")) {
                             ^

TypeError: message.member.roles.has is not a function

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question