can't set role to user (user.roles.add is not a function)

If I have a code like this
const member = interaction.options.getMember("user");
const type = interaction.options.getRole("type");
member.roles.add(type);

It doesn't work and it shows that add() is not a member of roles

And these are all the functions that are listed for roles
[[Prototype]] = Object
__defineGetter__ = ƒ __defineGetter__()
__defineSetter__ = ƒ __defineSetter__()
__lookupGetter__ = ƒ __lookupGetter__()
__lookupSetter__ = ƒ __lookupSetter__()
constructor = ƒ Object()
hasOwnProperty = ƒ hasOwnProperty()
isPrototypeOf = ƒ isPrototypeOf()
propertyIsEnumerable = ƒ propertyIsEnumerable()
toLocaleString = ƒ toLocaleString()
toString = ƒ toString()
valueOf = ƒ valueOf()


And that should be the correct way to set a role to a member according to the discord.js guide
https://discordjs.guide/popular-topics/faq.html#how-do-i-add-a-role-to-a-guild-member

instead I get this error:
error: Uncaught TypeError: member.roles.add is not a function
    member.roles.add(type);
               ^


discord.js: v14.16.3
deno: v2.0.3
Imagine a guide... that explores the many possibilities for your discord.js bot.
Was this page helpful?