!servericon和!uptime命令给出错误

时间:2020-09-05 12:33:57

标签: javascript discord.js bots

下面的我的正常运行时间命令:

# e and d 3 times
# m and b 1 times
# s 2 times

当我使用此命令时,出现错误:

( <3 e d>, <1 m b>, <2 s> )

下面的我的服务器图标命令:

const Discord = require('discord.js');

module.exports = {
  name: 'uptime',
  aliases: ['TimeOn'], 
  description: "",
  execute(client, message, args) { 

    let totalSeconds = client.uptime / 1000;
    let days = Math.floor(totalSeconds / 86400);
    let hours = Math.floor(totalSeconds / 3600);
    totalSeconds %= 3600;
    let minutes = Math.floor(totalSeconds / 60);
    let seconds = totalSeconds % 60;
          
    let uptime = `?️ ${days.toFixed()} days\n?️ ${hours.toFixed()} hours\n?️ ${minutes.toFixed()} minutes\n?️ ${seconds.toFixed()} seconds`;
          
    const embed = new Discord.MessageEmbed()
      .setTitle(`Uptime ?️`)
      .setThumbnail("https://imgur.com/WZMylbw.gif")
      .setColor("#FF0000")
      .setDescription(`**I've been online for**\n${uptime}`)

    message.channel.send(embed);
  }
};

当我使用此命令时,会出现错误:TypeError:

TypeError: Cannot read property 'send' of undefined 

有人知道如何解决这些错误吗?

1 个答案:

答案 0 :(得分:0)

请不要在此引用我的信息,因为您可能会对其进行不同的设置,但是请尝试将message参数放在第一位,我认为我没有真正看过它它,如果未在命令处理程序中以这种方式设置它,它将无法正常工作。因此,message可能返回undefined,而client返回实际消息。要对此进行测试,请尝试client.guild.idclient.channel.send()