discord - 我正在制作一个不和谐的机器人......我一直收到这个错误
问题描述
我正在使用“ban”命令(discord.js)制作一个不和谐的机器人,但我不断收到此错误.... [解析错误意外令牌案例]
剧本:
case 'ban': {
if (!isMod)
return;
let userID = args.includes('<@!') ? args.replace('<@!', '').replace('>', '')
: args.includes('<@') ? args.replace('<@', '').replace('<', '') : '';
if (userID == '') {
message.reply('Invalid user ID or mention.');
return;
}
message.guild.fetchMember(userID).then(member => {
member.kick("Banned by " + message.author.tag).then(m => {
message.channel.send(' Banned <@' + userID + '>.');
}).catch(() => {
console.error;
message.reply('Could not ban the specified member.');
});
};
break;
});
User.ban({reason: banReason})
解决方案
你错过了一个括号。
case 'ban': {
if (!isMod)
return;
let userID = args.includes('<@!') ? args.replace('<@!', '').replace('>', '')
: args.includes('<@') ? args.replace('<@', '').replace('<', '') : '';
if (userID == '') {
message.reply('Invalid user ID or mention.');
return;
}
message.guild.fetchMember(userID).then(member => {
member.kick("Banned by " + message.author.tag).then(m => {
message.channel.send(' Banned <@' + userID + '>.');
}).catch(() => {
console.error;
message.reply('Could not ban the specified member.');
});
});
break;
}
在 break 语句之前检查 - 这就是问题所在。
推荐阅读
- python - 有没有更好的读取文件的方法?
- pandas - 替换 DataFrame 中的 NaN 值
- angular - Angular LocalStorage Service setter 和 getter 不被识别为函数
- security - 如何存储用于在不同平台上进行身份验证的密码?
- excel - 运行时错误 91 将数据复制到工作簿并通过电子邮件发送
- python - 无法在 PHP 中解码来自 Python 的 JSON 字符串
- css - 如何管理我在同一张卡中从用户那里获取的不同尺寸的图像?
- javascript - 我应该如何测试我的不同汇总包
- javascript - 在javascript中将简单数组转换为“嵌套数组”的方法是什么?
- angular - 如何在 Angular 应用程序中显示 SSRS 报告?