Answer the question
In order to leave comments, you need to log in
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
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');
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 questionAsk a Question
731 491 924 answers to any question