Skip to content

Commit e082596

Browse files
committed
Add handling for when message.author is a discord.User
NB: Will give a sentry warning when this happens.
1 parent 748fcf1 commit e082596

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

bot/exts/help_channels/_cog.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -125,14 +125,19 @@ async def claim_channel(self, message: discord.Message) -> None:
125125
"""
126126
log.info(f"Channel #{message.channel} was claimed by `{message.author.id}`.")
127127
await self.move_to_in_use(message.channel)
128-
await self._handle_role_change(message.author, message.author.add_roles)
129128

130-
await _message.pin(message)
129+
# Handle odd edge case of `message.author` being a `discord.User` (see bot#1839)
130+
if isinstance(message.author, discord.User):
131+
log.warning("`message.author` is a `discord.User` so not handling role change or sending DM.")
132+
else:
133+
await self._handle_role_change(message.author, message.author.add_roles)
131134

132-
try:
133-
await _message.dm_on_open(message)
134-
except Exception as e:
135-
log.warning("Error occurred while sending DM:", exc_info=e)
135+
try:
136+
await _message.dm_on_open(message)
137+
except Exception as e:
138+
log.warning("Error occurred while sending DM:", exc_info=e)
139+
140+
await _message.pin(message)
136141

137142
# Add user with channel for dormant check.
138143
await _caches.claimants.set(message.channel.id, message.author.id)

0 commit comments

Comments
 (0)