让我的不和谐机器人从随机数组发送图像时遇到问题

时间:2021-01-18 03:54:28

标签: javascript arrays discord

我正在尝试制作一个机器人,当使用命令时,它会从数组中随机选择一个图像并将其发送到通道。但我不断收到以下错误:

(node:15680) UnhandledPromiseRejectionWarning: Error: ENOENT: no such file or directory, stat 'C:\DIRECTORYOFBOT'
(node:15680) 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)

数组:

  'https://media.giphy.com/media/CZpro4AZHs436/giphy.gif',
  'https://media.giphy.com/media/CZpro4AZHs436/giphy2.gif',
  'https://media.giphy.com/media/CZpro4AZHs436/giphy3.gif',
  ]

使机器人从数组中随机选择并发送的代码:

    message.channel.send({files: rando_imgs[Math.floor(Math.random() * rando_imgs.length)]})
    }
  }

我是 JavaScript 的初学者,所以请不要打扰我。

0 个答案:

没有答案