chipmunkbot3/commands/hole.js

29 lines
914 B
JavaScript
Raw Normal View History

2024-04-02 17:53:10 -04:00
const { literal, argument, greedyString } = require('brigadier-commands')
const { createNameSelector } = require('../util/command/utility')
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('hole')
.then(
argument('targets', greedyString())
.executes(this.holeCommand)
)
)
2024-02-11 21:23:41 -05:00
2024-04-02 17:53:10 -04:00
node.description = 'Creates a hole at the position of a players'
node.permissionLevel = 0
},
2024-02-11 21:23:41 -05:00
2024-04-02 17:53:10 -04:00
holeCommand (context) {
const source = context.source
const bot = source.bot
let selector = context.getArgument('targets')
const selector0 = selector[0]
if (selector0 !== '@' && selector0 !== '"' && selector0 !== "'" && selector.includes(' ')) selector = createNameSelector(selector)
2024-02-11 21:23:41 -05:00
2024-04-02 17:53:10 -04:00
bot.core.run(`execute at ${selector} run setblock ~ 1 ~ command_block{Command:'fill ~-1 0 ~-1 ~1 255 ~1 air destroy',auto:1b}`)
}
}