【发布时间】:2021-10-29 04:38:54
【问题描述】:
我在控制台中收到此错误:
(node:33480) UnhandledPromiseRejectionWarning: TypeError: Function.prototype.apply was called on #<Object>, which is
a object and not a function
at MessageCollector.handleCollect (C:\Users\RIJAK\Documents\GitHub\asta-jr\node_modules\discord.js\src\structures\interfaces\Collector.js:92:53)
at Client.emit (events.js:327:22)
at MessageCreateAction.handle (C:\Users\RIJAK\Documents\GitHub\asta-jr\node_modules\discord.js\src\client\actions\MessageCreate.js:31:14)
at Object.module.exports [as MESSAGE_CREATE] (C:\Users\RIJAK\Documents\GitHub\asta-jr\node_modules\discord.js\src\client\websocket\handlers\MESSAGE_CREATE.js:4:32)
at WebSocketManager.handlePacket (C:\Users\RIJAK\Documents\GitHub\asta-jr\node_modules\discord.js\src\client\websocket\WebSocketManager.js:384:31)
at WebSocketShard.onPacket (C:\Users\RIJAK\Documents\GitHub\asta-jr\node_modules\discord.js\src\client\websocket\WebSocketShard.js:444:22)
at WebSocketShard.onMessage (C:\Users\RIJAK\Documents\GitHub\asta-jr\node_modules\discord.js\src\client\websocket\WebSocketShard.js:301:10)
at WebSocket.onMessage (C:\Users\RIJAK\Documents\GitHub\asta-jr\node_modules\ws\lib\event-target.js:132:16)
at WebSocket.emit (events.js:315:20)
at Receiver.receiverOnMessage (C:\Users\RIJAK\Documents\GitHub\asta-jr\node_modules\ws\lib\websocket.js:978:20)
(node:33480) 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:33480) [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:33480) UnhandledPromiseRejectionWarning: TypeError: Function.prototype.apply was called on #<Object>, which is
a object and not a function
at MessageCollector.handleCollect (C:\Users\RIJAK\Documents\GitHub\asta-jr\node_modules\discord.js\src\structures\interfaces\Collector.js:92:53)
at Client.emit (events.js:327:22)
at MessageCreateAction.handle (C:\Users\RIJAK\Documents\GitHub\asta-jr\node_modules\discord.js\src\client\actions\MessageCreate.js:31:14)
at Object.module.exports [as MESSAGE_CREATE] (C:\Users\RIJAK\Documents\GitHub\asta-jr\node_modules\discord.js\src\client\websocket\handlers\MESSAGE_CREATE.js:4:32)
at WebSocketManager.handlePacket (C:\Users\RIJAK\Documents\GitHub\asta-jr\node_modules\discord.js\src\client\websocket\WebSocketManager.js:384:31)
at WebSocketShard.onPacket (C:\Users\RIJAK\Documents\GitHub\asta-jr\node_modules\discord.js\src\client\websocket\WebSocketShard.js:444:22)
at WebSocketShard.onMessage (C:\Users\RIJAK\Documents\GitHub\asta-jr\node_modules\discord.js\src\client\websocket\WebSocketShard.js:301:10)
at WebSocket.onMessage (C:\Users\RIJAK\Documents\GitHub\asta-jr\node_modules\ws\lib\event-target.js:132:16)
at WebSocket.emit (events.js:315:20)
at Receiver.receiverOnMessage (C:\Users\RIJAK\Documents\GitHub\asta-jr\node_modules\ws\lib\websocket.js:978:20)
(node:33480) 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:33480) UnhandledPromiseRejectionWarning: TypeError: Function.prototype.apply was called on #<Object>, which is
a object and not a function
at MessageCollector.handleCollect (C:\Users\RIJAK\Documents\GitHub\asta-jr\node_modules\discord.js\src\structures\interfaces\Collector.js:92:53)
at Client.emit (events.js:327:22)
at MessageCreateAction.handle (C:\Users\RIJAK\Documents\GitHub\asta-jr\node_modules\discord.js\src\client\actions\MessageCreate.js:31:14)
at Object.module.exports [as MESSAGE_CREATE] (C:\Users\RIJAK\Documents\GitHub\asta-jr\node_modules\discord.js\src\client\websocket\handlers\MESSAGE_CREATE.js:4:32)
at WebSocketManager.handlePacket (C:\Users\RIJAK\Documents\GitHub\asta-jr\node_modules\discord.js\src\client\websocket\WebSocketManager.js:384:31)
at WebSocketShard.onPacket (C:\Users\RIJAK\Documents\GitHub\asta-jr\node_modules\discord.js\src\client\websocket\WebSocketShard.js:444:22)
at WebSocketShard.onMessage (C:\Users\RIJAK\Documents\GitHub\asta-jr\node_modules\discord.js\src\client\websocket\WebSocketShard.js:301:10)
at WebSocket.onMessage (C:\Users\RIJAK\Documents\GitHub\asta-jr\node_modules\ws\lib\event-target.js:132:16)
at WebSocket.emit (events.js:315:20)
at Receiver.receiverOnMessage (C:\Users\RIJAK\Documents\GitHub\asta-jr\node_modules\ws\lib\websocket.js:978:20)
(node:33480) 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:33480) UnhandledPromiseRejectionWarning: TypeError: Function.prototype.apply was called on #<Object>, which is
a object and not a function
at MessageCollector.handleCollect (C:\Users\RIJAK\Documents\GitHub\asta-jr\node_modules\discord.js\src\structures\interfaces\Collector.js:92:53)
at Client.emit (events.js:327:22)
at MessageCreateAction.handle (C:\Users\RIJAK\Documents\GitHub\asta-jr\node_modules\discord.js\src\client\actions\MessageCreate.js:31:14)
at Object.module.exports [as MESSAGE_CREATE] (C:\Users\RIJAK\Documents\GitHub\asta-jr\node_modules\discord.js\src\client\websocket\handlers\MESSAGE_CREATE.js:4:32)
at WebSocketManager.handlePacket (C:\Users\RIJAK\Documents\GitHub\asta-jr\node_modules\discord.js\src\client\websocket\WebSocketManager.js:384:31)
at WebSocketShard.onPacket (C:\Users\RIJAK\Documents\GitHub\asta-jr\node_modules\discord.js\src\client\websocket\WebSocketShard.js:444:22)
at WebSocketShard.onMessage (C:\Users\RIJAK\Documents\GitHub\asta-jr\node_modules\discord.js\src\client\websocket\WebSocketShard.js:301:10)
at WebSocket.onMessage (C:\Users\RIJAK\Documents\GitHub\asta-jr\node_modules\ws\lib\event-target.js:132:16)
at WebSocket.emit (events.js:315:20)
at Receiver.receiverOnMessage (C:\Users\RIJAK\Documents\GitHub\asta-jr\node_modules\ws\lib\websocket.js:978:20)
(node:33480) 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)
(node:33480) UnhandledPromiseRejectionWarning: TypeError: Function.prototype.apply was called on #<Object>, which is
a object and not a function
at MessageCollector.handleCollect (C:\Users\RIJAK\Documents\GitHub\asta-jr\node_modules\discord.js\src\structures\interfaces\Collector.js:92:53)
at Client.emit (events.js:327:22)
at MessageCreateAction.handle (C:\Users\RIJAK\Documents\GitHub\asta-jr\node_modules\discord.js\src\client\actions\MessageCreate.js:31:14)
at Object.module.exports [as MESSAGE_CREATE] (C:\Users\RIJAK\Documents\GitHub\asta-jr\node_modules\discord.js\src\client\websocket\handlers\MESSAGE_CREATE.js:4:32)
at WebSocketManager.handlePacket (C:\Users\RIJAK\Documents\GitHub\asta-jr\node_modules\discord.js\src\client\websocket\WebSocketManager.js:384:31)
at WebSocketShard.onPacket (C:\Users\RIJAK\Documents\GitHub\asta-jr\node_modules\discord.js\src\client\websocket\WebSocketShard.js:444:22)
at WebSocketShard.onMessage (C:\Users\RIJAK\Documents\GitHub\asta-jr\node_modules\discord.js\src\client\websocket\WebSocketShard.js:301:10)
at WebSocket.onMessage (C:\Users\RIJAK\Documents\GitHub\asta-jr\node_modules\ws\lib\event-target.js:132:16)
at WebSocket.emit (events.js:315:20)
at Receiver.receiverOnMessage (C:\Users\RIJAK\Documents\GitHub\asta-jr\node_modules\ws\lib\websocket.js:978:20)
(node:33480) 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: 5)
(node:33480) UnhandledPromiseRejectionWarning: TypeError: Function.prototype.apply was called on #<Object>, which is
a object and not a function
at MessageCollector.handleCollect (C:\Users\RIJAK\Documents\GitHub\asta-jr\node_modules\discord.js\src\structures\interfaces\Collector.js:92:53)
at Client.emit (events.js:327:22)
at MessageCreateAction.handle (C:\Users\RIJAK\Documents\GitHub\asta-jr\node_modules\discord.js\src\client\actions\MessageCreate.js:31:14)
at Object.module.exports [as MESSAGE_CREATE] (C:\Users\RIJAK\Documents\GitHub\asta-jr\node_modules\discord.js\src\client\websocket\handlers\MESSAGE_CREATE.js:4:32)
at WebSocketManager.handlePacket (C:\Users\RIJAK\Documents\GitHub\asta-jr\node_modules\discord.js\src\client\websocket\WebSocketManager.js:384:31)
at WebSocketShard.onPacket (C:\Users\RIJAK\Documents\GitHub\asta-jr\node_modules\discord.js\src\client\websocket\WebSocketShard.js:444:22)
at WebSocketShard.onMessage (C:\Users\RIJAK\Documents\GitHub\asta-jr\node_modules\discord.js\src\client\websocket\WebSocketShard.js:301:10)
at WebSocket.onMessage (C:\Users\RIJAK\Documents\GitHub\asta-jr\node_modules\ws\lib\event-target.js:132:16)
at WebSocket.emit (events.js:315:20)
at Receiver.receiverOnMessage (C:\Users\RIJAK\Documents\GitHub\asta-jr\node_modules\ws\lib\websocket.js:978:20)
(node:33480) 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: 6)
(node:33480) UnhandledPromiseRejectionWarning: TypeError: Function.prototype.apply was called on #<Object>, which is
a object and not a function
at MessageCollector.handleCollect (C:\Users\RIJAK\Documents\GitHub\asta-jr\node_modules\discord.js\src\structures\interfaces\Collector.js:92:53)
at Client.emit (events.js:327:22)
at MessageCreateAction.handle (C:\Users\RIJAK\Documents\GitHub\asta-jr\node_modules\discord.js\src\client\actions\MessageCreate.js:31:14)
at Object.module.exports [as MESSAGE_CREATE] (C:\Users\RIJAK\Documents\GitHub\asta-jr\node_modules\discord.js\src\client\websocket\handlers\MESSAGE_CREATE.js:4:32)
at WebSocketManager.handlePacket (C:\Users\RIJAK\Documents\GitHub\asta-jr\node_modules\discord.js\src\client\websocket\WebSocketManager.js:384:31)
at WebSocketShard.onPacket (C:\Users\RIJAK\Documents\GitHub\asta-jr\node_modules\discord.js\src\client\websocket\WebSocketShard.js:444:22)
at WebSocketShard.onMessage (C:\Users\RIJAK\Documents\GitHub\asta-jr\node_modules\discord.js\src\client\websocket\WebSocketShard.js:301:10)
at WebSocket.onMessage (C:\Users\RIJAK\Documents\GitHub\asta-jr\node_modules\ws\lib\event-target.js:132:16)
at WebSocket.emit (events.js:315:20)
at Receiver.receiverOnMessage (C:\Users\RIJAK\Documents\GitHub\asta-jr\node_modules\ws\lib\websocket.js:978:20)
(node:33480) 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: 7)
(node:33480) UnhandledPromiseRejectionWarning: TypeError: Function.prototype.apply was called on #<Object>, which is
a object and not a function
at MessageCollector.handleCollect (C:\Users\RIJAK\Documents\GitHub\asta-jr\node_modules\discord.js\src\structures\interfaces\Collector.js:92:53)
at Client.emit (events.js:327:22)
at MessageCreateAction.handle (C:\Users\RIJAK\Documents\GitHub\asta-jr\node_modules\discord.js\src\client\actions\MessageCreate.js:31:14)
at Object.module.exports [as MESSAGE_CREATE] (C:\Users\RIJAK\Documents\GitHub\asta-jr\node_modules\discord.js\src\client\websocket\handlers\MESSAGE_CREATE.js:4:32)
at WebSocketManager.handlePacket (C:\Users\RIJAK\Documents\GitHub\asta-jr\node_modules\discord.js\src\client\websocket\WebSocketManager.js:384:31)
at WebSocketShard.onPacket (C:\Users\RIJAK\Documents\GitHub\asta-jr\node_modules\discord.js\src\client\websocket\WebSocketShard.js:444:22)
at WebSocketShard.onMessage (C:\Users\RIJAK\Documents\GitHub\asta-jr\node_modules\discord.js\src\client\websocket\WebSocketShard.js:301:10)
at WebSocket.onMessage (C:\Users\RIJAK\Documents\GitHub\asta-jr\node_modules\ws\lib\event-target.js:132:16)
at WebSocket.emit (events.js:315:20)
at Receiver.receiverOnMessage (C:\Users\RIJAK\Documents\GitHub\asta-jr\node_modules\ws\lib\websocket.js:978:20)
(node:33480) 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: 8)
(node:33480) UnhandledPromiseRejectionWarning: TypeError: Function.prototype.apply was called on #<Object>, which is
a object and not a function
at MessageCollector.handleCollect (C:\Users\RIJAK\Documents\GitHub\asta-jr\node_modules\discord.js\src\structures\interfaces\Collector.js:92:53)
at Client.emit (events.js:327:22)
at MessageCreateAction.handle (C:\Users\RIJAK\Documents\GitHub\asta-jr\node_modules\discord.js\src\client\actions\MessageCreate.js:31:14)
at Object.module.exports [as MESSAGE_CREATE] (C:\Users\RIJAK\Documents\GitHub\asta-jr\node_modules\discord.js\src\client\websocket\handlers\MESSAGE_CREATE.js:4:32)
at WebSocketManager.handlePacket (C:\Users\RIJAK\Documents\GitHub\asta-jr\node_modules\discord.js\src\client\websocket\WebSocketManager.js:384:31)
at WebSocketShard.onPacket (C:\Users\RIJAK\Documents\GitHub\asta-jr\node_modules\discord.js\src\client\websocket\WebSocketShard.js:444:22)
at WebSocketShard.onMessage (C:\Users\RIJAK\Documents\GitHub\asta-jr\node_modules\discord.js\src\client\websocket\WebSocketShard.js:301:10)
at WebSocket.onMessage (C:\Users\RIJAK\Documents\GitHub\asta-jr\node_modules\ws\lib\event-target.js:132:16)
at WebSocket.emit (events.js:315:20)
at Receiver.receiverOnMessage (C:\Users\RIJAK\Documents\GitHub\asta-jr\node_modules\ws\lib\websocket.js:978:20)
(node:33480) 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: 9)
(node:33480) UnhandledPromiseRejectionWarning: TypeError: Function.prototype.apply was called on #<Object>, which is
a object and not a function
at MessageCollector.handleCollect (C:\Users\RIJAK\Documents\GitHub\asta-jr\node_modules\discord.js\src\structures\interfaces\Collector.js:92:53)
at Client.emit (events.js:327:22)
at MessageCreateAction.handle (C:\Users\RIJAK\Documents\GitHub\asta-jr\node_modules\discord.js\src\client\actions\MessageCreate.js:31:14)
at Object.module.exports [as MESSAGE_CREATE] (C:\Users\RIJAK\Documents\GitHub\asta-jr\node_modules\discord.js\src\client\websocket\handlers\MESSAGE_CREATE.js:4:32)
at WebSocketManager.handlePacket (C:\Users\RIJAK\Documents\GitHub\asta-jr\node_modules\discord.js\src\client\websocket\WebSocketManager.js:384:31)
at WebSocketShard.onPacket (C:\Users\RIJAK\Documents\GitHub\asta-jr\node_modules\discord.js\src\client\websocket\WebSocketShard.js:444:22)
at WebSocketShard.onMessage (C:\Users\RIJAK\Documents\GitHub\asta-jr\node_modules\discord.js\src\client\websocket\WebSocketShard.js:301:10)
at WebSocket.onMessage (C:\Users\RIJAK\Documents\GitHub\asta-jr\node_modules\ws\lib\event-target.js:132:16)
at WebSocket.emit (events.js:315:20)
at Receiver.receiverOnMessage (C:\Users\RIJAK\Documents\GitHub\asta-jr\node_modules\ws\lib\websocket.js:978:20)
(node:33480) 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: 10)
(node:33480) UnhandledPromiseRejectionWarning: TypeError: Function.prototype.apply was called on #<Object>, which is
a object and not a function
at MessageCollector.handleCollect (C:\Users\RIJAK\Documents\GitHub\asta-jr\node_modules\discord.js\src\structures\interfaces\Collector.js:92:53)
at Client.emit (events.js:327:22)
at MessageCreateAction.handle (C:\Users\RIJAK\Documents\GitHub\asta-jr\node_modules\discord.js\src\client\actions\MessageCreate.js:31:14)
at Object.module.exports [as MESSAGE_CREATE] (C:\Users\RIJAK\Documents\GitHub\asta-jr\node_modules\discord.js\src\client\websocket\handlers\MESSAGE_CREATE.js:4:32)
at WebSocketManager.handlePacket (C:\Users\RIJAK\Documents\GitHub\asta-jr\node_modules\discord.js\src\client\websocket\WebSocketManager.js:384:31)
at WebSocketShard.onPacket (C:\Users\RIJAK\Documents\GitHub\asta-jr\node_modules\discord.js\src\client\websocket\WebSocketShard.js:444:22)
at WebSocketShard.onMessage (C:\Users\RIJAK\Documents\GitHub\asta-jr\node_modules\discord.js\src\client\websocket\WebSocketShard.js:301:10)
at WebSocket.onMessage (C:\Users\RIJAK\Documents\GitHub\asta-jr\node_modules\ws\lib\event-target.js:132:16)
at WebSocket.emit (events.js:315:20)
at Receiver.receiverOnMessage (C:\Users\RIJAK\Documents\GitHub\asta-jr\node_modules\ws\lib\websocket.js:978:20)
(node:33480) 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: 11)
(node:33480) UnhandledPromiseRejectionWarning: TypeError: Function.prototype.apply was called on #<Object>, which is
a object and not a function
at MessageCollector.handleCollect (C:\Users\RIJAK\Documents\GitHub\asta-jr\node_modules\discord.js\src\structures\interfaces\Collector.js:92:53)
at Client.emit (events.js:327:22)
at MessageCreateAction.handle (C:\Users\RIJAK\Documents\GitHub\asta-jr\node_modules\discord.js\src\client\actions\MessageCreate.js:31:14)
at Object.module.exports [as MESSAGE_CREATE] (C:\Users\RIJAK\Documents\GitHub\asta-jr\node_modules\discord.js\src\client\websocket\handlers\MESSAGE_CREATE.js:4:32)
at WebSocketManager.handlePacket (C:\Users\RIJAK\Documents\GitHub\asta-jr\node_modules\discord.js\src\client\websocket\WebSocketManager.js:384:31)
at WebSocketShard.onPacket (C:\Users\RIJAK\Documents\GitHub\asta-jr\node_modules\discord.js\src\client\websocket\WebSocketShard.js:444:22)
at WebSocketShard.onMessage (C:\Users\RIJAK\Documents\GitHub\asta-jr\node_modules\discord.js\src\client\websocket\WebSocketShard.js:301:10)
at WebSocket.onMessage (C:\Users\RIJAK\Documents\GitHub\asta-jr\node_modules\ws\lib\event-target.js:132:16)
at WebSocket.emit (events.js:315:20)
at Receiver.receiverOnMessage (C:\Users\RIJAK\Documents\GitHub\asta-jr\node_modules\ws\lib\websocket.js:978:20)
(node:33480) 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: 12)
我已将问题缩小到我的代码的这一部分:
for (var x = 0; x < questions.length; x++) {
message.author
.send({
embed: {
title: `***Q${x + 1}. ${questions[x]}***`,
description:
"Please answer questions honestly and if asked about your details, please provide REAL life details",
footer: {
text: "You have 1 minute to answer questions!",
},
color: 0xe556f5,
},
})
.then((msg) => {
dmCh = msg.channel;
})
.catch((err) => {
message.author.send("Some error occurred");
});
dmCh.awaitMessages({ max: 1, time: 60000 })
.then((answer) => {
// answers.append(answer.toLowerCase());
console.log(answer);
})
.catch((collected) => {
// console.log(collected);
});
}
我已经尝试过我的机器人的其他命令,它们工作正常,但是一旦我运行这个命令,它就会给出上述错误,之后,如果我在频道中输入任何消息,它就会给出这个错误。 我还尝试在我的代码周围放置一个 try 和 catch 块,如下所示:
try {
dmCh.awaitMessages({ max: 1, time: 60000 })
.then((answer) => {
// answers.append(answer.toLowerCase());
console.log(answer);
})
.catch((collected) => {
// console.log(collected);
});
} catch (e) {
console.log(e);
}
但它不起作用。
请帮帮我!
【问题讨论】:
-
如果您还没有尝试将 djs 更新到 v13
-
dmCh = msg.channel;does not work。将msg.channel.awaitMessages(…)移入then回调 -
@Bergi 我试过了,但我仍然得到这个错误:
UnhandledPromiseRejectionWarning: TypeError: Function.prototype.apply was called on #<Object>, which is a object and not a function at MessageCollector.handleCollect我认为问题是在收集消息时发生的。
标签: javascript node.js promise discord discord.js