Error with JavaScript code

Ok so I’m like really new to JavaScript so yeah please let me know what the error in this code is, Thanks!

The code:

const Discord = require('discord.js');

const bot = new Discord.client();

const token = '(token)';

bot.on('ready', () =>{

    console.log('This bot is online!');



The error message in VS code terminal:

node .
bot.on('ready', () => );

SyntaxError: Unexpected token ')'
    at wrapSafe (internal/modules/cjs/loader.js:1053:16)
    at Module._compile (internal/modules/cjs/loader.js:1101:27)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1157:10)
    at Module.load (internal/modules/cjs/loader.js:985:32)
    at Function.Module._load (internal/modules/cjs/loader.js:878:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
    at internal/main/run_main_module.js:17:47

Please let me know what the problem is at it wont let me run my discord bot :confused:

1 Like

you should be aware that sharing the token here might be dangerous, not sure if anyone could copy your code and use the bot for you XD, so just paste a random thing there if you didnt.

Oh, Thanks for informing m!

In the discord page for the bot, the client method is using capital letters,
like so

const bot = new Discord.Client();

I’d try that but I can’t guarantee anything.

Also, if you don’t see a console.log, I’d remove the backticks surrounding the log. From `console.log(‘this bot is online!’)` to console.log(‘this bot is online!’)
as the backticks are not necessary in this case.

1 Like

I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (’).