Struggling with awaitMessageComponent

I've got two awaitMessageComponent for a button, and then a select menu. I'm not really sure what is happening but when I click the button, everything is fine. THEN, when the select menu appears, I try to select an item, it immediately says int failed, I choose again and it works....
5 Replies
d.js docs
d.js docs3y 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.
Syjalo
Syjalo3y ago
Show the code
larkx
larkxOP3y ago
I'll send the whole thing
let embed = new MessageEmbed()
.setColor('#EDA920')

if(action == 'add') {
embed.setDescription('Choose what currency the list is in.')

let gbpButton = new MessageButton().setCustomId('gbp').setLabel('£ GBP').setStyle('PRIMARY')
let usdButton = new MessageButton().setCustomId('usd').setLabel('$ USD').setStyle('PRIMARY')
let eurButton = new MessageButton().setCustomId('eur').setLabel('€ EUR').setStyle('PRIMARY')

let row = new MessageActionRow().addComponents(gbpButton, usdButton, eurButton)
const btnResponseMsg = await interaction.reply({ embeds: [embed], components: [row], fetchReply: true, ephemeral: true })

const filter = (i) => i.user.id === interaction.user.id;
const selectedCurrency = await btnResponseMsg.awaitMessageComponent({ filter, componentType: 'BUTTON', time: 60000 })
const currency = selectedCurrency.customId
embed.setDescription('Select the price of the list.')

const units = {
'gbp': '£',
'usd': '$',
'eur': '€'
}
let embed = new MessageEmbed()
.setColor('#EDA920')

if(action == 'add') {
embed.setDescription('Choose what currency the list is in.')

let gbpButton = new MessageButton().setCustomId('gbp').setLabel('£ GBP').setStyle('PRIMARY')
let usdButton = new MessageButton().setCustomId('usd').setLabel('$ USD').setStyle('PRIMARY')
let eurButton = new MessageButton().setCustomId('eur').setLabel('€ EUR').setStyle('PRIMARY')

let row = new MessageActionRow().addComponents(gbpButton, usdButton, eurButton)
const btnResponseMsg = await interaction.reply({ embeds: [embed], components: [row], fetchReply: true, ephemeral: true })

const filter = (i) => i.user.id === interaction.user.id;
const selectedCurrency = await btnResponseMsg.awaitMessageComponent({ filter, componentType: 'BUTTON', time: 60000 })
const currency = selectedCurrency.customId
embed.setDescription('Select the price of the list.')

const units = {
'gbp': '£',
'usd': '$',
'eur': '€'
}
let row2 = new MessageActionRow()
.addComponents(
new MessageSelectMenu()
.setCustomId('addManagePrice')
.setPlaceholder('Select an price...')
.addOptions([
{ label: `${units[currency]}300`, value: '300' },
{ label: `${units[currency]}400`, value: '400' },
{ label: `${units[currency]}500`, value: '500' },
{ label: `${units[currency]}600`, value: '600' }
]),
);
interaction.editReply()
const selectResponseMsg = await interaction.editReply({ embeds: [embed], components: [row2], fetchReply: true, ephemeral: true })
const selectedPrice = await selectResponseMsg.awaitMessageComponent({ filter, componentType: 'SELECT_MENU', time: 60000 })
const price = selectedPrice.values

console.log(price)

const db = new QuickDB();
const listsDB = db.table('lists')
//listsDB.set(`${currency}.${}`)
}
let row2 = new MessageActionRow()
.addComponents(
new MessageSelectMenu()
.setCustomId('addManagePrice')
.setPlaceholder('Select an price...')
.addOptions([
{ label: `${units[currency]}300`, value: '300' },
{ label: `${units[currency]}400`, value: '400' },
{ label: `${units[currency]}500`, value: '500' },
{ label: `${units[currency]}600`, value: '600' }
]),
);
interaction.editReply()
const selectResponseMsg = await interaction.editReply({ embeds: [embed], components: [row2], fetchReply: true, ephemeral: true })
const selectedPrice = await selectResponseMsg.awaitMessageComponent({ filter, componentType: 'SELECT_MENU', time: 60000 })
const price = selectedPrice.values

console.log(price)

const db = new QuickDB();
const listsDB = db.table('lists')
//listsDB.set(`${currency}.${}`)
}
I haven't yet because I haven't gotten to that point No no, I get interaction failed before submitting let me make a gif of what happens
larkx
larkxOP3y ago
THANK YOU thank you thank you thank you new issue… Why isn't my modal submission acknowledging? I recieve the data but the modal doesn't close on the clients side??
const modalSubmission = await selectedPrice.awaitModalSubmit({ time: 300000 });
const pcppURL = modalSubmission.fields.getTextInputValue('list')
console.log(pcppURL)
embed.setDescription('The list has been created.')
selectedPrice.editReply({ embeds: [embed], components: [], ephemeral: true })
modalSubmission.reply({ embeds: [embed], components: [], ephemeral: true })
const modalSubmission = await selectedPrice.awaitModalSubmit({ time: 300000 });
const pcppURL = modalSubmission.fields.getTextInputValue('list')
console.log(pcppURL)
embed.setDescription('The list has been created.')
selectedPrice.editReply({ embeds: [embed], components: [], ephemeral: true })
modalSubmission.reply({ embeds: [embed], components: [], ephemeral: true })
Want results from more Discord servers?
Add your server