所以我想创建一个小用户配置文件,但我希望它打印出用户角色。有可能吗?
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;
答案 0 :(得分:1)
您正在寻找message.member.roles
,也称为"Guild Member Roles"
所以你的代码看起来像这样:
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;
请记住,此代码仅适用于在公会频道中接收的消息(而不是直接消息查询),因此请务必相应地处理任何其他方案。 : - )
答案 1 :(得分:0)
代码几乎是RichEmbed。您已经设置好了,如果只是从这里获得它,只需用图像进行配置。
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;