From 549945215021d69953aca91deada45b57f63ca43 Mon Sep 17 00:00:00 2001 From: Cal Corum Date: Sat, 11 Mar 2023 13:58:14 -0600 Subject: [PATCH] Update transactions.py Add freeze transaction cancellation notification --- cogs/transactions.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/cogs/transactions.py b/cogs/transactions.py index fbb4199..14415b1 100644 --- a/cogs/transactions.py +++ b/cogs/transactions.py @@ -387,6 +387,20 @@ class Transactions(commands.Cog): except Exception as e: await send_to_channel(self.bot, 'commissioners-office', f'Error running move:\n{move["moveid"]}') + async def notify_cancel(self, trans_data): + team = trans_data[1] + guild = self.bot.get_guild(int(os.environ.get('GUILD_ID'))) + + cancel_text = f'Your transaction containing {trans_data[0]["name"]} has been cancelled because some douche ' \ + f'with a worse team wanted him, too.' + gm_one = guild.get_member(team['gmid']) + await gm_one.send(cancel_text) + + gm_two = None + if team['gmid2'] is not None: + gm_two = guild.get_member(team['gmid2']) + await gm_two.send(cancel_text) + async def process_freeze_moves(self, current): all_moves = await get_transactions( season=current['season'], @@ -437,6 +451,7 @@ class Transactions(commands.Cog): logging.info(f'First: {first} / x: {x}\n\n') if not first: await patch_transaction(move_id=x[3], cancelled=True, frozen=False) + await self.notify_cancel(x) else: first = False