Skip to content

Commit

Permalink
[Tournaments] Prevent instant cancel of check-in
Browse files Browse the repository at this point in the history
If the time before the scheduled end of check-in is too short, skip it
  • Loading branch information
laggron42 committed Sep 20, 2021
1 parent eb84914 commit 545e850
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
18 changes: 11 additions & 7 deletions tournaments/objects/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -2172,13 +2172,17 @@ async def start_check_in(self):
)
if self.checkin_stop:
duration = (self.checkin_stop - datetime.now(self.tz)).total_seconds()
duration //= 60 # number of minutes
if duration >= 10:
self.checkin_reminders.append((5, False))
if duration >= 20:
self.checkin_reminders.append((10, True))
if duration >= 40:
self.checkin_reminders.append((15, False))
if duration < 60:
# don't start the check-in only to end it within a minute
self.ignored_events.append("checkin_stop")
else:
duration //= 60 # number of minutes
if duration >= 10:
self.checkin_reminders.append((5, False))
if duration >= 20:
self.checkin_reminders.append((10, True))
if duration >= 40:
self.checkin_reminders.append((15, False))
await self.save()

async def call_check_in(self, with_dm: bool = False):
Expand Down
2 changes: 1 addition & 1 deletion tournaments/tournaments.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ def __init__(self, bot: Red):
except Exception as e:
log.error("Couldn't load dev env values.", exc_info=e)

__version__ = "1.1.12"
__version__ = "1.1.13"
__author__ = ["retke (El Laggron)", "Wonderfall", "Xyleff"]

@commands.command(hidden=True)
Expand Down

0 comments on commit 545e850

Please sign in to comment.