choice argument type

This commit is contained in:
Daniel Odendahl Jr
2018-03-17 13:02:45 +00:00
parent 7c12d04e42
commit 679bb538cb
17 changed files with 84 additions and 121 deletions
+19
View File
@@ -0,0 +1,19 @@
const { ArgumentType } = require('discord.js-commando');
const { list } = require('../util/Util');
class ChoiceArgumentType extends ArgumentType {
constructor(client) {
super(client, 'choice');
}
validate(value, msg, arg) {
if (arg.choices.includes(value.toLowerCase())) return true;
return `Invalid ${arg.label}, please enter either ${list(arg.choices, 'or')}.`;
}
parse(value) {
return value.toLowerCase();
}
}
module.exports = ChoiceArgumentType;