chipmunkbot3/commands/clearchat.js

34 lines
1,019 B
JavaScript
Raw Normal View History

2024-04-02 17:53:10 -04:00
const { literal, argument, greedyString } = 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('clearchat')
.executes(this.clearChatCommand.bind(this))
.then(
argument('targets', greedyString())
.executes(this.targettedclearChatCommand.bind(this))
)
)
2024-02-11 21:23:41 -05:00
2024-04-02 17:53:10 -04:00
dispatcher.register(literal('cc').executes(this.clearChatCommand.bind(this)).redirect(node))
2024-02-11 21:23:41 -05:00
2024-04-02 17:53:10 -04:00
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')
},
2024-02-11 21:23:41 -05:00
2024-04-02 17:53:10 -04:00
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)
}
}