chipmunkbot3/commands/clearchat.js

33 lines
1,019 B
JavaScript

const { literal, argument, greedyString } = require('brigadier-commands')
module.exports = {
register (dispatcher) {
const node = dispatcher.register(
literal('clearchat')
.executes(this.clearChatCommand.bind(this))
.then(
argument('targets', greedyString())
.executes(this.targettedclearChatCommand.bind(this))
)
)
dispatcher.register(literal('cc').executes(this.clearChatCommand.bind(this)).redirect(node))
node.description = 'Clears the chat of everyone or a specific player'
node.permissionLevel = 0
},
clearChatCommand (context) {
const bot = context.source.bot
this.sendclearChatCommandMessage(bot, '@a')
},
targettedclearChatCommand (context) {
const bot = context.source.bot
this.sendclearChatCommandMessage(bot, context.getArgument('targets'))
},
sendclearChatCommandMessage (bot, targets) {
bot.tellraw({ text: '\n'.repeat(100) + 'The chat has been cleared', color: 'dark_green' }, targets)
}
}