execute function not ending after return statement?
Hello, I have the following
assign.js
command that I am trying to use to assign a targeted user to a specific team, which is kept track of in a MySQL database.
https://hastebin.skyra.pw/tusanaxana.js
When the user is not found to have registered in the database, I am expecting that the function should stop, because there is a return statement on line 26. However, this is not the case. All the subsequent lines of code still continue to run, and I'm not sure why. Any help would be greatly appreciated, thank you!
This is what I get logged in my console after I run the command and purposefully select a user that has not registered, along with a team name that I know is not valid. https://hastebin.skyra.pw/egaxekiweb.txt7 Replies
- What's your exact discord.js
npm list discord.js
and node node -v
version?
- Post the full error stack trace, not just the top part!
- Show your code!
- Explain what exactly your issue is.
- Not a discord.js issue? Check out #useful-servers.[email protected] and node v18.15.0
I have a feeling that the issue has something to do with the
return
statement on line 26 being nested within the callback function of con.execute()
on line 22, but I’m not sure how to properly solve the problemThe return just stops the function and returns to your code. Why the interaction.reply isn't working unsure
What I would do is have the function return a state then test for the state if it passes then continue the code if it fails end execution and send your reply
some thing like this
This was sent feom my phone so it may contain errors it is to be taken as an example and not an actual solution
so if I had something like
then my
something
variable would hold the value true
?It's should but you may want to do an await con.execute so that something has the intended value
Thanks! I will give this a shot when I get home
Just think of it this way if you want your code to stop after the function you will also need to tell the code to stop. If the function will take more than milliseconds to complete ie connecting to an outside source you will need to await the promise or you will recieve un intended results