I'm making a user info command for my bot in discord.js and I don't now how to get the roles of a user. I tried looking up the discord.js documentation but I couldn't find anything.I already have the user with this code:
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;
}
Thanks in advance!