How to get user details and give him a role by his "User ID"

How to get user details and give him role by his "User ID" I tried a lot but not working
6 Replies
d.js toolkit
d.js toolkitβ€’13mo 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
AC / LogicTubes_Boss πŸ‡ΈπŸ‡¦
Okay 1m Nitro Needed to send code πŸ˜‚ let me record a video
d.js docs
d.js docsβ€’13mo ago
To share long code snippets, use a service like gist, sourcebin, starbin, or similar instead of posting them as large code blocks or files.
AC / LogicTubes_Boss πŸ‡ΈπŸ‡¦
can I send it to you as DM? https://sourceb.in/c6kFIDLnnN there ^ ok let me check node:events:492 throw er; // Unhandled 'error' event ^ TypeError: Cannot read properties of undefined (reading 'add') When try member.roles.add(role); So member.roles = undefined guild.members.fetch("ID") I have post names User: <@ID> So I used channelName.slice(8,-1) let me send you the line
const guild = client.guilds.cache.get('1060487682557497414');

const role = interaction.guild.roles.cache.find(r => r.name === "Trail")
const member = guild.members.fetch(interaction.channel.name.slice(8,-1));
member.roles.add(role);
const guild = client.guilds.cache.get('1060487682557497414');

const role = interaction.guild.roles.cache.find(r => r.name === "Trail")
const member = guild.members.fetch(interaction.channel.name.slice(8,-1));
member.roles.add(role);
let me check Thank you!! works I missed waiting for the command to end Much love to you
Want results from more Discord servers?
Add your server