I'm trying to write a discord bot, right now it's a command to get married.
Everything works as it should, except for one thing. In the awaitReactions
function, I have a time of 10 seconds, and after this time I get this error:
node:internal/process/promises:246 triggerUncaughtException(err, true /* fromPromise */); [UnhandledPromiseRejection: This error originated either by throwing inside of a n async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason "#".] { code: 'ERR_UNHANDLED_REJECTION' }
I can't understand why this is happening, I have .catch()
at the end of the function and in theory everything should work as it should.
Why doesn't .catch()
work in my case? What could be the problem?
const { Command } = require('discord.js-commando');
const db = require("quick.db");
module.exports = class MarryCommand extends Command {
constructor(client) {
super(client, {
name: 'marry',
memberName: 'marry',
group: 'test',
description: 'Marry the mentioned user',
guildOnly: true,
args: [
{
key: 'userToMarry',
prompt: 'Please select the member you wish to marry.',
type: 'member'
}
]
});
}
run(message, { userToMarry }) {
const exists = db.get(`${message.author.id}.user`);
const married = db.get(`${userToMarry.id}.user`);
if (!userToMarry) {
return message.channel.send('Please try again with a valid user.')}
if (exists == message.author.id) {
return message.channel.send('You are already married!')}
if (married == userToMarry.id) {
return message.channel.send('This user is already married!')}
if (userToMarry.id == message.author.id) {
return message.channel.send('You cannot marry yourself!');
}
if (exists != message.author.id && married != userToMarry.id) {
message.channel.send(`**Important announcement!**
${message.author} makes a marriage proposal ${userToMarry}
Are you ready to get married?`).then(message => {
message.react('