Answer the question
In order to leave comments, you need to log in
How to get all user roles?
Hello. I am making an embed message where information about the user should be displayed, where his current roles will be present.
I can't figure out how to display the name of each role or mention the role using @role in embed.
Looking on the internet, everyone is using message.member.roles.cache. find() to find a role or . has() to check for presence. Tell me, please, how can I determine absolutely all the available roles for the user who sends the message and display it in embed?
Answer the question
In order to leave comments, you need to log in
The code below will output all user roles, including "@everyone", to a comma-separated string. If you have any more questions - ask.
bot.on('messageCreate', (message) => {
if (message.author.bot) return;
let roles = "";
message.member.roles.cache.map((role) => {
roles += role.name + ", ";
});
console.log(roles); // Вывод: "@Роль1, @Роль2, @everyone"
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question