Bots 节点app.js语法错误:意外令牌
我是编程新手,我想用Atom和Javascript制作一个discord机器人。我以前有一些编程经验,但不多。我试图通过其他带有相同错误代码的Q/A来寻求帮助,但我仍然不明白为什么我的程序不能工作。我在网上找到了写这篇文章的方法 我的计划是:Bots 节点app.js语法错误:意外令牌,bots,discord,unexpected-token,Bots,Discord,Unexpected Token,我是编程新手,我想用Atom和Javascript制作一个discord机器人。我以前有一些编程经验,但不多。我试图通过其他带有相同错误代码的Q/A来寻求帮助,但我仍然不明白为什么我的程序不能工作。我在网上找到了写这篇文章的方法 我的计划是: const Discord = require("discord.js"); const Config = require("./config.json"); const Token = require("./token.json"); con
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);
当我试图通过输入“node app.js”在Windows Powershell上使用node运行它时,它返回了错误消息:
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
我不明白怎么了!有人请帮我运行程序。如果出现以下情况,您会遇到问题:
if{message.author.bot} return;
vs
你有解决办法吗?如果是的话,你能把它贴在这里吗/
if(message.author.bot) return;