Brozy123 commited on
Commit
57bbc3a
·
verified ·
1 Parent(s): ecfd379

Update index.js

Browse files
Files changed (1) hide show
  1. index.js +43 -41
index.js CHANGED
@@ -77,7 +77,7 @@ const commandsData = [
77
  { name: 'motm', description: 'Award Man of the Match to a player', options: [{ name: 'player', type: 6, description: 'The player to award', required: true }] }
78
  ];
79
 
80
- client.once('ready', async () => {
81
  console.log(`[*] Logged in as ${client.user.tag}`);
82
 
83
  // Cleanup any backup channels created previously
@@ -1021,8 +1021,8 @@ client.on('interactionCreate', async (interaction) => {
1021
  return;
1022
  }
1023
 
1024
- if (interaction.isSelectMenu() && interaction.customId === 'formation_select') {
1025
- if (!roleStorage.isWhitelisted(interaction.guildId, interaction.member)) return interaction.reply({ content: "❌ No Permission to change formations.", ephemeral: true });
1026
  const guildId = interaction.guildId;
1027
  guildSelectedFormation.set(guildId, interaction.values[0]);
1028
  const map = new Map();
@@ -1066,50 +1066,58 @@ client.on('interactionCreate', async (interaction) => {
1066
  }
1067
  return;
1068
  }
1069
-
1070
- if (!interaction.isButton()) return;
1071
  const guildId = interaction.guildId;
1072
  const lineup = getGuildLineup(guildId);
1073
 
1074
- if (interaction.customId.startsWith('man_edit_')) {
1075
- if (!storage.isWhitelisted(interaction.guildId, interaction.member)) return interaction.reply({ content: "❌ No Permission", flags: [MessageFlags.Ephemeral] });
1076
- const posKey = interaction.customId.replace('man_edit_', '');
1077
- const row = new ActionRowBuilder().addComponents(
1078
- new UserSelectMenuBuilder()
1079
- .setCustomId(`man_pick_${posKey}`)
1080
- .setPlaceholder(`Select player for ${posKey}...`)
1081
- );
1082
- await interaction.reply({ content: `👤 Pick a player for **${posKey}**`, components: [row], ephemeral: true });
1083
- return;
1084
- }
 
1085
 
1086
- if (interaction.customId.startsWith('join_')) {
1087
- const pos = interaction.customId.replace('join_', '');
1088
- const userId = interaction.user.id;
 
 
 
1089
 
1090
- // Check if they were already in this specific position
1091
- let wasInCurrentPos = false;
1092
- const currentQ = lineup.get(pos) || [];
1093
- if (currentQ.includes(userId)) {
1094
- wasInCurrentPos = true;
 
 
 
 
 
1095
  }
1096
 
1097
- // Remove from all positions first
1098
- for (const [p, players] of lineup) {
1099
- lineup.set(p, players.filter(id => id !== userId));
 
 
1100
  }
1101
 
1102
- // Add to new position if they weren't just toggling off
1103
- if (!wasInCurrentPos) {
1104
- if (!lineup.get(pos)) lineup.set(pos, []);
1105
- lineup.get(pos).push(userId);
 
 
1106
  }
1107
-
1108
- await interaction.update(createLineupView(guildId));
1109
- return;
1110
  }
1111
 
1112
- if (interaction.customId.startsWith('tz_select_')) {
1113
  try {
1114
  await interaction.deferUpdate();
1115
  console.log(`[TZ] Handling selection for ${interaction.customId}`);
@@ -1161,12 +1169,6 @@ client.on('interactionCreate', async (interaction) => {
1161
  }
1162
  return;
1163
  }
1164
-
1165
- if (interaction.customId === 'lineup_clear') {
1166
- const map = new Map();
1167
- guildLineups.set(guildId, map);
1168
- await interaction.update(createLineupView(guildId));
1169
- }
1170
  });
1171
 
1172
  // --- 5. 24/7 HEARTBEAT (PINGER) ---
 
77
  { name: 'motm', description: 'Award Man of the Match to a player', options: [{ name: 'player', type: 6, description: 'The player to award', required: true }] }
78
  ];
79
 
80
+ client.once('clientReady', async () => {
81
  console.log(`[*] Logged in as ${client.user.tag}`);
82
 
83
  // Cleanup any backup channels created previously
 
1021
  return;
1022
  }
1023
 
1024
+ if (interaction.isStringSelectMenu() && interaction.customId === 'formation_select') {
1025
+ if (!roleStorage.isWhitelisted(interaction.guildId, interaction.member)) return interaction.reply({ content: "❌ No Permission to change formations.", flags: [MessageFlags.Ephemeral] });
1026
  const guildId = interaction.guildId;
1027
  guildSelectedFormation.set(guildId, interaction.values[0]);
1028
  const map = new Map();
 
1066
  }
1067
  return;
1068
  }
 
 
1069
  const guildId = interaction.guildId;
1070
  const lineup = getGuildLineup(guildId);
1071
 
1072
+ if (interaction.isButton()) {
1073
+ if (interaction.customId.startsWith('man_edit_')) {
1074
+ if (!roleStorage.isWhitelisted(interaction.guildId, interaction.member)) return interaction.reply({ content: "❌ No Permission", flags: [MessageFlags.Ephemeral] });
1075
+ const posKey = interaction.customId.replace('man_edit_', '');
1076
+ const row = new ActionRowBuilder().addComponents(
1077
+ new UserSelectMenuBuilder()
1078
+ .setCustomId(`man_pick_${posKey}`)
1079
+ .setPlaceholder(`Select player for ${posKey}...`)
1080
+ );
1081
+ await interaction.reply({ content: `👤 Pick a player for **${posKey}**`, components: [row], flags: [MessageFlags.Ephemeral] });
1082
+ return;
1083
+ }
1084
 
1085
+ if (interaction.customId.startsWith('join_')) {
1086
+ const pos = interaction.customId.replace('join_', '');
1087
+ const userId = interaction.user.id;
1088
+ let wasInCurrentPos = false;
1089
+ const currentQ = lineup.get(pos) || [];
1090
+ if (currentQ.includes(userId)) wasInCurrentPos = true;
1091
 
1092
+ for (const [p, players] of lineup) {
1093
+ lineup.set(p, players.filter(id => id !== userId));
1094
+ }
1095
+
1096
+ if (!wasInCurrentPos) {
1097
+ if (!lineup.get(pos)) lineup.set(pos, []);
1098
+ lineup.get(pos).push(userId);
1099
+ }
1100
+ await interaction.update(createLineupView(guildId));
1101
+ return;
1102
  }
1103
 
1104
+ if (interaction.customId === 'lineup_clear') {
1105
+ if (!roleStorage.isWhitelisted(interaction.guildId, interaction.member)) return interaction.reply({ content: "❌ No Permission", flags: [MessageFlags.Ephemeral] });
1106
+ lineup.clear();
1107
+ await interaction.update(createLineupView(guildId));
1108
+ return;
1109
  }
1110
 
1111
+ if (interaction.customId === 'lineup_done') {
1112
+ if (!roleStorage.isWhitelisted(interaction.guildId, interaction.member)) return interaction.reply({ content: "❌ No Permission", flags: [MessageFlags.Ephemeral] });
1113
+ await interaction.deferUpdate();
1114
+ const attachment = await createLineupAttachment(lineup, guildSelectedFormation.get(guildId) || 'default');
1115
+ await interaction.followUp({ files: [attachment] });
1116
+ return;
1117
  }
 
 
 
1118
  }
1119
 
1120
+ if (interaction.customId && interaction.customId.startsWith('tz_select_')) {
1121
  try {
1122
  await interaction.deferUpdate();
1123
  console.log(`[TZ] Handling selection for ${interaction.customId}`);
 
1169
  }
1170
  return;
1171
  }
 
 
 
 
 
 
1172
  });
1173
 
1174
  // --- 5. 24/7 HEARTBEAT (PINGER) ---