Issues with awaitMessageComponent
hey everyone.. trying to make a little game and having trouble with buttons.
if my user sends a slash command, i get an
Interaction
object, which i can reply to using .reply()
, attach buttons to that reply, and get the button output using .awaitMessageComponent()
.
this works perfectly.
.awaitMessageComponent()
returns a promise interaction that itself can be replied to.
I.E. something like this would hypothetically be able to be done (this is pseudocode - please excuse if there are any minor errors).
The idea is that we can reply to the initial slash command with a button message, then once they interact with the buttons, we reply to that interaction, allowing for a pretty clean turn-based combat system.
The issue i'm having is, whenever i create a reply to a button interaction, the buttons that i attach to it are unable to be read. I am sure it reaches the await reply.awaitMessageComponent(...)
code, but the await simply never finishes and it times out after three minutes, despite me pressing the buttons.
I would appreciate any advice on how to fix this error, or perhaps a more idiomatic manner in which i might solve the actual issue i'm having.
I am on version 14.16.3
. Thank you so much for the help =)12 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 OPdiscord.js version
14.16.3
node version 22.12.0
Unknown User•2mo ago
Message Not Public
Sign In & Join Server To View
ahh that works but it breaks on ephemeral messages
i had specifically done it this way to try and avoid the "10008: Unknown Message" error
do you think there is a way to make that happen after all
Unknown User•2mo ago
Message Not Public
Sign In & Join Server To View
turning on fetchReply is actually known to fix problems with ephemeral messages
can you show your exact code?
Unknown User•2mo ago
Message Not Public
Sign In & Join Server To View
strangely adding
fetchReply
to the initial reply actually breaks that one too
i can send my code
shoulds be most of what's relevantyou're trying to reply twice?
ah nvm thought show was called after pickAbility
which components aren't working though? and when?
when i make the reply here have
fetchReply: true
then the code this.response.edit({ components: [] });
in PlayerFighter.pickAbility()
throws the error DiscordAPIError[10008]: Unknown Message
if i don't make that one fetchReply: true
and only have this one in PlayerFighter.show()
be fetchReply: true
, then the same error is thrown at the same line of code, except that the first one works perfectly fine without needing fetchReply: true
, so it only errors once the second button input is performed
if i don't use fetchReply: true
at all, then the second button input (post PlayerFighter.show()
) simply hangs, and the code await this.response.awaitMessageComponent({ filter: e => e.user.id === this.id, time: 180_000 });
never finishes runningUnknown User•2mo ago
Message Not Public
Sign In & Join Server To View
yes
that fixed it x.x
thank you so much for the help