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')
.then(
argument('message', greedyString())
.executes(this.bruhifyCommand.bind(this))
.executes(c => this.bruhifyCommand(c))
)
)

View file

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

View file

@ -4,14 +4,14 @@ module.exports = {
register (dispatcher) {
const node = dispatcher.register(
literal('clearchat')
.executes(this.clearChatCommand.bind(this))
.executes(c => this.clearChatCommand(c))
.then(
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.permissionLevel = 0

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -13,15 +13,15 @@ module.exports = {
literal('render')
.then(
argument('location', location(bot.paths.images))
.executes(this.renderCommand)
.executes(c => this.renderCommand(c))
)
)
.then(
literal('list')
.executes(this.listCommand.bind(this))
.executes(c => this.listCommand(c))
.then(
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())
.then(
argument('username', greedyString())
.executes(this.joinCommand)
.executes(c => this.joinCommand(c))
)
)
)
.then(
literal('leave')
.executes(this.leaveCommand)
.executes(c => this.leaveCommand(c))
)
.then(
literal('answer')
.then(
argument('answer', integer())
.executes(this.answerCommand)
.executes(c => this.answerCommand(c))
)
)
)

View file

@ -22,12 +22,12 @@ module.exports = {
literal('count')
.then(
argument('string', greedyString())
.executes(this.countCommand.bind(this))
.executes(c => this.countCommand(c))
)
)
.then(
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 = {
register (dispatcher) {
const listNode = literal('list').executes(this.listCommand).build()
const listNode = literal('list').executes(c => this.listCommand(c)).build()
const node = dispatcher.register(
literal('mail')
@ -15,7 +15,7 @@ module.exports = {
argument('username', string())
.then(
argument('message', greedyString())
.executes(this.sendCommand)
.executes(c => this.sendCommand(c))
)
)
)
@ -24,12 +24,12 @@ module.exports = {
)
.then(
literal('read')
.executes(this.listCommand)
.executes(c => this.listCommand(c))
.redirect(listNode)
)
.then(
literal('clear')
.executes(this.clearCommand)
.executes(c => this.clearCommand(c))
)
)

View file

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

View file

@ -13,27 +13,27 @@ module.exports = {
literal('play')
.then(
argument('location', location(bot.paths.music))
.executes(this.playCommand)
.executes(c => this.playCommand(c))
)
)
.then(
literal('skip')
.executes(this.skipCommand)
.executes(c => this.skipCommand(c))
)
.then(
literal('stop')
.executes(this.stopCommand)
.executes(c => this.stopCommand(c))
)
.then(
literal('loop')
.executes(this.loopCommand)
.executes(c => this.loopCommand(c))
)
.then(
literal('list')
.executes(this.listCommand.bind(this))
.executes(c => this.listCommand(c))
.then(
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) {
const node = dispatcher.register(
literal('myuser')
.executes(this.myUserCommand)
.executes(c => this.myUserCommand(c))
)
node.description = 'Sends the username of the sender of the command'

View file

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

View file

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

View file

@ -4,10 +4,10 @@ module.exports = {
register (dispatcher) {
const node = dispatcher.register(
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.permissionLevel = 0

View file

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

View file

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

View file

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

View file

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

View file

@ -7,7 +7,7 @@ module.exports = {
literal('urban')
.then(
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(
literal('validate')
.requires(source => source.permissionLevel >= 1)
.executes(this.validateCommand)
.executes(c => this.validateCommand(c))
)
node.description = 'Checks if a hash is valid'