How to delete reply of an interaction that caused my interaction after 3 seconds?
I have a message with a button, when that button is clicked it sends another ephemeral message with another button. How do I delete the message that was sent by the previous interaction, when the last button so clicked after 3+ seconds.
How do I delete message 2 once I press No. I tried using interaction.deferReply and interaction.deferUpdate already. interaction.deleteReply() (also in combination with interaction.deleteReply()) does not work, it gives me an unknown webhook error.
17 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!Why not to make the communityevent response an ephemereal message and then update it?
The community event is supposed to be a public message. The organizer should than be able to cancel it by using the cancel button. Then the organizer should be asked for confirmation. Turning the public communityevent response into a confirmation sadly doesn’t work.
I don’t want to delete the public message, I want to delete the second (ephemeral) message asking to confirm the action.
From what I can see that is trying to delete the response to the slash command so the message with the title A. I’m trying to delete the confirmation message. (Message 2)
The principal is same, you maybe using the wrong interaction object,
<ButtonInteraction>.deferUpdate()
<ButtonInteraction>.deleteReply()
The first button interaction object ("Cancel") or the second ("no")?
When the buttons on the second response is clicked, you can also use the original interaction but you'll have to pass in the created message to
deleteReply()
callIsn't deleteReply() enough, if I use the original (first( Button Interaction)
Depending on how you do it
Why not just show us the code instead of making us guess
Pastebin
communityevent.js - Pastebin.com
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.
Pastebin
cancelevent.js - Pastebin.com
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.
Pastebin
canceleventabort.js - Pastebin.com
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.
Like qjuh said, do it wherever you handle the buttons for "Yes" and "No"
Do I need to have access to the first interaction object or is there a way to do it with only the second interaction object?
I have a command and button handler that runs a file based on the custom id
Yes, you can do it with your second interaction ^
You were told already...
How would I go about doing that with the second interaction object. interaction.message.delete() doesn't seem to work. (I might be using it incorrectly tho)
This ^ please read. I don't know how many times i need to point
With await please
I tried sending the message then deffering the update then deleting the interaction message. It gives me an Unknown Mesage error.
First message (cancel button)
Second message (no button)
From my understanding I'm telling discord to reply, then to wait for an update and then tell them to update (delete) the message.
Sorry, I thought it wasn't applicable for the example. I put the code in the wrong part. It works now.
I thought the code in the first message was supposed to be for the first handler.
Why do I need to defer an update for a new interaction tho?
I'm responding within 3 seconds.
So I need to react to interaction 2 so the reply triggered by interaction 1 exists (which can then be deleted)?
I just don't understand why I'm able to keep interaction 1 "alive" by defering interaction 2.
So what interaction.message.delete() should do?