(interaction)
| 271 | } |
| 272 | |
| 273 | async function handleReview(interaction) { |
| 274 | const appId = interaction.options.getString("id"); |
| 275 | |
| 276 | const application = await getApplication( |
| 277 | interaction.client, |
| 278 | interaction.guild.id, |
| 279 | appId, |
| 280 | ); |
| 281 | if (!application) { |
| 282 | return await replyUserError(interaction, { type: ErrorTypes.USER_INPUT, message: 'Application not found.' }); |
| 283 | } |
| 284 | |
| 285 | if (application.status !== "pending") { |
| 286 | return await replyUserError(interaction, { type: ErrorTypes.UNKNOWN, message: 'This application has already been processed.' }); |
| 287 | } |
| 288 | |
| 289 | const appEmbed = createEmbed({ |
| 290 | title: `Review Application`, |
| 291 | description: `**User:** <@${application.userId}>\n**Application:** ${application.roleName}\n**Application ID:** \`${appId}\``, |
| 292 | color: 'info', |
| 293 | }); |
| 294 | |
| 295 | if (application.answers && application.answers.length > 0) { |
| 296 | application.answers.forEach((item, index) => { |
| 297 | appEmbed.addFields({ |
| 298 | name: `Q${index + 1}: ${item.question}`, |
| 299 | value: item.answer || '*No answer provided*', |
| 300 | inline: false |
| 301 | }); |
| 302 | }); |
| 303 | } |
| 304 | |
| 305 | const buttonRow = new ActionRowBuilder().addComponents( |
| 306 | new ButtonBuilder() |
| 307 | .setCustomId(`app_review_approve_${appId}`) |
| 308 | .setLabel('Approve') |
| 309 | .setStyle(ButtonStyle.Success), |
| 310 | new ButtonBuilder() |
| 311 | .setCustomId(`app_review_deny_${appId}`) |
| 312 | .setLabel('Deny') |
| 313 | .setStyle(ButtonStyle.Danger), |
| 314 | ); |
| 315 | |
| 316 | await InteractionHelper.safeEditReply(interaction, { |
| 317 | embeds: [appEmbed], |
| 318 | components: [buttonRow], |
| 319 | flags: ["Ephemeral"], |
| 320 | }); |
| 321 | |
| 322 | const collector = interaction.channel.createMessageComponentCollector({ |
| 323 | componentType: ComponentType.Button, |
| 324 | filter: i => |
| 325 | i.user.id === interaction.user.id && |
| 326 | (i.customId.startsWith(`app_review_approve_${appId}`) || |
| 327 | i.customId.startsWith(`app_review_deny_${appId}`)), |
| 328 | time: 300_000, |
| 329 | max: 1, |
| 330 | }); |
no test coverage detected