fix: improve feedback type parsing from custom IDs and add validation for feedback types in interaction and view logic.
This commit is contained in:
@@ -27,7 +27,19 @@ export const handleFeedbackInteraction = async (interaction: Interaction) => {
|
|||||||
// Handle modal submission
|
// Handle modal submission
|
||||||
if (interaction.isModalSubmit() && interaction.customId.startsWith(FEEDBACK_CUSTOM_IDS.MODAL)) {
|
if (interaction.isModalSubmit() && interaction.customId.startsWith(FEEDBACK_CUSTOM_IDS.MODAL)) {
|
||||||
// Extract feedback type from customId (format: feedback_modal_FEATURE_REQUEST)
|
// 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) {
|
if (!config.feedbackChannelId) {
|
||||||
await interaction.reply({
|
await interaction.reply({
|
||||||
|
|||||||
@@ -94,6 +94,12 @@ export function buildFeedbackMessage(feedback: FeedbackData) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const theme = themes[feedback.type];
|
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);
|
const timestamp = Math.floor(feedback.timestamp.getTime() / 1000);
|
||||||
|
|
||||||
// Header Container
|
// Header Container
|
||||||
|
|||||||
Reference in New Issue
Block a user