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.
No description
17 Replies
d.js toolkit
d.js toolkit3mo ago
- 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!
Syjalo
Syjalo3mo ago
Why not to make the communityevent response an ephemereal message and then update it?
// Delete the message the button is attached to
await interaction.deferUpdate();
await interaction.deleteReply();

// Send a follow up message
await interaction,followUp('Message 2');
// Delete the message the button is attached to
await interaction.deferUpdate();
await interaction.deleteReply();

// Send a follow up message
await interaction,followUp('Message 2');
Maxi130
Maxi130OP3mo ago
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)
Maxi130
Maxi130OP3mo ago
No description
NyR
NyR3mo ago
The principal is same, you maybe using the wrong interaction object, <ButtonInteraction>.deferUpdate() <ButtonInteraction>.deleteReply()
Maxi130
Maxi130OP3mo ago
The first button interaction object ("Cancel") or the second ("no")?
NyR
NyR3mo ago
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() call
Maxi130
Maxi130OP3mo ago
Isn't deleteReply() enough, if I use the original (first( Button Interaction)
NyR
NyR3mo ago
Depending on how you do it Why not just show us the code instead of making us guess
Maxi130
Maxi130OP3mo ago
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.
NyR
NyR3mo ago
Like qjuh said, do it wherever you handle the buttons for "Yes" and "No"
Maxi130
Maxi130OP3mo ago
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
NyR
NyR3mo ago
Yes, you can do it with your second interaction ^ You were told already...
Maxi130
Maxi130OP3mo ago
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)
NyR
NyR3mo ago
This ^ please read. I don't know how many times i need to point
Syjalo
Syjalo3mo ago
With await please
Maxi130
Maxi130OP3mo ago
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)
interaction
.reply({
content:
"Do you want to cancel this event? (This should dissappear if no is selected)",
components: [actionRow],
})
.then(() => {
interaction.deferUpdate()
})
interaction
.reply({
content:
"Do you want to cancel this event? (This should dissappear if no is selected)",
components: [actionRow],
})
.then(() => {
interaction.deferUpdate()
})
Second message (no button)
interaction.message.delete()
interaction.message.delete()
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?
Want results from more Discord servers?
Add your server