Brozy123 commited on
Commit
d21735b
·
verified ·
1 Parent(s): c476954

Update index.js

Browse files
Files changed (1) hide show
  1. index.js +4 -39
index.js CHANGED
@@ -74,8 +74,7 @@ const commandsData = [
74
  { name: 'profileimage', description: 'Generate a high-quality visual profile card', options: [{ name: 'user', type: 6, description: 'The user to check', required: false }] },
75
  { name: 'giverole', description: 'Give a role to members (Admin)', options: [{ name: 'role', type: 8, description: 'The role', required: true }] },
76
  { name: 'uptime', description: 'Show how long the bot has been online' },
77
- { name: 'motm', description: 'Award Man of the Match to a player', options: [{ name: 'player', type: 6, description: 'The player to award', required: true }] },
78
- { name: 'settimezone', description: 'Set server timezone offset (e.g. 3 for UTC+3)', options: [{ name: 'offset', type: 4, description: 'Hours from UTC', required: true }] }
79
  ];
80
 
81
  client.once('ready', async () => {
@@ -191,7 +190,7 @@ client.on('messageCreate', async (message) => {
191
  const args = message.content.slice(prefix.length).trim().split(/ +/);
192
  const commandName = args.shift().toLowerCase();
193
 
194
- const allCommands = [...commandsData.map(c => c.name), 'sync', 'sync_cmds', 'reboot', 'grantservers', 'servers', 'help', 'motm', 'profileimage', 'settimezone'];
195
  if (allCommands.includes(commandName)) {
196
  logTransaction(client, commandName, message.author, message.guild, message.member);
197
  }
@@ -328,18 +327,6 @@ client.on('messageCreate', async (message) => {
328
  await message.reply("🔓 Channel Unlocked.");
329
  }
330
 
331
- if (commandName === 'settimezone') {
332
- if (!message.member.permissions.has('Administrator')) return message.reply("❌ Admin Only");
333
- const offset = parseInt(args[0]);
334
- if (isNaN(offset)) return message.reply("❌ Please provide a valid number (e.g. `!settimezone 3`)!");
335
-
336
- if (!storage.data.config[message.guildId]) storage.data.config[message.guildId] = {};
337
- storage.data.config[message.guildId].timezone = offset;
338
- storage.save('config');
339
-
340
- await message.reply(`✅ Timezone set to **UTC${offset >= 0 ? '+' : ''}${offset}**. All match times will now be adjusted correctly.`);
341
- }
342
-
343
  if (commandName === 'post') {
344
  if (!message.member.permissions.has('Administrator')) return message.reply("❌ Admin Only");
345
  const text = args.join(' ');
@@ -627,16 +614,6 @@ client.on('interactionCreate', async (interaction) => {
627
  const embed = UI.createEmbed("📊 Server Match Record", `✅ Wins: \`${r.wins}\`\n🟥 Losses: \`${r.losses}\`\n🤝 Draws: \`${r.draws}\``);
628
  await interaction.reply({ embeds: [embed] });
629
  }
630
- if (interaction.commandName === 'settimezone') {
631
- if (!interaction.member.permissions.has('Administrator')) return interaction.reply({ content: "❌ Admin Only", ephemeral: true });
632
- const offset = interaction.options.getInteger('offset');
633
-
634
- if (!storage.data.config[interaction.guildId]) storage.data.config[interaction.guildId] = {};
635
- storage.data.config[interaction.guildId].timezone = offset;
636
- storage.save('config');
637
-
638
- await interaction.reply({ content: `✅ Timezone set to **UTC${offset >= 0 ? '+' : ''}${offset}**. Match times are now calibrated!`, ephemeral: true });
639
- }
640
  if (interaction.commandName === 'setup') {
641
  if (!interaction.member.permissions.has('Administrator')) return interaction.reply({ content: "❌ Admin Only", ephemeral: true });
642
 
@@ -839,20 +816,11 @@ const TIMEZONE_MAP = {
839
  'CEST': 2, 'EET': 2, 'EEST': 3, 'MSK': 3, 'IST': 5.5, 'KST': 9, 'JST': 9
840
  };
841
 
842
- function parseMatchTime(timeInput, serverOffset = 0) {
843
  if (!timeInput) return null;
844
  const now = new Date();
845
  let targetDate = new Date();
846
 
847
- // Check if user provided a timezone code (e.g. "9 PM EST")
848
- let activeOffset = serverOffset;
849
- for (const [code, offset] of Object.entries(TIMEZONE_MAP)) {
850
- if (timeInput.toUpperCase().includes(code)) {
851
- activeOffset = offset;
852
- break;
853
- }
854
- }
855
-
856
  // Support formats like "9 PM", "4/23 9 PM", "4-23 9PM"
857
  const regex = /(?:(\d+)[/-](\d+)\s+)?(\d+)\s*(am|pm)/i;
858
  const match = timeInput.match(regex);
@@ -868,10 +836,7 @@ function parseMatchTime(timeInput, serverOffset = 0) {
868
  if (ampm === 'pm' && hours !== 12) hours += 12;
869
  if (ampm === 'am' && hours === 12) hours = 0;
870
  targetDate.setHours(hours, 0, 0, 0);
871
-
872
- // Convert to UTC by subtracting the offset
873
- const ts = Math.floor(targetDate.getTime() / 1000);
874
- return ts - (activeOffset * 3600);
875
  }
876
  return null;
877
  }
 
74
  { name: 'profileimage', description: 'Generate a high-quality visual profile card', options: [{ name: 'user', type: 6, description: 'The user to check', required: false }] },
75
  { name: 'giverole', description: 'Give a role to members (Admin)', options: [{ name: 'role', type: 8, description: 'The role', required: true }] },
76
  { name: 'uptime', description: 'Show how long the bot has been online' },
77
+ { name: 'motm', description: 'Award Man of the Match to a player', options: [{ name: 'player', type: 6, description: 'The player to award', required: true }] }
 
78
  ];
79
 
80
  client.once('ready', async () => {
 
190
  const args = message.content.slice(prefix.length).trim().split(/ +/);
191
  const commandName = args.shift().toLowerCase();
192
 
193
+ const allCommands = [...commandsData.map(c => c.name), 'sync', 'sync_cmds', 'reboot', 'grantservers', 'servers', 'help', 'motm', 'profileimage'];
194
  if (allCommands.includes(commandName)) {
195
  logTransaction(client, commandName, message.author, message.guild, message.member);
196
  }
 
327
  await message.reply("🔓 Channel Unlocked.");
328
  }
329
 
 
 
 
 
 
 
 
 
 
 
 
 
330
  if (commandName === 'post') {
331
  if (!message.member.permissions.has('Administrator')) return message.reply("❌ Admin Only");
332
  const text = args.join(' ');
 
614
  const embed = UI.createEmbed("📊 Server Match Record", `✅ Wins: \`${r.wins}\`\n🟥 Losses: \`${r.losses}\`\n🤝 Draws: \`${r.draws}\``);
615
  await interaction.reply({ embeds: [embed] });
616
  }
 
 
 
 
 
 
 
 
 
 
617
  if (interaction.commandName === 'setup') {
618
  if (!interaction.member.permissions.has('Administrator')) return interaction.reply({ content: "❌ Admin Only", ephemeral: true });
619
 
 
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();
822
  let targetDate = new Date();
823
 
 
 
 
 
 
 
 
 
 
824
  // Support formats like "9 PM", "4/23 9 PM", "4-23 9PM"
825
  const regex = /(?:(\d+)[/-](\d+)\s+)?(\d+)\s*(am|pm)/i;
826
  const match = timeInput.match(regex);
 
836
  if (ampm === 'pm' && hours !== 12) hours += 12;
837
  if (ampm === 'am' && hours === 12) hours = 0;
838
  targetDate.setHours(hours, 0, 0, 0);
839
+ return Math.floor(targetDate.getTime() / 1000);
 
 
 
840
  }
841
  return null;
842
  }