admin管理员组文章数量:1390503
I am not great at coding, really i'm still learning, but usually I can solve my own problems, however, i'm stuck here. I 'm not sure what is preventing the bot from running, Here is my current code:
const Discord = require("discord.js");
const TOKEN = "myToken";
const PREFIX = "f!"
var bot = new Discord.Client();
bot.on("ready", function() {
console.log("Ready");
});
bot.on("message", function (message) {
if (message.author.equals(bot.user)) return;
if (!message.content.startsWith(PREFIX)) return;
var args = message.content.substring(PREFIX.length).split(" ");
switch (args[0]) {
case "ping";
message.channel.sendMessage("Pong!");
break;
}
});
bot.login(TOKEN);
However, when i run it in cmd with the mand "node index", it doesn't run, even though the previous version I made did work, when i try to run this version, I get the following error statements;
SyntaxError: Unexpected token )
at createScript (vm.js:80:10)
at Object.runInThisContext (vm.js:139:10)
at Module._pile (module.js:588:28)
at Object.Module._extensions..js (module.js:635:10)
at Module.load (module.js:545:32)
at tryModuleLoad (module.js:508:12)
at Function.Module._load (module.js:500:3)
at Function.Module.runMain (module.js:665:10)
at startup (bootstrap_node.js:187:16)
at bootstrap_node.js:607:3
Any help would be appreciated, sorry if i sound like a total idiot.
I am not great at coding, really i'm still learning, but usually I can solve my own problems, however, i'm stuck here. I 'm not sure what is preventing the bot from running, Here is my current code:
const Discord = require("discord.js");
const TOKEN = "myToken";
const PREFIX = "f!"
var bot = new Discord.Client();
bot.on("ready", function() {
console.log("Ready");
});
bot.on("message", function (message) {
if (message.author.equals(bot.user)) return;
if (!message.content.startsWith(PREFIX)) return;
var args = message.content.substring(PREFIX.length).split(" ");
switch (args[0]) {
case "ping";
message.channel.sendMessage("Pong!");
break;
}
});
bot.login(TOKEN);
However, when i run it in cmd with the mand "node index", it doesn't run, even though the previous version I made did work, when i try to run this version, I get the following error statements;
SyntaxError: Unexpected token )
at createScript (vm.js:80:10)
at Object.runInThisContext (vm.js:139:10)
at Module._pile (module.js:588:28)
at Object.Module._extensions..js (module.js:635:10)
at Module.load (module.js:545:32)
at tryModuleLoad (module.js:508:12)
at Function.Module._load (module.js:500:3)
at Function.Module.runMain (module.js:665:10)
at startup (bootstrap_node.js:187:16)
at bootstrap_node.js:607:3
Any help would be appreciated, sorry if i sound like a total idiot.
Share Improve this question edited Apr 2, 2018 at 18:42 André 4,4974 gold badges33 silver badges58 bronze badges asked Oct 1, 2017 at 19:36 Marley S.Marley S. 191 gold badge1 silver badge2 bronze badges 1- By the way, do not post your token publicly to anyone. Always keep tokens to yourself. This is because anyone can access to your bot as long as they have the token. (I remend you reset your bot's token now) In the future, just replace the values of the token to something else that isn't a token. (People will get it as long as the value/variable name is not misleading.) – WQYeo Commented Oct 1, 2017 at 19:51
1 Answer
Reset to default 1The problem is in switch
statement, you need :
after case
, but there is ;
switch (args[0]) {
case "ping"; //here should be :
message.channel.sendMessage("Pong!");
break;
}
本文标签: javascriptSyntax Error Unexpected Tokendiscord bot codingStack Overflow
版权声明:本文标题:javascript - Syntax Error: Unexpected Token, discord bot coding - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744659890a2618180.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论