fix: improve feedback type parsing from custom IDs and add validation for feedback types in interaction and view logic.

This commit is contained in:
syntaxbullet
2025-12-24 20:23:52 +01:00
parent 42d2313933
commit 5ab19bf826
2 changed files with 19 additions and 1 deletions

View File

@@ -27,7 +27,19 @@ export const handleFeedbackInteraction = async (interaction: Interaction) => {
// Handle modal submission
if (interaction.isModalSubmit() && interaction.customId.startsWith(FEEDBACK_CUSTOM_IDS.MODAL)) {
// Extract feedback type from customId (format: feedback_modal_FEATURE_REQUEST)
const feedbackType = interaction.customId.split("_")[2] as FeedbackType;
const parts = interaction.customId.split("_");
const feedbackType = parts.slice(2).join("_") as FeedbackType;
console.log(`Processing feedback modal. CustomId: ${interaction.customId}, Extracted type: ${feedbackType}`);
if (!feedbackType || !["FEATURE_REQUEST", "BUG_REPORT", "GENERAL"].includes(feedbackType)) {
console.error(`Invalid feedback type extracted: ${feedbackType} from customId: ${interaction.customId}`);
await interaction.reply({
embeds: [createErrorEmbed("An error occurred processing your feedback. Please try again.")],
ephemeral: true
});
return;
}
if (!config.feedbackChannelId) {
await interaction.reply({

View File

@@ -94,6 +94,12 @@ export function buildFeedbackMessage(feedback: FeedbackData) {
};
const theme = themes[feedback.type];
if (!theme) {
console.error(`Unknown feedback type: ${feedback.type}`);
throw new Error(`Invalid feedback type: ${feedback.type}`);
}
const timestamp = Math.floor(feedback.timestamp.getTime() / 1000);
// Header Container