我在discord.js中为我的机器人创建了一个用户信息命令,现在我不知道如何获取用户的角色。我尝试查找discord.js文档,但什么也找不到。我已经有了具有以下代码的用户:
const {SlashCommandBuilder} = require('discord.js');
let user;
module.exports = {
data: new SlashCommandBuilder()
.setName('user')
.setDescription('Display info about a selected user')
.addUserOption(option => option.setName('target').setDescription('The user's information to show')),
async execute(interaction) {
user = interaction.options.getUser('target');
if (user) {
createEmbed(interaction)
}
},
};
function createEmbed(interaction) {
const embed = {
// other code
fields: [
{
name: 'Roles',
value: 'what goes here',
}
],
//other code
}
interaction.reply({
embeds: [embed]
})
return;
}
提前谢谢!
1条答案
按热度按时间uurity8g1#
Https://discord.js.org/#/docs/discord.js/main/class/GuildMemberRoleManager?scrollTo=cache