Interaction has already been acknowledged
Hi, I am making a Discord bot which utilizes interactions and message ids. Basically, whenever a message id is supplied into a command, it should currently reply back with the name of the channel which the command was run in. However, if the id is invalid, it should reply back with an error message.
Unfortunately so, the bot does reply with the channel name everytime the command is ran (regardless of the validity of the message id), and if the message id was invalid it just throws an error into the console, which goes as follows:
Command code below:
Thank you in advance for any tips and/or suggestions for improvements to the code :cronchycat:
14 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 OPyour return in your catch isnt doing anything
it is just returning its value
so your code will still progress
oh? how would i proceed with stopping the code at that point then?
use await
or store the result and do an instanceof check later
Could also do a .then()
unfortunately when I do that it the discord api just throws back this and the bot crashes
you can indeed also use a .then
Thank you in advance, will give feedback right when I get back to my pc :OKAY:
Np
mind showing me how to do that? I'm not really experienced in js as I've thought
:mdn: Using promises
A Promise is an object representing the eventual completion or failure of an asynchronous operation. Since most people are consumers of already-created promises, this guide will explain consumption of returned promises before explaining how to create them.
@treble/luna not sure if im doing it quite right, but i followed the docs you sent and made this up
now it throws
DiscordAPIError[10008]: Unknown Message
Unknown User•2mo ago
Message Not Public
Sign In & Join Server To View
Thank you very much!
I was gonna use the message variable to complete the to-do - get all the users which reacted to that specific message i didnt even notice i put that in there twice, oops
Also it was just a quick bot project, not something that I was wishing upon expanding/maintaining so I just skipped past the command handler thingy