Update transactions.py

Add freeze transaction cancellation notification
This commit is contained in:
Cal Corum 2023-03-11 13:58:14 -06:00
parent 600419c035
commit 5499452150

View File

@ -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