How do I add a role with discord.js

const target = interaction.options.getUser('target');
const role = interaction.options.getRole('role');
target.addRole(role);
const target = interaction.options.getUser('target');
const role = interaction.options.getRole('role');
target.addRole(role);
is this how i add the role?
3 Replies
d.js toolkit
d.js toolkit9mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button! - Marked as resolved by OP
Danial
Danial9mo ago
Users don't have roles, members do, change that getUser() to getMember() and it'd be target.roles.add(role)
paxton!!
paxton!!OP9mo ago
thank you! i will mark as solved
Want results from more Discord servers?
Add your server