Brozy123 commited on
Commit
b5a9244
·
verified ·
1 Parent(s): f9357dc

Update index.js

Browse files
Files changed (1) hide show
  1. index.js +29 -12
index.js CHANGED
@@ -2005,6 +2005,28 @@ function getGuildLineup(guildId) {
2005
  return guildLineups.get(guildId);
2006
  }
2007
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2008
  function createLineupView(guildId) {
2009
  const lineup = getGuildLineup(guildId);
2010
  const formKey = guildSelectedFormation.get(guildId) || 'default';
@@ -2016,20 +2038,21 @@ function createLineupView(guildId) {
2016
  let text = "";
2017
  for (const [posKey, posLabel] of formation) {
2018
  const players = lineup.get(posKey) || [];
 
2019
  if (players.length > 0) {
2020
  const starter = players[0];
2021
  const subs = players.slice(1);
2022
- let line = `🟩 **${posLabel}** ➔ <@${starter}>`;
2023
  if (subs.length > 0) {
2024
  line += ` (Substitute: ` + subs.map(p => `<@${p}>`).join(', ') + `)`;
2025
  }
2026
  text += line + "\n\n";
2027
  } else {
2028
- text += `⬛ **${posLabel}** ➔ *Open*\n\n`;
2029
  }
2030
  }
2031
 
2032
- const embed = UI.createEmbed(`⚽ MATCH LINEUP — ${formDisplayName}`, text, UI.colors.primary);
2033
  embed.setFooter({ text: "Click a position below to join/leave! Use the dropdown to change formation." });
2034
 
2035
  const rows = [];
@@ -2086,13 +2109,6 @@ function createLineupView(guildId) {
2086
  return { content, embeds: [embed], components: rows, allowedMentions: { parse: ['everyone'] } };
2087
  }
2088
 
2089
- function getFriendlyText(guildId, needed) {
2090
- const config = storage.data.config[guildId] || {};
2091
- let text = config.friendlyText || "⭐▬▬▬▬▬ **FRIENDLY** ▬▬▬▬▬⭐\n🤝 Session\n🟩 I'm In\n🟥 Busy\n⭐▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬⭐\n🗳️ Needed: {needed}\n@everyone";
2092
- return text.replace('{needed}', needed);
2093
- }
2094
-
2095
-
2096
  function createManagerEditor(guildId, client) {
2097
  const lineup = getGuildLineup(guildId);
2098
  const formKey = guildSelectedFormation.get(guildId) || 'default';
@@ -2101,11 +2117,11 @@ function createManagerEditor(guildId, client) {
2101
 
2102
  if (!formation) return { content: "❌ Error: Formation not found." };
2103
 
2104
- let text = "🛠️ **LINEUP GUI EDITOR**\n▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬\n";
2105
  for (const [posKey, posLabel] of formation) {
2106
  const players = lineup.get(posKey) || [];
2107
  const userStr = players.length > 0 ? `<@${players[0]}>` : "---";
2108
- text += `📦 **${posLabel}**: ${userStr}\n`;
2109
  }
2110
  text += "▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬\n*Click a box below to edit a position!*";
2111
 
@@ -2145,6 +2161,7 @@ function createManagerEditor(guildId, client) {
2145
  return { content: text, components: rows };
2146
  }
2147
 
 
2148
  // --- 5. 24/7 HEARTBEAT & RECOVERY ---
2149
  const fetch = require('node-fetch');
2150
 
 
2005
  return guildLineups.get(guildId);
2006
  }
2007
 
2008
+ function resolveEmojis(text, guildId) {
2009
+ if (!text || typeof text !== 'string') return text;
2010
+ const guild = client.guilds.cache.get(guildId);
2011
+ if (!guild) return text;
2012
+
2013
+ return text.replace(/:([a-zA-Z0-9_]+):/g, (match, name) => {
2014
+ const emoji = guild.emojis.cache.find(e => e.name === name);
2015
+ return emoji ? emoji.toString() : match;
2016
+ });
2017
+ }
2018
+
2019
+ function getFriendlyText(guildId, needed) {
2020
+ const config = storage.data.config[guildId] || {};
2021
+ let text = config.friendlyText || "⭐▬▬▬▬▬ **FRIENDLY** ▬▬▬▬▬⭐\n🤝 Session\n🟩 I'm In\n🟥 Busy\n⭐▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬⭐\n🗳️ Needed: {needed}\n@everyone";
2022
+
2023
+ // Replace {needed} placeholder
2024
+ text = text.replace('{needed}', needed);
2025
+
2026
+ // Resolve custom emojis
2027
+ return resolveEmojis(text, guildId);
2028
+ }
2029
+
2030
  function createLineupView(guildId) {
2031
  const lineup = getGuildLineup(guildId);
2032
  const formKey = guildSelectedFormation.get(guildId) || 'default';
 
2038
  let text = "";
2039
  for (const [posKey, posLabel] of formation) {
2040
  const players = lineup.get(posKey) || [];
2041
+ const resolvedLabel = resolveEmojis(posLabel, guildId);
2042
  if (players.length > 0) {
2043
  const starter = players[0];
2044
  const subs = players.slice(1);
2045
+ let line = `🟩 **${resolvedLabel}** ➔ <@${starter}>`;
2046
  if (subs.length > 0) {
2047
  line += ` (Substitute: ` + subs.map(p => `<@${p}>`).join(', ') + `)`;
2048
  }
2049
  text += line + "\n\n";
2050
  } else {
2051
+ text += `⬛ **${resolvedLabel}** ➔ *Open*\n\n`;
2052
  }
2053
  }
2054
 
2055
+ const embed = UI.createEmbed(`⚽ MATCH LINEUP — ${resolveEmojis(formDisplayName, guildId)}`, text, UI.colors.primary);
2056
  embed.setFooter({ text: "Click a position below to join/leave! Use the dropdown to change formation." });
2057
 
2058
  const rows = [];
 
2109
  return { content, embeds: [embed], components: rows, allowedMentions: { parse: ['everyone'] } };
2110
  }
2111
 
 
 
 
 
 
 
 
2112
  function createManagerEditor(guildId, client) {
2113
  const lineup = getGuildLineup(guildId);
2114
  const formKey = guildSelectedFormation.get(guildId) || 'default';
 
2117
 
2118
  if (!formation) return { content: "❌ Error: Formation not found." };
2119
 
2120
+ let text = `🛠️ **LINEUP GUI EDITOR** — ${resolveEmojis(formDisplayName, guildId)}\n▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬\n`;
2121
  for (const [posKey, posLabel] of formation) {
2122
  const players = lineup.get(posKey) || [];
2123
  const userStr = players.length > 0 ? `<@${players[0]}>` : "---";
2124
+ text += `📦 **${resolveEmojis(posLabel, guildId)}**: ${userStr}\n`;
2125
  }
2126
  text += "▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬\n*Click a box below to edit a position!*";
2127
 
 
2161
  return { content: text, components: rows };
2162
  }
2163
 
2164
+
2165
  // --- 5. 24/7 HEARTBEAT & RECOVERY ---
2166
  const fetch = require('node-fetch');
2167