Skip to content

Commit 29754d6

Browse files
committed
fix: race condition & console errors
1 parent 2c67e50 commit 29754d6

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

bot/exts/fun/adventure.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,8 @@ def _get_game_info(self) -> GameInfo:
173173

174174
async def notify_timeout(self) -> None:
175175
"""Notifies the user that the session has timed out."""
176+
if self.message is None:
177+
return
176178
await self.message.edit(content="⏰ You took too long to make a choice! The game has ended. :(")
177179

178180
async def timeout(self) -> None:
@@ -237,6 +239,10 @@ async def on_reaction_add(self, reaction: Reaction, user: User) -> None:
237239
# Run relevant action method
238240
all_emojis = [option["emoji"] for option in self.all_options]
239241

242+
# We technically don't need this, but it's here to mitigate race conditions.
243+
if emoji not in all_emojis:
244+
return
245+
240246
await self.pick_option(all_emojis.index(emoji))
241247

242248

0 commit comments

Comments
 (0)