Skip to content

Commit

Permalink
Fix crash when "Role" property of a ReactionRole is empty
Browse files Browse the repository at this point in the history
  • Loading branch information
dwrss committed Jan 24, 2025
1 parent a3ab765 commit 37bded3
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions botto/storage/beta_testers/beta_testers_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -342,14 +342,20 @@ async def get_reaction_role(
self, server_id: str, msg_id: str, key: str
) -> Optional[ReactionRole]:
async with self.reaction_roles_lock:
if (
(server_config := self.reaction_roles_cache.get(str(server_id)))
and (msg_config := server_config.get(str(msg_id)))
and (config := msg_config.get(key))
):
return config
else:
return await self._fetch_reaction(server_id, msg_id, key)
try:
if (
(server_config := self.reaction_roles_cache.get(str(server_id)))
and (msg_config := server_config.get(str(msg_id)))
and (config := msg_config.get(key))
):
return config
else:
return await self._fetch_reaction(server_id, msg_id, key)
except KeyError as err:
log.error(
f"Failed to get reaction role for {server_id}/{msg_id}/{key} due to decoding error: {err}"
)
return None

@cachedmethod(lambda self: self.cache, key=partial(hashkey, "app"))
async def fetch_app(self, record_id: str) -> Optional[App]:
Expand Down

0 comments on commit 37bded3

Please sign in to comment.