Refactor Discord gateway and add auto-threading#5
Open
coreymull wants to merge 1 commit into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
This PR refactors the Discord gateway from a monolithic handler into multiple NestJS injectable services, improves type-safety across Discord interaction entrypoints, and adds auto-threading for proposals and bounty-feed notifications.
Changes:
- Extracts interaction routing, proposal voting, message moderation, chef scheduling, and thread creation into dedicated services wired by a slimmer
DiscordGateway. - Replaces
any-typed Discord handlers/commands with Discord.js v14 interaction types. - Adds proposal auto-thread creation (persisted via
Proposal.threadCreated) and bounty-feed thread creation after posting notifications.
Reviewed changes
Copilot reviewed 22 out of 22 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/main.ts | Uses void bootstrap() to satisfy linting around unhandled promises. |
| src/discord/services/proposal-vote.service.ts | New service handling reaction-based proposal voting + XP. |
| src/discord/services/discord-xp.service.ts | Removes stub user creation; skips XP for unlinked Discord users. |
| src/discord/services/discord-thread.service.ts | New service to create proposal threads (discord.js) and bounty threads (REST). |
| src/discord/services/discord-role.service.ts | Adds response typing + centralized axios error formatting. |
| src/discord/services/discord-notification.service.ts | Adds messageId return for embeds and creates bounty threads after posting. |
| src/discord/services/discord-guild.service.ts | Removes any from channel lookup. |
| src/discord/services/discord-command-router.service.ts | New central router for slash commands + button interactions. |
| src/discord/services/chef-scheduler.service.ts | New interval-based weekly “Chef” check scheduler. |
| src/discord/services/channel-moderation.service.ts | New service for bot-only channel cleanup + quest hooks. |
| src/discord/handlers/discord-verify.service.ts | Types button interaction and improves channel narrowing. |
| src/discord/handlers/discord-setup.service.ts | Types setup interaction, adds verify-channel bootstrap helper, and improves permission/channel typing. |
| src/discord/discord.module.ts | Registers newly extracted services/providers in the module. |
| src/discord/discord.gateway.ts | Slimmed gateway: registers slash commands, wires events to services, and runs boot tasks on ready. |
| src/discord/commands/rank.ts | Types interaction as ChatInputCommandInteraction. |
| src/discord/commands/quest.ts | Types interaction + return types for quest methods. |
| src/discord/commands/propose.ts | Types interaction, types GitHub API response, and triggers proposal thread creation + persistence. |
| src/discord/commands/proposals.ts | Types interaction as ChatInputCommandInteraction. |
| src/discord/commands/onboarding.ts | Types interaction as ChatInputCommandInteraction. |
| src/discord/commands/leaderboard.ts | Types interaction as ChatInputCommandInteraction. |
| src/discord/commands/daily.ts | Removes eslint-disables and types interaction as ChatInputCommandInteraction. |
| src/ai/ai.service.ts | Types OpenRouter responses and hardens parsing/joins. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| }); | ||
| await this.prisma.proposal.update({ | ||
| where: { id: proposal.id }, | ||
| data: { upvotes: { decrement: isUpvote ? 1 : 0 } }, |
|
|
||
| this.client.on('error', (err) => { | ||
| this.logger.error(`Discord client error: ${err.message}`); | ||
| this.client.on('clientReady', () => { |
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.
Closes #1
Summary
discord.gateway.tsfrom 689 lines to 220 lines by moving command routing, proposal voting, channel moderation, verify-channel boot setup, and weekly Chef scheduling into injectable servicesthreadCreatedpersistence, plus bounty-feed thread creation after notification postsgithubIdstub user creation with a safe skip for unlinked Discord usersBefore / After Structure
Before:
discord.gateway.tshandled client setup, slash routing, button handling, message moderation, reaction voting, verify-channel setup, sync-points, and Chef scheduling.After:
src/discord/discord.gateway.ts: client initialization, slash-command registration, event wiringsrc/discord/services/discord-command-router.service.ts: slash/button routing, sync-points, admin Chef commandsrc/discord/services/proposal-vote.service.ts: reaction vote handlingsrc/discord/services/channel-moderation.service.ts: bot-only channel cleanup and quest message hookssrc/discord/services/chef-scheduler.service.ts: weekly Chef intervalsrc/discord/services/discord-thread.service.ts: proposal and bounty notification thread creationsrc/discord/handlers/discord-setup.service.ts: setup-server plus verify-channel bootstrappingVerification
npm run buildDATABASE_URL=postgresql://devloot:devloot@localhost:5432/devloot npx prisma generateDATABASE_URL=postgresql://devloot:devloot@localhost:5432/devloot npm run lintwc -l src/discord/discord.gateway.ts-> 220rg -n "eslint-disable|\bany\b" src/discord-> no matchesPayout
Algorand payout address:
R7NHEHQY6DZJM74L442ML3REU66F7XFZ6FVHGUH4MI7FXPPLMMRFUJBHEMDisclosure: this contribution was prepared by an autonomous coding agent under the
coreymullaccount.