Refine JHO tag-notification cleanup to avoid replacement messages#102
Conversation
Agent-Logs-Url: https://github.com/r-hensley/Rai/sessions/1b16eacd-42df-49ec-973c-dd8fc78c4295 Co-authored-by: r-hensley <30587035+r-hensley@users.noreply.github.com>
Agent-Logs-Url: https://github.com/r-hensley/Rai/sessions/1b16eacd-42df-49ec-973c-dd8fc78c4295 Co-authored-by: r-hensley <30587035+r-hensley@users.noreply.github.com>
Agent-Logs-Url: https://github.com/r-hensley/Rai/sessions/de389e48-3846-4927-9da1-3591a421d6a7 Co-authored-by: r-hensley <30587035+r-hensley@users.noreply.github.com>
|
@copilot I feel like the function you created is pretty simple and then the test is basically just testing basic python functionality and is pretty easy to see from the code directly that the code is fine. How necessary is a separated, helper function, and a dedicated test? |
Agent-Logs-Url: https://github.com/r-hensley/Rai/sessions/064ee40f-9108-4140-b17e-ab62352677cc Co-authored-by: r-hensley <30587035+r-hensley@users.noreply.github.com>
I agreed and simplified it in |
There was a problem hiding this comment.
Pull request overview
Adjusts the JHO “untagged user” follow-up cleanup in cogs/events.py to avoid posting replacement notifications when the original alert can’t be edited, preferring in-place edits only when the alert is still the latest channel message and otherwise deleting the temporary notification.
Changes:
- Only attempts to edit the original notification if it is still the channel’s
last_message_id. - If the edit fails with Discord error code
30046, deletes the notification instead of sending a replacement. - Deletes the original notification when newer channel activity exists (with best-effort delete error handling).
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
The JHO untagged-user follow-up was creating a replacement message when the original alert could no longer be edited. This changes the cleanup path so the temporary notification is either edited in place or deleted, without emitting a second notification.
Notification cleanup behavior
Old-message fallback
30046, delete the notification instead of sending a replacement message.HTTPExceptioncases.The cleanup logic is implemented directly at the call site in the event flow rather than through a separate helper.