mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-20 14:00:22 +02:00
Clean ups
This commit is contained in:
@@ -1,16 +0,0 @@
|
||||
const { ArgumentType } = require('discord.js-commando');
|
||||
|
||||
module.exports = class AvatarArgumentType extends ArgumentType {
|
||||
constructor(client) {
|
||||
super(client, 'avatar');
|
||||
}
|
||||
|
||||
validate(value, msg, arg) {
|
||||
return this.client.registry.types.get('user').validate(value, msg, arg);
|
||||
}
|
||||
|
||||
async parse(value, msg, arg) {
|
||||
const user = await this.client.registry.types.get('user').parse(value, msg, arg);
|
||||
return user.displayAvatarURL({ format: 'png', size: 512 });
|
||||
}
|
||||
};
|
||||
+15
-8
@@ -5,18 +5,25 @@ module.exports = class ImageArgumentType extends ArgumentType {
|
||||
super(client, 'image');
|
||||
}
|
||||
|
||||
validate(value, msg) {
|
||||
validate(value, msg, arg) {
|
||||
const attachment = msg.attachments.first();
|
||||
if (!attachment || !attachment.height || !attachment.width) return false;
|
||||
if (attachment.size > 8e+6) return 'Please provide an image under 8 MB.';
|
||||
return true;
|
||||
if (attachment) {
|
||||
if (!attachment.height || !attachment.width) return false;
|
||||
if (attachment.size > 8e+6) return 'Please provide an image under 8 MB.';
|
||||
return true;
|
||||
}
|
||||
return this.client.registry.types.get('user').validate(value, msg, arg);
|
||||
}
|
||||
|
||||
parse(value, msg) {
|
||||
return msg.attachments.first().url;
|
||||
async parse(value, msg, arg) {
|
||||
const attachment = msg.attachments.first();
|
||||
if (attachment) return attachment.url;
|
||||
const user = await this.client.registry.types.get('user').parse(value, msg, arg);
|
||||
return user.displayAvatarURL({ format: 'png', size: 512 });
|
||||
}
|
||||
|
||||
isEmpty(value, msg) {
|
||||
return msg.attachments.size === 0;
|
||||
isEmpty(value, msg, arg) {
|
||||
if (msg.attachments.size) return false;
|
||||
return this.client.registry.types.get('user').isEmpty(value, msg, arg);
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user