Command event overhaul
This commit is contained in:
parent
523bd90179
commit
d23094ccfd
4 changed files with 10 additions and 4 deletions
|
@ -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}`)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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, {
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue