0

I'm new to programming and I wanted to make a discord bot using Atom and Javascript. I had some previous programming experience, but not much. I tried to find help through other Q/A's with the same error code but I still can't figure out why my program doesn't work. I found how to write this online.

My program is:

const Discord = require("discord.js");  
const Config = require("./config.json");  
const Token = require("./token.json");  
const bot = new Discord.Client({disableEveryone: true})  
bot.on("ready", async () =>{    
    console.log(`${bot.user.username} is online! It's running on 
      ${bot.guild.size} servers!`);    
    bot.user.setActivity("Work in Progress", {type: "WATCHING"});  })  
    bot.on("message", async message => {    
       if{message.author.bot} return;    
       if(message.channel.type === "dm") return;    
       message.channel.send("Swift bot testing...")  })  
       bot.login(Token.token);

When I tried to run it with node on Windows Powershell by entering "node app.js", it returned with the error message:

   SyntaxError: 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 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

I don't understand what is wrong! Somebody please help me get my program running.

1
  • Have you got the solution? if yes, then can you please post it here/ Commented Dec 18, 2018 at 10:00

1 Answer 1

1

You have a problem in if:

if{message.author.bot} return;   

vs

if(message.author.bot) return;   
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.