aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Matteo Bertucci <[email protected]>2021-10-19 10:33:33 +0200
committerGravatar GitHub <[email protected]>2021-10-19 10:33:33 +0200
commite2bf284583df31512b483643abb4bdee4bb67918 (patch)
tree61b72738611830cc67c0c7aa0eb455acaa11e633
parentMerge pull request #1890 from python-discord/Migrate-to-socket_event_type (diff)
parentMerge branch 'main' into fix-sentry-BOT-1N6 (diff)
Merge pull request #1845 from python-discord/fix-sentry-BOT-1N6
Handle edge case of `message.author` being a `discord.User` when claiming a help channel.
-rw-r--r--bot/exts/help_channels/_cog.py19
1 files changed, 13 insertions, 6 deletions
diff --git a/bot/exts/help_channels/_cog.py b/bot/exts/help_channels/_cog.py
index 498305b47..3c6cf7f26 100644
--- a/bot/exts/help_channels/_cog.py
+++ b/bot/exts/help_channels/_cog.py
@@ -125,14 +125,21 @@ 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` not being a `discord.Member` (see bot#1839)
+ if not isinstance(message.author, discord.Member):
+ log.warning(
+ f"{message.author} ({message.author.id}) isn't a member. Not giving cooldown role 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)