javascript - 需要帮助找到我哪里出错了 DiscordJS
问题描述
与机器人混在一起没有任何 javascript 经验,所以我无法发现我出错的地方,它说的是意外的令牌并指向)最后我猜这不是问题,而是其他问题
const Discord = require('discord.js');
const client = new Discord.Client();
const {
prefix,
token
} = require('./config.json');
client.once('ready', () => {
console.log('Online');
});
client.on('message', message => {
const args = message.content.slice(prefix.length).trim().split(' ');
const command = args.shift().toLowerCase();
if (!message.content.startsWith(prefix) || message.author.bot) return;
else if (command === 'bargun') {
message.channel.send('bargun number one siege player I get wet when I hear his name');
} else if (command === 'siege') {
message.channel.send('Siege is Shit Game');
} else if (command === 'shaiiko') {
message.channel.send('Shaiiko is the coolest guy ever i want to be him')
} else if (command === 'kruzty') {
message.channel.send('Kruzty is a bitch');
} else if (command === 'cunt') {
if (!args.length) {
return message.channel.send(`${message.author} is a cunt`);
message.channel.send(`${command}\n${args} is a cunt.`);
};
}); client.login(token);
解决方案
const Discord = require('discord.js');
const client = new Discord.Client();
const {
prefix,
token
} = require('./config.json');
client.once('ready', () => {
console.log('Online');
});
client.on('message', message => {
const args = message.content.slice(prefix.length).trim().split(' ');
const command = args.shift().toLowerCase();
if (!message.content.startsWith(prefix) || message.author.bot) return;
else if (command === 'bargun') {
message.channel.send('bargun number one siege player I get wet when I hear his name');
} else if (command === 'siege') {
message.channel.send('Siege is Shit Game');
} else if (command === 'shaiiko') {
message.channel.send('Shaiiko is the coolest guy ever i want to be him')
} else if (command === 'kruzty') {
message.channel.send('Kruzty is a bitch');
} else if (command === 'cunt') {
if (!args.length) {
return message.channel.send(`${message.author} is a cunt`);
message.channel.send(`${command}\n${args} is a cunt.`);
};
}
});
client.login(token);
你在最后一个“else if”语句之后缺少一个'}'。这应该工作
推荐阅读
- git - 下载 GitHub 历史记录(提交、消息、分支、贡献者……)
- java - instanceOfT.getClass() 不返回类
- html - HTML 电子邮件签名 各种电子邮件的问题
- forms - 如何在移动到下一张幻灯片之前验证离子幻灯片中的表单?
- android - Firebase 动态链接在自定义域中无法正常工作
- python - 根据自定义逻辑操作列表
- bash - bash:从存储在变量中的日期中减去一天
- javascript - 从同一类的另一个方法中的事件侦听器中删除 JavaScript 类方法
- python - pyinstaller 无法识别捆绑的数据目录
- laravel - 我们的域参与了发送垃圾邮件,现在没有电子邮件进入收件箱