InteractionNotReplied, sometimes occurs
hello, i made a bot for hangman, but i am facing an issue where i keep getting this code
D:\Projects\node\discordbot\node_modules\discord.js\src\structures\interfaces\InteractionResponses.js:184
if (!this.deferred && !this.replied) return Promise.reject(new DiscordjsError(ErrorCodes.InteractionNotReplied));
^
Error [InteractionNotReplied]: The reply to this interaction has not been sent or deferred.
at ChatInputCommandInteraction.followUp (D:\Projects\node\discordbot\node_modules\discord.js\src\structures\interfaces\InteractionResponses.js:184:64)
at Object.execute (D:\Projects\node\discordbot\commands\hangman.js:47:17)
at Client.<anonymous> (D:\Projects\node\discordbot\main.js:39:23)
at Client.emit (node:events:518:28)
at InteractionCreateAction.handle (D:\Projects\node\discordbot\node_modules\discord.js\src\client\actions\InteractionCreate.js:97:12)
at module.exports [as INTERACTION_CREATE] (D:\Projects\node\discordbot\node_modules\discord.js\src\client\websocket\handlers\INTERACTION_CREATE.js:4:36)
at WebSocketManager.handlePacket (D:\Projects\node\discordbot\node_modules\discord.js\src\client\websocket\WebSocketManager.js:355:31)
at WebSocketManager.<anonymous> (D:\Projects\node\discordbot\node_modules\discord.js\src\client\websocket\WebSocketManager.js:239:12)
at WebSocketManager.emit (D:\Projects\node\discordbot\node_modules@vladfrangu\async_event_emitter\dist\index.cjs:282:31)
at WebSocketShard.<anonymous> (D:\Projects\node\discordbot\node_modules@discordjs\ws\dist\index.js:1173:51) { code: 'InteractionNotReplied' } Node.js v20.11.0
at WebSocketShard.<anonymous> (D:\Projects\node\discordbot\node_modules@discordjs\ws\dist\index.js:1173:51) { code: 'InteractionNotReplied' } Node.js v20.11.0
4 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 OPwithout including most of the gamelogic, this is how my code works, manipulating an array of active game sessions to see who is playing what game, and if statements to give appropriate replies when they fail/win the game depending on the input
i am testing getting wrong letters in the game of hangman, but sometimes it works and gives me the proper response, and sometimes it just breaks and gives the aforementioned error
Because you're not taking advantage of async/await with your interaction responses like you are with
createNewSession()
. You aren't waiting for the Promise of reply()
to resolve before then trying to follow-up, so now you're getting a race condition where you're sending the reply & follow-up at effectively the same time, You're getting inconsistent results because it's not certain which request will go through firstahhh must have missed that while reading the documentation, and i am also to blame for not figured it out intuitively, thank you very much