diff --git a/CHANGELOG.md b/CHANGELOG.md index 2b7a7e28ea..f1c8d12311 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,11 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). This project mostly adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html); however, insignificant breaking changes do not guarantee a major version bump, see the reasoning [here](https://github.com/modmail-dev/modmail/issues/319). If you're a plugin developer, note the "BREAKING" section. +# Unreleased + +### Fixed +* Confirm thread creation (react to contact) no longer leaves a thread stuck in a "not ready" cache state when the recipient has DMs disabled. The bot now catches `discord.Forbidden` when sending the confirmation prompt, cancels the thread, and clears the cache entry immediately instead of requiring a bot restart. (#3442) + # v4.2.1 ### Added diff --git a/core/thread.py b/core/thread.py index e0aea1338a..b5c9ad26c4 100644 --- a/core/thread.py +++ b/core/thread.py @@ -2635,14 +2635,27 @@ async def create( self.bot.config["confirm_thread_creation_deny"], ) ) - confirm = await destination.send( - embed=discord.Embed( - title=self.bot.config["confirm_thread_creation_title"], - description=self.bot.config["confirm_thread_response"], - color=self.bot.main_color, - ), - view=view, - ) + try: + confirm = await destination.send( + embed=discord.Embed( + title=self.bot.config["confirm_thread_creation_title"], + description=self.bot.config["confirm_thread_response"], + color=self.bot.main_color, + ), + view=view, + ) + except discord.Forbidden: + # Recipient has DMs disabled (or otherwise unreachable). Without this, + # the thread would stay stuck in cache in a "not ready" state until a + # bot restart, since view.wait() below would never run. + logger.warning( + "Could not send confirm-thread-creation message to %s, DMs are likely disabled.", + recipient, + ) + thread.cancelled = True + del self.cache[recipient.id] + return thread + await view.wait() if view.value is None: thread.cancelled = True diff --git a/plugins/registry.json b/plugins/registry.json index 506df880bd..ee6b17b792 100644 --- a/plugins/registry.json +++ b/plugins/registry.json @@ -63,13 +63,13 @@ "thumbnail_url": "https://i.imgur.com/Mo60CdK.png" }, "claim": { - "repository": "fourjr/modmail-plugins", - "branch": "v4", - "description": "Allows supporters to claim thread by sending ?claim in the thread channel", - "bot_version": "4.0.0", + "repository": "martinbndr/kyb3r-modmail-plugins", + "branch": "master", + "description": "Adds claim functionality to your modmail bot.", + "bot_version": "4.2.1", "title": "Claim Thread", - "icon_url": "https://i.imgur.com/Mo60CdK.png", - "thumbnail_url": "https://i.imgur.com/Mo60CdK.png" + "icon_url": "https://i.ibb.co/dsPjgKLj/87249157.png", + "thumbnail_url": "https://i.ibb.co/dsPjgKLj/87249157.png" }, "emote-manager": { "repository": "fourjr/modmail-plugins", @@ -125,4 +125,4 @@ "icon_url": "https://i.imgur.com/A1auJ95.png", "thumbnail_url": "https://i.imgur.com/A1auJ95.png" } -} +} \ No newline at end of file