mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-07 14:55:40 +02:00
Test
This commit is contained in:
@@ -7,6 +7,7 @@ class EmojiArgumentType extends ArgumentType {
|
||||
}
|
||||
|
||||
validate(value, msg) {
|
||||
if (!value) return false;
|
||||
const matches = value.match(/^(?:<:([a-zA-Z0-9_]+):)?([0-9]+)>?$/);
|
||||
if (matches && msg.client.emojis.has(matches[2])) return true;
|
||||
if (!msg.guild) return false;
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
const { ArgumentType } = require('discord.js-commando');
|
||||
|
||||
class ImageArgumentType extends ArgumentType {
|
||||
constructor(client) {
|
||||
super(client, 'image');
|
||||
}
|
||||
|
||||
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.size > 8e+6) return false;
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = ImageArgumentType;
|
||||
Reference in New Issue
Block a user