Discord bot token error

I have this issue, i can’t find the problem.

SyntaxError: Invalid or unexpected token
at createScript (vm.js:80:10)
at Object.runInThisContext (vm.js:139:10)
at Module._compile (module.js:617:28)
at Object.Module._extensions…js (module.js:664:10)
at Module.load (module.js:566:32)
at tryModuleLoad (module.js:506:12)
at Function.Module._load (module.js:498:3)
at Function.Module.runMain (module.js:694:10)
at startup (bootstrap_node.js:204:16)
at bootstrap_node.js:625:3

weird, doesn’t it usually give a file + line number for syntax errors?

try running a js syntax check on the file you’re running

I was a few minutes checking Syntax, or lines, or errors. But there’s nothing, everything’s seems good.

could it be from running something other than the file you looked at? that’d would be consistent with there not being an obvious file name in the error. any idea what it could be running?

I was thinking about other project with same token, but i already changed the token so i don’t know what it could be.

token here refers to an element of the programming language’s syntax, not a secret string used in authentication

Then i don’t know, i don’t have any idea of what it could be.

Online Node.js Compiler

here’s a sample broken script, you can try running it

/* Simple Hello World in Node.js */
console.log(*);

(I’ve replaced the string with an asterisk)

this gets split up into tokens:

  • /* Simple Hello World in Node.js */ - a comment
  • console - an identifier
  • . - dot
  • log - an identifier
  • ( - parenthesis
  • * - asterisk
  • ) - parenthesis
  • ; - semicolon

these are all tokens. certain patterns of tokens are meaningful, and you can run them as programs. not this sequence of patterns though. usually the asterisk is an operator for multiplying things (or possibly newfangled generator-related syntax) but there are no operands here—nothing to multiply together. it doesn’t have a meaning as a program.

usually the interpreter will tell you about where things went wrong, to the effect of “it made sense up until this point.” running this snippet gives:

/home/cg/root/650107a183006/main.js:2
console.log(*);
            ^

SyntaxError: Unexpected token '*'
    at wrapSafe (internal/modules/cjs/loader.js:915:16)
    at Module._compile (internal/modules/cjs/loader.js:963:27)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
    at Module.load (internal/modules/cjs/loader.js:863:32)
    at Function.Module._load (internal/modules/cjs/loader.js:708:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:60:12)
    at internal/main/run_main_module.js:17:47

(that path being where tutorialspoint apparently saves your script in this tool) but see, it usually shows what file, what line, and in this case even a snippet of the code from that line

Nope, i tried many things but nothing happens.

did you come across any other information about what’s the script where this error is?

Yeah, but nothing helps to me.

what were the few lines before this message then?

rbd/pnpm-volume/96899617-85c2-4e14-8a59-d1c695e21231/node_modules/.registry.npmjs.org/discord.js/14.13.0/node_modules/discord.js/src/client/BaseClient.js:29
userAgentAppendix: options.rest?.userAgentAppendix
^
.

I been thinking that is the package the issue.

1 Like

ah yeah, that’s the indication of where the syntax error is. referring to that ?. part right? that operator is added pretty recently. try running it in node 14+

1 Like

Oh ok, thank you so much. :slight_smile:

Okay. It’s still an issue.

what’s it erroring on now?

/rbd/pnpm-volume/96899617-85c2-4e14-8a59-d1c695e21231/node_modules/discord.js/src/client/Client.js:509
throw new DiscordjsTypeError(ErrorCodes.ClientMissingIntents);
TypeError [ClientMissingIntents]: Valid intents must be provided for the Client.
at Client._validateOptions (/rbd/pnpm-volume/96899617-85c2-4e14-8a59-d1c695e21231/node_modules/discord.js/src/client/Client.js:509:13)
at new Client (/rbd/pnpm-volume/96899617-85c2-4e14-8a59-d1c695e21231/node_modules/discord.js/src/client/Client.js:78:10)
Object. (/app/server.js:25:16)
at Module._compile (node:internal/modules/cjs/loader:1103:14)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12)
at node:internal/main/run_main_module:17:47 {
code: ‘ClientMissingIntents’
}

I think is something that i don’t see.

oh good, that means the program can at least be parsed. I’m gonna let someone else respond to the actual discord.js issues though.

Thank you so much.