-
Notifications
You must be signed in to change notification settings - Fork 2
refactor: modularize events.js and add missing tests #240
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
Merged
Merged
Changes from 10 commits
Commits
Show all changes
33 commits
Select commit
Hold shift + click to select a range
d73ef96
refactor(events): extract ready handler to events/ready.js
bdfe4f8
refactor(events): extract messageCreate handler to events/messageCrea…
f13be71
refactor(events): extract guildMemberAdd and voiceState handlers
549a9e6
refactor(events): extract interaction handlers to events/interactionC…
5930224
refactor(events): extract reaction handlers to events/reactions.js
08b1fda
refactor(events): extract error handlers to events/errors.js
f250bfb
refactor(events): extract voice state handler to events/voiceState.js
e4c7b93
refactor(events): update main events.js to use extracted modules
24195e9
refactor(events): modularize event handlers
ecc6714
test(utils): add cronParser and flattenToLeafPaths tests
45e3569
fix(test): correct cronParser timezone handling and dangerousKeys imp…
7c1df72
Merge branch 'main' into feat/code-quality-improvements
BillChirico 011237f
refactor: wire guildMemberAdd handler from dedicated module
2b6bcfa
fix: use safeReply when interaction not deferred, sanitize error mess…
de39ceb
fix: add error logging for background tasks
64d6e16
fix: add mobile responsive header
0b88cd2
fix(test): use JSON.parse for __proto__ test reliability
c53c502
style: apply biome lint fixes
d69a2d9
fix(a11y): resolve accessibility errors in landing page
a3e1415
fix(a11y): add aria-expanded and aria-controls to mobile nav toggle
0d942a8
fix: check both deferred and replied in showcase error handler
043d801
docs: fix markdownlint MD022/MD031 violations in task files
59d72f6
fix: await accumulateMessage before evaluateNow for immediate triage
4f9c4a8
fix: import DANGEROUS_KEYS instead of duplicating
a442741
fix(messageCreate): improve async error handling and abort on buffer …
80b6482
fix(interactionCreate): improve error handling for deferred interactions
7aba485
fix(events): wrap sendSpamAlert in try/catch to prevent unhandled rej…
2b5d10f
fix(interactionCreate): add config gates and wrap fallback replies
48d53db
fix(test): update ticket handler tests for sanitized error messages
c4ff232
fix: resolve biome lint issues
abd62a7
fix: update tests for events module refactoring
daf4354
fix(test): add config mocks for challenge and poll handlers
e9096a4
fix: resolve biome lint errors (duplicate keys + formatting)
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| /** | ||
| * Error Event Handlers | ||
| * Handles Discord client errors and process-level error handling | ||
| */ | ||
|
|
||
| import { Events } from 'discord.js'; | ||
| import { error as logError } from '../../logger.js'; | ||
|
|
||
| /** @type {boolean} Guard against duplicate process-level handler registration */ | ||
| let processHandlersRegistered = false; | ||
|
|
||
| /** | ||
| * Register error event handlers | ||
| * @param {Client} client - Discord client | ||
| */ | ||
| export function registerErrorHandlers(client) { | ||
| client.on(Events.Error, (err) => { | ||
| logError('Discord error', { error: err.message, stack: err.stack }); | ||
| }); | ||
|
|
||
| if (!processHandlersRegistered) { | ||
| process.on('unhandledRejection', (err) => { | ||
| logError('Unhandled rejection', { error: err?.message || String(err), stack: err?.stack }); | ||
| }); | ||
| process.on('uncaughtException', async (err) => { | ||
| logError('Uncaught exception — shutting down', { | ||
| error: err?.message || String(err), | ||
| stack: err?.stack, | ||
| }); | ||
| try { | ||
| const { Sentry } = await import('../../sentry.js'); | ||
| await Sentry.flush(2000); | ||
| } catch { | ||
| // ignore — best-effort flush | ||
| } | ||
| process.exit(1); | ||
| }); | ||
| processHandlersRegistered = true; | ||
| } | ||
| } |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| /** | ||
| * Guild Member Add Event Handler | ||
| * Handles welcome messages when users join a guild | ||
| */ | ||
|
|
||
| import { Events } from 'discord.js'; | ||
| import { getConfig } from '../config.js'; | ||
| import { sendWelcomeMessage } from '../welcome.js'; | ||
|
|
||
| /** | ||
| * Register a handler that sends the configured welcome message when a user joins a guild. | ||
| * @param {Client} client - Discord client instance to attach the event listener to. | ||
| * @param {Object} _config - Unused (kept for API compatibility); handler resolves per-guild config via getConfig(). | ||
| */ | ||
| export function registerGuildMemberAddHandler(client, _config) { | ||
| client.on(Events.GuildMemberAdd, async (member) => { | ||
| const guildConfig = getConfig(member.guild.id); | ||
| await sendWelcomeMessage(member, client, guildConfig); | ||
| }); | ||
| } | ||
greptile-apps[bot] marked this conversation as resolved.
Show resolved
Hide resolved
BillChirico marked this conversation as resolved.
Show resolved
Hide resolved
|
||
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.