i got error for removing the semi colon
i got error for removing the semi colon
31 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 staffUnknown User•2w ago
Message Not Public
Sign In & Join Server To View
im just confused lol why it got error for removing semi colon
Unknown User•2w ago
Message Not Public
Sign In & Join Server To View
thank you i thought it was necessary
Unknown User•2w ago
Message Not Public
Sign In & Join Server To View
how do u know if its required
Unknown User•2w ago
Message Not Public
Sign In & Join Server To View
oh thank you bro this should be not the variable thing

hey also bro do u know how do i get autocompletion thing on command files
you're supposed to put it on the end of the last line, not at the beginning of the next one
maybe it works but it's definitely not how you're supposed to do it
It’s pretty common to place it at the behinning in codebases not using semicolons
Ig immedietely invoked functions are somewhat rare, but you usually see them every now and then (especially before top level await was a thing). It’s also used for a bunch of literals which ig are also kinda rare (eg.
[1,2,3].forEach(…
)
What I’m saying is that, in codebases that don’t use semicolons at the end of every line (I think that’s the default behavior with prettier formatting?), if they need to seperate statements so they don’t turn into non-sense (for IIFE and the literal examples above), it’s pretty common to place the semicolon at the beginning of the row
Okii ty, my mistakeif you're new to JS, very much consider using semicolons, and even better use a tool like Prettier that manages them for you. Prettier would handle this edge case knowing you can't do
fn() ()
the JS reasoning is that this would attempt to call a function that's the return of your previous function, for example:
Question, I just don't do semicolons, no errors with any of that tho?
you can write plenty of properly functioning js code with no semicolons, but as showcased above, it sometimes causes issues
therefore it's generally recommended just as good practice, even when not necessary
if you search
in:#djs-help-v14 semicolon
in this server, you may find there's quite a few cases of it being necessaryI don't believe in such async statements
Thanks anyways
u forgot the semi colons same mistake that i made
then
do read what I said tho: HIGHLY recommend yourself to equip yourself with Prettier and auto insert them (or remove), regardless of the setting you use, Prettier will cover your ass from ASI
you made him test it his question is a yes or no answer
no, his question was a retorical one
"I don't do semicolons and there's no issues with that code"
so Qjuh said "now test this"
JavaScript actually needs semicolons. If you dont write them, then ASI (automatic semicolon insertion) comes into play.
I believe you are using some prettier (or another formatter) that formats your code, making it not executable.
Let me give you an example:
Prettier will now think that you want to open Line 2 with the
[]
expression and rewrites your code into
which will fail because you can't index a boolean
...
Edit:
I believe in your case the same thing happens but with the ()
expressions
e.g.

P.S. I just noticed you have no formatter, so it is probably the ASI doing this. There is nothing you can do, this is standard JS.

Full explaination: https://medium.com/free-code-camp/codebyte-why-are-explicit-semicolons-important-in-javascript-49550bea0b82
Medium
Why explicit semicolons are important in JavaScript
Gotchas where automatic semicolon insertion can lead to bugs
Unknown User•2w ago
Message Not Public
Sign In & Join Server To View
see my code was right you should put semi colons before the func
@Mark
Thank you for letting us now. I appreciate your valuable input. Im pretty sure OP knew (as you did) that his question was not related to discord.js.
Lucky that u noticed straight ahead that he was just pretending in his code to use discord.js and knew beforehand that his semicolon question had nuffin to do with discord.js because he obv is a professional developer as you are :yya:
I thought it did that
When I get in trouble, I'll change my ways 😭
