Refactor command functions

no more .bind(this)!
This commit is contained in:
Chipmunk 2024-07-31 22:34:19 -04:00
parent 447de630a1
commit a362324478
27 changed files with 50 additions and 50 deletions

View file

@ -13,7 +13,7 @@ module.exports = {
literal('bruhify') literal('bruhify')
.then( .then(
argument('message', greedyString()) argument('message', greedyString())
.executes(this.bruhifyCommand.bind(this)) .executes(c => this.bruhifyCommand(c))
) )
) )

View file

@ -6,7 +6,7 @@ module.exports = {
literal('cb') literal('cb')
.then( .then(
argument('command', greedyString()) argument('command', greedyString())
.executes(this.runCommand) .executes(c => this.runCommand(c))
) )
) )

View file

@ -4,14 +4,14 @@ module.exports = {
register (dispatcher) { register (dispatcher) {
const node = dispatcher.register( const node = dispatcher.register(
literal('clearchat') literal('clearchat')
.executes(this.clearChatCommand.bind(this)) .executes(c => this.clearChatCommand(c))
.then( .then(
argument('targets', greedyString()) argument('targets', greedyString())
.executes(this.targettedclearChatCommand.bind(this)) .executes(c => this.targettedclearChatCommand(c))
) )
) )
dispatcher.register(literal('cc').executes(this.clearChatCommand.bind(this)).redirect(node)) dispatcher.register(literal('cc').executes(c => this.clearChatCommand(c)).redirect(node))
node.description = 'Clears the chat of everyone or a specific player' node.description = 'Clears the chat of everyone or a specific player'
node.permissionLevel = 0 node.permissionLevel = 0

View file

@ -19,7 +19,7 @@ module.exports = {
literal('create') literal('create')
.then( .then(
argument('options', json()) argument('options', json())
.executes(this.createCommand.bind(this)) .executes(c => this.createCommand(c))
) )
) )
.then( .then(
@ -30,7 +30,7 @@ module.exports = {
argument('name', string()) argument('name', string())
.then( .then(
argument('data', json()) argument('data', json())
.executes(this.writeCommand.bind(this)) .executes(c => this.writeCommand(c))
) )
) )
) )
@ -39,12 +39,12 @@ module.exports = {
literal('end') literal('end')
.then( .then(
argument('client', string()) argument('client', string())
.executes(this.endCommand.bind(this)) .executes(c => this.endCommand(c))
) )
) )
.then( .then(
literal('list') literal('list')
.executes(this.listCommand.bind(this)) .executes(c => this.listCommand(c))
) )
) )

View file

@ -11,7 +11,7 @@ module.exports = {
argument('interval', integer()) argument('interval', integer())
.then( .then(
argument('command', greedyString()) argument('command', greedyString())
.executes(this.addCommand) .executes(c => this.addCommand(c))
) )
) )
) )
@ -19,16 +19,16 @@ module.exports = {
literal('remove') literal('remove')
.then( .then(
argument('index', integer()) argument('index', integer())
.executes(this.removeCommand) .executes(c => this.removeCommand(c))
) )
) )
.then( .then(
literal('list') literal('list')
.executes(this.listCommand) .executes(c => this.listCommand(c))
) )
.then( .then(
literal('clear') literal('clear')
.executes(this.clearCommand) .executes(c => this.clearCommand(c))
) )
) )

View file

@ -5,7 +5,7 @@ module.exports = {
register (dispatcher) { register (dispatcher) {
const node = dispatcher.register( const node = dispatcher.register(
literal('credits') literal('credits')
.executes(this.creditsCommand) .executes(c => this.creditsCommand(c))
) )
node.description = 'Lists people who have contributed to the bot' node.description = 'Lists people who have contributed to the bot'

View file

@ -6,7 +6,7 @@ module.exports = {
literal('csvr') literal('csvr')
.then( .then(
argument('host', greedyString()) argument('host', greedyString())
.executes(this.consoleServerCommand) .executes(c => this.consoleServerCommand(c))
) )
) )

View file

@ -6,7 +6,7 @@ module.exports = {
literal('echo') literal('echo')
.then( .then(
argument('message', greedyString()) argument('message', greedyString())
.executes(this.echoCommand) .executes(c => this.echoCommand(c))
) )
) )

View file

@ -4,7 +4,7 @@ module.exports = {
register (dispatcher) { register (dispatcher) {
const node = dispatcher.register( const node = dispatcher.register(
literal('end') literal('end')
.executes(this.endCommand) .executes(c => this.endCommand(c))
) )
node.description = "Ends the bot's connection to the server" node.description = "Ends the bot's connection to the server"

View file

@ -7,10 +7,10 @@ module.exports = {
register (dispatcher) { register (dispatcher) {
const node = dispatcher.register( const node = dispatcher.register(
literal('help') literal('help')
.executes(this.listCommands) .executes(c => this.listCommands(c))
.then( .then(
argument('command', greedyString()) argument('command', greedyString())
.executes(this.showCommandInfo) .executes(c => this.showCommandInfo(c))
) )
) )

View file

@ -7,7 +7,7 @@ module.exports = {
literal('hole') literal('hole')
.then( .then(
argument('targets', greedyString()) argument('targets', greedyString())
.executes(this.holeCommand) .executes(c => this.holeCommand(c))
) )
) )

View file

@ -13,15 +13,15 @@ module.exports = {
literal('render') literal('render')
.then( .then(
argument('location', location(bot.paths.images)) argument('location', location(bot.paths.images))
.executes(this.renderCommand) .executes(c => this.renderCommand(c))
) )
) )
.then( .then(
literal('list') literal('list')
.executes(this.listCommand.bind(this)) .executes(c => this.listCommand(c))
.then( .then(
argument('location', path(bot.paths.images)) argument('location', path(bot.paths.images))
.executes(this.locationListCommand.bind(this)) .executes(c => this.locationListCommand(c))
) )
) )
) )

View file

@ -10,19 +10,19 @@ module.exports = {
argument('pin', integer()) argument('pin', integer())
.then( .then(
argument('username', greedyString()) argument('username', greedyString())
.executes(this.joinCommand) .executes(c => this.joinCommand(c))
) )
) )
) )
.then( .then(
literal('leave') literal('leave')
.executes(this.leaveCommand) .executes(c => this.leaveCommand(c))
) )
.then( .then(
literal('answer') literal('answer')
.then( .then(
argument('answer', integer()) argument('answer', integer())
.executes(this.answerCommand) .executes(c => this.answerCommand(c))
) )
) )
) )

View file

@ -22,12 +22,12 @@ module.exports = {
literal('count') literal('count')
.then( .then(
argument('string', greedyString()) argument('string', greedyString())
.executes(this.countCommand.bind(this)) .executes(c => this.countCommand(c))
) )
) )
.then( .then(
literal('abort') literal('abort')
.executes(this.abortCommand.bind(this)) .executes(c => this.abortCommand(c))
) )
) )

View file

@ -5,7 +5,7 @@ const UNABLE_TO_LOAD_PLAYER_DATA_ERROR = new DynamicCommandExceptionType(error =
module.exports = { module.exports = {
register (dispatcher) { register (dispatcher) {
const listNode = literal('list').executes(this.listCommand).build() const listNode = literal('list').executes(c => this.listCommand(c)).build()
const node = dispatcher.register( const node = dispatcher.register(
literal('mail') literal('mail')
@ -15,7 +15,7 @@ module.exports = {
argument('username', string()) argument('username', string())
.then( .then(
argument('message', greedyString()) argument('message', greedyString())
.executes(this.sendCommand) .executes(c => this.sendCommand(c))
) )
) )
) )
@ -24,12 +24,12 @@ module.exports = {
) )
.then( .then(
literal('read') literal('read')
.executes(this.listCommand) .executes(c => this.listCommand(c))
.redirect(listNode) .redirect(listNode)
) )
.then( .then(
literal('clear') literal('clear')
.executes(this.clearCommand) .executes(c => this.clearCommand(c))
) )
) )

View file

@ -4,7 +4,7 @@ module.exports = {
register (dispatcher) { register (dispatcher) {
const node = dispatcher.register( const node = dispatcher.register(
literal('matrix') literal('matrix')
.executes(this.matrixCommand) .executes(c => this.matrixCommand(c))
) )
node.description = 'Sends the Matrix invite' node.description = 'Sends the Matrix invite'

View file

@ -13,27 +13,27 @@ module.exports = {
literal('play') literal('play')
.then( .then(
argument('location', location(bot.paths.music)) argument('location', location(bot.paths.music))
.executes(this.playCommand) .executes(c => this.playCommand(c))
) )
) )
.then( .then(
literal('skip') literal('skip')
.executes(this.skipCommand) .executes(c => this.skipCommand(c))
) )
.then( .then(
literal('stop') literal('stop')
.executes(this.stopCommand) .executes(c => this.stopCommand(c))
) )
.then( .then(
literal('loop') literal('loop')
.executes(this.loopCommand) .executes(c => this.loopCommand(c))
) )
.then( .then(
literal('list') literal('list')
.executes(this.listCommand.bind(this)) .executes(c => this.listCommand(c))
.then( .then(
argument('location', path(bot.paths.music)) argument('location', path(bot.paths.music))
.executes(this.locationListCommand.bind(this)) .executes(c => this.locationListCommand(c))
) )
) )
) )

View file

@ -4,7 +4,7 @@ module.exports = {
register (dispatcher) { register (dispatcher) {
const node = dispatcher.register( const node = dispatcher.register(
literal('myuser') literal('myuser')
.executes(this.myUserCommand) .executes(c => this.myUserCommand(c))
) )
node.description = 'Sends the username of the sender of the command' node.description = 'Sends the username of the sender of the command'

View file

@ -6,7 +6,7 @@ module.exports = {
literal('netmsg') literal('netmsg')
.then( .then(
argument('message', greedyString()) argument('message', greedyString())
.executes(this.netMsgCommand) .executes(c => this.netMsgCommand(c))
) )
) )

View file

@ -7,7 +7,7 @@ module.exports = {
literal('rainbowify') literal('rainbowify')
.then( .then(
argument('message', greedyString()) argument('message', greedyString())
.executes(this.rainbowifyCommand) .executes(c => this.rainbowifyCommand(c))
) )
) )

View file

@ -4,10 +4,10 @@ module.exports = {
register (dispatcher) { register (dispatcher) {
const node = dispatcher.register( const node = dispatcher.register(
literal('randomteleport') literal('randomteleport')
.executes(this.randomTeleportCommand) .executes(c => this.randomTeleportCommand(c))
) )
dispatcher.register(literal('rtp').executes(this.randomTeleportCommand).redirect(node)) dispatcher.register(literal('rtp').executes(c => this.randomTeleportCommand(c)).redirect(node))
node.description = 'Teleports the sender to a random location' node.description = 'Teleports the sender to a random location'
node.permissionLevel = 0 node.permissionLevel = 0

View file

@ -4,7 +4,7 @@ module.exports = {
register (dispatcher) { register (dispatcher) {
const node = dispatcher.register( const node = dispatcher.register(
literal('rc') literal('rc')
.executes(this.refillCoreCommand) .executes(c => this.refillCoreCommand(c))
) )
node.description = "Refills the bot's command core" node.description = "Refills the bot's command core"

View file

@ -4,7 +4,7 @@ module.exports = {
register (dispatcher) { register (dispatcher) {
const node = dispatcher.register( const node = dispatcher.register(
literal('reload') literal('reload')
.executes(this.reloadCommand) .executes(c => this.reloadCommand(c))
) )
node.description = 'Attempts to reload all commands' node.description = 'Attempts to reload all commands'

View file

@ -10,7 +10,7 @@ module.exports = {
literal('seen') literal('seen')
.then( .then(
argument('username', string()) argument('username', string())
.executes(this.seenCommand) .executes(c => this.seenCommand(c))
) )
) )

View file

@ -10,7 +10,7 @@ module.exports = {
argument('amount', integer()) argument('amount', integer())
.then( .then(
argument('entity', string()) argument('entity', string())
.executes(this.spawnMobCommand) .executes(c => this.spawnMobCommand(c))
) )
) )
) )

View file

@ -7,7 +7,7 @@ module.exports = {
literal('urban') literal('urban')
.then( .then(
argument('word', greedyString()) argument('word', greedyString())
.executes(this.urbanCommand.bind(this)) .executes(c => this.urbanCommand(c))
) )
) )

View file

@ -5,7 +5,7 @@ module.exports = {
const node = dispatcher.register( const node = dispatcher.register(
literal('validate') literal('validate')
.requires(source => source.permissionLevel >= 1) .requires(source => source.permissionLevel >= 1)
.executes(this.validateCommand) .executes(c => this.validateCommand(c))
) )
node.description = 'Checks if a hash is valid' node.description = 'Checks if a hash is valid'