Skip to content

Commit ceda9dc

Browse files
committed
withdraw fixed
abort matches, when the tournament was deleted
1 parent 8d19b0a commit ceda9dc

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

plugins/tournament/commands.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ async def signup(self, interaction: discord.Interaction, tournament_id: int, squ
333333
@utils.squadron_role_check()
334334
async def withdraw(self, interaction: discord.Interaction, tournament_id: int, squadron_id: int):
335335
tournament = await self.get_tournament(tournament_id)
336-
if tournament['start'] > datetime.now(timezone.utc):
336+
if tournament['start'] <= datetime.now(timezone.utc):
337337
# noinspection PyUnresolvedReferences
338338
await interaction.response.send_message("You can not withdraw from an active tournament.", ephemeral=True)
339339
return

plugins/tournament/listener.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,8 @@ async def wait_until_choices_finished(self, server: Server):
194194
SELECT choices_{side}_ack FROM tm_matches WHERE match_id = %s
195195
""", (match_id,))
196196
row = await cursor.fetchone()
197+
if not row:
198+
raise ValueError("Match aborted!")
197199
finished[side] = row[0]
198200
if time == int(time_to_choose / 2):
199201
await self.inform_squadrons(
@@ -216,7 +218,11 @@ async def next_round(self, server: Server, match_id: int):
216218
await self.inform_squadrons(server, message=_("You can now use {} to chose your customizations!").format(
217219
(await utils.get_command(self.bot, group=self.plugin.match.name,
218220
name=self.plugin.customize.name)).mention))
219-
await self.wait_until_choices_finished(server)
221+
try:
222+
await self.wait_until_choices_finished(server)
223+
except ValueError:
224+
await self.audit(server, f"Match {match_id} aborted!")
225+
return
220226

221227
# Start the next round
222228
async with self.apool.connection() as conn:

0 commit comments

Comments
 (0)