Auto-Import Command Leaderboard

This commit is contained in:
Dragon Fire
2020-06-06 00:26:54 -04:00
parent a75fb109a7
commit 1d9095868d
5 changed files with 32 additions and 57 deletions
-27
View File
@@ -1,27 +0,0 @@
const { ArgumentType } = require('discord.js-commando');
const fileTypeRe = /\.(json)$/i;
const request = require('node-superfetch');
module.exports = class JsonFileArgumentType extends ArgumentType {
constructor(client) {
super(client, 'json-file');
}
validate(value, msg) {
const attachment = msg.attachments.first();
if (!attachment) return false;
if (!fileTypeRe.test(attachment.name)) return 'Please provide a JSON file.';
return true;
}
async parse(value, msg) {
const attachment = msg.attachments.first();
const { body } = await request.get(attachment.url);
return body;
}
isEmpty(value, msg, arg) {
if (msg.attachments.size) return false;
return this.client.registry.types.get('user').isEmpty(value, msg, arg);
}
};