littlelimedragon, union types

This commit is contained in:
Daniel Odendahl Jr
2018-03-23 11:10:59 +00:00
parent fa18852775
commit ed7b4cb5e1
16 changed files with 40 additions and 33 deletions
+1 -12
View File
@@ -7,27 +7,16 @@ class ImageArgumentType extends ArgumentType {
async validate(value, msg) {
const attachment = msg.attachments.first();
if (!attachment) {
const valid = await this.client.registry.types.get('user').validate(value, msg);
return valid;
}
if (!attachment.height || !attachment.width) return false;
if (!attachment || !attachment.height || !attachment.width) return false;
if (attachment.size > 8e+6) return 'Please provide an image under 8 MB.';
return true;
}
parse(value, msg) {
if (!msg.attachments.size) {
return this.client.registry.types.get('user').parse(value, msg).displayAvatarURL({
format: 'png',
size: 512
});
}
return msg.attachments.first().url;
}
isEmpty(value, msg) {
if (!msg.attachments.size) return !value;
return !msg.attachments.size;
}
}