D
D
danielfonov2021-02-14 10:21:09
Node.js
danielfonov, 2021-02-14 10:21:09

The bot does not understand roles.add, what should I do?

Line: message.author.roles.add("737598576124756018")
Tried by any means, followed discord.js methods, does not help.
I need the post author to be given a role with id 737598576124756018
I would be very grateful if I could get any help!! Very important!!

Error: TypeError: Cannot read property 'add' of undefined

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander, 2021-02-14
@danielfonov

the author property is of the class type User , which at one time represents a discord user , not a server member .
if you want to work with a server member , you must use the member property , which is of class type GuildMember .

K
Kirill, 2021-02-14
@KIRIK12

Try

message.author.roles.cache.add("737598576124756018");

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question