Files
xiao/types/image.js
T
Daniel Odendahl Jr 2c86665b34 Fix?
2018-03-23 11:24:49 +00:00

25 lines
570 B
JavaScript

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 || !attachment.height || !attachment.width) return false;
if (attachment.size > 8e+6) return 'Please provide an image under 8 MB.';
return true;
}
parse(value, msg) {
return msg.attachments.first().url;
}
isEmpty(value, msg) {
return msg.attachments.size === 0;
}
}
module.exports = ImageArgumentType;