#How to edit an embed that was sent alongside buttons upon user interaction when clicking on a button

21 messages · Page 1 of 1 (latest)

misty wagon
#
const { ActionRowBuilder, ButtonBuilder, ButtonStyle } = require("discord.js")
const { EmbedBuilder } = require("discord.js");

module.exports = {
    name: "bees",
    description: "Show all bees in game!",
    run: async (client, interaction) => {
        const row = new ActionRowBuilder();
        
        const rarebeesbutton = new ButtonBuilder()
        .setCustomId("rarebees")
        .setLabel("Rare Bees")
        .setStyle(ButtonStyle.Primary);

        const epicbeesbutton = new ButtonBuilder()
        .setCustomId("epicbees")
        .setLabel("Epic Bees")
        .setStyle(ButtonStyle.Primary);

        const legendarybeesbutton = new ButtonBuilder()
        .setCustomId("legendarybees")
        .setLabel("Legendary Bees")
        .setStyle(ButtonStyle.Primary);

        const mythicbeesbutton = new ButtonBuilder()
        .setCustomId("mythicbees")
        .setLabel("Mythic Bees")
        .setStyle(ButtonStyle.Primary);

        const eventbeesbutton = new ButtonBuilder()
        .setCustomId("eventbees")
        .setLabel("Event Bees")
        .setStyle(ButtonStyle.Primary);


        row.addComponents([rarebeesbutton, epicbeesbutton, legendarybeesbutton, mythicbeesbutton, eventbeesbutton]);

        const beesembed = new EmbedBuilder()
            .setTitle('BSS Bee Types')
            .setColor(0x0099FF)
            .setDescription('Using the dropdown menu below, please choose which rarity bee type you would like to look at')
            .setThumbnail("https://media.discordapp.net/attachments/1002120413414965248/1002120775198842961/iconnew.png")
            .setFooter({ text: `Developed by Qwerty`});

        return interaction.followUp({ embeds: [beesembed], components: [row] });
    }
};

I created this command which sends an embed alongside buttons. Now, when a specific button is clicked, I want to edit the original embed sent and have different title and description set

patent wadi
#

• 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.

misty wagon
#

This is my interactionCreate event

#

Is there anything I need to change to edit the original embed?

#

It seems to keep saying this when I try the buttons out

vale verge
#

Because you need to begin with a reply

#

Or a deferReply etc

#

Nerf gun probs gonna explain things better then I would

misty wagon
#

interaction.deferReply?

vale verge
#

If you wanna go ahead

#

If you wanna edit the message you can use interaction.update I think

#

Interaction.message.edit

#

Update is better from my knowledge

misty wagon
#

Okay thanks, I will try this out.

vale verge
#

You can do like
.update({embeds: []})

misty wagon
#

@vale verge Do you know how to make it so that only the person who used the command can click the buttons and anyone who is trying to click the buttons and hasnt sent the command cannot click on the buttons for interactions

smoky atlas
vale verge
#

Like my brain just took a few seconds to get that one but it’s so obvious