N
N
Nikolai Fedorov2020-02-01 03:04:41
Node.js
Nikolai Fedorov, 2020-02-01 03:04:41

How to issue a role on command?

I need to write a code to issue a role on a specific command, please help

Answer the question

In order to leave comments, you need to log in

1 answer(s)
C
CatCatcher, 2020-02-01
@crystal_mint00

Well, let's say the command structure looks like !role [упоминание].
The ID of the role to be issued is 123456789012345678 (RMB on the role and "Copy ID", I think you know)

message.guild.members.get(message.author.id).addRole('123456789012345678');

We just got the guild member (not the user) by the ID of the author of the message and gave him a role.
Next (via mention)
user = message.content.split(' ')[1];
//далее 2 способа
//первый
message.guild.members.get(message.mentions.first()).addRole('123456789012345678');
//второй
if (user.includes('!')) user = user.slice(3, -1);
else user = user.slice(2, -1);
message.guild.members.get(user).addRole('123456789012345678');

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question