node-brigadier-commands/lib/arguments/BoolArgumentType.js
Chipmunk d302cf8f37 Implement argument types
Also fixes CommandDispatcher not throwing parse exceptions correctly, RequiredArgumentBuilder returning incorrect objects, and CommandContext.getArgument not returning the correct value
2023-09-01 18:41:31 -04:00

25 lines
571 B
JavaScript

const ArgumentType = require('./ArgumentType.js')
const EXAMPLES = ['true', 'false']
class BoolArgumentType extends ArgumentType {
static bool () {
return new BoolArgumentType()
}
parse (reader) {
return reader.readBoolean()
}
async listSuggestions (context, builder) {
if ('true'.startsWith(builder.remainingLowerCase)) builder.suggest('true')
if ('false'.startsWith(builder.remainingLowerCase)) builder.suggest('false')
return builder.buildPromise()
}
getExamples () {
return EXAMPLES
}
}
module.exports = BoolArgumentType