MCPcopy Index your code
hub / github.com/codebymitch/TitanBot / handleSetImages

Function handleSetImages

src/commands/Tools/embedbuilder.js:485–602  ·  view source on GitHub ↗
(selectInteraction, rootInteraction, state)

Source from the content-addressed store, hash-verified

483}
484
485async function handleSetImages(selectInteraction, rootInteraction, state) {
486 await selectInteraction.deferUpdate().catch(() => {});
487
488 const imageSelect = new StringSelectMenuBuilder()
489 .setCustomId('eb_image_pick')
490 .setPlaceholder('What would you like to change?')
491 .addOptions(
492 new StringSelectMenuOptionBuilder()
493 .setLabel('Set Thumbnail')
494 .setDescription('Small image displayed in the top-right corner')
495 .setValue('set_thumbnail')
496 .setEmoji('🖼️'),
497 new StringSelectMenuOptionBuilder()
498 .setLabel('Set Large Image')
499 .setDescription('Full-width banner image at the bottom')
500 .setValue('set_image')
501 .setEmoji('📸'),
502 new StringSelectMenuOptionBuilder()
503 .setLabel('Clear Thumbnail')
504 .setDescription('Remove the current thumbnail')
505 .setValue('clear_thumbnail')
506 .setEmoji('🗑️'),
507 new StringSelectMenuOptionBuilder()
508 .setLabel('Clear Large Image')
509 .setDescription('Remove the current large image')
510 .setValue('clear_image')
511 .setEmoji('🗑️'),
512 );
513
514 await selectInteraction.followUp({
515 embeds: [
516 new EmbedBuilder()
517 .setTitle('Set Images')
518 .setDescription('Choose which image to set or remove.')
519 .addFields(
520 { name: 'Thumbnail', value: state.thumbnail ? `[View](${state.thumbnail})` : '`Not set`', inline: true },
521 { name: 'Large Image', value: state.image ? `[View](${state.image})` : '`Not set`', inline: true },
522 )
523 .setColor(getColor('info')),
524 ],
525 components: [new ActionRowBuilder().addComponents(imageSelect)],
526 flags: MessageFlags.Ephemeral,
527 });
528
529 const imgMenuCollector = rootInteraction.channel.createMessageComponentCollector({
530 componentType: ComponentType.StringSelect,
531 filter: i =>
532 i.user.id === selectInteraction.user.id && i.customId === 'eb_image_pick',
533 time: 60_000,
534 max: 1,
535 });
536
537 imgMenuCollector.on('collect', async imgInter => {
538 try {
539 const pick = imgInter.values[0];
540
541 if (pick === 'clear_thumbnail') {
542 state.thumbnail = null;

Callers 1

executeFunction · 0.85

Calls 6

getColorFunction · 0.90
replyUserErrorFunction · 0.90
isValidUrlFunction · 0.85
followUpMethod · 0.80
safeShowModalMethod · 0.80
refreshDashboardFunction · 0.70

Tested by

no test coverage detected