Brozy123 commited on
Commit
ee89cf5
·
verified ·
1 Parent(s): ad32722

Update index.js

Browse files
Files changed (1) hide show
  1. index.js +10 -6
index.js CHANGED
@@ -282,11 +282,11 @@ 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[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
  }
@@ -542,13 +542,14 @@ client.on('interactionCreate', async (interaction) => {
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`;
551
- const msg = await interaction.reply({ content, fetchReply: true });
552
  await msg.react('🟩');
553
  storage.data.active_polls[interaction.guildId] = msg.id;
554
  storage.save('active_polls');
@@ -810,7 +811,7 @@ client.on('messageReactionAdd', async (reaction, user) => {
810
  }
811
  });
812
 
813
- function parseMatchTime(timeInput) {
814
  if (!timeInput) return null;
815
  const now = new Date();
816
  let targetDate = new Date();
@@ -829,7 +830,10 @@ function parseMatchTime(timeInput) {
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
  }
 
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
  }
 
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');
 
811
  }
812
  });
813
 
814
+ function parseMatchTime(timeInput, offset = 0) {
815
  if (!timeInput) return null;
816
  const now = new Date();
817
  let targetDate = new Date();
 
830
  if (ampm === 'pm' && hours !== 12) hours += 12;
831
  if (ampm === 'am' && hours === 12) hours = 0;
832
  targetDate.setHours(hours, 0, 0, 0);
833
+
834
+ // Adjust for timezone offset (offset is in hours, e.g. +3 for UTC+3)
835
+ const ts = Math.floor(targetDate.getTime() / 1000);
836
+ return ts - (offset * 3600);
837
  }
838
  return null;
839
  }