Reputation: 87
I am getting this error in my console:
(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)
and I have narrowed down the problem to this part of my code:
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);
});
}
I have tried other commands of my bot and they work fine but as soon as I run this command, it gives the above-mentioned error and after this, if I type any message in the channel it gives this error. I have also tried putting a try and catch block around my code like this:
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);
}
but it doesn't work.
Please help me!
Upvotes: 0
Views: 408
Reputation: 6710
The error occures because you haven't provided a filter
function.
Here's an example from the documentation
// Await !vote messages
const filter = m => m.content.startsWith('!vote');
// Errors: ['time'] treats ending because of the time limit as an error
channel.awaitMessages({ filter, max: 4, time: 60000, errors: ['time'] })
.then(collected => console.log(collected.size))
.catch(collected => console.log(`After a minute, only ${collected.size} out of 4 voted.`));
Documentation on DmChannel#awaitMessages() (v13)
If you're using v12
channel.awaitMessages(filter, { max: 4, time: 60000, errors: ['time'] }) //...
Upvotes: 0
Reputation: 1073959
The only part of the code shown in the question that looks like it could generate an unhandled rejection is the
message.author.send("Some error occurred");
in the catch
handler. If that throws an error, it will reject the promise from catch
, and that rejection isn't being handled anywhere.
You can catch that rejection by adding a second catch
handler, or using try
/catch
inside the catch
handler you have:
.catch(err => {
try {
message.author.send("Some error occurred");
} catch (e) {
// ...
}
});
If send
returns a promise, that won't handle the promise. To handle both throw exceptions and a rejection from send
, return the result of send
and add a second catch
handler:
.catch(err => {
return message.author.send("Some error occurred");
})
.catch(err => {
// Do whatever you want to do when the error handling failed
});
But it's also possible that some function you're calling is creating a promise that it isn't passing back to your code, and failing to handle rejection of that promise.
Upvotes: 1