Brozy123 commited on
Commit
82de593
·
verified ·
1 Parent(s): fe79507

Update index.js

Browse files
Files changed (1) hide show
  1. index.js +12 -13
index.js CHANGED
@@ -1313,20 +1313,19 @@ client.on('interactionCreate', async (interaction) => {
1313
  guildLineups.set(guildId, map);
1314
  saveLineup();
1315
 
1316
- await interaction.reply({ content: `✅ Formation set to **${formName}**!`, ephemeral: true });
1317
-
1318
- // Update the board if it exists, or tell them to use /lineup
1319
- const boardInfo = activeLineupMessages.get(guildId);
1320
- if (boardInfo) {
1321
- try {
1322
- const channel = await client.channels.fetch(boardInfo.channelId);
1323
- const msg = await channel.messages.fetch(boardInfo.messageId);
1324
- if (msg) await msg.edit(createLineupView(guildId));
1325
- } catch (e) { }
1326
  } else {
1327
- // If no board, send the view as a new message
1328
- const view = createLineupView(guildId);
1329
- await interaction.channel.send(view);
 
 
1330
  }
1331
  return;
1332
  }
 
1313
  guildLineups.set(guildId, map);
1314
  saveLineup();
1315
 
1316
+ const view = createLineupView(guildId);
1317
+
1318
+ // If the modal was triggered from a message (like the initial setup message), update it!
1319
+ if (interaction.message) {
1320
+ await interaction.update(view);
1321
+ activeLineupMessages.set(guildId, { channelId: interaction.channelId, messageId: interaction.message.id });
1322
+ addToCleanupQueue(guildId, interaction.channelId, interaction.message.id, 'lineup');
 
 
 
1323
  } else {
1324
+ // Otherwise reply ephemerally and send a new message
1325
+ await interaction.reply({ content: `✅ Formation set to **${formName}**!`, ephemeral: true });
1326
+ const msg = await interaction.channel.send(view);
1327
+ activeLineupMessages.set(guildId, { channelId: interaction.channelId, messageId: msg.id });
1328
+ addToCleanupQueue(guildId, interaction.channelId, msg.id, 'lineup');
1329
  }
1330
  return;
1331
  }