-
-
Notifications
You must be signed in to change notification settings - Fork 40
[FIX] fixed bug per issue 678. This allows the bot to retrieve the co… #679
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
…rrect moderator from a single case view instead of whoever runs the command returning as the moderator.
Reviewer's Guide by SourceryThis PR fixes a bug where the incorrect moderator was being displayed in the single case view. The fix involves retrieving the moderator from the Sequence diagram for case view moderator retrievalsequenceDiagram
participant User as Discord User
participant Bot as Tux Bot
participant DB as Case Database
User->>Bot: /case view case:5
Bot->>DB: Get case details
DB-->>Bot: Return case with moderator_id
Bot->>Bot: Convert moderator_id to Member
Bot-->>User: Display case with correct moderator
State diagram for case view moderator resolutionstateDiagram-v2
[*] --> CommandReceived
CommandReceived --> FetchCase: /case view
FetchCase --> ModeratorResolution
ModeratorResolution --> DisplayCase: Convert moderator_id to Member
ModeratorResolution --> ErrorState: Conversion failed
DisplayCase --> [*]
ErrorState --> [*]
File-Level Changes
Assessment against linked issues
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
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.
Hey @scottc943 - I've reviewed your changes and they look great!
Here's what I looked at during the review
- 🟡 General issues: 1 issue found
- 🟢 Security: all looks good
- 🟢 Testing: all looks good
- 🟢 Complexity: all looks good
- 🟢 Documentation: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
tux/cogs/moderation/cases.py
Outdated
| moderator = await commands.MemberConverter().convert(ctx, str(case.case_moderator_id)) | ||
|
|
||
| if isinstance(moderator, discord.Member): |
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.
suggestion: Add error handling for MemberConverter().convert() to handle cases where the moderator is no longer in the server
The conversion could fail if the moderator has left the server. Consider adding a try-except block to handle MemberNotFound and other potential exceptions, falling back to using the ID or a placeholder value.
| moderator = await commands.MemberConverter().convert(ctx, str(case.case_moderator_id)) | |
| if isinstance(moderator, discord.Member): | |
| try: | |
| moderator = await commands.MemberConverter().convert(ctx, str(case.case_moderator_id)) | |
| except (commands.MemberNotFound, commands.errors.MemberNotFound): | |
| # Create a placeholder value when moderator is no longer in server | |
| moderator = f"Unknown Moderator (ID: {case.case_moderator_id})" | |
| if isinstance(moderator, (discord.Member, str)): |
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.
Looks good to me (Guess not, silly me)
electron271
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.
please fix ci
Shouldn't be approved. Is in fact not functional.
…verter Refactor the code to handle cases where the moderator is not found as a member by using UserConverter as a fallback. This ensures that the moderator information is correctly retrieved even if they are not a current member of the server.
|
fixed ci issues |
…rrect moderator from a single case view instead of whoever runs the command returning as the moderator.
Description
Fixes #678
Allows us to view the correct moderator within the single case view now. For example when we run /case view case:5 it would show the correct moderator that took that case instead of the moderator that ran the command.
Guidelines
My code follows the style guidelines of this project (formatted with Ruff)
I have performed a self-review of my own code
I have commented my code, particularly in hard-to-understand areas
I have made corresponding changes to the documentation if needed
My changes generate no new warnings
I have tested this change
Any dependent changes have been merged and published in downstream modules
I have added all appropriate labels to this PR
[ X] I have followed all of these guidelines.
How Has This Been Tested? (if applicable)
I have tested my code via running the dev tux instance on the development server and testing that the moderator returns correctly.
Screenshots (if applicable)
N/A
Additional Information
N/A
Summary by Sourcery
Bug Fixes:
/case viewwould show the user who ran the command as the moderator instead of the moderator who originally took the case.