0

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!

Rijak Singh
  • 67
  • 1
  • 9
  • Try updating djs to v13 if you haven't yet – Elitezen Aug 30 '21 at 12:32
  • 1
    [`dmCh = msg.channel;` does not work](https://stackoverflow.com/questions/23667086/why-is-my-variable-unaltered-after-i-modify-it-inside-of-a-function-asynchron). Move the `msg.channel.awaitMessages(…)` *inside* the `then` callback – Bergi Aug 30 '21 at 12:33
  • @Bergi I tried that but I still get this error: `UnhandledPromiseRejectionWarning: TypeError: Function.prototype.apply was called on #, which is a object and not a function at MessageCollector.handleCollect` I think the problem is occuring while collecting the messages. – Rijak Singh Aug 30 '21 at 13:01

2 Answers2

1

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.

T.J. Crowder
  • 1,031,962
  • 187
  • 1,923
  • 1,875
  • I have tried that but it is still showing the same error. Moreover, I tried commenting out the await messages part and it stopped giving that error. So I think there is a problem with that. I have been trying to solve this since 2 hours but I just don't understand why there is a rejection... – Rijak Singh Aug 30 '21 at 12:20
  • @RijakSingh - That suggests that the last paragraph above applies: `dmCh.awaitMessages` is creating a promise it **doesn't** return, and failing to handle rejection of that promise. – T.J. Crowder Aug 30 '21 at 12:22
  • read the [docs](https://discord.js.org/#/docs/main/stable/class/TextChannel?scrollTo=awaitMessages) on `awaitMessages()` - it gives some example code on how message collectors work. – Joe Moore Aug 30 '21 at 12:25
  • 1
    Try awaiting `.send()` for error handling, as it also returns a promise – Elitezen Aug 30 '21 at 12:28
  • @Elitezen I tried that and now it doesn't give an error and sends the embed but as soon as i enter the answer it gives the following error: `(node:39544) UnhandledPromiseRejectionWarning: TypeError: Function.prototype.apply was called on #, which is a object and not a function` – Rijak Singh Aug 30 '21 at 12:37
  • The problem occurs while collecting the message, can someone help? – Rijak Singh Aug 30 '21 at 12:53
0

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'] }) //...
Elitezen
  • 6,551
  • 6
  • 15
  • 29
  • It doesn't work even after filter function – Rijak Singh Aug 30 '21 at 14:47
  • Does the error still occure? The documentation points to the v13 example, ensure you are using v13 or implement the filter according to the v12 documentation – Elitezen Aug 30 '21 at 14:49
  • I think it is trying to call the object as a function because it is in the filter argument spot. Due to this I believe they are in v12 and the filter must be the first argument – MrMythical Aug 30 '21 at 15:21
  • Thank You so much for the answer but is there a way to go back to v12? I kinda updated cuz I was stuck in this and now my code is broken. – Rijak Singh Aug 30 '21 at 16:49
  • You can do `npm uninstall discord.js` then `npm install discord.js@`. However it's best you learn v13 as v12 will be deprecated in the future – Elitezen Aug 30 '21 at 17:45