Bot running 2 commands at once
does anyone know why my code would be running 2 different commands at 1 time when I use the balance command code is the first comment
9 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 OP-- command want to run
https://hastebin.com/share/jakajuguwi.javascript
-- additional command ran
https://hastebin.com/share/xazefigiqu.javascript
-- index.js code
https://hastebin.com/share/opazewiqam.javascript
I have more commands I am in the process of adding but havent activated them yet because I wanted to figure this out first
BIG UPDATE: Now when I run any command the new ones (the ones in the original post) run as well
In JavaScript, = is used for assignment, == for loose equality, and === for strict equality checks.
- Equality and sameness in JavaScript: learn more
So why would it be messing up all of a sudden? It works correctly if I comment out those commands.
You are not comparing the commandName, you are reassigning it. Which will return the reassigned name and a non-empty string will always be truthy. So all your if statements runs. See the tag
Also, you'd benifit from having a command handler instead of multiple if..else
That when I’m adding commands to the code I literally copy and paste the part the commandName line and then I just change the command name and code that goes into the command itself. These aren’t the first commands I’ve added into my bot.
I promise I’m not trying to sound rude if I use words like literally and I hope my last sentence didn’t sound too rude either 😅 it just blows my mind that I did my normal routine when I added those 2 new commands and all of a sudden it’s messed up. After work I’m gonna comment those out and see if it goes back to normal
So why did I have almost 50 commands working until I added the balance command?
I never said I only had 1 command before I added these 2 new ones 😉
regardless of how the mistake happened, it's there
fix that and it should work
Can you atleast make it make sense on why it’s just now all of a sudden an issue?
oh my god, 🤦♂️ I hate dyslexia and everything about my eyes right now 😅 I was thinking I had a single = on every command 🤦♂️ thinking about it now I don't think I copy-pasted like normal for the 'addmoney' command...However, I copied and pasted the wrong code when I made the other economy commands. I'm so sorry for sounding rude. I didn't mean it that way at all