mirror of
https://github.com/ChipmunkMC/node-brigadier-commands.git
synced 2024-11-14 19:14:55 -05:00
Chipmunk
d302cf8f37
Also fixes CommandDispatcher not throwing parse exceptions correctly, RequiredArgumentBuilder returning incorrect objects, and CommandContext.getArgument not returning the correct value
25 lines
571 B
JavaScript
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
|