T
T
Tranz45552021-05-28 10:17:09
Node.js
Tranz4555, 2021-05-28 10:17:09

How to write a code for a Discord bot to issue a role when commanded, for example: !role @nickname @role. I write in Node.js. Can you help?

I'm starting to write my bot for Discord, I don't know how to write code so that it gives a role to a certain person, for example: !role @nickname @role. I write on Node.js, Urgently, help!!!

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Anton Neverov, 2021-05-28
@Tranz4555

What exactly do you not understand? There is documentation - https://discord.js.org/#/docs/main/stable/general/...
The user has a `.roles` property. Which returns GuildMemberRoleManager . This object already has a `.add()` method which adds a role by role object.
The role and user object can be obtained from the Message object that you will catch from the chat. The `.mentions` property contains MessageMentions , which already has `.users` and `.roles`.
Combine these two knowledge and you will get what you want.

T
Tranz4555, 2021-05-28
@Tranz4555

I don't know at all, please help

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question