diff --git a/commands/about.js b/commands/about.js index 34e2e68..a7d981f 100644 --- a/commands/about.js +++ b/commands/about.js @@ -204,7 +204,7 @@ const displayServerList = function (c) { index.bot.forEach((item, i) => { if (item.host.options && item.host.options.hidden && c.verify !== 3 && c.bot.id !== i) return let message = 'command.about.serverListItem' - if (c.bot.id == i) message = 'command.about.serverListItem.thisServer' + if (c.bot.id === i) message = 'command.about.serverListItem.thisServer' c.reply({ translate: getMessage(c.lang, message), color: c.colors.secondary, diff --git a/commands/settings.js b/commands/settings.js index 21adf66..2138edd 100644 --- a/commands/settings.js +++ b/commands/settings.js @@ -3,7 +3,7 @@ const fs = require('fs') const settings = require('../settings.json') module.exports = { execute: (c) => { - if (c.type == 'console') { + if (c.type === 'console') { c.reply({ text: getMessage(c.lang, 'command.settings.disabled.console'), color: c.colors.secondary diff --git a/plugins/!chat.js b/plugins/!chat.js index 2a44939..f4c1ba0 100755 --- a/plugins/!chat.js +++ b/plugins/!chat.js @@ -4,14 +4,14 @@ const parseConsole = require('../util/chatparse_console.js') const parse1204 = require('../util/parseNBT.js') const { getMessage } = require('../util/lang.js') const convertChatStyleItem = (item) => { - let output={}; - for(const i in item){ + const output = {} + for (const i in item) { output[i] = item[i].value } - return output; + return output } const convertChatTypeItem = (item) => { - if(item.style){ + if (item.style) { return { translation_key: item.translation_key.value, parameters: item.parameters.value.value, @@ -27,16 +27,16 @@ const convertChatTypeItem = (item) => { } module.exports = { load: (b) => { - b.messageCount = 0; - b.chatDisabledUntil = 0; - b.interval.antiSpam = setInterval(()=>{ - b.messageCount = 0; + b.messageCount = 0 + b.chatDisabledUntil = 0 + b.interval.antiSpam = setInterval(() => { + b.messageCount = 0 }, 4000) b.messageTypes = [] b._client.on('registry_data', (data) => { if (data.codec.value['minecraft:chat_type']) { b.messageTypes = data.codec.value['minecraft:chat_type'] - const nbtItems = data.codec.value['minecraft:chat_type'].value.value.value.value; + const nbtItems = data.codec.value['minecraft:chat_type'].value.value.value.value nbtItems.forEach((item, i) => { b.messageTypes[i] = convertChatTypeItem(item.element.value.chat.value) }) @@ -44,24 +44,24 @@ module.exports = { }) b._client.on('profileless_chat', (data) => { const messageType = b.messageTypes[data.type] - let json = {translate: messageType.translation_key, with: []} - messageType.parameters.forEach((item, i)=>{ - if(item == "content"){ + const json = { translate: messageType.translation_key, with: [] } + messageType.parameters.forEach((item, i) => { + if (item === 'content') { json.with[i] = parse1204(data.message) - } else if(item == "sender"){ + } else if (item === 'sender') { json.with[i] = parse1204(data.name) - } else if(item == "target"){ + } else if (item === 'target') { json.with[i] = parse1204(data.target) } }) - for(const i in messageType.style){ + for (const i in messageType.style) { json[i] = messageType.style[i] } - let username = "" - let nickname = "" - let uuid = "00000000-0000-0000-0000-000000000000" - let message = "" - if (messageType.translation_key == "%s") { + let username = '' + let nickname = '' + let uuid = '00000000-0000-0000-0000-000000000000' + let message = '' + if (messageType.translation_key === '%s') { const parsed = parsePlain(json) const split = parsed.split(': ') const chatName = split.splice(0, 1)[0] @@ -69,7 +69,7 @@ module.exports = { nickname = chatNameSplit[chatNameSplit.length - 1] username = b.findRealName(chatName) uuid = b.findUUID(username) - message = split.join(": ") + message = split.join(': ') } else { message = parsePlain(parse1204(data.message)) uuid = b.findUUID(parsePlain(parse1204(data.name))) @@ -77,7 +77,7 @@ module.exports = { username = parsePlain(parse1204(data.name)) } b.emit('chat', { - json: json, + json, type: 'profileless', uuid, message, @@ -88,25 +88,25 @@ module.exports = { b._client.on('player_chat', (data) => { const messageType = b.messageTypes[data.type] - let json = {translate: messageType.translation_key, with: []} - messageType.parameters.forEach((item, i)=>{ - if(item == "content"){ - if(messageType.translation_key === "%s"){ + const json = { translate: messageType.translation_key, with: [] } + messageType.parameters.forEach((item, i) => { + if (item === 'content') { + if (messageType.translation_key === '%s') { json.with[i] = parse1204(data.unsignedChatContent) } else { json.with[i] = data.plainMessage } - } else if(item == "sender"){ + } else if (item === 'sender') { json.with[i] = parse1204(data.networkName) - } else if(item == "target"){ + } else if (item === 'target') { json.with[i] = parse1204(data.networkTargetName) } }) - for(const i in messageType.style){ + for (const i in messageType.style) { json[i] = messageType.style[i] } b.emit('chat', { - json: json, + json, type: 'player', uuid: data.senderUuid, message: data.plainMessage, @@ -169,10 +169,10 @@ module.exports = { }) b.on('chat', (data) => { - b.messageCount++; - if(Date.now() < b.chatDisabledUntil) return - if(b.messageCount >= 100){ - b.info(getMessage(settings.defaultLang, "chat.antiSpamTriggered")) + b.messageCount++ + if (Date.now() < b.chatDisabledUntil) return + if (b.messageCount >= 100) { + b.info(getMessage(settings.defaultLang, 'chat.antiSpamTriggered')) b.chatDisabledUntil = Date.now() + 30000 return } diff --git a/plugins/command.js b/plugins/command.js index 45d0734..604aaaf 100755 --- a/plugins/command.js +++ b/plugins/command.js @@ -9,7 +9,7 @@ if (!fs.readdirSync('.').includes('userPref') && !settings.userSettingsDisabled) const loadSettings = function (uuid) { try { - if(settings.userSettingsDisabled){ + if (settings.userSettingsDisabled) { return {} } else { return require(`../userPref/${uuid}.json`) diff --git a/plugins/selfcare.js b/plugins/selfcare.js index e3ea2a5..ba2f27b 100755 --- a/plugins/selfcare.js +++ b/plugins/selfcare.js @@ -67,7 +67,7 @@ module.exports = { b.sc_tasks.gamemode.failed = 1 } else if (p.reason === 3 && p.gameMode === 1) { b.sc_tasks.gamemode.failed = 0 - } else if (p.reason === 4){ + } else if (p.reason === 4) { b.sc_tasks.respawn.failed = 1 } })