APRK01 commited on
Commit
264934b
Β·
1 Parent(s): 81f0e16

feat: allow attaching images via dashboard editor

Browse files
Files changed (1) hide show
  1. src/systems/massdrop.js +54 -2
src/systems/massdrop.js CHANGED
@@ -131,16 +131,23 @@ function generateDashboard(session) {
131
  const row1 = new ActionRowBuilder().addComponents(
132
  new StringSelectMenuBuilder()
133
  .setCustomId('mass_select_edit')
134
- .setPlaceholder('✏️ Select a drop to edit its details...')
135
  .addOptions(safeOptions)
136
  );
137
 
138
  const row2 = new ActionRowBuilder().addComponents(
 
 
 
 
 
 
 
139
  new ButtonBuilder().setCustomId('mass_deploy').setLabel(`Deploy ${session.files.length} Drops`).setStyle(ButtonStyle.Success).setEmoji('πŸš€'),
140
  new ButtonBuilder().setCustomId('mass_cancel').setLabel('Cancel All').setStyle(ButtonStyle.Danger)
141
  );
142
 
143
- return { embeds: [embed], components: [row1, row2] };
144
  }
145
 
146
  /**
@@ -222,6 +229,27 @@ async function handleMassDropMessage(message) {
222
  }
223
  }
224
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
225
  else if (session.step === 'deploying') {
226
  const channelId = message.content.replace(/[<#>]/g, '');
227
 
@@ -431,6 +459,30 @@ async function handleMassDropInteraction(interaction) {
431
  return true;
432
  }
433
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
434
  // ── MODAL SUBMISSIONS ──
435
  if (interaction.isModalSubmit() && interaction.customId.startsWith('mass_modal_')) {
436
  const itemIndex = parseInt(interaction.customId.split('_').pop(), 10);
 
131
  const row1 = new ActionRowBuilder().addComponents(
132
  new StringSelectMenuBuilder()
133
  .setCustomId('mass_select_edit')
134
+ .setPlaceholder('✏️ Select a drop to edit text...')
135
  .addOptions(safeOptions)
136
  );
137
 
138
  const row2 = new ActionRowBuilder().addComponents(
139
+ new StringSelectMenuBuilder()
140
+ .setCustomId('mass_select_image')
141
+ .setPlaceholder('πŸ–ΌοΈ Select a drop to attach an image...')
142
+ .addOptions(safeOptions)
143
+ );
144
+
145
+ const row3 = new ActionRowBuilder().addComponents(
146
  new ButtonBuilder().setCustomId('mass_deploy').setLabel(`Deploy ${session.files.length} Drops`).setStyle(ButtonStyle.Success).setEmoji('πŸš€'),
147
  new ButtonBuilder().setCustomId('mass_cancel').setLabel('Cancel All').setStyle(ButtonStyle.Danger)
148
  );
149
 
150
+ return { embeds: [embed], components: [row1, row2, row3] };
151
  }
152
 
153
  /**
 
229
  }
230
  }
231
  }
232
+ else if (session.step === 'waiting_image') {
233
+ // Stop waiting if they click cancel (handled in interactions) or upload an image
234
+ if (message.attachments.size > 0) {
235
+ const imageAttachment = message.attachments.find(a => (a.contentType || '').startsWith('image/'));
236
+ if (imageAttachment) {
237
+ const targetIndex = session.pendingImageIndex;
238
+ if (targetIndex !== undefined && session.files[targetIndex]) {
239
+ session.files[targetIndex].imageUrl = imageAttachment.url;
240
+ }
241
+
242
+ // Return to dashboard
243
+ session.step = 'dashboard';
244
+ session.pendingImageIndex = null;
245
+
246
+ await message.react('πŸ–ΌοΈ').catch(() => { });
247
+ await message.reply(generateDashboard(session));
248
+ } else {
249
+ await message.reply({ content: '⚠️ Please attach a valid image file, or click Cancel on the dashboard to abort.', ephemeral: true });
250
+ }
251
+ }
252
+ }
253
  else if (session.step === 'deploying') {
254
  const channelId = message.content.replace(/[<#>]/g, '');
255
 
 
459
  return true;
460
  }
461
 
462
+ if (interaction.isStringSelectMenu() && interaction.customId === 'mass_select_image') {
463
+ const selectedValue = interaction.values[0]; // e.g. mass_edit_0
464
+ const itemIndex = parseInt(selectedValue.split('_').pop(), 10);
465
+ const file = session.files[itemIndex];
466
+
467
+ // Put session into waiting state for this specific index
468
+ session.step = 'waiting_image';
469
+ session.pendingImageIndex = itemIndex;
470
+
471
+ await interaction.update({
472
+ embeds: [createEmbed({
473
+ title: 'πŸ–ΌοΈ Attach Image',
474
+ description: `> Drop the image file here to attach it to **${file.title}**.\n\n*Dashboard will automatically reload once received.*`,
475
+ color: Colors.INFO
476
+ })],
477
+ components: [
478
+ new ActionRowBuilder().addComponents(
479
+ new ButtonBuilder().setCustomId('mass_finish').setLabel('Cancel Attachment').setStyle(ButtonStyle.Secondary)
480
+ )
481
+ ]
482
+ });
483
+ return true;
484
+ }
485
+
486
  // ── MODAL SUBMISSIONS ──
487
  if (interaction.isModalSubmit() && interaction.customId.startsWith('mass_modal_')) {
488
  const itemIndex = parseInt(interaction.customId.split('_').pop(), 10);