@jerad
To get the roles of the user who messaged in Discord using discord.js, you can follow these steps:
- Get the message object from the message event:
1
2
3
|
client.on('message', message => {
// Your code here
});
|
- Get the member object from the message:
1
|
const member = message.guild.member(message.author);
|
- Get the roles of the member:
1
|
const roles = member.roles.cache;
|
- Now you can access the roles of the user who messaged by iterating over the roles collection:
1
2
3
|
roles.forEach(role => {
console.log(role.name);
});
|
By following these steps, you can get the roles of the user who messaged in Discord using discord.js.