1
0
Fork 0

delete author message and added processing message

akairo
loicbersier 5 years ago
parent 18b6e48460
commit 5d48e554e0

@ -8,7 +8,7 @@ const superagent = require('superagent');
class vid2giftCommand extends Command { class vid2giftCommand extends Command {
constructor() { constructor() {
super('vid2gift', { super('vid2gift', {
aliases: ['vid2gif', 'v2g'], aliases: ['vid2gif', 'v2g', 'vg'],
category: 'utility', category: 'utility',
args: [ args: [
{ {
@ -36,11 +36,15 @@ class vid2giftCommand extends Command {
async exec(message, args) { async exec(message, args) {
let vid = args.vid; let vid = args.vid;
let loadingmsg = await message.channel.send('Processing <a:loadingmin:527579785212329984>');
if (!vid) { if (!vid) {
loadingmsg.delete();
return message.channel.send('I need a video to do that!'); return message.channel.send('I need a video to do that!');
} else if (vid) { } else if (vid) {
const { body: buffer } = await superagent.get(vid).catch(() => { const { body: buffer } = await superagent.get(vid).catch(() => {
loadingmsg.delete();
return message.channel.send('An error as occured, please try again'); return message.channel.send('An error as occured, please try again');
}); });
let options = ''; let options = '';
@ -61,14 +65,18 @@ class vid2giftCommand extends Command {
fs.writeFile(`${os.tmpdir()}/${message.id}v2g`, buffer, () => { 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`) exec(`ffmpeg -i ${os.tmpdir()}/${message.id}v2g ${options} ${os.tmpdir()}/${message.id}v2g.gif -hide_banner`)
.then(() => { .then(() => {
loadingmsg.delete();
message.delete();
return message.channel.send({files: [`${os.tmpdir()}/${message.id}v2g.gif`]}) return message.channel.send({files: [`${os.tmpdir()}/${message.id}v2g.gif`]})
.catch(err => { .catch(err => {
console.error(err); console.error(err);
loadingmsg.delete();
return message.channel.send('Could not send the file! Perhaps the file is too big?'); return message.channel.send('Could not send the file! Perhaps the file is too big?');
}); });
}) })
.catch(err => { .catch(err => {
console.error(err); console.error(err);
loadingmsg.delete();
return message.channel.send('There was an error during conversion! maybe try with another file type?'); return message.channel.send('There was an error during conversion! maybe try with another file type?');
}); });
}); });

Loading…
Cancel
Save