mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-13 00:09:08 +02:00
Framework Rewrite
This commit is contained in:
+10
-10
@@ -1,18 +1,18 @@
|
||||
const { ArgumentType } = require('discord.js-commando');
|
||||
const Argument = require('../framework/ArgumentType');
|
||||
const fileTypeRe = /\.(jpe?g|png|gif|jfif|bmp)(\?.+)?$/i;
|
||||
const request = require('node-superfetch');
|
||||
const validURL = require('valid-url');
|
||||
|
||||
module.exports = class ImageArgumentType extends ArgumentType {
|
||||
module.exports = class ImageArgument extends Argument {
|
||||
constructor(client) {
|
||||
super(client, 'image');
|
||||
}
|
||||
|
||||
async validate(value, msg, arg, currentMsg) {
|
||||
const attachment = currentMsg.attachments.first();
|
||||
async validate(value, msg) {
|
||||
const attachment = msg.attachments.first();
|
||||
if (attachment) {
|
||||
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 (attachment.size > 8e+6) return false;
|
||||
if (!fileTypeRe.test(attachment.name)) return false;
|
||||
return true;
|
||||
}
|
||||
if (fileTypeRe.test(value.toLowerCase())) {
|
||||
@@ -27,15 +27,15 @@ module.exports = class ImageArgumentType extends ArgumentType {
|
||||
return false;
|
||||
}
|
||||
|
||||
parse(value, msg, arg, currentMsg) {
|
||||
const attachment = currentMsg.attachments.first();
|
||||
parse(value, msg) {
|
||||
const attachment = msg.attachments.first();
|
||||
if (attachment) return attachment.url;
|
||||
if (fileTypeRe.test(value.toLowerCase())) return value;
|
||||
return null;
|
||||
}
|
||||
|
||||
isEmpty(value, msg, arg, currentMsg) {
|
||||
if (currentMsg.attachments.size) return false;
|
||||
isEmpty(value, msg) {
|
||||
if (msg.attachments.size) return false;
|
||||
return !value;
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user