-
Notifications
You must be signed in to change notification settings - Fork 12
Improved Suggestions module readability and extracted Empheral const into a util file #177
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…ce functionality - Extracted reusable functions for handling suggestion interactions (voting, managing approvals/rejections) to improve maintainability. - Added `generateVoteMessage` and `createReasonModal` utilities for better user feedback and modular modal creation. - Refactored imports across suggestion module files for consistency. - Consolidated ephemeral flag usage with a new constant and cleaned up redundant code paths. - Enhanced suggestion archiving logic with additional validations and error handling.
- Replaced repetitive ephemeral flag arrays with a centralized constant (`EPHEMERAL_FLAG`). - Streamlined defer and reply calls across modules to improve consistency and maintainability.
| } = { | ||
| "suggestion-no": -1, | ||
| "suggestion-yes": 1, | ||
| const SUGGESTION_BUTTON_MAP: Record<string, SuggestionVoteType> = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would rather this be more explicitly typed that it can only take the SUGGESTION_YES/NO_ID keys
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I.e.
SUGGESTION_BUTTON_MAP : { [SUGGESTION_NO_ID] : number, [SUGGESTION_YES_ID]: number }
I think this is the syntax
src/modules/suggest/suggest.ts
Outdated
| if (!interaction.guild) { | ||
| await interaction.followUp({ | ||
| content: "This can only be done in a guild!", | ||
| flags: "Ephemeral", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't we need EPHEMERAL_FLAG here? ;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, and i thought about it, why not just directly use MessageFlags.Ephemeral
…s modules - Refactored all occurrences of `EPHEMERAL_FLAG` to use `MessageFlags.Ephemeral` for better consistency with Discord.js standards. - Removed redundant `EPHEMERAL_FLAG` constant and adjusted related import statements. - Improved maintainability by directly referencing Discord.js enum for ephemeral message flags.
…annotations - Added validation for invalid button interactions with user-friendly ephemeral replies. - Updated `SUGGESTION_BUTTON_MAP` type annotations for better type safety and error handling. - Reformatted imports for consistency and readability.
No description provided.