"this interaction failed"

const seeRooms = async (interaction, embed, page, room_names, channel_id, room_pictures, count) => {

embed.setAuthor({ name: `Please select the room you are looking for!` })
.setTitle(`Room Name: ${room_names[page-1]}`)
.setFooter({ text:`Page ${page}/${room_names.length}` })
.setImage(room_pictures[page-1])

const left_button = new discord.ButtonBuilder()
.setCustomId('left')
.setEmoji('◀')
.setStyle(discord.ButtonStyle.Secondary)

const right_button = new discord.ButtonBuilder()
.setCustomId('right')
.setEmoji('▶')
.setStyle(discord.ButtonStyle.Secondary)

const select_button = new discord.ButtonBuilder()
.setCustomId('select')
.setEmoji('⏹')
.setStyle(discord.ButtonStyle.Secondary)

if(page == 1){
left_button.setDisabled(true)
}

if(page == room_names.length){
right_button.setDisabled(true)
}

const buttonsRow = new discord.ActionRowBuilder()
.addComponents(left_button, select_button, right_button)

var msg

if(interaction.deffered || interaction.replied){
msg = await interaction.editReply({ embeds: [embed], components: [buttonsRow] })
}
else{
msg = await interaction.update({ embeds: [embed], components: [buttonsRow] })
}

const collector = msg.createMessageComponentCollector({ componentType: discord.ComponentType.Button, time: 6*1000*60 })
collector.on('collect', async i => {
switch(i.customId){
case 'left':
page -= 1
count+=1
seeRooms(interaction, embed, page, room_names, channel_id, room_pictures, count)
break
case 'right':
page +=1
count+=1
seeRooms(interaction, embed, page, room_names, channel_id, room_pictures, count)
break
case 'select':
console.log('select')
break
}
})
}
const seeRooms = async (interaction, embed, page, room_names, channel_id, room_pictures, count) => {

embed.setAuthor({ name: `Please select the room you are looking for!` })
.setTitle(`Room Name: ${room_names[page-1]}`)
.setFooter({ text:`Page ${page}/${room_names.length}` })
.setImage(room_pictures[page-1])

const left_button = new discord.ButtonBuilder()
.setCustomId('left')
.setEmoji('◀')
.setStyle(discord.ButtonStyle.Secondary)

const right_button = new discord.ButtonBuilder()
.setCustomId('right')
.setEmoji('▶')
.setStyle(discord.ButtonStyle.Secondary)

const select_button = new discord.ButtonBuilder()
.setCustomId('select')
.setEmoji('⏹')
.setStyle(discord.ButtonStyle.Secondary)

if(page == 1){
left_button.setDisabled(true)
}

if(page == room_names.length){
right_button.setDisabled(true)
}

const buttonsRow = new discord.ActionRowBuilder()
.addComponents(left_button, select_button, right_button)

var msg

if(interaction.deffered || interaction.replied){
msg = await interaction.editReply({ embeds: [embed], components: [buttonsRow] })
}
else{
msg = await interaction.update({ embeds: [embed], components: [buttonsRow] })
}

const collector = msg.createMessageComponentCollector({ componentType: discord.ComponentType.Button, time: 6*1000*60 })
collector.on('collect', async i => {
switch(i.customId){
case 'left':
page -= 1
count+=1
seeRooms(interaction, embed, page, room_names, channel_id, room_pictures, count)
break
case 'right':
page +=1
count+=1
seeRooms(interaction, embed, page, room_names, channel_id, room_pictures, count)
break
case 'select':
console.log('select')
break
}
})
}
4 Replies
d.js toolkit
d.js toolkit12mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button! - Marked as resolved by staff
meap moop
meap moopOP12mo ago
im trying to create a simple page flipping embed thing. where if i press a button it shows u the next page and so on. everything works perfectly find but if i press it doesnt actually finish the interaction or something and on discord it says "'this interaction failed". how can i fix this? everything works fine i think its more of just discord api and need to tell discord that this interaction has been finished i would appricaite if someone could help <33 thanks ├── [email protected] ├── [email protected] └── [email protected] ^ npm list
d.js docs
d.js docs12mo ago
discord.js includes multiple sub-packages, installing these separately can mess with internal code:
npm uninstall discord-api-types @discordjs/rest @discordjs/builders
yarn remove discord-api-types @discordjs/rest @discordjs/builders
pnpm remove discord-api-types @discordjs/rest @discordjs/builders
npm uninstall discord-api-types @discordjs/rest @discordjs/builders
yarn remove discord-api-types @discordjs/rest @discordjs/builders
pnpm remove discord-api-types @discordjs/rest @discordjs/builders
meap moop
meap moopOP12mo ago
Could u explain to me ahat u mean? i feel like that doesnt solve the issue since the listeners are working completely fine… nvm i founjd the fix! i had to deferupdate on the new interaction which is caused by the button and then pass in interaction to the new function ty for the reply tho :] problem was that since im uodating the original interaction, the new interaction caused by the button is not gettin updated
Want results from more Discord servers?
Add your server