From 54eb048e0b7e8fb66c2812d2486c69b359ce6d76 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Sat, 24 Aug 2024 09:06:55 -0400 Subject: [PATCH] Make the name field in options useful (netmsg) --- commands/netmsg.js | 45 +++++++++++++++++++++++++----------------- lang/en-US.json | 1 + util/Command.js | 1 + util/ConsoleCommand.js | 3 ++- 4 files changed, 31 insertions(+), 19 deletions(-) diff --git a/commands/netmsg.js b/commands/netmsg.js index 3522bc7..814a5c6 100644 --- a/commands/netmsg.js +++ b/commands/netmsg.js @@ -2,29 +2,39 @@ const { bot } = require('../index.js') const { getMessage } = require('../util/lang.js') module.exports = { execute: (c) => { - if (c.bot.host && c.bot.host.options.hidden) { - c.reply({ - text: getMessage(c.lang, 'command.netmsg.disabled'), - color: c.colors.secondary - }) - return + let host = c.host + let port = c.port + if(c.bot.host.options && c.bot.host.options.hidden){ + host = "localhost" // Makes hidden servers appear as localhost + port = "25565" } const json = { translate: '[%s] %s: %s', with: [ { - translate: '%s:%s', - with: [ - { - text: c.host, - color: c.colors.primary - }, - { - text: c.port + '', - color: c.colors.primary + text: c.serverName, + hoverEvent: { + action: "show_text", + value: { + translate: '%s: %s:%s', + with: [ + { + text: getMessage(c.lang, "command.netmsg.serverAddress"), + color: c.colors.primary + }, + { + text: host, + color: c.colors.primary + }, + { + text: port + '', + color: c.colors.primary + } + ], + color: c.colors.secondary } - ], - color: c.colors.secondary + }, + color: c.colors.primary }, { text: c.username, @@ -37,7 +47,6 @@ module.exports = { color: 'white' } bot.forEach(item => { - if (item.host.options.hidden) return item.tellraw('@a', json) }) } diff --git a/lang/en-US.json b/lang/en-US.json index bdf6f31..cf5a5e1 100644 --- a/lang/en-US.json +++ b/lang/en-US.json @@ -64,6 +64,7 @@ "command.help.noCommand": "Command does not exist", "command.help.alias": "Alias to %s", "command.netmsg.disabled": "This command has been disabled on this server.", + "command.netmsg.serverAddress": "Server Address", "command.settings.disabled.console": "This command cannot be run from the console.", "command.settings.get.colorPrimary": "Primary color", "command.settings.get.colorSecondary": "Secondary color", diff --git a/util/Command.js b/util/Command.js index 8ef2247..e86f28a 100644 --- a/util/Command.js +++ b/util/Command.js @@ -16,6 +16,7 @@ class Command { this.verify = verify this.host = bot.host.host this.port = bot.host.port + this.serverName = bot.host.options.name this.prefs = prefs if (prefs.lang) { this.lang = prefs.lang diff --git a/util/ConsoleCommand.js b/util/ConsoleCommand.js index 4664ab7..ebf1f64 100644 --- a/util/ConsoleCommand.js +++ b/util/ConsoleCommand.js @@ -7,7 +7,7 @@ class ConsoleCommand { this.reply = text => process.stdout.write(parse(text) + '\n') this.uuid = 'dde5a2a6-ebdd-7bbb-8eac-f75b10c10446' this.username = 'Owner' - this.nickname = 'Console' + this.nickname = 'Owner' this.command = cmd this.msgType = '_bot_console' this.prefix = '' @@ -20,6 +20,7 @@ class ConsoleCommand { this.verify = 3 this.host = '' this.port = '3' + this.serverName = 'botvX Console' this.lang = settings.defaultLang this.colors = settings.colors }