image: fix some error handling
This commit is contained in:
parent
3822efc744
commit
f85975d380
1 changed files with 10 additions and 3 deletions
|
@ -9,9 +9,16 @@ const Jimp = require("jimp");
|
|||
async function createImageCallback(msg, url, callback, filename) {
|
||||
msg.channel.sendTyping();
|
||||
|
||||
const img = await getImage(msg, url);
|
||||
if (!img)
|
||||
return "Image not found. Please give URL, attachment, user mention or custom emoji.";
|
||||
let img;
|
||||
try {
|
||||
img = await getImage(msg, url);
|
||||
} catch (e) {
|
||||
if (e == "Image not found in last 20 messages.") {
|
||||
return "Image not found. Please give URL, attachment, user mention or custom emoji.";
|
||||
} else {
|
||||
return ":warning: An internal error occurred.";
|
||||
}
|
||||
}
|
||||
|
||||
const out = await callback(img);
|
||||
|
||||
|
|
Loading…
Reference in a new issue