From 5d48e554e082fab8d33423d0f44b445b8d579ec0 Mon Sep 17 00:00:00 2001 From: loicbersier Date: Sat, 12 Oct 2019 15:17:20 +0200 Subject: [PATCH] delete author message and added processing message --- commands/utility/vid2gif.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/commands/utility/vid2gif.js b/commands/utility/vid2gif.js index 4ac1992..466e70a 100644 --- a/commands/utility/vid2gif.js +++ b/commands/utility/vid2gif.js @@ -8,7 +8,7 @@ const superagent = require('superagent'); class vid2giftCommand extends Command { constructor() { super('vid2gift', { - aliases: ['vid2gif', 'v2g'], + aliases: ['vid2gif', 'v2g', 'vg'], category: 'utility', args: [ { @@ -36,11 +36,15 @@ class vid2giftCommand extends Command { async exec(message, args) { let vid = args.vid; + let loadingmsg = await message.channel.send('Processing '); + if (!vid) { + loadingmsg.delete(); return message.channel.send('I need a video to do that!'); } else if (vid) { const { body: buffer } = await superagent.get(vid).catch(() => { + loadingmsg.delete(); return message.channel.send('An error as occured, please try again'); }); let options = ''; @@ -61,14 +65,18 @@ class vid2giftCommand extends Command { fs.writeFile(`${os.tmpdir()}/${message.id}v2g`, buffer, () => { exec(`ffmpeg -i ${os.tmpdir()}/${message.id}v2g ${options} ${os.tmpdir()}/${message.id}v2g.gif -hide_banner`) .then(() => { + loadingmsg.delete(); + message.delete(); return message.channel.send({files: [`${os.tmpdir()}/${message.id}v2g.gif`]}) .catch(err => { console.error(err); + loadingmsg.delete(); return message.channel.send('Could not send the file! Perhaps the file is too big?'); }); }) .catch(err => { console.error(err); + loadingmsg.delete(); return message.channel.send('There was an error during conversion! maybe try with another file type?'); }); });