Make the name field in options useful (netmsg)

This commit is contained in:
7cc5c4f330d47060 2024-08-24 09:06:55 -04:00
parent 35486c19fe
commit 54eb048e0b
Signed by: 7cc5c4f330d47060
SSH key fingerprint: SHA256:e+4tcZut1nBpe10PqjaO+Rvie0Q7W4qIvFzcUw+7riA
4 changed files with 31 additions and 19 deletions

View file

@ -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',
text: c.serverName,
hoverEvent: {
action: "show_text",
value: {
translate: '%s: %s:%s',
with: [
{
text: c.host,
text: getMessage(c.lang, "command.netmsg.serverAddress"),
color: c.colors.primary
},
{
text: c.port + '',
text: host,
color: c.colors.primary
},
{
text: port + '',
color: c.colors.primary
}
],
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)
})
}

View file

@ -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",

View file

@ -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

View file

@ -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
}