Skip to content

Commit

Permalink
refact(event): reduce min delay between 2 ttt rewards
Browse files Browse the repository at this point in the history
  • Loading branch information
ZRunner committed Nov 30, 2024
1 parent 920b8c1 commit 913e9cf
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion modules/bot_events/bot_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ def __init__(self, bot: Axobot):

self._subcog: AbstractSubcog = ChristmasSubcog(
self.bot, self.current_event, self.current_event_data, self.current_event_id)
self.min_delay_between_ttt_wins = 30 # seconds between 2 tictactoe wins
self.last_ttt_win: dict[int, int] = defaultdict(int) # map of user_id -> timestamp

@property
Expand Down Expand Up @@ -140,7 +141,7 @@ async def on_tictactoe_win(self, interaction: discord.Interaction):
return
now = time.time()
# limit to 1 win per minute
if self.last_ttt_win[interaction.user.id] + 60 > now:
if self.last_ttt_win[interaction.user.id] + self.min_delay_between_ttt_wins > now:
return
self.last_ttt_win[interaction.user.id] = now
points = 7
Expand Down

0 comments on commit 913e9cf

Please sign in to comment.