(interaction)
| 221 | } |
| 222 | |
| 223 | async function handleRemoveFilterModal(interaction) { |
| 224 | const config = await getGuildConfig(interaction.client, interaction.guildId); |
| 225 | const ignore = getIgnoreList(config); |
| 226 | const options = []; |
| 227 | |
| 228 | for (const userId of ignore.users || []) { |
| 229 | options.push( |
| 230 | new StringSelectMenuOptionBuilder() |
| 231 | .setLabel(`User ${userId}`) |
| 232 | .setDescription('Remove this user from the ignore list') |
| 233 | .setValue(`user:${userId}`), |
| 234 | ); |
| 235 | } |
| 236 | |
| 237 | for (const channelId of ignore.channels || []) { |
| 238 | options.push( |
| 239 | new StringSelectMenuOptionBuilder() |
| 240 | .setLabel(`Channel ${channelId}`) |
| 241 | .setDescription('Remove this channel from the ignore list') |
| 242 | .setValue(`channel:${channelId}`), |
| 243 | ); |
| 244 | } |
| 245 | |
| 246 | if (options.length === 0) { |
| 247 | return replyUserError(interaction, { |
| 248 | type: ErrorTypes.USER_INPUT, |
| 249 | message: 'There are no ignore filters to remove.', |
| 250 | }); |
| 251 | } |
| 252 | |
| 253 | const modalCustomId = 'log_dash_filter_modal:remove'; |
| 254 | |
| 255 | const filterSelect = new StringSelectMenuBuilder() |
| 256 | .setCustomId('filter_entry') |
| 257 | .setPlaceholder('Select a filter to remove…') |
| 258 | .setMinValues(1) |
| 259 | .setMaxValues(1) |
| 260 | .addOptions(options.slice(0, 25)); |
| 261 | |
| 262 | const filterLabel = new LabelBuilder() |
| 263 | .setLabel('Filter to Remove') |
| 264 | .setDescription('Choose a user or channel to un-ignore') |
| 265 | .setStringSelectMenuComponent(filterSelect); |
| 266 | |
| 267 | const modal = new ModalBuilder() |
| 268 | .setCustomId(modalCustomId) |
| 269 | .setTitle('Remove Ignore Filter') |
| 270 | .addLabelComponents(filterLabel); |
| 271 | |
| 272 | await interaction.showModal(modal); |
| 273 | |
| 274 | try { |
| 275 | const modalSubmission = await interaction.awaitModalSubmit({ |
| 276 | time: 5 * 60 * 1000, |
| 277 | filter: (i) => i.user.id === interaction.user.id && i.customId === modalCustomId, |
| 278 | }); |
| 279 | |
| 280 | const entry = modalSubmission.fields.getField('filter_entry')?.values?.[0]; |
no test coverage detected