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 = "[email protected]";
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 = "[email protected]";
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 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.
Bella Moonaria
interaction.values is undefined
Marcus
MarcusOP2y ago
hmm but it should not be undefined
Bella Moonaria
You're accessing it in the beginning of your event, not even checking if its a select menu interaction
Marcus
MarcusOP2y ago
So where do I have to place it
SpecialSauce
SpecialSauce2y ago
After you check if it’s a select menu interaction. Otherwise that prop doesn’t exist
Marcus
MarcusOP2y ago
Marcus
MarcusOP2y 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
SpecialSauce2y ago
You can’t have two buttons with the same id
Marcus
MarcusOP2y ago
Marcus
MarcusOP2y ago
how can I make them inlined? I found out
Want results from more Discord servers?
Add your server