#Disable button method not working?

15 messages · Page 1 of 1 (latest)

rugged crater
#

NSFW - Hello, i'm using this to edit a command that is used to post an NSFW image to the server. This button allows the user to repeat the command without having to type it out. What i'm looking for, is a way to restrict the button from being pressed for 5 seconds, then for it to enable itself after this 5 seconds is up. Please let me know what i would need to change, or add for this.

var embed = new EmbedBuilder()
            .setImage(result.body.image.split(" ").join(""))
            .setColor(settings.embed_colour)
            .setFooter({ text: `Displaying ${interaction.options._hoistedOptions[0].value.toLowerCase()} (hentai)` })
            interaction.reply({ embeds: [ embed ], components: [ button ] })
            .then(msg => {
                setTimeout(function() {
                    var button = new ActionRowBuilder()
                    .addComponents(
                        new ButtonBuilder()
                        .setCustomId(`repeat.hentai.${interaction.options._hoistedOptions[0].value.toLowerCase()}`)
                        .setLabel('Repeat')
                        .setStyle(ButtonStyle.Primary)
                        .setDisabled(false),
                    );

                    msg.update({ embeds: [ embed ], components: [ button ] })
                }, 5000);
            })
            .catch(console.error);
flat dew
#

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

rugged crater
#

Apologies for the awful formatting, I just copied and pasted.

#

Here's a pastebin:

#

msg.edit was also tried instead of msg.update.

#

both of those just return {this} is not a function.

minor palm
rugged crater
#

Should be the interaction

#

Trying to edit the interaction response

minor palm
#

pastebin the entire file :)

#

also can you show the full error* stack?

rugged crater
brittle eagle
#

or use interaction.editReply()