Skip to content

Commit e2bf284

Browse files
authored
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.
2 parents aec75bd + 5ce6017 commit e2bf284

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

bot/exts/help_channels/_cog.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -125,14 +125,21 @@ 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` not being a `discord.Member` (see bot#1839)
130+
if not isinstance(message.author, discord.Member):
131+
log.warning(
132+
f"{message.author} ({message.author.id}) isn't a member. Not giving cooldown role or sending DM."
133+
)
134+
else:
135+
await self._handle_role_change(message.author, message.author.add_roles)
131136

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)
137+
try:
138+
await _message.dm_on_open(message)
139+
except Exception as e:
140+
log.warning("Error occurred while sending DM:", exc_info=e)
141+
142+
await _message.pin(message)
136143

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

0 commit comments

Comments
 (0)