Brozy123 commited on
Commit
49dbfd2
·
verified ·
1 Parent(s): 9ec0a33

Update index.js

Browse files
Files changed (1) hide show
  1. index.js +67 -23
index.js CHANGED
@@ -282,21 +282,22 @@ client.on('messageCreate', async (message) => {
282
  if (!roleStorage.isWhitelisted(message.guildId, message.member)) return message.reply("❌ No Permission");
283
  const home = args[0] || "Home";
284
  const away = args[1] || "Away";
 
285
  const timeInput = args.slice(3).join(" ");
286
 
287
- let timeStr = "";
288
- const offset = storage.data.config[message.guildId]?.timezone || 0;
289
- const ts = parseMatchTime(timeInput, offset);
290
- if (ts) {
291
- timeStr = `\n🕒 **Time**: <t:${ts}:F> (<t:${ts}:R>)`;
292
- }
293
 
294
- const content = `⭐▬▬ 🏆 **LEAGUE MATCH** 🏆 ▬▬⭐\n🏟️ **${home}** vs **${away}**\n🔗 ${link}\n🤝 Session${timeStr}\n⭐▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬⭐\n@everyone`;
295
- const msg = await message.channel.send({ content, allowedMentions: { parse: ['everyone'] } });
296
- await msg.react('🟩');
297
- await msg.react('🟥');
298
- storage.data.active_polls[message.guildId] = msg.id;
299
- storage.save('active_polls');
 
 
 
 
 
300
  }
301
 
302
  if (commandName === 'setup') {
@@ -541,18 +542,18 @@ client.on('interactionCreate', async (interaction) => {
541
  const away = interaction.options.getString('away');
542
  const link = interaction.options.getString('link');
543
  const timeInput = interaction.options.getString('time');
544
- let timeStr = "";
545
- const offset = storage.data.config[interaction.guildId]?.timezone || 0;
546
- const ts = parseMatchTime(timeInput, offset);
547
- if (ts) {
548
- timeStr = `\n🕒 **Time**: <t:${ts}:F> (<t:${ts}:R>)`;
549
- }
550
 
551
- const content = `⭐▬▬ 🏆 **LEAGUE MATCH** 🏆 ▬▬⭐\n🏟️ **${home}** vs **${away}**\n🔗 ${link}\n🤝 Session${timeStr}\n⭐▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬⭐\n@everyone`;
552
- const msg = await interaction.reply({ content, fetchReply: true, allowedMentions: { parse: ['everyone'] } });
553
- await msg.react('🟩');
554
- storage.data.active_polls[interaction.guildId] = msg.id;
555
- storage.save('active_polls');
 
 
 
 
 
 
556
  }
557
 
558
  if (interaction.commandName === 'win' || interaction.commandName === 'loss' || interaction.commandName === 'draw') {
@@ -816,6 +817,23 @@ const TIMEZONE_MAP = {
816
  'CEST': 2, 'EET': 2, 'EEST': 3, 'MSK': 3, 'IST': 5.5, 'KST': 9, 'JST': 9
817
  };
818
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
819
  function parseMatchTime(timeInput) {
820
  if (!timeInput) return null;
821
  const now = new Date();
@@ -1076,6 +1094,32 @@ client.on('interactionCreate', async (interaction) => {
1076
  }
1077
 
1078
  await interaction.update(createLineupView(guildId));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1079
  }
1080
 
1081
  if (interaction.customId === 'lineup_clear') {
 
282
  if (!roleStorage.isWhitelisted(message.guildId, message.member)) return message.reply("❌ No Permission");
283
  const home = args[0] || "Home";
284
  const away = args[1] || "Away";
285
+ const link = args[2] || "TBA";
286
  const timeInput = args.slice(3).join(" ");
287
 
288
+ if (!timeInput) return message.reply("❌ Please provide a time (e.g. `!leaguematch Home Away Link 9 PM`)!");
 
 
 
 
 
289
 
290
+ const matchId = `match_${Date.now()}`;
291
+ pendingMatches.set(matchId, { home, away, link, timeInput, channelId: message.channelId });
292
+
293
+ const row = new ActionRowBuilder().addComponents(
294
+ new StringSelectMenuBuilder()
295
+ .setCustomId(`tz_select_${matchId}`)
296
+ .setPlaceholder('Select YOUR current timezone...')
297
+ .addOptions(TIMEZONE_OPTIONS)
298
+ );
299
+
300
+ await message.reply({ content: "🌍 **One last step!** Please select your timezone below so I can set the exact time for everyone:", components: [row] });
301
  }
302
 
303
  if (commandName === 'setup') {
 
542
  const away = interaction.options.getString('away');
543
  const link = interaction.options.getString('link');
544
  const timeInput = interaction.options.getString('time');
 
 
 
 
 
 
545
 
546
+ const matchId = `match_${Date.now()}`;
547
+ pendingMatches.set(matchId, { home, away, link, timeInput, channelId: interaction.channelId });
548
+
549
+ const row = new ActionRowBuilder().addComponents(
550
+ new StringSelectMenuBuilder()
551
+ .setCustomId(`tz_select_${matchId}`)
552
+ .setPlaceholder('Select YOUR current timezone...')
553
+ .addOptions(TIMEZONE_OPTIONS)
554
+ );
555
+
556
+ await interaction.reply({ content: "🌍 **Select your timezone** to finalize the match schedule:", components: [row], ephemeral: true });
557
  }
558
 
559
  if (interaction.commandName === 'win' || interaction.commandName === 'loss' || interaction.commandName === 'draw') {
 
817
  'CEST': 2, 'EET': 2, 'EEST': 3, 'MSK': 3, 'IST': 5.5, 'KST': 9, 'JST': 9
818
  };
819
 
820
+ const pendingMatches = new Map();
821
+ const TIMEZONE_OPTIONS = [
822
+ { label: 'UTC -8 (Pacific Time)', value: '-8' },
823
+ { label: 'UTC -7 (Mountain Time)', value: '-7' },
824
+ { label: 'UTC -6 (Central Time)', value: '-6' },
825
+ { label: 'UTC -5 (Eastern Time)', value: '-5' },
826
+ { label: 'UTC +0 (London, GMT)', value: '0' },
827
+ { label: 'UTC +1 (Central Europe)', value: '1' },
828
+ { label: 'UTC +2 (Eastern Europe)', value: '2' },
829
+ { label: 'UTC +3 (Moscow, Saudi Arabia)', value: '3' },
830
+ { label: 'UTC +4 (Dubai, UAE)', value: '4' },
831
+ { label: 'UTC +5.5 (India)', value: '5.5' },
832
+ { label: 'UTC +8 (China, Singapore)', value: '8' },
833
+ { label: 'UTC +9 (Japan, Korea)', value: '9' },
834
+ { label: 'UTC +10 (Sydney)', value: '10' }
835
+ ];
836
+
837
  function parseMatchTime(timeInput) {
838
  if (!timeInput) return null;
839
  const now = new Date();
 
1094
  }
1095
 
1096
  await interaction.update(createLineupView(guildId));
1097
+ return;
1098
+ }
1099
+
1100
+ if (interaction.customId.startsWith('tz_select_')) {
1101
+ const matchId = interaction.customId.replace('tz_select_', '');
1102
+ const matchData = pendingMatches.get(matchId);
1103
+ if (!matchData) return interaction.reply({ content: "❌ Session expired.", ephemeral: true });
1104
+
1105
+ const offset = parseFloat(interaction.values[0]);
1106
+ const baseTs = parseMatchTime(matchData.timeInput);
1107
+ if (!baseTs) return interaction.reply({ content: "❌ Could not parse time format. Please use `9 PM` or `4/23 9 PM`.", ephemeral: true });
1108
+
1109
+ const finalTs = baseTs - (offset * 3600);
1110
+ const content = `⭐▬▬ 🏆 **LEAGUE MATCH** 🏆 ▬▬⭐\n🏟️ **${matchData.home}** vs **${matchData.away}**\n🔗 ${matchData.link}\n🕒 **Time**: <t:${finalTs}:F> (<t:${finalTs}:R>)\n🤝 Session\n⭐▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬⭐\n@everyone`;
1111
+
1112
+ const channel = await client.channels.fetch(matchData.channelId);
1113
+ const msg = await channel.send({ content, allowedMentions: { parse: ['everyone'] } });
1114
+ await msg.react('🟩');
1115
+ await msg.react('🟥');
1116
+
1117
+ storage.data.active_polls[interaction.guildId] = msg.id;
1118
+ storage.save('active_polls');
1119
+
1120
+ pendingMatches.delete(matchId);
1121
+ await interaction.update({ content: "✅ Match scheduled successfully!", components: [] });
1122
+ return;
1123
  }
1124
 
1125
  if (interaction.customId === 'lineup_clear') {