Improved Suggestions module readability and extracted Empheral const into a util file#177
Merged
Merged
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.
bristermitten
requested changes
Oct 3, 2025
| } = { | ||
| "suggestion-no": -1, | ||
| "suggestion-yes": 1, | ||
| const SUGGESTION_BUTTON_MAP: Record<string, SuggestionVoteType> = { |
Member
There was a problem hiding this comment.
I would rather this be more explicitly typed that it can only take the SUGGESTION_YES/NO_ID keys
Member
There was a problem hiding this comment.
I.e.
SUGGESTION_BUTTON_MAP : { [SUGGESTION_NO_ID] : number, [SUGGESTION_YES_ID]: number }
I think this is the syntax
| if (!interaction.guild) { | ||
| await interaction.followUp({ | ||
| content: "This can only be done in a guild!", | ||
| flags: "Ephemeral", |
Member
There was a problem hiding this comment.
don't we need EPHEMERAL_FLAG here? ;)
Contributor
Author
There was a problem hiding this comment.
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.
bristermitten
approved these changes
Oct 5, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.