Skip to content

Commit

Permalink
fix: eslint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
DuckySoLucky committed Feb 21, 2023
1 parent 91fc751 commit 6d2fa50
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 48 deletions.
2 changes: 0 additions & 2 deletions src/discord/commands/infoCommand.js
Original file line number Diff line number Diff line change
@@ -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");
Expand Down
67 changes: 22 additions & 45 deletions src/discord/commands/onlineCommand.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
const { EmbedBuilder } = require("discord.js");
const { replaceAllRanks } = require("../../contracts/helperFunctions");

module.exports = {
name: "online",
Expand Down Expand Up @@ -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")
Expand Down
2 changes: 1 addition & 1 deletion src/minecraft/handlers/ChatHandler.js
Original file line number Diff line number Diff line change
@@ -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')
Expand All @@ -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) {
Expand Down

0 comments on commit 6d2fa50

Please sign in to comment.