#Disable button method not working?

1 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);