Spaces:
Runtime error
Runtime error
Update index.js
Browse files
index.js
CHANGED
|
@@ -819,19 +819,31 @@ const TIMEZONE_MAP = {
|
|
| 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
|
|
|
|
|
|
|
|
|
|
|
|
|
| 827 |
{ label: 'UTC +1 (Central Europe)', value: '1' },
|
| 828 |
-
{ label: 'UTC +2 (Eastern Europe)', value: '2' },
|
| 829 |
-
{ label: 'UTC +3 (Moscow
|
| 830 |
-
{ label: 'UTC +4 (Dubai
|
| 831 |
-
{ label: 'UTC +5
|
| 832 |
-
{ label: 'UTC +
|
| 833 |
-
{ label: 'UTC +
|
| 834 |
-
{ label: 'UTC +
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 835 |
];
|
| 836 |
|
| 837 |
function parseMatchTime(timeInput) {
|
|
@@ -1098,27 +1110,34 @@ client.on('interactionCreate', async (interaction) => {
|
|
| 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.
|
| 1104 |
|
| 1105 |
const offset = parseFloat(interaction.values[0]);
|
| 1106 |
const baseTs = parseMatchTime(matchData.timeInput);
|
| 1107 |
-
if (!baseTs) return interaction.
|
| 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 |
-
|
| 1113 |
-
|
| 1114 |
-
|
| 1115 |
-
|
| 1116 |
-
|
| 1117 |
-
|
| 1118 |
-
|
|
|
|
| 1119 |
|
| 1120 |
-
|
| 1121 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1122 |
return;
|
| 1123 |
}
|
| 1124 |
|
|
|
|
| 819 |
|
| 820 |
const pendingMatches = new Map();
|
| 821 |
const TIMEZONE_OPTIONS = [
|
| 822 |
+
{ label: 'UTC -11 (Midway)', value: '-11' },
|
| 823 |
+
{ label: 'UTC -10 (Hawaii)', value: '-10' },
|
| 824 |
+
{ label: 'UTC -9 (Alaska)', value: '-9' },
|
| 825 |
{ label: 'UTC -8 (Pacific Time)', value: '-8' },
|
| 826 |
{ label: 'UTC -7 (Mountain Time)', value: '-7' },
|
| 827 |
{ label: 'UTC -6 (Central Time)', value: '-6' },
|
| 828 |
{ label: 'UTC -5 (Eastern Time)', value: '-5' },
|
| 829 |
+
{ label: 'UTC -4 (Atlantic Time)', value: '-4' },
|
| 830 |
+
{ label: 'UTC -3 (Brazil/Argentina)', value: '-3' },
|
| 831 |
+
{ label: 'UTC -2 (Mid-Atlantic)', value: '-2' },
|
| 832 |
+
{ label: 'UTC -1 (Azores)', value: '-1' },
|
| 833 |
+
{ label: 'UTC +0 (GMT / London)', value: '0' },
|
| 834 |
{ label: 'UTC +1 (Central Europe)', value: '1' },
|
| 835 |
+
{ label: 'UTC +2 (Eastern Europe / Egypt)', value: '2' },
|
| 836 |
+
{ label: 'UTC +3 (Moscow / Saudi / EEST)', value: '3' },
|
| 837 |
+
{ label: 'UTC +4 (Dubai / Baku)', value: '4' },
|
| 838 |
+
{ label: 'UTC +5 (Pakistan / Uzbekistan)', value: '5' },
|
| 839 |
+
{ label: 'UTC +5:30 (India / IST)', value: '5.5' },
|
| 840 |
+
{ label: 'UTC +6 (Bangladesh)', value: '6' },
|
| 841 |
+
{ label: 'UTC +7 (Thailand / Vietnam)', value: '7' },
|
| 842 |
+
{ label: 'UTC +8 (China / Singapore / Perth)', value: '8' },
|
| 843 |
+
{ label: 'UTC +9 (Japan / Korea)', value: '9' },
|
| 844 |
+
{ label: 'UTC +10 (Sydney / Guam)', value: '10' },
|
| 845 |
+
{ label: 'UTC +11 (Solomon Islands)', value: '11' },
|
| 846 |
+
{ label: 'UTC +12 (New Zealand / Fiji)', value: '12' }
|
| 847 |
];
|
| 848 |
|
| 849 |
function parseMatchTime(timeInput) {
|
|
|
|
| 1110 |
}
|
| 1111 |
|
| 1112 |
if (interaction.customId.startsWith('tz_select_')) {
|
| 1113 |
+
await interaction.deferUpdate(); // Prevent "Interaction failed" timeout
|
| 1114 |
+
|
| 1115 |
const matchId = interaction.customId.replace('tz_select_', '');
|
| 1116 |
const matchData = pendingMatches.get(matchId);
|
| 1117 |
+
if (!matchData) return interaction.followUp({ content: "❌ Session expired or bot restarted. Please run the command again.", ephemeral: true });
|
| 1118 |
|
| 1119 |
const offset = parseFloat(interaction.values[0]);
|
| 1120 |
const baseTs = parseMatchTime(matchData.timeInput);
|
| 1121 |
+
if (!baseTs) return interaction.followUp({ content: "❌ Could not parse time format. Please use `9 PM` or `4/23 9 PM`.", ephemeral: true });
|
| 1122 |
|
| 1123 |
const finalTs = baseTs - (offset * 3600);
|
| 1124 |
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`;
|
| 1125 |
|
| 1126 |
+
try {
|
| 1127 |
+
const channel = await client.channels.fetch(matchData.channelId);
|
| 1128 |
+
const msg = await channel.send({ content, allowedMentions: { parse: ['everyone'] } });
|
| 1129 |
+
await msg.react('🟩');
|
| 1130 |
+
await msg.react('🟥');
|
| 1131 |
+
|
| 1132 |
+
storage.data.active_polls[interaction.guildId] = msg.id;
|
| 1133 |
+
storage.save('active_polls');
|
| 1134 |
|
| 1135 |
+
pendingMatches.delete(matchId);
|
| 1136 |
+
await interaction.editReply({ content: "✅ Match scheduled successfully!", components: [] });
|
| 1137 |
+
} catch (e) {
|
| 1138 |
+
console.error(e);
|
| 1139 |
+
await interaction.followUp({ content: "❌ Failed to send match announcement. Check bot permissions.", ephemeral: true });
|
| 1140 |
+
}
|
| 1141 |
return;
|
| 1142 |
}
|
| 1143 |
|