gpt4 book ai didi

javascript - Angular 色 Discord.js(在嵌入中打印 Angular 色)

转载 作者:行者123 更新时间:2023-11-30 20:45:28 31 4
gpt4 key购买 nike

所以我想做一个小的用户配置文件,但我希望它打印出用户 Angular 色。可能吗?

  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;

最佳答案

您正在寻找 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;

请记住,此代码仅适用于在公会 channel 中收到的消息(而不是直接消息查询),因此请确保相应地处理任何其他情况。 :-)

关于javascript - Angular 色 Discord.js(在嵌入中打印 Angular 色),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48754018/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com