Disable button method not working?

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);
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);
10 Replies
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
AJ
AJOP2y ago
Apologies for the awful formatting, I just copied and pasted. Here's a pastebin:
AJ
AJOP2y ago
Pastebin
var embed = new EmbedBuilder() .setImage(result.body.ima...
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
AJ
AJOP2y ago
msg.edit was also tried instead of msg.update. both of those just return {this} is not a function.
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
AJ
AJOP2y ago
Should be the interaction Trying to edit the interaction response
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
AJ
AJOP2y ago
Currently out on a bike ride, will do that in 30 mins
Parogo_72
Parogo_722y ago
fetchReply: true inside the interaction.reply and then msg.edit or use interaction.editReply()
AJ
AJOP2y ago
Nice one, thanks
Want results from more Discord servers?
Add your server