Button Interactions

hello! im trying to make a way to send different embed depending on the rarity. it works when i press a button but the only issue is, discord itself flags it as "This interaction failed" whenever the person uses it. so i think its still waiting for my bot to response even though it has. this is the code and below is an image of what the player sees after using the button
if (interaction.customId === "roam") {
const rarity = randomm(1, 100);
if (rarity >= 60) {
const roamembed = new EmbedBuilder()
.setTitle("Roaming")
.setDescription("You haven't found anything yet");
console.log("found nothing");
await interaction.message.edit({ embeds: [roamembed] });
} else if (rarity >= 40) {
const mobs = $Var.mobs;
const snakeembed = new EmbedBuilder()
.setTitle(`Target Found: ${mobs.mob1.name}`)
.setDescription(
`
Level Recommended: 1-15

*Rewards*
- Jol ${mobs.mob1.rewards.jol}
- Exp ${mobs.mob1.rewards.Exp}
- Drops ${mobs.mob1.rewards.drops}
`
)
.setThumbnail(mobs.mob1.image);

// Create action row with both buttons
const actionRow = new ActionRowBuilder().addComponents(
new ButtonBuilder()
.setCustomId("roam")
.setLabel("ROAM")
.setStyle(ButtonStyle.Primary),
new ButtonBuilder()
.setCustomId("fight")
.setLabel("FIGHT")
.setStyle(ButtonStyle.Danger)
);
console.log("found Snake");
await interaction.message.edit({
embeds: [snakeembed],
components: [actionRow],
});
}
}
if (interaction.customId === "roam") {
const rarity = randomm(1, 100);
if (rarity >= 60) {
const roamembed = new EmbedBuilder()
.setTitle("Roaming")
.setDescription("You haven't found anything yet");
console.log("found nothing");
await interaction.message.edit({ embeds: [roamembed] });
} else if (rarity >= 40) {
const mobs = $Var.mobs;
const snakeembed = new EmbedBuilder()
.setTitle(`Target Found: ${mobs.mob1.name}`)
.setDescription(
`
Level Recommended: 1-15

*Rewards*
- Jol ${mobs.mob1.rewards.jol}
- Exp ${mobs.mob1.rewards.Exp}
- Drops ${mobs.mob1.rewards.drops}
`
)
.setThumbnail(mobs.mob1.image);

// Create action row with both buttons
const actionRow = new ActionRowBuilder().addComponents(
new ButtonBuilder()
.setCustomId("roam")
.setLabel("ROAM")
.setStyle(ButtonStyle.Primary),
new ButtonBuilder()
.setCustomId("fight")
.setLabel("FIGHT")
.setStyle(ButtonStyle.Danger)
);
console.log("found Snake");
await interaction.message.edit({
embeds: [snakeembed],
components: [actionRow],
});
}
}
No description
4 Replies
d.js docs
d.js docs10mo ago
:method: ButtonInteraction#update() Updates the original message of the component on which the interaction was received on.
AlexCdDg
AlexCdDg10mo ago
Using <ButtonInteraction>.message.edit does not acknowledge the interaction But .update does
TOPRYUNO
TOPRYUNOOP10mo ago
interesting illl try it thanks for the help! didnt know that was a function i could use
AlexCdDg
AlexCdDg10mo ago
No problem 👍
Want results from more Discord servers?
Add your server