chipmunkbot3/commands/kahoot.js

49 lines
1.2 KiB
JavaScript
Raw Normal View History

2024-04-02 17:53:10 -04:00
const { literal, argument, integer, greedyString } = require('brigadier-commands')
2024-02-11 21:23:41 -05:00
2024-04-02 17:53:10 -04:00
module.exports = {
register (dispatcher) {
const node = dispatcher.register(
literal('kahoot')
.then(
literal('join')
.then(
argument('pin', integer())
.then(
argument('username', greedyString())
.executes(c => this.joinCommand(c))
2024-04-02 17:53:10 -04:00
)
)
)
.then(
literal('leave')
.executes(c => this.leaveCommand(c))
2024-04-02 17:53:10 -04:00
)
.then(
literal('answer')
.then(
argument('answer', integer())
.executes(c => this.answerCommand(c))
2024-04-02 17:53:10 -04:00
)
)
)
2024-02-11 21:23:41 -05:00
2024-04-02 17:53:10 -04:00
node.description = 'kahoot client lol'
node.permissionLevel = 0
},
joinCommand (context) {
const bot = context.source.bot
bot.kahoot.join(context.getArgument('pin'), context.getArgument('username'))
},
leaveCommand (context) {
const bot = context.source.bot
bot.kahoot.leave()
},
answerCommand (context) {
const bot = context.source.bot
bot.kahoot.answer(context.getArgument('answer'))
2024-02-11 21:23:41 -05:00
}
}