await not behaving nicely after displaying a modal
Very silly question relating to async/await. After I display a modal, I collect the input using:
In the
if(submittedModal) {}
block, my await
commands no longer seem to work asynchronously. For example, I'm trying to make a call to a MySQL database based on the result of the modal (await connection.promise().query('select * ...)
, but it doesn't wait for the results of that query before barrelling on. Am I doing something 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 OPshow your code for the db query
but like with more context
sure! 1 sec
first of all stop using var specially if you are declaring variables with the same name, because they basically get merged, use let or const, var is already out of spec basically
'kay!
so you say that cwflags is coming as undefined?
Right, there's nothing there when I log it
what module are you using for this db calls
mysql2
looked further, i'm going to close this as not discordjs related, i'm doing this with an
insert
in another bot i wrote and it behaves perfectly fine there - i just matched all the syntax and it looks exactly correct, so this appears to be out of scope
thank you though ❤️alright
i was gonna say why you were calling promise before the query
you couldve use execute aswell
i'm just very used to using connection.promise().query() for mysql2, is the short answer
thats alright, you can close the ticket now. If you have more issues feel free to post a new one in #other-js-ts
thanks!