Brozy123 commited on
Commit
9f45800
·
verified ·
1 Parent(s): 5ce32d5

Update index.js

Browse files
Files changed (1) hide show
  1. index.js +21 -2
index.js CHANGED
@@ -255,13 +255,24 @@ client.on('messageCreate', async (message) => {
255
  const res = args[0] || "?-?";
256
  const scorers = args.slice(1).join(" ");
257
  const record = storage.getRecord(message.guildId);
 
258
  if (type === 'win') record.wins++;
259
  else if (type === 'loss') record.losses++;
260
  else record.draws++;
 
 
 
 
 
 
 
 
 
261
  const mentions = scorers.match(/<@!?(\d+)>/g) || [];
262
  mentions.forEach(m => storage.addStat(m.replace(/[<@!>]/g, ''), 'goals'));
 
263
  storage.save('records');
264
- const embed = UI.createEmbed(`⭐ ${type.toUpperCase()} RECORDED`, `🏟️ **Result**: ${res}\n\n⚽ **Scorers**:\n${scorers || "None"}`, type === 'win' ? UI.colors.success : UI.colors.danger);
265
  await message.channel.send({ embeds: [embed] });
266
  }
267
 
@@ -541,6 +552,14 @@ client.on('interactionCreate', async (interaction) => {
541
  else if (type === 'loss') record.losses++;
542
  else record.draws++;
543
 
 
 
 
 
 
 
 
 
544
  // Process scorers
545
  const mentions = scorers.match(/<@!?(\d+)>/g) || [];
546
  mentions.forEach(m => {
@@ -549,7 +568,7 @@ client.on('interactionCreate', async (interaction) => {
549
  });
550
 
551
  storage.save('records');
552
- const embed = UI.createEmbed(`⭐ ${type.toUpperCase()} RECORDED`, `🏟️ **Result**: ${res}\n\n⚽ **Scorers**:\n${scorers || "None"}`, type === 'win' ? UI.colors.success : UI.colors.danger);
553
  await interaction.reply({ embeds: [embed] });
554
  }
555
 
 
255
  const res = args[0] || "?-?";
256
  const scorers = args.slice(1).join(" ");
257
  const record = storage.getRecord(message.guildId);
258
+
259
  if (type === 'win') record.wins++;
260
  else if (type === 'loss') record.losses++;
261
  else record.draws++;
262
+
263
+ // Auto-increment matches for everyone on the lineup board
264
+ const lineup = getGuildLineup(message.guildId);
265
+ const playersOnBoard = new Set();
266
+ for (const players of lineup.values()) {
267
+ players.forEach(p => playersOnBoard.add(p));
268
+ }
269
+ playersOnBoard.forEach(uid => storage.addStat(uid, 'matches'));
270
+
271
  const mentions = scorers.match(/<@!?(\d+)>/g) || [];
272
  mentions.forEach(m => storage.addStat(m.replace(/[<@!>]/g, ''), 'goals'));
273
+
274
  storage.save('records');
275
+ const embed = UI.createEmbed(`⭐ ${type.toUpperCase()} RECORDED`, `🏟️ **Result**: ${res}\n\n⚽ **Scorers**:\n${scorers || "None"}\n\n📊 *Matches have been recorded for everyone on the current lineup board.*`, type === 'win' ? UI.colors.success : UI.colors.danger);
276
  await message.channel.send({ embeds: [embed] });
277
  }
278
 
 
552
  else if (type === 'loss') record.losses++;
553
  else record.draws++;
554
 
555
+ // Auto-increment matches for everyone on the lineup board
556
+ const lineup = getGuildLineup(interaction.guildId);
557
+ const playersOnBoard = new Set();
558
+ for (const players of lineup.values()) {
559
+ players.forEach(p => playersOnBoard.add(p));
560
+ }
561
+ playersOnBoard.forEach(uid => storage.addStat(uid, 'matches'));
562
+
563
  // Process scorers
564
  const mentions = scorers.match(/<@!?(\d+)>/g) || [];
565
  mentions.forEach(m => {
 
568
  });
569
 
570
  storage.save('records');
571
+ const embed = UI.createEmbed(`⭐ ${type.toUpperCase()} RECORDED`, `🏟️ **Result**: ${res}\n\n⚽ **Scorers**:\n${scorers || "None"}\n\n📊 *Matches have been recorded for everyone on the current lineup board.*`, type === 'win' ? UI.colors.success : UI.colors.danger);
572
  await interaction.reply({ embeds: [embed] });
573
  }
574