Command event overhaul

This commit is contained in:
7cc5c4f330d47060 2024-09-11 01:35:15 -04:00
parent 523bd90179
commit d23094ccfd
Signed by: 7cc5c4f330d47060
SSH key fingerprint: SHA256:e+4tcZut1nBpe10PqjaO+Rvie0Q7W4qIvFzcUw+7riA
4 changed files with 10 additions and 4 deletions

View file

@ -25,8 +25,8 @@ module.exports = {
b.on('plainchat', (msg, type) => {
if (!settings.disableLogging && !settings.disableChatLogging) chatlog(`chat_${b.host.host}_${b.host.port}`, `[${type}] ${msg}`)
})
b.on('command', (name, uuid, text) => {
if (!settings.disableLogging && !settings.disableCommandLogging) chatlog(`cmd_${b.host.host}_${b.host.port}`, `${name} (${uuid}): ${text}`)
b.on('command', c => {
if (!settings.disableLogging && !settings.disableCommandLogging) chatlog(`cmd_${b.host.host}_${b.host.port}`, `${c.username} (${c.uuid}): ${c.command}`)
})
}
}

View file

@ -42,7 +42,11 @@ module.exports = {
if (verify > 0) {
text = cmd.slice(0, cmd.length - 1).join(' ')
}
b.emit('command', name, uuid, text, prefix)
const commandClass = new Command(uuid, name, nickname, text, msgType, prefix, b, verify, userSettings);
b.emit("command",commandClass)
if(commandClass.cancel === true) return
if (cmds[cmd[0].toLowerCase()]) {
const command = cmds[cmd[0].toLowerCase()]
const permsN = getMessage(lang, 'command.help.permsNormal')
@ -61,7 +65,7 @@ module.exports = {
return
}
try {
cmds[cmd[0].toLowerCase()].execute(new Command(uuid, name, nickname, text, msgType, prefix, b, verify, userSettings))
if(commandClass.cancel === false) cmds[cmd[0].toLowerCase()].execute(commandClass)
} catch (e) {
console.log(e)
b.tellraw(uuid, {

View file

@ -18,6 +18,7 @@ class Command {
this.port = bot.host.port
this.serverName = bot.host.options.name
this.prefs = prefs
this.cancel = false;
if (prefs.lang) {
this.lang = prefs.lang
} else {

View file

@ -22,6 +22,7 @@ class ConsoleCommand {
this.host = ''
this.port = '3'
this.serverName = `${version.botName} Console`
this.cancel = false;
this.lang = settings.defaultLang
this.colors = settings.colors
}