From 6d2fa5080b330d5b9a923ffbe0bba4f64077132a Mon Sep 17 00:00:00 2001 From: DuckySoLucky Date: Tue, 21 Feb 2023 16:37:56 +0100 Subject: [PATCH] fix: eslint errors --- src/discord/commands/infoCommand.js | 2 - src/discord/commands/onlineCommand.js | 67 +++++++++------------------ src/minecraft/handlers/ChatHandler.js | 2 +- 3 files changed, 23 insertions(+), 48 deletions(-) diff --git a/src/discord/commands/infoCommand.js b/src/discord/commands/infoCommand.js index ddd2f8c9..3ef732b9 100644 --- a/src/discord/commands/infoCommand.js +++ b/src/discord/commands/infoCommand.js @@ -1,5 +1,3 @@ -const { toFixed } = require("../../contracts/helperFunctions.js"); -const { version } = require("../../../package.json"); // eslint-disable-next-line const { EmbedBuilder } = require("discord.js"); const config = require("../../../config.json"); diff --git a/src/discord/commands/onlineCommand.js b/src/discord/commands/onlineCommand.js index 92881019..65efc811 100644 --- a/src/discord/commands/onlineCommand.js +++ b/src/discord/commands/onlineCommand.js @@ -1,5 +1,4 @@ const { EmbedBuilder } = require("discord.js"); -const { replaceAllRanks } = require("../../contracts/helperFunctions"); module.exports = { name: "online", @@ -28,55 +27,33 @@ module.exports = { try { const messages = await promise; - messages.map((message) => message.trim()); - let onlineMembers = messages.find((message) => - message.startsWith("Online Members: ") - ); - onlineMembers = - onlineMembers.split(": ")[0] + - ": " + - `\`${onlineMembers.split(": ")[1]}\``; + const trimmedMessages = messages.map(message => message.trim()); - let offlineMembers = messages.find((message) => - message.startsWith("Offline Members: ") - ); - offlineMembers = - offlineMembers.split(": ")[0] + - ": " + - `\`${offlineMembers.split(": ")[1]}\``; - - let totalMembers = messages.find((message) => - message.startsWith("Total Members: ") - ); - totalMembers = - totalMembers.split(": ")[0] + - ": " + - `\`${totalMembers.split(": ")[1]}\``; - - const onlineMembersList = messages - - let description = `**ONLINE**\n${onlineMembers}\n${offlineMembers}\n${totalMembers}\n\n`; - let online = []; - for (const [index, item] of Object.entries(onlineMembersList)) { + const onlineMembersMessage = trimmedMessages.find(message => message.startsWith("Online Members: ")); + const onlineMembers = `${onlineMembersMessage.split(": ")[0]}: \`${onlineMembersMessage.split(": ")[1]}\``; + + const offlineMembersMessage = trimmedMessages.find(message => message.startsWith("Offline Members: ")); + const offlineMembers = `${offlineMembersMessage.split(": ")[0]}: \`${offlineMembersMessage.split(": ")[1]}\``; + + const totalMembersMessage = trimmedMessages.find(message => message.startsWith("Total Members: ")); + const totalMembers = `${totalMembersMessage.split(": ")[0]}: \`${totalMembersMessage.split(": ")[1]}\``; + + const onlineMembersList = trimmedMessages; + + let description = `\n${onlineMembers}\n${offlineMembers}\n${totalMembers}\n\n**ONLINE**`; + + let online = onlineMembersList.flatMap((item, index) => { if (item.includes("-- ")) { const nextLine = onlineMembersList[parseInt(index) + 1]; - if (nextLine) { - if (nextLine.includes("●")) { - online = online.concat( - nextLine.split("●").map((item) => item.trim()) - ); - } + if (nextLine && nextLine.includes("●")) { + return nextLine.split("●").map(item => item.trim()); } } - } - - online = online.filter((item) => item); - - description += online - .map((item) => { - return `\`${item}\``; - }) - .join(", "); + return []; + }); + + online = online.filter(item => item); + description += online.map(item => `\`${item}\``).join(", "); const embed = new EmbedBuilder() .setColor("#2ECC71") diff --git a/src/minecraft/handlers/ChatHandler.js b/src/minecraft/handlers/ChatHandler.js index 980d8f1d..93d85cce 100644 --- a/src/minecraft/handlers/ChatHandler.js +++ b/src/minecraft/handlers/ChatHandler.js @@ -1,7 +1,6 @@ const { replaceAllRanks, toFixed, addCommas } = require('../../contracts/helperFunctions.js') const { getLatestProfile } = require('../../../API/functions/getLatestProfile.js') const delay = ms => new Promise(resolve => setTimeout(resolve, ms)) -let guildInfo = [], guildRanks = [], members = [], guildTop = [] const hypixel = require('../../contracts/API/HypixelRebornAPI.js') const { getUUID } = require('../../contracts/API/PlayerDBAPI.js') const eventHandler = require('../../contracts/EventHandler.js') @@ -13,6 +12,7 @@ const config = require('../../../config.json') const Logger = require('../../Logger.js') /*eslint-enable */ const fs = require('fs') +let guildTop = []; class StateHandler extends eventHandler { constructor(minecraft, command, discord) {