Bug Catching in File Commands

This commit is contained in:
Daniel Odendahl Jr
2017-05-02 11:18:51 +00:00
parent 4fd695c655
commit a9d29cdec4
15 changed files with 29 additions and 15 deletions
+2 -1
View File
@@ -34,7 +34,8 @@ module.exports = class YearsCommand extends Command {
az.composite(avatar, 461, 127);
az.getBuffer(Jimp.MIME_PNG, (err, buff) => {
if (err) return msg.say('An Unknown Error Occurred.');
return msg.channel.send({files: [{attachment: buff}]});
return msg.channel.send({files: [{attachment: buff}]})
.catch(() => msg.say('An Unknown Error Occurred.'));
});
}
};
+2 -1
View File
@@ -35,7 +35,8 @@ module.exports = class BeautifulCommand extends Command {
grunkle.composite(avatar, 342, 301);
grunkle.getBuffer(Jimp.MIME_PNG, (err, buff) => {
if (err) return msg.say('An Unknown Error Occurred.');
return msg.channel.send({files: [{attachment: buff}]});
return msg.channel.send({files: [{attachment: buff}]})
.catch(() => msg.say('An Unknown Error Occurred.'));
});
}
};
+2 -1
View File
@@ -37,7 +37,8 @@ module.exports = class BobRossCommand extends Command {
blank.composite(bob, 0, 0);
blank.getBuffer(Jimp.MIME_PNG, (err, buff) => {
if (err) return msg.say('An Unknown Error Occurred.');
return msg.channel.send({files: [{attachment: buff}]});
return msg.channel.send({files: [{attachment: buff}]})
.catch(() => msg.say('An Unknown Error Occurred.'));
});
}
};
+2 -1
View File
@@ -27,7 +27,8 @@ module.exports = class GreyscaleCommand extends Command {
avatar.greyscale();
avatar.getBuffer(Jimp.MIME_PNG, (err, buff) => {
if (err) return msg.say('An Unknown Error Occurred.');
return msg.channel.send({files: [{attachment: buff}]});
return msg.channel.send({files: [{attachment: buff}]})
.catch(() => msg.say('An Unknown Error Occurred.'));
});
}
};
+2 -1
View File
@@ -27,7 +27,8 @@ module.exports = class InvertCommand extends Command {
avatar.invert();
avatar.getBuffer(Jimp.MIME_PNG, (err, buff) => {
if (err) return msg.say('An Unknown Error Occurred.');
return msg.channel.send({files: [{attachment: buff}]});
return msg.channel.send({files: [{attachment: buff}]})
.catch(() => msg.say('An Unknown Error Occurred.'));
});
}
};
+2 -1
View File
@@ -36,7 +36,8 @@ module.exports = class RIPCommand extends Command {
grave.composite(avatar, 158, 51);
grave.getBuffer(Jimp.MIME_PNG, (err, buff) => {
if (err) return msg.say('An Unknown Error Occurred.');
return msg.channel.send({files: [{attachment: buff}]});
return msg.channel.send({files: [{attachment: buff}]})
.catch(() => msg.say('An Unknown Error Occurred.'));
});
}
};
+2 -1
View File
@@ -39,7 +39,8 @@ module.exports = class SteamCardCommand extends Command {
blank.print(font, 38, 20, username);
blank.getBuffer(Jimp.MIME_PNG, (err, buff) => {
if (err) return msg.say('An Unknown Error Occurred.');
return msg.channel.send({files: [{attachment: buff}]});
return msg.channel.send({files: [{attachment: buff}]})
.catch(() => msg.say('An Unknown Error Occurred.'));
});
}
};
+2 -1
View File
@@ -33,7 +33,8 @@ module.exports = class TriggeredCommand extends Command {
blank.composite(triggered, 0, 0);
blank.getBuffer(Jimp.MIME_PNG, (err, buff) => {
if (err) return msg.say('An Unknown Error Occurred.');
return msg.channel.send({files: [{attachment: buff}]});
return msg.channel.send({files: [{attachment: buff}]})
.catch(() => msg.say('An Unknown Error Occurred.'));
});
}
};
+2 -1
View File
@@ -31,7 +31,8 @@ module.exports = class WantedCommand extends Command {
wanted.composite(avatar, 189, 438);
wanted.getBuffer(Jimp.MIME_PNG, (err, buff) => {
if (err) return msg.say('An Unknown Error Occurred.');
return msg.channel.send({files: [{attachment: buff}]});
return msg.channel.send({files: [{attachment: buff}]})
.catch(() => msg.say('An Unknown Error Occurred.'));
});
}
};
+2 -1
View File
@@ -14,6 +14,7 @@ module.exports = class SpamCommand extends Command {
if (msg.channel.type !== 'dm')
if (!msg.channel.permissionsFor(this.client.user).has('ATTACH_FILES'))
return msg.say('This Command requires the `Attach Files` Permission.');
return msg.channel.send({files: ['https://i.imgur.com/2JFu5xE.jpg']});
return msg.channel.send({files: ['https://i.imgur.com/2JFu5xE.jpg']})
.catch(() => msg.say('An Unknown Error Occurred.'));
}
};
+2 -1
View File
@@ -21,7 +21,8 @@ module.exports = class CatCommand extends Command {
try {
const { body } = await request
.get('http://random.cat/meow');
return msg.channel.send({files: [body.file]});
return msg.channel.send({files: [body.file]})
.catch(() => msg.say('An Unknown Error Occurred.'));
} catch (err) {
return msg.say('An Unknown Error Occurred.');
}
+2 -1
View File
@@ -18,7 +18,8 @@ module.exports = class DogCommand extends Command {
try {
const { body } = await request
.get('https://random.dog/woof.json');
return msg.channel.send({files: [body.url]});
return msg.channel.send({files: [body.url]})
.catch(() => msg.say('An Unknown Error Occurred.'));
} catch (err) {
return msg.say('An Unknown Error Occurred.');
}
+2 -1
View File
@@ -19,6 +19,7 @@ module.exports = class XiaoCommand extends Command {
if (!msg.channel.permissionsFor(this.client.user).has('ATTACH_FILES'))
return msg.say('This Command requires the `Attach Files` Permission.');
const xiao = xiaos[Math.floor(Math.random() * xiaos.length)];
return msg.channel.send({files: [xiao]});
return msg.channel.send({files: [xiao]})
.catch(() => msg.say('An Unknown Error Occurred.'));
}
};
+2 -1
View File
@@ -34,7 +34,8 @@ module.exports = class MapCommand extends Command {
try {
const { body } = await request
.get(`https://maps.googleapis.com/maps/api/staticmap?center=${query}&zoom=${zoom}&size=500x500&key=${process.env.GOOGLE_KEY}`);
return msg.channel.send({files: [{attachment: body}]});
return msg.channel.send({files: [{attachment: body}]})
.catch(() => msg.say('An Unknown Error Occurred.'));
} catch (err) {
return msg.say('An Error Occurred. The location may not have been found.');
}
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "xiaobot",
"version": "17.2.0",
"version": "17.2.1",
"description": "A Discord Bot",
"main": "shardingmanager.js",
"scripts": {