From 5f0c8a99e1741bdaa0e4bf6dda74c6c0c9ac63ec Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Sat, 17 Aug 2024 07:38:04 -0400 Subject: [PATCH] Pass message type to commands --- plugins/!chat.js | 10 ++++++++-- plugins/command.js | 4 ++-- util/Command.js | 3 ++- util/ConsoleCommand.js | 1 + 4 files changed, 13 insertions(+), 5 deletions(-) diff --git a/plugins/!chat.js b/plugins/!chat.js index bf9ed69..96b6f95 100755 --- a/plugins/!chat.js +++ b/plugins/!chat.js @@ -157,7 +157,13 @@ module.exports = { uuid = b.findUUID(username) message = split.join(': ') } - b.emit('chat', { json, type: 'legacy', uuid: data.uuid ? data.uuid : uuid, message, username }) + b.emit('chat', { + json, + type: 'legacy', + uuid: data.uuid ? data.uuid : uuid, + message, + username + }) }) b.on('chat', (data) => { @@ -173,7 +179,7 @@ module.exports = { for (const i in b.prefix) { if (fullCommand.startsWith(b.prefix[i])) { const command = fullCommand.slice(b.prefix[i].length) - b.runCommand(data.username, data.nickname, data.uuid, command, b.prefix[i]) + b.runCommand(data.username, data.nickname, data.uuid, command, data.type, b.prefix[i]) } } }) diff --git a/plugins/command.js b/plugins/command.js index c43b613..7fa853b 100755 --- a/plugins/command.js +++ b/plugins/command.js @@ -18,7 +18,7 @@ module.exports = { load: (b) => { b.prefix = settings.prefix b.lastCmd = 0 - b.runCommand = (name, nickname, uuid, text, prefix) => { + b.runCommand = (name, nickname, uuid, text, msgType, prefix) => { if (uuid === '00000000-0000-0000-0000-000000000000') return if (Date.now() - b.lastCmd <= 1000) return const userSettings = loadSettings(uuid) @@ -45,7 +45,7 @@ module.exports = { return } try { - cmds[cmd[0].toLowerCase()].execute(new Command(uuid, name, nickname, text, prefix, b, verify, userSettings)) + cmds[cmd[0].toLowerCase()].execute(new Command(uuid, name, nickname, text, msgType, prefix, b, verify, userSettings)) } catch (e) { console.log(e) b.tellraw(uuid, { diff --git a/util/Command.js b/util/Command.js index 222a3da..6eef075 100644 --- a/util/Command.js +++ b/util/Command.js @@ -1,12 +1,13 @@ const settings = require('../settings.json') class Command { - constructor (uuid, user, nick, cmd, prefix, bot, verify, prefs) { + constructor (uuid, user, nick, cmd, msgType, prefix, bot, verify, prefs) { this.send = (text, uuid) => { bot.tellraw(uuid || '@a', text) } this.reply = text => bot.tellraw(uuid, text) this.uuid = uuid this.username = user this.nickname = nick this.command = cmd + this.msgType = msgType; this.prefix = prefix this.bot = bot this.type = 'minecraft' diff --git a/util/ConsoleCommand.js b/util/ConsoleCommand.js index 1a4f3e9..e20f9ea 100644 --- a/util/ConsoleCommand.js +++ b/util/ConsoleCommand.js @@ -10,6 +10,7 @@ class ConsoleCommand { this.username = 'Owner' this.nickname = 'Console' this.command = cmd + this.msgType = "_bot_console"; this.prefix = '' // prefix does not exist at console this.bot = index2 >= 0 ? index.bot[index2]