Javascript 我的discord.js代码说它不能输出空消息,即使它不应该是空的

Javascript 我的discord.js代码说它不能输出空消息,即使它不应该是空的,javascript,node.js,discord.js,Javascript,Node.js,Discord.js,我有一个discord.js机器人,我想添加一个info命令。我告诉它获取用户信息,它在控制台中吐了出来: (node:15012) UnhandledPromiseRejectionWarning: DiscordAPIError: Cannot send an empty message at RequestHandler.execute (C:\Users\jakub\OneDrive\Počítač\da discord bot\node_modules\discord.js\s

我有一个discord.js机器人,我想添加一个info命令。我告诉它获取用户信息,它在控制台中吐了出来:

(node:15012) UnhandledPromiseRejectionWarning: DiscordAPIError: Cannot send an empty message
    at RequestHandler.execute (C:\Users\jakub\OneDrive\Počítač\da discord bot\node_modules\discord.js\src\rest\RequestHandler.js:154:13)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
    at async RequestHandler.push (C:\Users\jakub\OneDrive\Počítač\da discord bot\node_modules\discord.js\src\rest\RequestHandler.js:39:14)
(node:15012) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:15012) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
(node:15012) UnhandledPromiseRejectionWarning: DiscordAPIError: Cannot send an empty message
    at RequestHandler.execute (C:\Users\jakub\OneDrive\Počítač\da discord bot\node_modules\discord.js\src\rest\RequestHandler.js:154:13)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
    at async RequestHandler.push (C:\Users\jakub\OneDrive\Počítač\da discord bot\node_modules\discord.js\src\rest\RequestHandler.js:39:14)
(node:15012) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)
(node:15012) UnhandledPromiseRejectionWarning: DiscordAPIError: Cannot send an empty message
    at RequestHandler.execute (C:\Users\jakub\OneDrive\Počítač\da discord bot\node_modules\discord.js\src\rest\RequestHandler.js:154:13)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
    at async RequestHandler.push (C:\Users\jakub\OneDrive\Počítač\da discord bot\node_modules\discord.js\src\rest\RequestHandler.js:39:14)
(node:15012) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 3)
(node:15012) UnhandledPromiseRejectionWarning: DiscordAPIError: Cannot send an empty message
    at RequestHandler.execute (C:\Users\jakub\OneDrive\Počítač\da discord bot\node_modules\discord.js\src\rest\RequestHandler.js:154:13)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
    at async RequestHandler.push (C:\Users\jakub\OneDrive\Počítač\da discord bot\node_modules\discord.js\src\rest\RequestHandler.js:39:14)
(node:15012) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 4)
这是我的密码

函数信息(){
message.channel.send(message.notices.users);
else if(命令==“信息”){
如果(!args[0]){
返回message.channel.send(“您需要提供一个参数”);
}
else if(message.guild.member(message.notices.users.length==0)){
返回message.channel.send(“您需要Ping某人!”);
}
message.channel.send(info.username);
message.channel.send(info.createdAt);
message.channel.send(info.id);
message.channel.send(info.joinedAt);
}
);

我如何才能1.改进我的代码,2.帮助解决问题?

让我们假装我没有看到
,否则,如果在您的代码块中散步

function info() {
  message.channel.send(message.mentions.users);

  if (command === "info") {
    if (!args) { // [0] is useless here
      return message.reply("You Need to provide an argument");
    } else if (!message.mentions.users) {
      return message.reply("You Need to Ping someone!");
    }

    message.channel.send(`${info.username}\n${info.createdAt}\n${info.id}\n${info.joinedAt}`)

  }
};
我要补充一点,我对你的代码一无所知。 以下是我所改变的:

  • 试图更正语法错误
  • 去除多余的东西
  • 没有多次发送消息:这是因为速率限制,最重要的是慢节点

如果这是您给出的错误所涉及的唯一代码,那么很有可能是的,您正在尝试发送空消息:该
info
甚至定义在哪里?

让我们假设我没有看到该
否则,如果在您的代码块中散步

function info() {
  message.channel.send(message.mentions.users);

  if (command === "info") {
    if (!args) { // [0] is useless here
      return message.reply("You Need to provide an argument");
    } else if (!message.mentions.users) {
      return message.reply("You Need to Ping someone!");
    }

    message.channel.send(`${info.username}\n${info.createdAt}\n${info.id}\n${info.joinedAt}`)

  }
};
我要补充一点,我对你的代码一无所知。 以下是我所改变的:

  • 试图更正语法错误
  • 去除多余的东西
  • 没有多次发送消息:这是因为速率限制,最重要的是慢节点

如果这是您给出的错误所涉及的唯一代码,那么很有可能是的,您试图发送的是空消息:该
info
哪有定义?

您的代码似乎有点混乱您的代码似乎有点混乱