【发布时间】:2021-01-10 04:41:19
【问题描述】:
我只是想测试我的机器人是否工作,我很确定我做的一切都正确,但似乎有问题。每次我运行我的 ping 命令时,它都会向我抛出一个错误。
错误:
(node:9304) UnhandledPromiseRejectionWarning: ReferenceError: Invalid left-hand side in assignment
at Object.run (C:\Users\Familia\OneDrive\Documents\Other Stuff\Visual Studio code\blade\commands\ping.js:10:38)
at Client.<anonymous> (C:\Users\Familia\OneDrive\Documents\Other Stuff\Visual Studio code\blade\bot.js:55:42)
我的 Ping.js 代码:
const Discord = require('discord.js')
module.exports = {
name: "ping",
description: "test command",
async run (client, message, args) {
const ping = new Discord.MessageEmbed()
.setDescription(`????\`${Date.now() - message.createdTimestamp}\`ms`);
message.channel.send(ping);
}
}
这是 bot.js:55:42 的参考:
client.on("message", async message => {
if(message.content.startsWith(prefix)) {
const args = message.content.slice(prefix.length).trim().split(/ +/);
const command = args.shift().toLowerCase();
if(!client.commands.has(command)) return;
try {
client.commands.get(command).run(client, message, args); // This line
} catch (error){
console.error(error);
}
}
})
如果这似乎是一个愚蠢的问题,我很抱歉,我很抱歉!
【问题讨论】:
标签: node.js discord discord.js