So I want to make a little user profile, but I want it to print out the users roles. Is it possible?
case "Profile":
var embed = new Discord.RichEmbed()
.addField(message.author.username, "Roles: " + [How would I put the users roles here?]) // user, roles
.addField("Stats", "XP: 0/100 Level 0") // XP, Level?
.setColor(0x00ffff)
.setThumbnail(message.author.avatarURL)
message.channel.sendEmbed(embed);
console.log(message.author + ` Viewed their profile!`)
break;
You're looking for message.member.roles
, also known as the "Guild Member Roles"
So your code could look something like this:
case "Profile":
var embed = new Discord.RichEmbed()
.addField(message.author.username, "Roles: " + message.member.roles.map(role => role.name).join(", ")) // user, roles
.addField("Stats", "XP: 0/100 Level 0") // XP, Level?
.setColor(0x00ffff)
.setThumbnail(message.author.avatarURL)
message.channel.sendEmbed(embed);
console.log(message.author + ` Viewed their profile!`)
break;
Keep in mind that this code will only work for messages that are received in a guild channel (as opposed to a direct message query), so make sure to handle any other scenarios accordingly. :-)
The code is pretty much the RichEmbed. You have set it and just need to configure it with the image if you just got it from here.
case "Profile":
var embed = new Discord.RichEmbed()
.addField(message.author.username, "Roles: " + message.member.roles.map(role => role.name).join(", ")) // user, roles
.addField("Stats", "XP: 0/100 Level 0") // XP, Level?
.setColor(0x00ffff)
.setThumbnail(message.author.avatarURL)
message.channel.sendEmbed(embed);
console.log(message.author + ` Viewed their profile!`)
break;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.