fix: handle Forbidden when sending confirm-thread-creation DM (#3442)#3447
Conversation
Replaces the claim plugin by fourjr to my claim plugin due to being fundamentally broken as of the current time. It has been created few support issues already that were not successfull to use the plugin.
|
Hi, it looks like you are trying to merge this into the master branch. Can you change this into the development branch? Thanks for the PR tho! |
|
Hi! I've opened a PR for this issue and implemented a fix for the thread cleanup path when DM delivery fails. Please have a look when convenient. Feedback is welcome. Thanks! |
|
Thanks for pointing that out. I've updated the PR to target the Please let me know if there's anything else that needs to be adjusted. |
|
Thanks for the PR and update. |
sebkuip
left a comment
There was a problem hiding this comment.
Looks good! Thanks for the PR!
Since it's a small fix, we are looking into adding it to the V4.3.0 (beta/unstable for some time) update coming soon as well. We'll update your proposed changelog entry to fit correctly into the format we'll use then.
StephenDaDev
left a comment
There was a problem hiding this comment.
I think this looks good. Thanks for your contribution!
Deployed on test instance; tested working, bug has been resolved.
Added to changelog commit e8f141
|
Thanks for your contribution! |
|
Thank you again for your excellent first-time contribution! |
Closes #3442
Bug
When both
react to contactandconfirm_thread_creationare enabled, and the recipient has DMs disabled, the confirmation prompt sent fromThreadManager.create()can raise an uncaughtdiscord.Forbiddenexception.Because the exception occurs before
view.wait()is reached, the thread remains cached in a "not ready" state and never gets cleaned up. As a result, subsequent contact attempts may report that a thread already exists, and the stale state persists until the bot is restarted.Fix
Added a
try/except discord.Forbiddenblock around the confirmation promptsend()call.If the DM cannot be delivered, the code now:
This mirrors the existing cleanup logic already used for the deny and timeout paths below.
Testing
python -m py_compileblackThe repository does not currently include an automated test suite, so validation was performed through code review and manual tracing of the execution flow.