aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Izan <[email protected]>2021-09-24 16:17:36 +0100
committerGravatar Izan <[email protected]>2021-09-24 16:17:36 +0100
commite082596ff49b22dbb47d3bf8aa75ae98e2264620 (patch)
treea5b8f9766f204404a0415e6aa21498c79288c97a
parentMerge pull request #1843 from python-discord/fix-paste-site-inconsistency (diff)
Add handling for when `message.author` is a `discord.User`
NB: Will give a sentry warning when this happens.
-rw-r--r--bot/exts/help_channels/_cog.py17
1 files changed, 11 insertions, 6 deletions
diff --git a/bot/exts/help_channels/_cog.py b/bot/exts/help_channels/_cog.py
index cfc9cf477..ecffc59fd 100644
--- a/bot/exts/help_channels/_cog.py
+++ b/bot/exts/help_channels/_cog.py
@@ -125,14 +125,19 @@ class HelpChannels(commands.Cog):
"""
log.info(f"Channel #{message.channel} was claimed by `{message.author.id}`.")
await self.move_to_in_use(message.channel)
- await self._handle_role_change(message.author, message.author.add_roles)
- await _message.pin(message)
+ # Handle odd edge case of `message.author` being a `discord.User` (see bot#1839)
+ if isinstance(message.author, discord.User):
+ log.warning("`message.author` is a `discord.User` so not handling role change or sending DM.")
+ else:
+ await self._handle_role_change(message.author, message.author.add_roles)
- try:
- await _message.dm_on_open(message)
- except Exception as e:
- log.warning("Error occurred while sending DM:", exc_info=e)
+ try:
+ await _message.dm_on_open(message)
+ except Exception as e:
+ log.warning("Error occurred while sending DM:", exc_info=e)
+
+ await _message.pin(message)
# Add user with channel for dormant check.
await _caches.claimants.set(message.channel.id, message.author.id)