Framework Rewrite

This commit is contained in:
Dragon Fire
2021-06-05 12:17:33 -04:00
parent 5c9f237321
commit 7917766ce3
48 changed files with 1101 additions and 294 deletions
+10 -10
View File
@@ -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;
}
};