How to use FLAGS

How to use flags?
19 Replies
d.js toolkit
d.js toolkit3y ago
• What's your exact discord.js npm list discord.js and node node -v version? • Post the full error stack trace, not just the top part! • Show your code! • Explain what exactly your issue is. • Not a discord.js issue? Check out #useful-servers.
MrMythical
MrMythical3y ago
Your question is really vague Could you clarify?
FuzzX
FuzzXOP3y ago
like .flags how to display the badges properly because it sends object [Object] for me
MrMythical
MrMythical3y ago
You cans use .toArray() if you are using user flags
FuzzX
FuzzXOP3y ago
how?
d.js docs
d.js docs3y ago
method UserFlagsBitField#toArray() Gets an Array of bitfield names based on the bits available.
FuzzX
FuzzXOP3y ago
it says .toArray() isn't a function and when I use .toArray I get undefined
MrMythical
MrMythical3y ago
What exactly are you doing
FuzzX
FuzzXOP3y ago
trying to display all off a user's badges
MrMythical
MrMythical3y ago
And what are you trying
FuzzX
FuzzXOP3y ago
.addFields({ name: `\`👴\`・Badges:`, value: `${badges}`, inline: false })
.addFields({ name: `\`👴\`・Badges:`, value: `${badges}`, inline: false })
MrMythical
MrMythical3y ago
What is badges
FuzzX
FuzzXOP3y ago
badges like active developer or hype squad balance
MrMythical
MrMythical3y ago
... like what is defined as?
FuzzX
FuzzXOP3y ago
??
MrMythical
MrMythical3y ago
what is it defined as
FuzzX
FuzzXOP3y ago
const { SlashCommandBuilder, EmbedBuilder, PermissionsBitField } = require('discord.js');

module.exports = {
data: new SlashCommandBuilder()
.setName('userinfo')
.setDescription('Get information about an user')
.addUserOption(option => option.setName(`user`).setDescription(`Select a user`).setRequired(false)),
async execute (interaction) {
const user = interaction.options.getUser(`user`) || interaction.user;
const member = await interaction.guild.members.fetch(user.id);
const icon = user.displayAvatarURL();
const tag = user.tag;
const nick = member.displayName;
const perms = member.permissions;
const badges = member.toArray;

const embed = new EmbedBuilder()
.setColor("Yellow")
.setThumbnail(icon)
.setDescription(`\`\`・${user}'s Information`)
.addFields({ name: `\`💳\`・ID:`, value: `${user.id}`, inline: false })
.addFields({ name: `\`📖\`・Nickname:`, value: `${nick}`, inline: false })
.addFields({ name: `\`🤖\`・Bot:`, value: `${user.bot}`, inline: false })
.addFields({ name: `\`👋\`・Joined Server:`, value: `<t:${Math.floor(member.joinedTimestamp / 1000)}:R>`, inline: false })
.addFields({ name: `\`👴\`・Joined Discord:`, value: `<t:${Math.floor(user.createdTimestamp / 1000)}:R>`, inline: false })
.addFields({ name: `\`👴\`・Badges:`, value: `${badges}`, inline: false })
.setFooter({ text: tag, iconURL: icon })

await interaction.reply({ embeds: [embed] })
}
}
const { SlashCommandBuilder, EmbedBuilder, PermissionsBitField } = require('discord.js');

module.exports = {
data: new SlashCommandBuilder()
.setName('userinfo')
.setDescription('Get information about an user')
.addUserOption(option => option.setName(`user`).setDescription(`Select a user`).setRequired(false)),
async execute (interaction) {
const user = interaction.options.getUser(`user`) || interaction.user;
const member = await interaction.guild.members.fetch(user.id);
const icon = user.displayAvatarURL();
const tag = user.tag;
const nick = member.displayName;
const perms = member.permissions;
const badges = member.toArray;

const embed = new EmbedBuilder()
.setColor("Yellow")
.setThumbnail(icon)
.setDescription(`\`\`・${user}'s Information`)
.addFields({ name: `\`💳\`・ID:`, value: `${user.id}`, inline: false })
.addFields({ name: `\`📖\`・Nickname:`, value: `${nick}`, inline: false })
.addFields({ name: `\`🤖\`・Bot:`, value: `${user.bot}`, inline: false })
.addFields({ name: `\`👋\`・Joined Server:`, value: `<t:${Math.floor(member.joinedTimestamp / 1000)}:R>`, inline: false })
.addFields({ name: `\`👴\`・Joined Discord:`, value: `<t:${Math.floor(user.createdTimestamp / 1000)}:R>`, inline: false })
.addFields({ name: `\`👴\`・Badges:`, value: `${badges}`, inline: false })
.setFooter({ text: tag, iconURL: icon })

await interaction.reply({ embeds: [embed] })
}
}
MrMythical
MrMythical3y ago
it's user.flags.toArray()
FuzzX
FuzzXOP3y ago
ok ty

Did you find this page helpful?