无法读取makeBWAPIRequest的属性

时间:2019-09-06 17:03:12

标签: javascript node.js

我正在设置一个可以搜索电影数据库的机器人

module.exports.run = async (bot, message, args) => {
 let response = await bot.methods.makeBWAPIRequest('/nasa/apod');

  await message.channel.send({
    embed: {
      author: {
        name: 'Astronomy Picture of the Day',
        url: 'http://apod.nasa.gov/'
      },
      title: response.title,
      description: response.explanation,
      image: {
        url: response.hdurl || response.url
      },
      footer: {
        text: `Powered by NASA • Image Credit & Copyright - ${response.copyright}`
      }
    }
  });

};
(node:2267) UnhandledPromiseRejectionWarning: TypeError: Cannot read
property 'makeBWAPIRequest' of undefined

at Object.module.exports.run (/app/commands/Developer/test.js:4:35)

at Client.bot.on (/app/events/message.js:49:30)

   at Client.emit (events.js:189:13)

   at MessageCreateHandler.handle (/rbd/pnpm-volume/a3979b19-6440-4f90-b018-3b40fba4eac3/node_modules/.registry.npmjs.org/discord.js/11.5.1/node_modules/discord.js/src/client/websocket/packets/handlers/MessageCreate.js:9:34)

   at WebSocketPacketManager.handle (/rbd/pnpm-volume/a3979b19-6440-4f90-b018-3b40fba4eac3/node_modules/.registry.npmjs.org/discord.js/11.5.1/node_modules/discord.js/src/client/websocket/packets/WebSocketPacketManager.js:105:65)

   at WebSocketConnection.onPacket (/rbd/pnpm-volume/a3979b19-6440-4f90-b018-3b40fba4eac3/node_modules/.registry.npmjs.org/discord.js/11.5.1/node_modules/discord.js/src/client/websocket/WebSocketConnection.js:333:35)

   at WebSocketConnection.onMessage (/rbd/pnpm-volume/a3979b19-6440-4f90-b018-3b40fba4eac3/node_modules/.registry.npmjs.org/discord.js/11.5.1/node_modules/discord.js/src/client/websocket/WebSocketConnection.js:296:17)

   at WebSocket.onMessage (/rbd/pnpm-volume/a3979b19-6440-4f90-b018-3b40fba4eac3/node_modules/.registry.npmjs.org/ws/6.2.1/node_modules/ws/lib/event-target.js:120:16)

   at WebSocket.emit (events.js:189:13)

   at Receiver.receiverOnMessage (/rbd/pnpm-volume/a3979b19-6440-4f90-b018-3b40fba4eac3/node_modules/.registry.npmjs.org/ws/6.2.1/node_modules/ws/lib/websocket.js:789:20)

(node:2267) 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(). (rejection id: 1)

(node:2267) [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.

0 个答案:

没有答案