mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-15 00:12:38 +02:00
littlelimedragon, union types
This commit is contained in:
+1
-12
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user