#Editing message buttons
1 messages · Page 1 of 1 (latest)
Making a thread so others aren't as confused by who you're talking to :P
I also realized I'm braindead and both errors are not occurring at the same time.
This code produces this error:
async function confirmPrompt(message, time) {
const confirmButtons = new MessageActionRow()
.addComponents(
new MessageButton()
.setCustomId('confirm')
.setLabel('Confirm')
.setStyle('SUCCESS')
.setDisabled(true),
new MessageButton()
.setCustomId('cancel')
.setLabel('Cancel')
.setStyle('DANGER')
.setDisabled(true)
);
// No need to check for author because the message is ephemeral
return await message.awaitMessageComponent({
filter: (i) => i.customId == "confirm" || i.customId == "cancel",
time: time,
componentType: 'BUTTON'
}).then((interaction) => {
interaction.update({
components: [ confirmButtons ]
});
if (interaction.customId == "confirm") {
return "confirm";
} else {
return "cancel";
}
})
.catch(() => {
message.edit({
components: [ confirmButtons ]
});
return "cancel";
})
}
DiscordAPIError: Unknown Message
at RequestHandler.execute (G:\Code\Debugging\Discord\TLGOadmin\node_modules\discord.js\src\rest\RequestHandler.js:350:13)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async RequestHandler.push (G:\Code\Debugging\Discord\TLGOadmin\node_modules\discord.js\src\rest\RequestHandler.js:51:14)
at async MessageManager.edit (G:\Code\Debugging\Discord\TLGOadmin\node_modules\discord.js\src\managers\MessageManager.js:132:15) {
method: 'patch',
path: '/channels/929000047029420034/messages/931716547716726805',
code: 10008,
httpStatus: 404,
requestData: {
avatar_url: undefined,
allowed_mentions: undefined,
flags: 64,
message_reference: undefined,
attachments: undefined,
sticker_ids: undefined
},
files: []
}
}
Changing the
.catch(() => {
message.edit({
components: [ confirmButtons ]
});
return "cancel";
})
to
.catch((message) => {
message.edit({
components: [ confirmButtons ]
});
return "cancel";
})
throws
TypeError: message.edit is not a function
at G:\Code\Debugging\Discord\TLGOadmin\commands\ban.js:142:17
at async confirmPrompt (G:\Code\Debugging\Discord\TLGOadmin\commands\ban.js:126:12)
at async G:\Code\Debugging\Discord\TLGOadmin\commands\ban.js:66:34
at async Object.execute (G:\Code\Debugging\Discord\TLGOadmin\commands\ban.js:56:13)
at async Client.<anonymous> (G:\Code\Debugging\Discord\TLGOadmin\index.js:40:3)
G:\Code\Debugging\Discord\TLGOadmin\node_modules\discord.js\src\structures\interfaces\InteractionResponses.js:90
if (this.deferred || this.replied) throw new Error('INTERACTION_ALREADY_REPLIED');
^
Error [INTERACTION_ALREADY_REPLIED]: The reply to this interaction has already been sent or deferred.
at CommandInteraction.reply (G:\Code\Debugging\Discord\TLGOadmin\node_modules\discord.js\src\structures\interfaces\InteractionResponses.js:90:46)
at Client.<anonymous> (G:\Code\Debugging\Discord\TLGOadmin\index.js:43:22) {
[Symbol(code)]: 'INTERACTION_ALREADY_REPLIED'
}
dapi error stack traces are stupid as always
the second way isn't valid anyway
so you can ignore it for now
👍
can you log message in the catch please


My message collector is working though, so it's definitely defined
so you wanna tell me that it logged empty
Precisely!
I suppose I could in theory just edit the buttons outside of the function (although i'd rather do it inside)...
The only difference between us is mine is getting called by a slash command, and the message that is fetched is a reply to it. (and it is ephemeral)
I don't see why any of this should affect it though
yes
you can edit ephemeral messages right?
I mean, if I do click a button it does work
in the .then()
so editing buttons on an ephemeral message is possible
no
updating using an interaction is a different thing
if its an ephemeral reply and you dont click the button, no
the message the buttons are attached to?
yes
initial reply
Will try
omg it works
Thank you so much
I've spent the last two hours working on this 🤯
yk, you could have told me that with the ephemeral reply and slash command first 
in a comment for the code i posted was // No need to check for author because the message is ephemeral
I thought you knew :P
I will be more explicit next time lol
well how should I know, all I see is a variable called "message" xD
lmao

