我正在执行一个可以计算机器人ping的命令,但是我遇到了问题。告诉我msg
未定义。我应该如何定义它?这是我的代码:
module.exports = {
name: 'ping',
description: "shows the bot/'s ping",
execute(message, args) {
message.channel.send('`ping is being calculated...`').then((message) => {
const ping = msg.createdTimestamp - message.createdTimestamp;
message.edit(`${ping} ms`);
});
},
};
答案 0 :(得分:1)
您的message
被定义为message
,而不是msg
。只需编辑此行:
.then((msg) => {
const ping = msg.createdTimestamp - message.createdTimestamp;
msg.edit(ping + 'ms');
});
答案 1 :(得分:0)
代码本身是正确的,您只是传递了错误的名称作为参数。使用msg
代替message
。
message.channel.send("ping is being calculated...").then((msg) => {
const ping = msg.createdTimestamp - message.createdTimestamp;
message.edit(`${ping} ms`);
});