-
Notifications
You must be signed in to change notification settings - Fork 1
refactor!: ConnectionState & Event Handling #5
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
base: master
Are you sure you want to change the base?
Conversation
definitely doesn't work yet, just felt like there was way too much changes not to commit already
large part left is the ConnectionState itself since events haven't been transformed yet
I need to make more commits
Paillat-dev
left a comment
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 didn't try running the code yet, will do that later today
Co-authored-by: Paillat <jeremiecotti@ik.me> Signed-off-by: VincentRPS <vincentbusiness55@gmail.com>
|
@VincentRPS You should also import defaultdict |
|
Any news ? See traceback of another error here: https://canary.discord.com/channels/881207955029110855/881735314987708456/1373639761696133160 |
Signed-off-by: VincentRPS <vincentbusiness55@gmail.com>
|
Congrats @VincentRPS you successfully broke the docs ! 🎉 |
Co-authored-by: Paillat <jeremiecotti@ik.me> Signed-off-by: VincentRPS <vincentbusiness55@gmail.com>
|
@VincentRPS I am going to rebase this for you and push here |
M'kay! |
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.
Pull Request Overview
This PR implements a major refactor of the ConnectionState and event handling system, migrating from a parser-based dispatch model to an event emitter pattern. The changes convert many synchronous operations to async, introduce a new event system, and restructure how Discord gateway events are processed.
Key Changes
- Refactored ConnectionState into a new
app.statemodule with async event handling - Introduced a new event emitter system with typed events in
discord/events/directory - Converted many synchronous methods to async (e.g.,
_get_guild,get_member,store_user) - Added generic type support for interactions and improved type safety across the codebase
Reviewed Changes
Copilot reviewed 82 out of 129 changed files in this pull request and generated 12 comments.
Show a summary per file
| File | Description |
|---|---|
| discord/state.py | Completely removed - migrated to app.state |
| discord/types/interactions.py | Added generic type support and more specific interaction type definitions |
| discord/types/channel.py | Introduced channel type hierarchy with base classes |
| discord/template.py | Converted to async factory pattern, updated state imports |
| discord/guild.py | Major async conversion of member/emoji/sticker operations |
| discord/message.py | Converted to async factory pattern, removed update handlers |
| discord/member.py | Added async factory method _from_data |
| discord/interactions.py | Added generic type support and async conversion |
| discord/gateway.py | Removed dispatch listeners, switched to event emitter |
| discord/events/*.py | New event system implementation files |
| discord/gears/*.py | New modular event handling system |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Migrate 18 remaining parse_x methods from ConnectionState to new Event subclasses following the established event migration pattern.
Created event files:
- audit_log.py: GuildAuditLogEntryCreate
- scheduled_event.py: GuildScheduledEvent{Create,Update,Delete,UserAdd,UserRemove}
- integration.py: GuildIntegrationsUpdate, Integration{Create,Update,Delete}
- stage_instance.py: StageInstance{Create,Update,Delete}
- voice.py: VoiceStateUpdate, VoiceServerUpdate, VoiceChannelStatusUpdate
- typing.py: TypingStart
- webhook.py: WebhooksUpdate
Changes to ConnectionState:
- Removed 18 parse_x methods
- Removed _get_typing_user helper (moved to typing.py)
- Cleaned up unused imports (AuditLogEntry, ScheduledEventStatus, _integration_factory, ScheduledEvent, StageInstance)
- Kept parse_guild_members_chunk (internal infrastructure)
Bug fixes:
- Fixed subscriber count decrement in GuildScheduledEventUserRemove
🤖 Generated with [Claude Code](https://claude.com/claude-code)
aea4e81 to
ef0c971
Compare
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Paillat <jeremiecotti@ik.me>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Paillat <jeremiecotti@ik.me>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Paillat <jeremiecotti@ik.me>
Co-authored-by: Emma Terzioglu <emreterzioglu49@gmail.com> Signed-off-by: Paillat <jeremiecotti@ik.me>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Paillat <jeremiecotti@ik.me>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Paillat <jeremiecotti@ik.me>
Signed-off-by: Vincent Jose <vincentbusiness55@gmail.com>
Removed duplicated GuildCreate, GuildJoin, and GuildAvailable event classes from gateway.py. Signed-off-by: Vincent Jose <vincentbusiness55@gmail.com>
VincentRPS
left a comment
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.
fix for old threads
Signed-off-by: Vincent Jose <vincentbusiness55@gmail.com>
Signed-off-by: Vincent Jose <vincentbusiness55@gmail.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Vincent Jose <vincentbusiness55@gmail.com>
There are a lot of things here, but they should be mostly covered in the changelog.