我正在使用discord.js,node.js和npm制作一个discord机器人。我收到此错误:SyntaxError:意外令牌'}'。我有点白痴,所以我真的无法说出是什么给了我这个语法错误,或更确切地说,是这个错误发生的地方。
// a is funny letter haha laugh
const Discord = require("discord.js")
const client = new Discord.Client()
// epicly loads main commands like an epic
require('./core/loadWidgetListeners')(client);
// verify login thats kinda epic tho ngl
client.on("ready", () => {
console.log(`Logged in as ${client.user.tag}!`)
})
// not epic function makes me not feel epic ): UnU
function hasUpperCase(str) {
return (/[A-Z]/.test(str) // EPIC FUNCTION EPIC
}
// epic ping pong teehee
client.on("message", msg => {
if (msg.content.toLowerCase() === "ping") {
if (hasUpperCase(msg.content)) {
msg.reply("pong! (screw you for using uppercase characters in that command)")
} else {
msg.reply("pong!")
}
}
})
// haha funny message aaaaaaaaaaaaaaaaaaaaaaaaaa aSd ASADSdaS
client.on("message", msg => {
if (msg.content.toLowerCase() === "snoopdoguhohstinky") {
msg.channel.send("n o")
}
})
// logging code makes me EA SPORTS
client.on('ready', () => {
console.log(`${client.user.username} is active.`);
})
// hack my bot, i dare you.
client.login("CENSORED FOR OBVIOUS REASONS")
js让我觉得自己像个笨蛋
答案 0 :(得分:3)
以下行缺少右括号。
return (/[A-Z]/.test(str) // EPIC FUNCTION EPIC