Why is my discord bot's script showing "Uncaught syntax error: unexpected identifier"?

79 Views Asked by At

I'm new to creating discord bots and I made this hello world code but it is not working. In node.js, I did the "nodemon --inspect index.js" but it says "uncaught syntax error: unexpected identifier". I've installed nodemon and discord.js already, and also copied the code from discord.js.org but it still doesn't work like it should. What should I do to make it work?

const Discord = require('discord.js');
const client = new Discord.Client();

client.on('ready', () => {
  console.log(`Logged in as ${client.user.tag}!`);
});

client.on('message', msg => {
  if (msg.content === 'ping') {
    msg.reply('Pong!');
  }
});

client.login('token');
0

There are 0 best solutions below