所以,我正在编写一个不和谐的机器人,一切正常,直到我发送命令,然后我收到错误“类型错误:无法读取未定义的属性'发送'。”我不知道我做错了什么。 ping.js:
module.exports = {
name: 'ping',
description: 'this is a ping command.',
commands: ['ping', 'uptime', 'latency', 'server', 'api'],
permissionError: 'you need be able send messages',
permissions: ['SEND_MESSAGES'],
async execute(message, client, Harrybot, Discord) {
var color = [0x00c09a, 0x008369, 0x00d166, 0x008e44, 0x0099e1, 0x006798, 0xa652bb, 0x712f8f, 0xfd0061, 0xbc0057, 0xf8c300, 0xcc7900, 0xf93a2f, 0xa62019, 0x91a6a6, 0x969c9f, 0x597e8d, 0x4e6f7b];
var randomColor = color[Math.floor(Math.random() * color.length)];
const pingEmbed = {
color: randomColor,
title: '〽️ Pinging...',
};
console.log(`--ping`);
const m = await message.channel.send({ embed: pingEmbed });
return m.edit({
embed: {
color: randomColor,
title: `?`,
fields: [
{
name: 'Server latency',
value: `\`${m.createdTimestamp - message.createdTimestamp}ms\``
},
{
name: 'API latency:',
value: `\`${Math.round(message.client.ws.ping)}ms\``
},
{
name: 'Uptime:',
value: `\`${(message.client.uptime) / 1000} seconds\`.`,
},
],
}
});
}
};
在我切换到不同的命令处理程序之前,这曾经有效