Understanding the differences between various deleteReply functions
Discordjs version: [email protected]
Node version: v20.8.1
I've got a SlashCommand that spawns the interaction shown in the picuture.
The idea is to show a ephemeral message, click a button to "edit" various options and then after pressing "apply" show the new overview of the settings.
I'm struggling to understand the differences between the various "deleteReply" functions.
I have this function
button_updateSettings
to handle the click event for the "Apply" button.
What is the correct/best way to delete the "Bot is waiting..." message?
Why do some options not work/throw an error?3 Replies
- What's your exact discord.js
npm list discord.js
and node node -v
version?
- Not a discord.js issue? Check out #other-js-ts.
- Consider reading #how-to-get-help to improve your question!
- Explain what exactly your issue is.
- Post the full error stack trace, not just the top part!
- Show your code!
- Issue solved? Press the button!
- ✅
Marked as resolved by OP<Interaction>.deleteReply()
deletes a reply to an interaction
by default it deletes the initial response, but you can delete a different message by specifying a message id
this is why await interaction.deleteReply(interaction.message.id)
deletes the message the component is on, because that's the message you told it to delete
<Interaction>.deleteReply()
internally just uses <Interaction>.webhook.deleteMessage()
, so you're free to use either method
the issue with using loadingMessage.id
in your second and fourth examples is that deferReply
resolves in an InterationResponse
if you don't specify fetchReply: true
in the options
in this case, loadingMessage.id
would be the button interaction's id, which isn't a valid message id
all of this being said, is there a reason you're not just using <ButtonInteraction>.update()
or <ButtonInteraction>.deferUpdate()
?thank you for the detailed response! This example was mostly for demonstration purposes because I was confused as to why the second and fourth example would differ from the third, I wasn't aware of the
fetchReply: true
option. Regarding update()/deferUpdate()
, maybe I misunderstood the docs but isn't editReply
supposed to be an alternative? Why would I still need to call update()/deferUpdate()
? (I'm currently busy but I will try it later this day)