(selectInteraction, rootInteraction, state)
| 791 | } |
| 792 | |
| 793 | async function handleRemoveField(selectInteraction, rootInteraction, state) { |
| 794 | await selectInteraction.deferUpdate(); |
| 795 | |
| 796 | const pickSelect = new StringSelectMenuBuilder() |
| 797 | .setCustomId('eb_remove_field_pick') |
| 798 | .setPlaceholder('Select a field to remove...') |
| 799 | .addOptions( |
| 800 | state.fields.slice(0, 25).map((f, i) => |
| 801 | new StringSelectMenuOptionBuilder() |
| 802 | .setLabel(`${i + 1}. ${f.name.substring(0, 50)}`) |
| 803 | .setDescription( |
| 804 | `${f.value.substring(0, 90)}${f.value.length > 90 ? '…' : ''}`, |
| 805 | ) |
| 806 | .setValue(String(i)) |
| 807 | .setEmoji('➖'), |
| 808 | ), |
| 809 | ); |
| 810 | |
| 811 | await selectInteraction.followUp({ |
| 812 | embeds: [ |
| 813 | new EmbedBuilder() |
| 814 | .setTitle('Remove Field') |
| 815 | .setDescription('Select the field you want to delete.') |
| 816 | .setColor(getColor('warning')), |
| 817 | ], |
| 818 | components: [new ActionRowBuilder().addComponents(pickSelect)], |
| 819 | flags: MessageFlags.Ephemeral, |
| 820 | }); |
| 821 | |
| 822 | const removeCollector = rootInteraction.channel.createMessageComponentCollector({ |
| 823 | componentType: ComponentType.StringSelect, |
| 824 | filter: i => |
| 825 | i.user.id === selectInteraction.user.id && i.customId === 'eb_remove_field_pick', |
| 826 | time: 60_000, |
| 827 | max: 1, |
| 828 | }); |
| 829 | |
| 830 | removeCollector.on('collect', async removeInter => { |
| 831 | await removeInter.deferUpdate(); |
| 832 | const idx = parseInt(removeInter.values[0], 10); |
| 833 | state.fields.splice(idx, 1); |
| 834 | await refreshDashboard(rootInteraction, state); |
| 835 | }); |
| 836 | } |
| 837 | |
| 838 | async function handleReorderFields(selectInteraction, rootInteraction, state) { |
| 839 | await selectInteraction.deferUpdate(); |
no test coverage detected