mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-04 15:56:52 +02:00
23 lines
545 B
JavaScript
23 lines
545 B
JavaScript
const { ArgumentType } = require('discord.js-commando');
|
|
|
|
module.exports = class ImageArgumentType extends ArgumentType {
|
|
constructor(client) {
|
|
super(client, 'image');
|
|
}
|
|
|
|
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;
|
|
}
|
|
};
|