From d445108a9819a95939c14fd818b8c3b29cfc20e1 Mon Sep 17 00:00:00 2001 From: Bsian Date: Mon, 23 Dec 2019 14:42:24 +0000 Subject: [PATCH] Promise rejections --- src/class/Util.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/class/Util.ts b/src/class/Util.ts index 8e5aaed..03e702d 100644 --- a/src/class/Util.ts +++ b/src/class/Util.ts @@ -167,11 +167,11 @@ export default class Util { public async messageCollector(message: Message, question: string, timeout: number, shouldDelete = false, choices: string[] = null, filter = (msg: Message): boolean|void => {}): Promise { const msg = await message.channel.createMessage(question); return new Promise((res, rej) => { - setTimeout(() => { if (shouldDelete) msg.delete(); rej(new Error('Did not supply a valid input in time')); }, timeout); + setTimeout(() => { if (shouldDelete) msg.delete().catch(); rej(new Error('Did not supply a valid input in time')); }, timeout); this.client.on('messageCreate', (Msg) => { if (filter(Msg) === false) return; const verif = choices ? choices.includes(Msg.content) : Msg.content; - if (verif) { if (shouldDelete) msg.delete(); res(Msg); } + if (verif) { if (shouldDelete) msg.delete().catch(); res(Msg); } }); }); }