I am currently having trouble with my slash commands. I am trying to get it so that in the author spot of the embed, it posts the author's Name & tag, and their profile. For some reason I keep receiving this error:
TypeError: Cannot read properties of undefined (reading 'user')
It would be amazing if someone could help me fix this. If you need the code to help me with the issue, here is a preview of it below!
If you need to DM me to fix this issue, you can DM me. Puggy™#9999
const { MessageActionRow, MessageButton, MessageEmbed } = require('discord.js');
module.exports = {
name: 'help',
description: 'Help Command',
options: [],
async execute(client, interaction) {
const embed = new MessageEmbed()
.setAuthor({ name: `${interaction.user.tag}`, iconURL: `${interaction.user.displayAvatarURL({dynamic: true})}`})
.setThumbnail("https://images-ext-2.discordapp.net/external/d7TMnLgFFrq6n5ICbvBdHMK8PkBveAYydv2Z-zUMtGQ/%3Fsize%3D512/https/cdn.discordapp.com/avatars/937174535684374528/5c1630bd97bce9ecfec7408d584eb2da.webp?width=478&height=478")
.addField("About Atlantis Utilities", `Custom bot made for the ** Atlantis .Community & Giveaways** discord server.`)
.setFooter({ text: 'Use the buttons below to navigate through the help command' });
const embed1 = new MessageEmbed()
.setColor("#000000")
.setThumbnail("https://images-ext-2.discordapp.net/external/d7TMnLgFFrq6n5ICbvBdHMK8PkBveAYydv2Z-zUMtGQ/%3Fsize%3D512/https/cdn.discordapp.com/avatars/937174535684374528/5c1630bd97bce9ecfec7408d584eb2da.webp?width=478&height=478")
.setTitle(`${client.user.username} Commands!`)
.setDescription(`` +
"\n\n"+ "**Information Commands**\n`Avatar, BlackListWords, Help, Profile, RolePerms, Serverinfo, Stafflist, Userinfo`") //
const embed2 = new MessageEmbed()
.setColor("#000000")
.setThumbnail("https://images-ext-2.discordapp.net/external/d7TMnLgFFrq6n5ICbvBdHMK8PkBveAYydv2Z-zUMtGQ/%3Fsize%3D512/https/cdn.discordapp.com/avatars/937174535684374528/5c1630bd97bce9ecfec7408d584eb2da.webp?width=478&height=478")
.setTitle(`${client.user.username} Commands!`)
.setDescription(`` +
"\n\n"+ "**Moderation Commands**\n`Ban, BannedUsers, Hackban, Kick, ModNick, Mute, Purge, RemoveWarn, Timeout, Unban, Unmute, Warn, Warninfo, Warnings`")
const embed3 = new MessageEmbed()
.setColor("#000000")
.setThumbnail("https://images-ext-2.discordapp.net/external/d7TMnLgFFrq6n5ICbvBdHMK8PkBveAYydv2Z-zUMtGQ/%3Fsize%3D512/https/cdn.discordapp.com/avatars/937174535684374528/5c1630bd97bce9ecfec7408d584eb2da.webp?width=478&height=478")
.setTitle(`${client.user.username} Commands!`)
.setDescription(`` +
"\n\n"+ "**Utility Commands**\n`Addrole, ChannelPerms, CreateRole, Cult, EditAchievement, Embed, Hire, PresetRole, RemoveRole, ResetCase, RoleEveryone, RoleEveryoneRemove`\n\n**Giveaway**\n`end-giveaway, reroll-giveawy, start-giveaway`\n\n**Configuartion**\n`config_atlantis, config_profile`\n\n**Suggestion**\n`Suggest, Accept-Suggestion, Deny-Suggestion`")
const button1 = new MessageButton()
.setCustomId('home')
.setLabel('Home')
.setStyle('PRIMARY')
.setEmoji(``)
const button2 = new MessageButton()
.setCustomId('help1')
.setLabel('Information')
.setStyle('SECONDARY')
.setEmoji(`❓`)
const button3 = new MessageButton()
.setCustomId('help2')
.setLabel('Moderation')
.setStyle('SECONDARY')
.setEmoji(``)
const button4 = new MessageButton()
.setCustomId('help3')
.setLabel('Utility')
.setStyle('SECONDARY')
.setEmoji(`⚙️`)
const row = new MessageActionRow()
.addComponents(button1, button2, button3, button4);
await interaction.reply({embeds: [embed1], components: [row]})
const filter = i => i.user.id === `${interaction.user.id}`;
const collector = interaction.channel.createMessageComponentCollector({ filter, time: 120000 });
collector.on('collect', async i => {
if (i.customId === 'help1') {
await i.update({ embeds: [embed2], components: [row] });
}
});
}
};```
Alrighty, so the issue was with my command handler. The issue has been solved
:D