How to use FLAGS

How to use flags?
19 Replies
d.js toolkit
d.js toolkit2y 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
MrMythical2y ago
Your question is really vague Could you clarify?
FuzzX
FuzzXOP2y ago
like .flags how to display the badges properly because it sends object [Object] for me
MrMythical
MrMythical2y ago
You cans use .toArray() if you are using user flags
FuzzX
FuzzXOP2y ago
how?
d.js docs
d.js docs2y ago
method UserFlagsBitField#toArray() Gets an Array of bitfield names based on the bits available.
FuzzX
FuzzXOP2y ago
it says .toArray() isn't a function and when I use .toArray I get undefined
MrMythical
MrMythical2y ago
What exactly are you doing
FuzzX
FuzzXOP2y ago
trying to display all off a user's badges
MrMythical
MrMythical2y ago
And what are you trying
FuzzX
FuzzXOP2y ago
.addFields({ name: `\`👴\`・Badges:`, value: `${badges}`, inline: false })
.addFields({ name: `\`👴\`・Badges:`, value: `${badges}`, inline: false })
MrMythical
MrMythical2y ago
What is badges
FuzzX
FuzzXOP2y ago
badges like active developer or hype squad balance
MrMythical
MrMythical2y ago
... like what is defined as?
FuzzX
FuzzXOP2y ago
??
MrMythical
MrMythical2y ago
what is it defined as
FuzzX
FuzzXOP2y 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
MrMythical2y ago
it's user.flags.toArray()
FuzzX
FuzzXOP2y ago
ok ty
Want results from more Discord servers?
Add your server