Spaces:
Runtime error
Runtime error
Update index.js
Browse files
index.js
CHANGED
|
@@ -833,7 +833,7 @@ const TIMEZONE_OPTIONS = [
|
|
| 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' },
|
|
@@ -1110,33 +1110,54 @@ client.on('interactionCreate', async (interaction) => {
|
|
| 1110 |
}
|
| 1111 |
|
| 1112 |
if (interaction.customId.startsWith('tz_select_')) {
|
| 1113 |
-
|
| 1114 |
-
|
| 1115 |
-
|
| 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 |
-
|
| 1120 |
-
|
| 1121 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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
|
| 1137 |
-
|
| 1138 |
-
|
| 1139 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1140 |
}
|
| 1141 |
return;
|
| 1142 |
}
|
|
|
|
| 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 / Iraq / 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' },
|
|
|
|
| 1110 |
}
|
| 1111 |
|
| 1112 |
if (interaction.customId.startsWith('tz_select_')) {
|
| 1113 |
+
try {
|
| 1114 |
+
await interaction.deferUpdate();
|
| 1115 |
+
console.log(`[TZ] Handling selection for ${interaction.customId}`);
|
|
|
|
|
|
|
| 1116 |
|
| 1117 |
+
const matchId = interaction.customId.replace('tz_select_', '');
|
| 1118 |
+
const matchData = pendingMatches.get(matchId);
|
| 1119 |
+
|
| 1120 |
+
if (!matchData) {
|
| 1121 |
+
console.warn(`[TZ] Match data not found for ${matchId}`);
|
| 1122 |
+
return interaction.followUp({ content: "❌ Match session expired or bot restarted. Please try the command again.", ephemeral: true });
|
| 1123 |
+
}
|
| 1124 |
+
|
| 1125 |
+
const offset = parseFloat(interaction.values[0]);
|
| 1126 |
+
const baseTs = parseMatchTime(matchData.timeInput);
|
| 1127 |
+
|
| 1128 |
+
if (!baseTs) {
|
| 1129 |
+
return interaction.followUp({ content: "❌ Could not parse your time input. Use `9 PM` or `4/23 9 PM`.", ephemeral: true });
|
| 1130 |
+
}
|
| 1131 |
+
|
| 1132 |
+
const finalTs = baseTs - (offset * 3600);
|
| 1133 |
+
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`;
|
| 1134 |
+
|
| 1135 |
+
console.log(`[TZ] Attempting to send message to channel ${matchData.channelId}`);
|
| 1136 |
+
const channel = await client.channels.fetch(matchData.channelId).catch(e => {
|
| 1137 |
+
console.error("[TZ] Failed to fetch channel:", e);
|
| 1138 |
+
return null;
|
| 1139 |
+
});
|
| 1140 |
+
|
| 1141 |
+
if (!channel) {
|
| 1142 |
+
return interaction.followUp({ content: "❌ Could not find the original channel. Please try again in a public channel.", ephemeral: true });
|
| 1143 |
+
}
|
| 1144 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1145 |
const msg = await channel.send({ content, allowedMentions: { parse: ['everyone'] } });
|
| 1146 |
+
await msg.react('🟩').catch(() => {});
|
| 1147 |
+
await msg.react('🟥').catch(() => {});
|
| 1148 |
|
| 1149 |
storage.data.active_polls[interaction.guildId] = msg.id;
|
| 1150 |
storage.save('active_polls');
|
| 1151 |
|
| 1152 |
pendingMatches.delete(matchId);
|
| 1153 |
+
await interaction.editReply({ content: "✅ Match scheduled! I have posted it in the channel.", components: [] });
|
| 1154 |
+
console.log(`[TZ] Successfully completed match scheduling.`);
|
| 1155 |
+
|
| 1156 |
+
} catch (err) {
|
| 1157 |
+
console.error("[TZ] Critical Error:", err);
|
| 1158 |
+
try {
|
| 1159 |
+
await interaction.followUp({ content: "❌ A system error occurred while processing your selection.", ephemeral: true });
|
| 1160 |
+
} catch(e) {}
|
| 1161 |
}
|
| 1162 |
return;
|
| 1163 |
}
|