mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-17 08:17:35 +02:00
Fix
This commit is contained in:
@@ -32,12 +32,15 @@ module.exports = class OcrCommand extends Command {
|
|||||||
await worker.load();
|
await worker.load();
|
||||||
await worker.loadLanguage('eng');
|
await worker.loadLanguage('eng');
|
||||||
await worker.initialize('eng');
|
await worker.initialize('eng');
|
||||||
|
let timedOut = false;
|
||||||
setTimeout(async () => {
|
setTimeout(async () => {
|
||||||
|
timedOut = true;
|
||||||
await worker.terminate();
|
await worker.terminate();
|
||||||
await reactIfAble(res, res.author, FAILURE_EMOJI_ID, '❌');
|
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);
|
}, 30000);
|
||||||
const { data: { text } } = await worker.recognize(image);
|
const { data: { text } } = await worker.recognize(image);
|
||||||
|
if (timedOut) return null;
|
||||||
await worker.terminate();
|
await worker.terminate();
|
||||||
await reactIfAble(msg, this.client.user, SUCCESS_EMOJI_ID, '✅');
|
await reactIfAble(msg, this.client.user, SUCCESS_EMOJI_ID, '✅');
|
||||||
if (!text) return msg.reply('There is no text in this image.');
|
if (!text) return msg.reply('There is no text in this image.');
|
||||||
|
|||||||
Reference in New Issue
Block a user