(interaction)
| 137 | } |
| 138 | |
| 139 | async function handleAddFilterModal(interaction) { |
| 140 | const filterType = interaction.customId.replace('log_dash_add_filter:', ''); |
| 141 | if (filterType !== 'user' && filterType !== 'channel') { |
| 142 | return interaction.reply({ content: '❌ Invalid filter type.', ephemeral: true }); |
| 143 | } |
| 144 | |
| 145 | const modalCustomId = `log_dash_filter_modal:add:${filterType}`; |
| 146 | |
| 147 | let modal; |
| 148 | if (filterType === 'user') { |
| 149 | const userSelect = new UserSelectMenuBuilder() |
| 150 | .setCustomId('ignore_user') |
| 151 | .setPlaceholder('Select a user to ignore…') |
| 152 | .setMinValues(1) |
| 153 | .setMaxValues(1); |
| 154 | |
| 155 | const userLabel = new LabelBuilder() |
| 156 | .setLabel('User to Ignore') |
| 157 | .setDescription('Choose a user whose actions should not be logged') |
| 158 | .setUserSelectMenuComponent(userSelect); |
| 159 | |
| 160 | modal = new ModalBuilder() |
| 161 | .setCustomId(modalCustomId) |
| 162 | .setTitle('Add User Filter') |
| 163 | .addLabelComponents(userLabel); |
| 164 | } else { |
| 165 | const channelSelect = new ChannelSelectMenuBuilder() |
| 166 | .setCustomId('ignore_channel') |
| 167 | .setPlaceholder('Select a channel to ignore…') |
| 168 | .setMinValues(1) |
| 169 | .setMaxValues(1) |
| 170 | .addChannelTypes(ChannelType.GuildText, ChannelType.GuildAnnouncement, ChannelType.GuildVoice); |
| 171 | |
| 172 | const channelLabel = new LabelBuilder() |
| 173 | .setLabel('Channel to Ignore') |
| 174 | .setDescription('Choose a channel whose events should not be logged') |
| 175 | .setChannelSelectMenuComponent(channelSelect); |
| 176 | |
| 177 | modal = new ModalBuilder() |
| 178 | .setCustomId(modalCustomId) |
| 179 | .setTitle('Add Channel Filter') |
| 180 | .addLabelComponents(channelLabel); |
| 181 | } |
| 182 | |
| 183 | await interaction.showModal(modal); |
| 184 | |
| 185 | try { |
| 186 | const modalSubmission = await interaction.awaitModalSubmit({ |
| 187 | time: 5 * 60 * 1000, |
| 188 | filter: (i) => i.user.id === interaction.user.id && i.customId === modalCustomId, |
| 189 | }); |
| 190 | |
| 191 | let id; |
| 192 | if (filterType === 'user') { |
| 193 | id = modalSubmission.fields.getField('ignore_user')?.values?.[0]; |
| 194 | } else { |
| 195 | id = modalSubmission.fields.getField('ignore_channel')?.values?.[0]; |
| 196 | } |
no test coverage detected