Spaces:
Runtime error
Runtime error
Update index.js
Browse files
index.js
CHANGED
|
@@ -282,8 +282,16 @@ 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 link = args
|
| 286 |
-
const
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 287 |
const msg = await message.channel.send({ content, allowedMentions: { parse: ['everyone'] } });
|
| 288 |
await msg.react('🟩');
|
| 289 |
await msg.react('🟥');
|
|
@@ -532,20 +540,11 @@ client.on('interactionCreate', async (interaction) => {
|
|
| 532 |
const home = interaction.options.getString('home');
|
| 533 |
const away = interaction.options.getString('away');
|
| 534 |
const link = interaction.options.getString('link');
|
| 535 |
-
const
|
| 536 |
-
|
| 537 |
let timeStr = "";
|
| 538 |
-
|
| 539 |
-
|
| 540 |
-
|
| 541 |
-
if (match) {
|
| 542 |
-
let h = parseInt(match[1]);
|
| 543 |
-
if (match[2].toLowerCase() === 'pm' && h !== 12) h += 12;
|
| 544 |
-
const date = new Date();
|
| 545 |
-
date.setHours(h, 0, 0, 0);
|
| 546 |
-
const ts = Math.floor(date.getTime() / 1000);
|
| 547 |
-
timeStr = `\n🕒 **Time**: <t:${ts}:F> (<t:${ts}:R>)`;
|
| 548 |
-
}
|
| 549 |
}
|
| 550 |
|
| 551 |
const content = `⭐▬▬ 🏆 **LEAGUE MATCH** 🏆 ▬▬⭐\n🏟️ **${home}** vs **${away}**\n🔗 ${link}\n🤝 Session${timeStr}\n⭐▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬⭐\n@everyone`;
|
|
@@ -811,6 +810,30 @@ client.on('messageReactionAdd', async (reaction, user) => {
|
|
| 811 |
}
|
| 812 |
});
|
| 813 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 814 |
// --- 4. LINEUP LOGIC ---
|
| 815 |
const FORMATIONS = {
|
| 816 |
"default": [["GK", "GK"], ["CB", "CB"], ["LB", "LB"], ["RB", "RB"], ["CM", "CM"], ["RW", "RW"], ["LW", "LW"]],
|
|
|
|
| 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 |
+
let timeStr = "";
|
| 289 |
+
const ts = parseMatchTime(timeInput);
|
| 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('🟥');
|
|
|
|
| 540 |
const home = interaction.options.getString('home');
|
| 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 ts = parseMatchTime(timeInput);
|
| 546 |
+
if (ts) {
|
| 547 |
+
timeStr = `\n🕒 **Time**: <t:${ts}:F> (<t:${ts}:R>)`;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 548 |
}
|
| 549 |
|
| 550 |
const content = `⭐▬▬ 🏆 **LEAGUE MATCH** 🏆 ▬▬⭐\n🏟️ **${home}** vs **${away}**\n🔗 ${link}\n🤝 Session${timeStr}\n⭐▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬⭐\n@everyone`;
|
|
|
|
| 810 |
}
|
| 811 |
});
|
| 812 |
|
| 813 |
+
function parseMatchTime(timeInput) {
|
| 814 |
+
if (!timeInput) return null;
|
| 815 |
+
const now = new Date();
|
| 816 |
+
let targetDate = new Date();
|
| 817 |
+
// Support formats like "9 PM", "4/23 9 PM", "4-23 9PM"
|
| 818 |
+
const regex = /(?:(\d+)[/-](\d+)\s+)?(\d+)\s*(am|pm)/i;
|
| 819 |
+
const match = timeInput.match(regex);
|
| 820 |
+
if (match) {
|
| 821 |
+
const month = match[1];
|
| 822 |
+
const day = match[2];
|
| 823 |
+
let hours = parseInt(match[3]);
|
| 824 |
+
const ampm = match[4].toLowerCase();
|
| 825 |
+
if (month && day) {
|
| 826 |
+
targetDate.setMonth(parseInt(month) - 1);
|
| 827 |
+
targetDate.setDate(parseInt(day));
|
| 828 |
+
}
|
| 829 |
+
if (ampm === 'pm' && hours !== 12) hours += 12;
|
| 830 |
+
if (ampm === 'am' && hours === 12) hours = 0;
|
| 831 |
+
targetDate.setHours(hours, 0, 0, 0);
|
| 832 |
+
return Math.floor(targetDate.getTime() / 1000);
|
| 833 |
+
}
|
| 834 |
+
return null;
|
| 835 |
+
}
|
| 836 |
+
|
| 837 |
// --- 4. LINEUP LOGIC ---
|
| 838 |
const FORMATIONS = {
|
| 839 |
"default": [["GK", "GK"], ["CB", "CB"], ["LB", "LB"], ["RB", "RB"], ["CM", "CM"], ["RW", "RW"], ["LW", "LW"]],
|