From 586ef50dc4f5f0e7a2c34a3d2cb33810752d2e68 Mon Sep 17 00:00:00 2001 From: Dragon Fire Date: Mon, 15 Mar 2021 17:17:36 -0400 Subject: [PATCH] Fix --- commands/analyze/ocr.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/commands/analyze/ocr.js b/commands/analyze/ocr.js index 93716736..2f8ee7ec 100644 --- a/commands/analyze/ocr.js +++ b/commands/analyze/ocr.js @@ -32,12 +32,15 @@ module.exports = class OcrCommand extends Command { await worker.load(); await worker.loadLanguage('eng'); await worker.initialize('eng'); + let timedOut = false; setTimeout(async () => { + timedOut = true; await worker.terminate(); await reactIfAble(res, res.author, FAILURE_EMOJI_ID, '❌'); - return msg.reply('Scanning took longer than 30 seconds, so I\'ve given up.'); + await msg.reply('Scanning took longer than 30 seconds, so I\'ve given up.'); }, 30000); const { data: { text } } = await worker.recognize(image); + if (timedOut) return null; await worker.terminate(); await reactIfAble(msg, this.client.user, SUCCESS_EMOJI_ID, '✅'); if (!text) return msg.reply('There is no text in this image.');