mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-03 23:36:43 +02:00
Require images to be jpg or png in image type
This commit is contained in:
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "xiao",
|
||||
"version": "98.1.0",
|
||||
"version": "98.1.1",
|
||||
"description": "Your personal server companion.",
|
||||
"main": "Xiao.js",
|
||||
"scripts": {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
const { ArgumentType } = require('discord.js-commando');
|
||||
const fileTypeRe = /\.(jpe?g|png)$/i;
|
||||
|
||||
module.exports = class ImageArgumentType extends ArgumentType {
|
||||
constructor(client) {
|
||||
@@ -10,6 +11,7 @@ module.exports = class ImageArgumentType extends ArgumentType {
|
||||
if (attachment) {
|
||||
if (!attachment.height || !attachment.width) return false;
|
||||
if (attachment.size > 8e+6) return 'Please provide an image under 8 MB.';
|
||||
if (!fileTypeRe.test(attachment.name)) return 'Please only send PNG or JPG format images.';
|
||||
return true;
|
||||
}
|
||||
return this.client.registry.types.get('user').validate(value, msg, arg);
|
||||
|
||||
Reference in New Issue
Block a user