Discord seems to have troubles editing an interaction, but still doing it
I have troubles handling interactions reply with the single function below: i have a board with buttons, and when using one the bot should reply with another board of the same type. Then, I have to click another button before having a final confirmation message, but at this point the reply content is edited alone, the button stay in the loading position before being edited and I have the interaction failed error, event though the reply was sent and I didn't receive any error (video linked)
The problem happens on editReply, I don't understand why as I am using it the right way (or do I?)
IMO editReply should be usable several times, I you may edit multiple times a reply
It's only visual as absolutely no error is triggered, but still really annoying as the user would think that something went wrong.
13 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 OPYou should use
.update()
on the coming interaction, not .editReply()
on the old interaction. If you don't respond to the interaction that just created, Discord won't know if it's successful.Update trigger the already aknowledged interaction error
For the case that I show in the video, the first click trigger the basic reply, and then editReply on the second clic
What's brainfucking me is that it doesn't actually crash
Everything run normally
The error is only present in the app
Did you use .deferUpdate()?
Nope
But I tried doing so, and the problem remains
It only happens when I use editReply
It's hard to say without seeing the actual code of sending editing these buttons
The function handling this is the code block in my initial message
It's the global function I'm calling for each reply/editReply I use in the code
Yeah I saw that code. But I need the code that use this function
I tried switching the global function with reply + editreply, and the problem remained
I'm not on my pc rn, I'll give the code later if you want
Feel free to ask any clarification, I tried to make it as readable as possible
Ah, you got a point, I'll try that
It doesn't work: the interaction is already sent, so calling update would trigger the already sent error. And I can't call it in the first place, because the board is meant to be static so it would edit the board message to use update first
Event tho using update after all this is still a better thing to do, my problem is located before that
The first click trigger a interaction.reply, resulting in the list message with the numbers.
Then, I click and it triggers an editReply, editing the message. But the problem is that even though the interaction is actually edited right away, the buttons stay in the loading position and give the interaction failed error after the 3s delay
As if Discord isn't aware that it successfully edited the interaction, if I should schematize the problem
It doesn't work
Update is used for the initial response
And i don't want to update the initial message, as it is the board
I must reply first if I wanna keep the board in place
Calling update on that message triggers the already aknowledged interaction error, I already tried
It's considered as a reply to the first interaction
I actually called it on the interaction, I just poor-worded my sentence, my bad
If you want to see the global interaction event handler, i didn't showed it as it's not triggered by my current case (only the initial interaction, that seems to work as intended), and I don't want to flood you with irrelevant code
Hum, would it be easier to understand if I point to you the starting point in the github repo, and you follow it by yourself from there ?
GitHub
Sparky/src/main.ts at main · Kyusaor/Sparky
Bot d'aide pour Lords Mobile. Contribute to Kyusaor/Sparky development by creating an account on GitHub.
The command is called setglobalping in the buttonInteraction handler
Ah, it's probably that indeed
I'll try tomorrow, I'll let you know if it's working. Thanks for taking your time to help!
Yup, obviously
I already started to fix that earlier
It worked, thanks