#User info command using options
1 messages · Page 1 of 1 (latest)
Could you send all the related code
Some of it still needs changing as I'm doing some testing but here it is. All of the stuff in the additional bit needs the member object which is why I wanted it
const uservar = interaction.options.getUser("target")
const user = await interaction.guild.members.fetch(uservar.id)
if (!uservar)
const userFlags = user.flags.toArray();
const roles = interaction.member.roles.cache
.sort((a, b) => b.position - a.position)
.map(role=>role.toString())
.slice(0, -1);
let booststatus = ''
if (!interaction.member.roles.premiumSubscriberRole) {
booststatus = 'No'
} else booststatus = 'Yes'
const userinfoEmbed = new Discord.MessageEmbed()
.setTitle('__User Info__')
.addField("Info", `\nUsername: \`${user.username}\`\nTag: \`${user.discriminator}\`\nID: \`${user.id}\`\nIs a bot: \`${user.bot}\`\nProfile badges: \`${userFlags.length ? userFlags.map(flag => flags[flag]).join(', ') : 'None'}\`\nAvatar: [Avatar link](${user.displayAvatarURL()})\nCreated: \`${moment(user.createdTimestamp).format('LL')} ${moment(user.createdTimestamp).format('LT')}, ${moment(user.createdTimestamp).fromNow()}\``)
.addField("Additional info",`\nJoined server: \`${moment(user.joinedAt).format('LL LTS')}\`\nIs Boosting: \`${booststatus}\`\nHighest Role: \`${user.roles.highest.id === interaction.guild.id ? 'None' : user.roles.highest.name}\`\nHoist Role: \`${user.roles.hoist ? user.roles.hoist.name : 'None'}\`\nRoles: \`${roles.length}\``)
.setThumbnail(user.displayAvatarURL({ dynamic: true }))
.setColor("#ff3030")
.setFooter({text: interaction.client.user.tag})
.setTimestamp();
And what error do you get
TypeError: Cannot read properties of null (reading 'id')
Check uservar before using it, you only check if after you try accessing it in user
there's no error, uservar is true
Which line yields the error?