33 lines
1,010 B
JavaScript
33 lines
1,010 B
JavaScript
const { literal, argument, greedyString } = require('brigadier-commands')
|
|
|
|
module.exports = {
|
|
register (dispatcher) {
|
|
const node = dispatcher.register(
|
|
literal('clearchat')
|
|
.executes(c => this.clearChatCommand(c))
|
|
.then(
|
|
argument('targets', greedyString())
|
|
.executes(c => this.targettedclearChatCommand(c))
|
|
)
|
|
)
|
|
|
|
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
|
|
},
|
|
|
|
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)
|
|
}
|
|
}
|