From 1ef5ec1140c58191a3f6d080cc97a585cdf55fbe Mon Sep 17 00:00:00 2001 From: loicbersier Date: Thu, 27 Feb 2020 17:57:16 +0100 Subject: [PATCH] Send message when error occures --- commands/fun/audio2image.js | 10 ++++++++-- commands/fun/image2audio.js | 10 ++++++++-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/commands/fun/audio2image.js b/commands/fun/audio2image.js index 1a72dcc9..b2a2be49 100644 --- a/commands/fun/audio2image.js +++ b/commands/fun/audio2image.js @@ -53,7 +53,10 @@ class audio2imageCommand extends Command { .format('s16le') .audioCodec('pcm_s16le') .output(`${os.tmpdir()}/${message.id}1.sw`) - .on('error', (err, stdout, stderr) => console.error(`${err}\n${stdout}\n${stderr}`)) + .on('error', (err, stdout, stderr) => { + console.error(`${err}\n${stdout}\n${stderr}`); + return message.channel.send('Uh oh, an error has occured!'); + }) .on('end', () => { ffmpeg() .input(`${os.tmpdir()}/${message.id}1.sw`) @@ -63,7 +66,10 @@ class audio2imageCommand extends Command { .inputFormat('rawvideo') .frames('1') .output(`${os.tmpdir()}/a2i${message.id}.png`) - .on('error', (err, stdout, stderr) => console.error(`${err}\n${stdout}\n${stderr}`)) + .on('error', (err, stdout, stderr) => { + console.error(`${err}\n${stdout}\n${stderr}`); + return message.channel.send('Uh oh, an error has occured!'); + }) .on('end', () => { console.log('finished'); loadingmsg.delete(); diff --git a/commands/fun/image2audio.js b/commands/fun/image2audio.js index 7dbc1a70..d7e4a30c 100644 --- a/commands/fun/image2audio.js +++ b/commands/fun/image2audio.js @@ -44,7 +44,10 @@ class image2audioCommand extends Command { ffmpeg(`${os.tmpdir()}/${message.id}.png`) .format('rawvideo') .output(`${os.tmpdir()}/${message.id}1.png`) - .on('error', (err, stdout, stderr) => console.error(`${err}\n${stdout}\n${stderr}`)) + .on('error', (err, stdout, stderr) => { + console.error(`${err}\n${stdout}\n${stderr}`); + return message.channel.send('Uh oh, an error has occured!'); + }) .on('end', () => { ffmpeg() .audioBitrate(44100) @@ -52,7 +55,10 @@ class image2audioCommand extends Command { .input(`${os.tmpdir()}/${message.id}1.png`) .inputFormat('s16le') .output(`${os.tmpdir()}/i2a_${message.id}.wav`) - .on('error', (err, stdout, stderr) => console.error(`${err}\n${stdout}\n${stderr}`)) + .on('error', (err, stdout, stderr) => { + console.error(`${err}\n${stdout}\n${stderr}`); + return message.channel.send('Uh oh, an error has occured!'); + }) .on('end', () => { console.log('finished'); loadingmsg.delete();