if no image send message about it and catch error

This commit is contained in:
loicbersier 2019-10-13 21:59:17 +02:00
parent e6902ec5b1
commit 5e18aa5d67
6 changed files with 54 additions and 0 deletions

View file

@ -32,6 +32,10 @@ class autocropCommand extends Command {
url = Attachment[0].url;
}
if (!url) {
return message.channel.send('You need an image to use this command!');
}
let loadingmsg = await message.channel.send('Processing <a:loadingmin:527579785212329984>');
@ -46,10 +50,15 @@ class autocropCommand extends Command {
.then(() => {
loadingmsg.delete();
return message.channel.send({files: [output]});
})
.catch(error => {
console.error(error);
return message.channel.send('Oh no, an error just occured! Maybe the format of your image don\'t work?');
});
}
}

View file

@ -11,6 +11,7 @@ class blurCommand extends Command {
{
id: 'link',
type: 'string',
},
{
id: 'radius',
@ -38,6 +39,10 @@ class blurCommand extends Command {
url = Attachment[0].url;
}
if (!url) {
return message.channel.send('You need an image to use this command!');
}
let loadingmsg = await message.channel.send('Processing <a:loadingmin:527579785212329984>');
jimp.read({
@ -51,10 +56,15 @@ class blurCommand extends Command {
.then(() => {
loadingmsg.delete();
return message.channel.send({files: [output]});
})
.catch(error => {
console.error(error);
return message.channel.send('Oh no, an error just occured! Maybe the format of your image don\'t work?');
});
}
}

View file

@ -38,6 +38,10 @@ class gaussianCommand extends Command {
url = Attachment[0].url;
}
if (!url) {
return message.channel.send('You need an image to use this command!');
}
let loadingmsg = await message.channel.send('Processing <a:loadingmin:527579785212329984>');
jimp.read({
@ -51,10 +55,15 @@ class gaussianCommand extends Command {
.then(() => {
loadingmsg.delete();
return message.channel.send({files: [output]});
})
.catch(error => {
console.error(error);
return message.channel.send('Oh no, an error just occured! Maybe the format of your image don\'t work?');
});
}
}

View file

@ -32,6 +32,10 @@ class jpegifyCommand extends Command {
url = Attachment[0].url;
}
if (!url) {
return message.channel.send('You need an image to use this command!');
}
let loadingmsg = await message.channel.send('Processing <a:loadingmin:527579785212329984>');
jimp.read({
@ -45,9 +49,14 @@ class jpegifyCommand extends Command {
.then(() => {
loadingmsg.delete();
return message.channel.send({files: [output]});
})
.catch(error => {
console.error(error);
return message.channel.send('Oh no, an error just occured! Maybe the format of your image don\'t work?');
});
}
}

View file

@ -32,6 +32,10 @@ class mirrorCommand extends Command {
url = Attachment[0].url;
}
if (!url) {
return message.channel.send('You need an image to use this command!');
}
let loadingmsg = await message.channel.send('Processing <a:loadingmin:527579785212329984>');
jimp.read({
@ -45,6 +49,10 @@ class mirrorCommand extends Command {
.then(() => {
loadingmsg.delete();
return message.channel.send({files: [output]});
})
.catch(error => {
console.error(error);
return message.channel.send('Oh no, an error just occured! Maybe the format of your image don\'t work?');
});

View file

@ -36,6 +36,10 @@ class rotateCommand extends Command {
url = Attachment[0].url;
}
if (!url) {
return message.channel.send('You need an image to use this command!');
}
let loadingmsg = await message.channel.send('Processing <a:loadingmin:527579785212329984>');
jimp.read({
@ -49,10 +53,15 @@ class rotateCommand extends Command {
.then(() => {
loadingmsg.delete();
return message.channel.send({files: [output]});
})
.catch(error => {
console.error(error);
return message.channel.send('Oh no, an error just occured! Maybe the format of your image don\'t work?');
});
}
}