chipmunkbot3/commands/randomteleport.js

27 lines
764 B
JavaScript
Raw Normal View History

2024-04-02 17:53:10 -04:00
const { literal } = 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('randomteleport')
.executes(this.randomTeleportCommand)
)
2024-02-11 21:23:41 -05:00
2024-04-02 17:53:10 -04:00
dispatcher.register(literal('rtp').executes(this.randomTeleportCommand).redirect(node))
2024-02-11 21:23:41 -05:00
2024-04-02 17:53:10 -04:00
node.description = 'Teleports the sender to a random location'
node.permissionLevel = 0
},
randomTeleportCommand (context) {
const source = context.source
const bot = source.bot
const player = source.getPlayerOrThrow()
bot.core.run(`tp ${player.uuid} ${randomInt(-30000000, 30000000)} 256 ${randomInt(-30000000, 30000000)}`)
}
2024-02-11 21:23:41 -05:00
}
2024-04-02 17:53:10 -04:00
function randomInt (min, max) {
return Math.floor((Math.random() * (max - min)) + min)
}