mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-25 06:42:51 +02:00
Update to latest commando
This commit is contained in:
@@ -5,21 +5,21 @@ module.exports = class ImageOrAvatarArgumentType extends ArgumentType {
|
|||||||
super(client, 'image-or-avatar');
|
super(client, 'image-or-avatar');
|
||||||
}
|
}
|
||||||
|
|
||||||
async validate(value, msg, arg) {
|
async validate(value, msg, arg, currentMsg) {
|
||||||
const image = await this.client.registry.types.get('image').validate(value, msg, arg);
|
const image = await this.client.registry.types.get('image').validate(value, msg, arg, currentMsg);
|
||||||
if (image) return image;
|
if (image) return image;
|
||||||
return this.client.registry.types.get('user').validate(value, msg, arg);
|
return this.client.registry.types.get('user').validate(value, msg, arg, currentMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
async parse(value, msg, arg) {
|
async parse(value, msg, arg) {
|
||||||
const image = this.client.registry.types.get('image').parse(value, msg, arg);
|
const image = this.client.registry.types.get('image').parse(value, msg, arg, currentMsg);
|
||||||
if (image) return image;
|
if (image) return image;
|
||||||
const user = await this.client.registry.types.get('user').parse(value, msg, arg);
|
const user = await this.client.registry.types.get('user').parse(value, msg, arg, currentMsg);
|
||||||
return user.displayAvatarURL({ format: 'png', size: 512 });
|
return user.displayAvatarURL({ format: 'png', size: 512 });
|
||||||
}
|
}
|
||||||
|
|
||||||
isEmpty(value, msg, arg) {
|
isEmpty(value, msg, arg) {
|
||||||
return this.client.registry.types.get('image').isEmpty(value, msg, arg)
|
return this.client.registry.types.get('image').isEmpty(value, msg, arg, currentMsg)
|
||||||
&& this.client.registry.types.get('user').isEmpty(value, msg, arg);
|
&& this.client.registry.types.get('user').isEmpty(value, msg, arg, currentMsg);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
+7
-7
@@ -8,8 +8,8 @@ module.exports = class ImageArgumentType extends ArgumentType {
|
|||||||
super(client, 'image');
|
super(client, 'image');
|
||||||
}
|
}
|
||||||
|
|
||||||
async validate(value, msg) {
|
async validate(value, msg, arg, currentMsg) {
|
||||||
const attachment = msg.attachments.first();
|
const attachment = currentMsg.attachments.first();
|
||||||
if (attachment) {
|
if (attachment) {
|
||||||
if (attachment.size > 8e+6) return 'Please provide an image under 8 MB.';
|
if (attachment.size > 8e+6) return 'Please provide an image under 8 MB.';
|
||||||
if (!fileTypeRe.test(attachment.name)) return 'Please only send PNG, JPG, BMP, or GIF format images.';
|
if (!fileTypeRe.test(attachment.name)) return 'Please only send PNG, JPG, BMP, or GIF format images.';
|
||||||
@@ -27,15 +27,15 @@ module.exports = class ImageArgumentType extends ArgumentType {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
parse(value, msg) {
|
parse(value, msg, arg, currentMsg) {
|
||||||
const attachment = msg.attachments.first();
|
const attachment = currentMsg.attachments.first();
|
||||||
if (attachment) return attachment.url;
|
if (attachment) return attachment.url;
|
||||||
if (fileTypeRe.test(value.toLowerCase())) return value;
|
if (fileTypeRe.test(value.toLowerCase())) return value;
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
isEmpty(value, msg) {
|
isEmpty(value, msg, arg, currentMsg) {
|
||||||
if (msg.attachments.size) return false;
|
if (currentMsg.attachments.size) return false;
|
||||||
return true;
|
return !value;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user