mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-24 02:15:10 +02:00
Framework Rewrite
This commit is contained in:
+12
-12
@@ -1,25 +1,25 @@
|
||||
const { ArgumentType } = require('discord.js-commando');
|
||||
const Argument = require('../framework/ArgumentType');
|
||||
|
||||
module.exports = class ImageOrAvatarArgumentType extends ArgumentType {
|
||||
module.exports = class ImageOrAvatarArgument extends Argument {
|
||||
constructor(client) {
|
||||
super(client, 'image-or-avatar');
|
||||
}
|
||||
|
||||
async validate(value, msg, arg, currentMsg) {
|
||||
const image = await this.client.registry.types.get('image').validate(value, msg, arg, currentMsg);
|
||||
async validate(value, msg, arg) {
|
||||
const image = await this.client.registry.types.get('image').validate(value, msg, arg);
|
||||
if (image) return image;
|
||||
return this.client.registry.types.get('user').validate(value, msg, arg, currentMsg);
|
||||
return this.client.registry.types.get('user').validate(value, msg, arg);
|
||||
}
|
||||
|
||||
async parse(value, msg, arg, currentMsg) {
|
||||
const image = this.client.registry.types.get('image').parse(value, msg, arg, currentMsg);
|
||||
async parse(value, msg, arg) {
|
||||
const image = this.client.registry.types.get('image').parse(value, msg, arg);
|
||||
if (image) return image;
|
||||
const user = await this.client.registry.types.get('user').parse(value, msg, arg, currentMsg);
|
||||
return user.displayAvatarURL({ format: 'png', size: 512 });
|
||||
const user = await this.client.registry.types.get('user').parse(value, msg, arg);
|
||||
return user.displayAvatarURL({ format: 'png', size: arg.avatarSize || 512 });
|
||||
}
|
||||
|
||||
isEmpty(value, msg, arg, currentMsg) {
|
||||
return this.client.registry.types.get('image').isEmpty(value, msg, arg, currentMsg)
|
||||
&& this.client.registry.types.get('user').isEmpty(value, msg, arg, currentMsg);
|
||||
isEmpty(value, msg, arg) {
|
||||
return this.client.registry.types.get('image').isEmpty(value, msg, arg)
|
||||
&& this.client.registry.types.get('user').isEmpty(value, msg, arg);
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user