-
-
Notifications
You must be signed in to change notification settings - Fork 0
add: record nickname changes on Discord member update #36
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
🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
…tables 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
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 functionality to track and record nickname changes for Discord server members. When a Discord member's nickname is updated, the bot now captures and persists this change to the database, maintaining a historical record of nickname modifications.
- Adds a new
RecordNicknameChangeUsecasethat coordinates between messenger, user, and nickname changelog repositories - Implements Discord bot event handler
on_member_update()to detect and record nickname changes - Extends repository layer with
get_by_name()method for messenger lookup and adds dependency injection decorators
Reviewed changes
Copilot reviewed 22 out of 23 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
src/system/usecase/nickname/record_nickname_change.py |
Core usecase implementation that orchestrates nickname change recording |
src/system/usecase/nickname/dto.py |
Request/response DTOs for nickname change recording |
src/system/usecase/nickname/interface.py |
Abstract interface for the nickname change usecase |
src/system/ui/discord/bot.py |
Discord bot client with on_member_update event handler |
src/system/infrastructure/repository/sqlalchemy/crud/messenger.py |
Adds get_by_name method and @Inject decorator |
src/system/infrastructure/repository/sqlalchemy/crud/user.py |
Adds @Inject decorator for dependency injection |
src/system/infrastructure/repository/sqlalchemy/crud/nickname.py |
Adds @Inject decorator for dependency injection |
src/system/domain/interface/repository/messenger.py |
Adds abstract get_by_name method to interface |
src/system/di/module/usecase/nickname/module.py |
DI module binding for nickname usecase |
src/system/di/module/ui/discord/bot/module.py |
DI module binding for Discord bot |
src/system/di/container.py |
Registers new DI modules in the container |
migration/versions/87e1bd665ac8_create_initial_tables.py |
Creates messenger, user, and nickname_changelog tables |
migration/versions/b59d27038977_seed_discord_messenger.py |
Seeds the discord messenger record |
migration/env.py |
Enhances database URL conversion for asyncpg compatibility |
pyproject.toml |
Adds greenlet dependency |
src/system/usecase/nickname/test_*.py |
Comprehensive test coverage for usecase, DTOs, and interface |
src/system/ui/discord/test_bot.py |
Tests for Discord bot event handling and edge cases |
src/system/infrastructure/repository/sqlalchemy/crud/test_messenger.py |
Tests for get_by_name repository method |
src/system/di/module/*/test_*.py |
Tests for DI module bindings |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| sa.Column('after', sa.String(), nullable=False), | ||
| sa.Column('record_id', src.system.infrastructure.repository.sqlalchemy.type.ulid.ULIDColumn(length=26), nullable=False), | ||
| sa.Column('created_at', sa.DateTime(timezone=True), nullable=False), | ||
| sa.ForeignKeyConstraint(['user_record_id'], ['user.record_id'], ), |
Copilot
AI
Jan 4, 2026
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.
The foreign key constraint on the user_record_id column is missing explicit onupdate and ondelete actions. For consistency with the user table's foreign key constraint (which has onupdate='CASCADE', ondelete='CASCADE'), consider adding explicit cascade behavior here. This ensures nickname changelogs are handled appropriately when the parent user record is updated or deleted.
| sa.ForeignKeyConstraint(['user_record_id'], ['user.record_id'], ), | |
| sa.ForeignKeyConstraint(['user_record_id'], ['user.record_id'], onupdate='CASCADE', ondelete='CASCADE'), |
|
|
||
| Records nickname changes to the database. | ||
| """ | ||
| if before.nick == after.nick: |
Copilot
AI
Jan 4, 2026
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.
The equality check before.nick == after.nick will not properly detect changes when one value is None and the other is an empty string "". Since None is converted to "" in lines 49-50, this creates an edge case: if before.nick is None and after.nick is "", they are treated as the same when checked at line 43 but would be different after conversion. Consider normalizing both values before the comparison, such as: (before.nick or "") == (after.nick or "").
| if before.nick == after.nick: | |
| if (before.nick or "") == (after.nick or ""): |
1b5128b to
a8a03fd
Compare
This reverts commit c723c3c.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #36 +/- ##
==========================================
Coverage 100.00% 100.00%
==========================================
Files 47 53 +6
Lines 552 674 +122
==========================================
+ Hits 552 674 +122 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
No description provided.