Cannot read properties of undefined.. (Error)

client.on(Events.InteractionCreate, async interaction => {
const selected = interaction.values[0];

if (!interaction.isStringSelectMenu()) return;

if (interaction.customId === 'HxLength') {

if (selected === 'first_option') {

const codeString = "marcusharlund@gmail.com";
const formattedString = `\`\`\`js\n${codeString}\n\`\`\``;

const embedHx2 = new EmbedBuilder()
.setTitle('Payment')
.setThumbnail('https://media.discordapp.net/attachments/665912408396660746/1092044479252414564/paypal_2.png')
.setDescription('wafs' + (formattedString))
.setFooter({ text: `${interaction.user.username}'s Ticket`, iconURL: interaction.user.displayAvatarURL() })
.setColor("#116cf5")
.setTimestamp()

interaction.reply({ components: [], embeds: [embedHx2] })

}



}

});
client.on(Events.InteractionCreate, async interaction => {
const selected = interaction.values[0];

if (!interaction.isStringSelectMenu()) return;

if (interaction.customId === 'HxLength') {

if (selected === 'first_option') {

const codeString = "marcusharlund@gmail.com";
const formattedString = `\`\`\`js\n${codeString}\n\`\`\``;

const embedHx2 = new EmbedBuilder()
.setTitle('Payment')
.setThumbnail('https://media.discordapp.net/attachments/665912408396660746/1092044479252414564/paypal_2.png')
.setDescription('wafs' + (formattedString))
.setFooter({ text: `${interaction.user.username}'s Ticket`, iconURL: interaction.user.displayAvatarURL() })
.setColor("#116cf5")
.setTimestamp()

interaction.reply({ components: [], embeds: [embedHx2] })

}



}

});
11 Replies
d.js toolkit
d.js toolkit16mo 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.
Bella Moonaria
Bella Moonaria16mo ago
interaction.values is undefined
Marcus
Marcus16mo ago
hmm but it should not be undefined
Bella Moonaria
Bella Moonaria16mo ago
You're accessing it in the beginning of your event, not even checking if its a select menu interaction
Marcus
Marcus16mo ago
So where do I have to place it
SpecialSauce
SpecialSauce16mo ago
After you check if it’s a select menu interaction. Otherwise that prop doesn’t exist
Marcus
Marcus16mo ago
Marcus
Marcus16mo ago
// this will create buttons
const button = new ActionRowBuilder()
.addComponents(
new ButtonBuilder()
.setCustomId(`ticket-setup-${interaction.guild.id}-${category.id}`)
.setLabel('💸 Purchase Ticket')
.setStyle(ButtonStyle.Success)
);

const button2 = new ActionRowBuilder()
.addComponents(
new ButtonBuilder()
.setCustomId(`ticket-setup-${interaction.guild.id}-${category.id}`)
.setLabel('❓ Support Ticket')
.setStyle(ButtonStyle.Success)
);



// this will send confirm reply
await interaction.reply({
content: `The ticket has been setup to ${channel} successfully.`,
ephemeral: true
})

// this will send the ticket setup to the provided channel
channel.send({ embeds: [embed], components: [button, button2]})
}
}
// this will create buttons
const button = new ActionRowBuilder()
.addComponents(
new ButtonBuilder()
.setCustomId(`ticket-setup-${interaction.guild.id}-${category.id}`)
.setLabel('💸 Purchase Ticket')
.setStyle(ButtonStyle.Success)
);

const button2 = new ActionRowBuilder()
.addComponents(
new ButtonBuilder()
.setCustomId(`ticket-setup-${interaction.guild.id}-${category.id}`)
.setLabel('❓ Support Ticket')
.setStyle(ButtonStyle.Success)
);



// this will send confirm reply
await interaction.reply({
content: `The ticket has been setup to ${channel} successfully.`,
ephemeral: true
})

// this will send the ticket setup to the provided channel
channel.send({ embeds: [embed], components: [button, button2]})
}
}
SpecialSauce
SpecialSauce16mo ago
You can’t have two buttons with the same id
Marcus
Marcus16mo ago
Marcus
Marcus16mo ago
how can I make them inlined? I found out