Update calls for /current to new Current class
This commit is contained in:
parent
50d0f89c1d
commit
afba7ce456
278
cogs/admins.py
278
cogs/admins.py
@ -1,5 +1,7 @@
|
|||||||
import copy
|
import copy
|
||||||
|
|
||||||
|
from api_calls.current import get_current
|
||||||
|
from exceptions import ApiException, log_exception
|
||||||
from helpers import *
|
from helpers import *
|
||||||
from db_calls import db_get, db_patch, db_post, put_player, get_player_by_name, patch_draftpick
|
from db_calls import db_get, db_patch, db_post, put_player, get_player_by_name, patch_draftpick
|
||||||
|
|
||||||
@ -20,13 +22,9 @@ class Admins(commands.Cog):
|
|||||||
@commands.command(name='current', help='Current db info')
|
@commands.command(name='current', help='Current db info')
|
||||||
@commands.is_owner()
|
@commands.is_owner()
|
||||||
async def current_command(self, ctx):
|
async def current_command(self, ctx):
|
||||||
current = await db_get('current')
|
current = await get_current()
|
||||||
current_string = ''
|
|
||||||
|
|
||||||
for x in current:
|
await ctx.send(f'{current}')
|
||||||
current_string += f'{x}: {current[x]}\n'
|
|
||||||
|
|
||||||
await ctx.send(current_string)
|
|
||||||
|
|
||||||
@commands.command(name='blast', help='Megaphone')
|
@commands.command(name='blast', help='Megaphone')
|
||||||
@commands.is_owner()
|
@commands.is_owner()
|
||||||
@ -35,12 +33,11 @@ class Admins(commands.Cog):
|
|||||||
await ctx.send(random_conf_gif())
|
await ctx.send(random_conf_gif())
|
||||||
|
|
||||||
@app_commands.command(name='blast', description='Send a message')
|
@app_commands.command(name='blast', description='Send a message')
|
||||||
@app_commands.guilds(discord.Object(id=os.environ.get('GUILD_ID')))
|
@app_commands.guilds(discord.Object(id=os.environ.get('GUILD_ID', 0)))
|
||||||
@app_commands.checks.has_any_role('Da Commish')
|
@app_commands.checks.has_any_role('Da Commish')
|
||||||
async def blast_slash(
|
async def blast_slash(
|
||||||
self, interaction: discord.Interaction, channel: discord.TextChannel, msg_content: str = None,
|
self, interaction: discord.Interaction, channel: discord.TextChannel, msg_content: Optional[str] = None, embed_title: Optional[str] = None, embed_field_name: Optional[str] = None, image_url: Optional[str] = None, color_hex: Optional[str] = None):
|
||||||
embed_title: str = None, embed_field_name: str = None, image_url: str = None, color_hex: str = None):
|
current = await get_current()
|
||||||
current = await db_get('current')
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
embed = None
|
embed = None
|
||||||
@ -49,7 +46,7 @@ class Admins(commands.Cog):
|
|||||||
title=embed_title,
|
title=embed_title,
|
||||||
color=int(color_hex, 16) if color_hex is not None else int('0xa5fffc', 16)
|
color=int(color_hex, 16) if color_hex is not None else int('0xa5fffc', 16)
|
||||||
)
|
)
|
||||||
embed.set_footer(text=f'SBa Season {current["season"]}', icon_url=LOGO)
|
embed.set_footer(text=f'SBa Season {current.season}', icon_url=LOGO)
|
||||||
embed.set_image(url=image_url)
|
embed.set_image(url=image_url)
|
||||||
if embed_field_name:
|
if embed_field_name:
|
||||||
embed.add_field(
|
embed.add_field(
|
||||||
@ -95,7 +92,7 @@ class Admins(commands.Cog):
|
|||||||
|
|
||||||
# Try to get card
|
# Try to get card
|
||||||
|
|
||||||
current = await db_get('current')
|
current = await get_current()
|
||||||
try:
|
try:
|
||||||
sheets = pygsheets.authorize(service_file='storage/major-domo-service-creds.json')
|
sheets = pygsheets.authorize(service_file='storage/major-domo-service-creds.json')
|
||||||
scorecard = sheets.open_by_url(sheet_url)
|
scorecard = sheets.open_by_url(sheet_url)
|
||||||
@ -109,26 +106,31 @@ class Admins(commands.Cog):
|
|||||||
g_data = setup_tab.get_values('M2', 'R3')
|
g_data = setup_tab.get_values('M2', 'R3')
|
||||||
at_abbrev = g_data[0][0]
|
at_abbrev = g_data[0][0]
|
||||||
ht_abbrev = g_data[1][0]
|
ht_abbrev = g_data[1][0]
|
||||||
away_team = await get_team_by_abbrev(at_abbrev, current['season'])
|
away_team = await get_team_by_abbrev(at_abbrev, current.season)
|
||||||
home_team = await get_team_by_abbrev(ht_abbrev, current['season'])
|
home_team = await get_team_by_abbrev(ht_abbrev, current.season)
|
||||||
week_num = g_data[0][5]
|
week_num = g_data[0][5]
|
||||||
game_num = g_data[1][5]
|
game_num = g_data[1][5]
|
||||||
|
|
||||||
|
if not away_team:
|
||||||
|
log_exception(ApiException(f'Season {current.season} {at_abbrev} was not found'))
|
||||||
|
if not home_team:
|
||||||
|
log_exception(ApiException(f'Season {current.season} {ht_abbrev} was not found'))
|
||||||
|
|
||||||
logger.info(f'gdata: {g_data}\nweek/game: {week_num}/{game_num}')
|
logger.info(f'gdata: {g_data}\nweek/game: {week_num}/{game_num}')
|
||||||
|
|
||||||
dupe_g_query = await db_get('games', params=[
|
dupe_g_query = await db_get('games', params=[
|
||||||
('season', current['season']), ('week_start', week_num), ('week_end', week_num),
|
('season', current.season), ('week_start', week_num), ('week_end', week_num),
|
||||||
('away_team_id', away_team['id']), ('home_team_id', home_team['id']), ('game_num', game_num)
|
('away_team_id', away_team['id']), ('home_team_id', home_team['id']), ('game_num', game_num)
|
||||||
])
|
])
|
||||||
if dupe_g_query['count'] != 0:
|
if dupe_g_query and dupe_g_query.get('count'):
|
||||||
await ctx.send(f'This game has already been played! Maybe one day I can automatically wipe it for you.')
|
await ctx.send(f'This game has already been played! Maybe one day I can automatically wipe it for you.')
|
||||||
return
|
return
|
||||||
|
|
||||||
g_query = await db_get('games', params=[
|
g_query = await db_get('games', params=[
|
||||||
('season', current['season']), ('week_start', week_num), ('week_end', week_num),
|
('season', current.season), ('week_start', week_num), ('week_end', week_num),
|
||||||
('away_team_id', away_team['id']), ('home_team_id', home_team['id'])
|
('away_team_id', away_team['id']), ('home_team_id', home_team['id'])
|
||||||
])
|
])
|
||||||
if g_query['count'] == 0:
|
if not g_query or not g_query.get('count'):
|
||||||
await ctx.send(
|
await ctx.send(
|
||||||
f'I don\'t see any games between {away_team["abbrev"]} and {home_team["abbrev"]} in week {week_num}.'
|
f'I don\'t see any games between {away_team["abbrev"]} and {home_team["abbrev"]} in week {week_num}.'
|
||||||
)
|
)
|
||||||
@ -175,7 +177,7 @@ class Admins(commands.Cog):
|
|||||||
# await ctx.send('Collecting transactions...')
|
# await ctx.send('Collecting transactions...')
|
||||||
# all_vals = []
|
# all_vals = []
|
||||||
# all_moves = await get_transactions(
|
# all_moves = await get_transactions(
|
||||||
# season=current['season'],
|
# season=current.season,
|
||||||
# timeout=30
|
# timeout=30
|
||||||
# )
|
# )
|
||||||
# await ctx.send(f'Processing transactions ({len(all_moves)} found)...')
|
# await ctx.send(f'Processing transactions ({len(all_moves)} found)...')
|
||||||
@ -248,153 +250,153 @@ class Admins(commands.Cog):
|
|||||||
@commands.command(name='setdemweek', help='Set player\'s demotion week')
|
@commands.command(name='setdemweek', help='Set player\'s demotion week')
|
||||||
@commands.is_owner()
|
@commands.is_owner()
|
||||||
async def set_dem_week_command(self, ctx, week_num, *, player_name):
|
async def set_dem_week_command(self, ctx, week_num, *, player_name):
|
||||||
current = await db_get('current')
|
current = await get_current()
|
||||||
player_cog = self.bot.get_cog('Players')
|
player_cog = self.bot.get_cog('Players')
|
||||||
player_name = await fuzzy_player_search(ctx, ctx.channel, self.bot, player_name, player_cog.player_list.keys())
|
player_name = await fuzzy_player_search(ctx, ctx.channel, self.bot, player_name, player_cog.player_list.keys())
|
||||||
# player = await get_one_player(player_name)
|
# player = await get_one_player(player_name)
|
||||||
p_query = await db_get('players', params=[('season', current['season']), ('name', player_name)])
|
p_query = await db_get('players', params=[('season', current.season), ('name', player_name)])
|
||||||
player = p_query['players'][0]
|
player = p_query['players'][0]
|
||||||
player['demotion_week'] = week_num
|
player['demotion_week'] = week_num
|
||||||
|
|
||||||
await put_player(player)
|
await put_player(player)
|
||||||
await ctx.send(random_conf_gif())
|
await ctx.send(random_conf_gif())
|
||||||
|
|
||||||
@app_commands.command(name='set-keepers', description='Post final keepers')
|
# @app_commands.command(name='set-keepers', description='Post final keepers')
|
||||||
@app_commands.guilds(discord.Object(id=os.environ.get('GUILD_ID')))
|
# @app_commands.guilds(discord.Object(id=os.environ.get('GUILD_ID')))
|
||||||
# @app_commands.checks.has_any_role('Da Commish')
|
# # @app_commands.checks.has_any_role('Da Commish')
|
||||||
async def keeper_slash(
|
# async def keeper_slash(
|
||||||
self, interaction: discord.Interaction, keeper_1_name: str,
|
# self, interaction: discord.Interaction, keeper_1_name: str,
|
||||||
keeper_2_name: Optional[str] = None, keeper_3_name: Optional[str] = None,
|
# keeper_2_name: Optional[str] = None, keeper_3_name: Optional[str] = None,
|
||||||
keeper_4_name: Optional[str] = None, keeper_5_name: Optional[str] = None,
|
# keeper_4_name: Optional[str] = None, keeper_5_name: Optional[str] = None,
|
||||||
keeper_6_name: Optional[str] = None, keeper_7_name: Optional[str] = None,
|
# keeper_6_name: Optional[str] = None, keeper_7_name: Optional[str] = None,
|
||||||
team_abbrev: Optional[str] = None):
|
# team_abbrev: Optional[str] = None):
|
||||||
if interaction.channel.name == 'season-9-chat':
|
# if interaction.channel.name == 'season-9-chat':
|
||||||
await interaction.response.send_message(f'everybody laugh at {interaction.user.display_name} for trying '
|
# await interaction.response.send_message(f'everybody laugh at {interaction.user.display_name} for trying '
|
||||||
f'to run keepers here')
|
# f'to run keepers here')
|
||||||
return
|
# return
|
||||||
|
|
||||||
await interaction.response.defer()
|
# await interaction.response.defer()
|
||||||
current = await db_get('current')
|
# current = await get_current()
|
||||||
|
|
||||||
if current['week'] != -1:
|
# if current.week != -1:
|
||||||
logger.info('entering the thot check')
|
# logger.info('entering the thot check')
|
||||||
await interaction.edit_original_response(content='https://c.tenor.com/FCAj8xDvEHwAAAAC/be-gone-thot.gif')
|
# await interaction.edit_original_response(content='https://c.tenor.com/FCAj8xDvEHwAAAAC/be-gone-thot.gif')
|
||||||
player_role = get_role(interaction, SBA_PLAYERS_ROLE_NAME)
|
# player_role = get_role(interaction, SBA_PLAYERS_ROLE_NAME)
|
||||||
logger.info('beginning sleep')
|
# logger.info('beginning sleep')
|
||||||
await asyncio.sleep(random.randint(3, 7))
|
# await asyncio.sleep(random.randint(3, 7))
|
||||||
|
|
||||||
try:
|
# try:
|
||||||
await interaction.user.remove_roles(player_role)
|
# await interaction.user.remove_roles(player_role)
|
||||||
except Exception as e:
|
# except Exception as e:
|
||||||
logger.error(f'unable to remove {player_role} role from {interaction.user}: {e}')
|
# logger.error(f'unable to remove {player_role} role from {interaction.user}: {e}')
|
||||||
|
|
||||||
return
|
# return
|
||||||
|
|
||||||
owner_team = await get_team_by_owner(current['season'], interaction.user.id)
|
# owner_team = await get_team_by_owner(current.season, interaction.user.id)
|
||||||
|
|
||||||
if team_abbrev is not None and interaction.user.id != 258104532423147520 and \
|
# if team_abbrev is not None and interaction.user.id != 258104532423147520 and \
|
||||||
team_abbrev != owner_team['abbrev']:
|
# team_abbrev != owner_team['abbrev']:
|
||||||
await interaction.edit_original_response(
|
# await interaction.edit_original_response(
|
||||||
content='Omg you are so quirky and random trying to set another team\'s keepers.')
|
# content='Omg you are so quirky and random trying to set another team\'s keepers.')
|
||||||
return
|
# return
|
||||||
else:
|
# else:
|
||||||
team_abbrev = owner_team['abbrev']
|
# team_abbrev = owner_team['abbrev']
|
||||||
this_team = await get_team_by_abbrev(team_abbrev, current['season'])
|
# this_team = await get_team_by_abbrev(team_abbrev, current.season)
|
||||||
|
|
||||||
if this_team is None:
|
# if this_team is None:
|
||||||
await interaction.edit_original_response(content=f'Team {team_abbrev} not found')
|
# await interaction.edit_original_response(content=f'Team {team_abbrev} not found')
|
||||||
return
|
# return
|
||||||
|
|
||||||
def get_pos_nickname(position):
|
# def get_pos_nickname(position):
|
||||||
if 'B' in position:
|
# if 'B' in position:
|
||||||
return 'IF'
|
# return 'IF'
|
||||||
elif position == 'SS':
|
# elif position == 'SS':
|
||||||
return 'IF'
|
# return 'IF'
|
||||||
elif 'F' in position:
|
# elif 'F' in position:
|
||||||
return 'OF'
|
# return 'OF'
|
||||||
elif 'P' in position:
|
# elif 'P' in position:
|
||||||
return 'P'
|
# return 'P'
|
||||||
elif position == 'C':
|
# elif position == 'C':
|
||||||
return 'C'
|
# return 'C'
|
||||||
else:
|
# else:
|
||||||
return 'DH'
|
# return 'DH'
|
||||||
|
|
||||||
k_query = await db_get('keepers', params=[('team_id', this_team['id'])])
|
# k_query = await db_get('keepers', params=[('team_id', this_team['id'])])
|
||||||
if k_query['count'] > 0:
|
# if k_query['count'] > 0:
|
||||||
await interaction.edit_original_response(content=random_gif('please go away'))
|
# await interaction.edit_original_response(content=random_gif('please go away'))
|
||||||
await interaction.channel.send('You\'ve already posted your keepers. I can\'t help you.')
|
# await interaction.channel.send('You\'ve already posted your keepers. I can\'t help you.')
|
||||||
return
|
# return
|
||||||
|
|
||||||
k_list = []
|
# k_list = []
|
||||||
k_ids = []
|
# k_ids = []
|
||||||
keeper_string = ''
|
# keeper_string = ''
|
||||||
keeper_swar = 0.0
|
# keeper_swar = 0.0
|
||||||
p_query = await db_get('draftpicks', params=[
|
# p_query = await db_get('draftpicks', params=[
|
||||||
('season', current['season']), ('owner_team_id', this_team['id']), ('pick_round_start', 1),
|
# ('season', current.season), ('owner_team_id', this_team['id']), ('pick_round_start', 1),
|
||||||
('pick_round_end', 8), ('sort', 'order-asc'), ('short_output', False)
|
# ('pick_round_end', 8), ('sort', 'order-asc'), ('short_output', False)
|
||||||
])
|
# ])
|
||||||
picks = p_query['picks']
|
# picks = p_query['picks']
|
||||||
count = 0
|
# count = 0
|
||||||
|
|
||||||
for x in [keeper_1_name, keeper_2_name, keeper_3_name, keeper_4_name, keeper_5_name, keeper_6_name,
|
# for x in [keeper_1_name, keeper_2_name, keeper_3_name, keeper_4_name, keeper_5_name, keeper_6_name,
|
||||||
keeper_7_name]:
|
# keeper_7_name]:
|
||||||
if x is not None:
|
# if x is not None:
|
||||||
this_player = await get_player_by_name(current['season'], x)
|
# this_player = await get_player_by_name(current.season, x)
|
||||||
if this_player is None:
|
# if this_player is None:
|
||||||
await interaction.edit_original_response(
|
# await interaction.edit_original_response(
|
||||||
content='No fuzzy search here can help you. Ya gotta get it right.')
|
# content='No fuzzy search here can help you. Ya gotta get it right.')
|
||||||
return
|
# return
|
||||||
# logger.info(f'keeper_slash - this_player: {this_player}')
|
# # logger.info(f'keeper_slash - this_player: {this_player}')
|
||||||
if this_player['team']['id'] != this_team['id']:
|
# if this_player['team']['id'] != this_team['id']:
|
||||||
await interaction.edit_original_response(
|
# await interaction.edit_original_response(
|
||||||
content=f'Lol {this_player["name"]}. Oh my god be more I hate you.')
|
# content=f'Lol {this_player["name"]}. Oh my god be more I hate you.')
|
||||||
return
|
# return
|
||||||
|
|
||||||
k_ids.append(this_player['id'])
|
# k_ids.append(this_player['id'])
|
||||||
k_list.append({
|
# k_list.append({
|
||||||
'season': current['season'],
|
# 'season': current.season,
|
||||||
'team_id': this_team['id'],
|
# 'team_id': this_team['id'],
|
||||||
'player_id': this_player['id']
|
# 'player_id': this_player['id']
|
||||||
})
|
# })
|
||||||
# logger.info(f'keeper_slash - updated k_list')
|
# # logger.info(f'keeper_slash - updated k_list')
|
||||||
|
|
||||||
keeper_string += f'{get_pos_nickname(this_player["pos_1"])} - ' \
|
# keeper_string += f'{get_pos_nickname(this_player["pos_1"])} - ' \
|
||||||
f'{this_player["name"]} ({this_player["wara"]:.2f})\n'
|
# f'{this_player["name"]} ({this_player["wara"]:.2f})\n'
|
||||||
keeper_swar += this_player['wara']
|
# keeper_swar += this_player['wara']
|
||||||
# logger.info(f'keeper_slash - updated keeper_swar')
|
# # logger.info(f'keeper_slash - updated keeper_swar')
|
||||||
|
|
||||||
this_pick = picks[count]
|
# this_pick = picks[count]
|
||||||
this_pick['player'] = this_player
|
# this_pick['player'] = this_player
|
||||||
# logger.info(f'keeper_slash - patching draftpick')
|
# # logger.info(f'keeper_slash - patching draftpick')
|
||||||
await patch_draftpick(this_pick)
|
# await patch_draftpick(this_pick)
|
||||||
count += 1
|
# count += 1
|
||||||
|
|
||||||
resp = await db_post('keepers', payload={
|
# resp = await db_post('keepers', payload={
|
||||||
'count': len(k_list),
|
# 'count': len(k_list),
|
||||||
'keepers': k_list
|
# 'keepers': k_list
|
||||||
})
|
# })
|
||||||
output_string = f'{resp}\nMoving remaining players to FA...'
|
# output_string = f'{resp}\nMoving remaining players to FA...'
|
||||||
await interaction.edit_original_response(content=output_string)
|
# await interaction.edit_original_response(content=output_string)
|
||||||
|
|
||||||
fa_team = await get_team_by_abbrev('FA', current['season'])
|
# fa_team = await get_team_by_abbrev('FA', current.season)
|
||||||
p_query = await db_get('players', params=[
|
# p_query = await db_get('players', params=[
|
||||||
('season', current['season']), ('team_id', this_team['id'])
|
# ('season', current.season), ('team_id', this_team['id'])
|
||||||
])
|
# ])
|
||||||
for x in p_query['players']:
|
# for x in p_query['players']:
|
||||||
if x['id'] not in k_ids:
|
# if x['id'] not in k_ids:
|
||||||
x['team'] = fa_team
|
# x['team'] = fa_team
|
||||||
await put_player(x)
|
# await put_player(x)
|
||||||
|
|
||||||
output_string += f'\nNon-kept players have been booted\nBuilding embeds...'
|
# output_string += f'\nNon-kept players have been booted\nBuilding embeds...'
|
||||||
await interaction.edit_original_response(content=output_string)
|
# await interaction.edit_original_response(content=output_string)
|
||||||
|
|
||||||
embed = get_team_embed(title=f'{this_team["lname"]} Keepers', team=this_team)
|
# embed = get_team_embed(title=f'{this_team["lname"]} Keepers', team=this_team)
|
||||||
embed.add_field(name=f'Keepers', value=keeper_string)
|
# embed.add_field(name=f'Keepers', value=keeper_string)
|
||||||
embed.add_field(name='Total sWAR', value=f'{keeper_swar:.2f}')
|
# embed.add_field(name='Total sWAR', value=f'{keeper_swar:.2f}')
|
||||||
await send_to_channel(self.bot, 'sba-network-news', content=None, embed=embed)
|
# await send_to_channel(self.bot, 'sba-network-news', content=None, embed=embed)
|
||||||
|
|
||||||
output_string += f'\nJust sent keeper message to sba-network-news'
|
# output_string += f'\nJust sent keeper message to sba-network-news'
|
||||||
await interaction.edit_original_response(content=output_string)
|
# await interaction.edit_original_response(content=output_string)
|
||||||
|
|
||||||
@commands.command(name='migrate-players', help='Migrate players between "same-set" seasons')
|
@commands.command(name='migrate-players', help='Migrate players between "same-set" seasons')
|
||||||
@commands.has_any_role('Da Commish')
|
@commands.has_any_role('Da Commish')
|
||||||
|
|||||||
@ -2,6 +2,7 @@ import copy
|
|||||||
import math
|
import math
|
||||||
|
|
||||||
from helpers import *
|
from helpers import *
|
||||||
|
from api_calls.current import get_current
|
||||||
from peewee import *
|
from peewee import *
|
||||||
import discord
|
import discord
|
||||||
from discord import app_commands
|
from discord import app_commands
|
||||||
@ -442,17 +443,17 @@ class Fun(commands.Cog):
|
|||||||
day_or_night: Literal['day', 'night'] = 'night',
|
day_or_night: Literal['day', 'night'] = 'night',
|
||||||
result: Literal['no-doubt', 'bp-homerun', 'bp-flyout'] = 'bp-homerun', d20: int = None):
|
result: Literal['no-doubt', 'bp-homerun', 'bp-flyout'] = 'bp-homerun', d20: int = None):
|
||||||
await interaction.response.defer()
|
await interaction.response.defer()
|
||||||
current = await db_get('current')
|
current = await get_current()
|
||||||
team = await get_team_by_owner(current['season'], interaction.user.id)
|
team = await get_team_by_owner(current.season, interaction.user.id)
|
||||||
|
|
||||||
result_text = 'Home Run'
|
result_text = 'Home Run'
|
||||||
if result == 'bp-flyout':
|
if result == 'bp-flyout':
|
||||||
result_text = 'Fly Out'
|
result_text = 'Fly Out'
|
||||||
|
|
||||||
season = 'fall'
|
season = 'fall'
|
||||||
if current['week'] < 6:
|
if current.week < 6:
|
||||||
season = 'spring'
|
season = 'spring'
|
||||||
elif current['week'] < 17:
|
elif current.week < 17:
|
||||||
season = 'summer'
|
season = 'summer'
|
||||||
|
|
||||||
hr_count = 16
|
hr_count = 16
|
||||||
|
|||||||
198
cogs/players.py
198
cogs/players.py
@ -9,9 +9,10 @@ from discord import app_commands
|
|||||||
from discord.ext import tasks
|
from discord.ext import tasks
|
||||||
from discord.app_commands import Choice
|
from discord.app_commands import Choice
|
||||||
|
|
||||||
|
from api_calls.current import get_current
|
||||||
from helpers import *
|
from helpers import *
|
||||||
from db_calls import db_get, db_patch, get_team_by_abbrev, get_team_by_owner, put_player, get_player_by_name, db_post, \
|
from db_calls import db_get, db_patch, get_team_by_abbrev, get_team_by_owner, put_player, get_player_by_name, db_post, db_delete
|
||||||
db_delete
|
import api_calls as api
|
||||||
from typing import Literal, Optional
|
from typing import Literal, Optional
|
||||||
|
|
||||||
logger = logging.getLogger('discord_app')
|
logger = logging.getLogger('discord_app')
|
||||||
@ -117,10 +118,10 @@ class Players(commands.Cog):
|
|||||||
async def get_dice_embed(self, channel, title, message):
|
async def get_dice_embed(self, channel, title, message):
|
||||||
team = None
|
team = None
|
||||||
try:
|
try:
|
||||||
current = await db_get('current')
|
current = await get_current()
|
||||||
team_abbrev = re.split('-', channel.name)
|
team_abbrev = re.split('-', channel.name)
|
||||||
if len(team_abbrev[0]) <= 4 and team_abbrev not in ['the', 'city']:
|
if len(team_abbrev[0]) <= 4 and team_abbrev not in ['the', 'city']:
|
||||||
tquery = await db_get('teams', params=[('season', current['season']), ('team_abbrev', team_abbrev[0])])
|
tquery = await db_get('teams', params=[('season', current.season), ('team_abbrev', team_abbrev[0])])
|
||||||
if tquery['count'] > 0:
|
if tquery['count'] > 0:
|
||||||
team = tquery['teams'][0]
|
team = tquery['teams'][0]
|
||||||
except (ValueError, AttributeError, requests.ReadTimeout) as e:
|
except (ValueError, AttributeError, requests.ReadTimeout) as e:
|
||||||
@ -271,9 +272,9 @@ class Players(commands.Cog):
|
|||||||
@tasks.loop(count=1)
|
@tasks.loop(count=1)
|
||||||
async def build_master_player_list(self):
|
async def build_master_player_list(self):
|
||||||
# logger.info(f'build_master_player_list - getting current')
|
# logger.info(f'build_master_player_list - getting current')
|
||||||
current = await db_get('current')
|
current = await get_current()
|
||||||
# logger.info(f'build_master_player_list - getting all_players')
|
# logger.info(f'build_master_player_list - getting all_players')
|
||||||
p_query = await db_get('players', timeout=8, params=[('season', current['season'])])
|
p_query = await db_get('players', timeout=8, params=[('season', current.season)])
|
||||||
# logger.info(f'build_master_player_list - building player_list')
|
# logger.info(f'build_master_player_list - building player_list')
|
||||||
self.player_list = {x['name'].lower(): x['id'] for x in p_query['players']}
|
self.player_list = {x['name'].lower(): x['id'] for x in p_query['players']}
|
||||||
logger.info(f'player list count: {len(self.player_list)}')
|
logger.info(f'player list count: {len(self.player_list)}')
|
||||||
@ -344,7 +345,7 @@ class Players(commands.Cog):
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
async def update_injuries(ctx):
|
async def update_injuries(ctx):
|
||||||
current = await db_get('current')
|
current = await get_current()
|
||||||
injury_log = discord.utils.get(ctx.guild.text_channels, name='injury-log')
|
injury_log = discord.utils.get(ctx.guild.text_channels, name='injury-log')
|
||||||
|
|
||||||
# Build new messages
|
# Build new messages
|
||||||
@ -353,7 +354,7 @@ class Players(commands.Cog):
|
|||||||
inj_team = {}
|
inj_team = {}
|
||||||
inj_week = {}
|
inj_week = {}
|
||||||
i_query = await db_get('injuries', params=[
|
i_query = await db_get('injuries', params=[
|
||||||
('season', current['season']), ('is_active', True), ('sort', 'return-asc')
|
('season', current.season), ('is_active', True), ('sort', 'return-asc')
|
||||||
])
|
])
|
||||||
|
|
||||||
for x in i_query['injuries']:
|
for x in i_query['injuries']:
|
||||||
@ -439,16 +440,16 @@ class Players(commands.Cog):
|
|||||||
@staticmethod
|
@staticmethod
|
||||||
async def game_progress(current):
|
async def game_progress(current):
|
||||||
# s_query = await db_get('schedules', params=[
|
# s_query = await db_get('schedules', params=[
|
||||||
# ('season', current['season']), ('week_start', current['week']), ('week_end', current['week'])
|
# ('season', current.season), ('week_start', current.week), ('week_end', current.week)
|
||||||
# ])
|
# ])
|
||||||
# r_query = await db_get('results', params=[
|
# r_query = await db_get('results', params=[
|
||||||
# ('season', current['season']), ('week_start', current['week']), ('week_end', current['week'])
|
# ('season', current.season), ('week_start', current.week), ('week_end', current.week)
|
||||||
# ])
|
# ])
|
||||||
gp_query = await db_get('games', params=[
|
gp_query = await db_get('games', params=[
|
||||||
('season', current['season']), ('week', current['week']), ('played', True), ('short_output', True)
|
('season', current.season), ('week', current.week), ('played', True), ('short_output', True)
|
||||||
])
|
])
|
||||||
all_query = await db_get('games', params=[
|
all_query = await db_get('games', params=[
|
||||||
('season', current['season']), ('week', current['week']), ('short_output', True)
|
('season', current.season), ('week', current.week), ('short_output', True)
|
||||||
])
|
])
|
||||||
|
|
||||||
return {'games_played': gp_query['count'], 'game_count': all_query['count']}
|
return {'games_played': gp_query['count'], 'game_count': all_query['count']}
|
||||||
@ -554,7 +555,7 @@ class Players(commands.Cog):
|
|||||||
|
|
||||||
# @staticmethod
|
# @staticmethod
|
||||||
# def get_standings_embed(current, progress, al_standings, nl_standings):
|
# def get_standings_embed(current, progress, al_standings, nl_standings):
|
||||||
# embed = discord.Embed(title=f'Season {current["season"]} | Week {current["week"]} | '
|
# embed = discord.Embed(title=f'Season {current.season} | Week {current.week} | '
|
||||||
# f'{progress["games_played"]}/{progress["game_count"]} games played',
|
# f'{progress["games_played"]}/{progress["game_count"]} games played',
|
||||||
# color=0xB70000)
|
# color=0xB70000)
|
||||||
# embed.add_field(name=f'**Full Standings**', value=SBA_STANDINGS_URL, inline=False)
|
# embed.add_field(name=f'**Full Standings**', value=SBA_STANDINGS_URL, inline=False)
|
||||||
@ -565,13 +566,13 @@ class Players(commands.Cog):
|
|||||||
|
|
||||||
@commands.command(name='team', aliases=['roster', 'myboys', 'mybois'], help='Get team overview')
|
@commands.command(name='team', aliases=['roster', 'myboys', 'mybois'], help='Get team overview')
|
||||||
async def team_command(self, ctx, team_abbrev: str = None):
|
async def team_command(self, ctx, team_abbrev: str = None):
|
||||||
current = await db_get('current')
|
current = await get_current()
|
||||||
|
|
||||||
# Get Team
|
# Get Team
|
||||||
if team_abbrev is not None:
|
if team_abbrev is not None:
|
||||||
team = await get_team_by_abbrev(team_abbrev, current['season'])
|
team = await get_team_by_abbrev(team_abbrev, current.season)
|
||||||
else:
|
else:
|
||||||
team = await get_team_by_owner(season=current['season'], owner_id=ctx.author.id)
|
team = await get_team_by_owner(season=current.season, owner_id=ctx.author.id)
|
||||||
|
|
||||||
# Create team embed
|
# Create team embed
|
||||||
embed = get_team_embed(f'{team["lname"]} Overview', team)
|
embed = get_team_embed(f'{team["lname"]} Overview', team)
|
||||||
@ -607,14 +608,14 @@ class Players(commands.Cog):
|
|||||||
# Get player info
|
# Get player info
|
||||||
il_players = None
|
il_players = None
|
||||||
if team['abbrev'][-2:].lower() != 'il':
|
if team['abbrev'][-2:].lower() != 'il':
|
||||||
il_team = await get_team_by_abbrev(team['abbrev'], current['season'])
|
il_team = await get_team_by_abbrev(team['abbrev'], current.season)
|
||||||
p_query = await db_get('players', params=[
|
p_query = await db_get('players', params=[
|
||||||
('season', current['season']), ('team_id', il_team['id']), ('sort', 'cost-desc')
|
('season', current.season), ('team_id', il_team['id']), ('sort', 'cost-desc')
|
||||||
])
|
])
|
||||||
il_players = p_query['players']
|
il_players = p_query['players']
|
||||||
|
|
||||||
p_query = await db_get('players', params=[
|
p_query = await db_get('players', params=[
|
||||||
('season', current['season']), ('team_id', team['id']), ('sort', 'cost-desc')
|
('season', current.season), ('team_id', team['id']), ('sort', 'cost-desc')
|
||||||
])
|
])
|
||||||
players = p_query['players']
|
players = p_query['players']
|
||||||
il_wara = 0
|
il_wara = 0
|
||||||
@ -640,8 +641,8 @@ class Players(commands.Cog):
|
|||||||
embed.add_field(name='Injured sWAR', value=f'{il_wara:.2f}')
|
embed.add_field(name='Injured sWAR', value=f'{il_wara:.2f}')
|
||||||
|
|
||||||
s_query = await db_get('schedules', params=[
|
s_query = await db_get('schedules', params=[
|
||||||
('season', current['season']), ('team_abbrev', team['abbrev']), ('week_start', current['week']),
|
('season', current.season), ('team_abbrev', team['abbrev']), ('week_start', current.week),
|
||||||
('week_end', current['week']+2 if current['week']+2 > 0 else 2), ('short_output', False)
|
('week_end', current.week+2 if current.week+2 > 0 else 2), ('short_output', False)
|
||||||
])
|
])
|
||||||
if s_query['count'] > 0:
|
if s_query['count'] > 0:
|
||||||
team_schedule = s_query['schedules']
|
team_schedule = s_query['schedules']
|
||||||
@ -656,16 +657,16 @@ class Players(commands.Cog):
|
|||||||
if matchup['hometeam'] == team:
|
if matchup['hometeam'] == team:
|
||||||
st_abbrev = matchup['awayteam']['abbrev']
|
st_abbrev = matchup['awayteam']['abbrev']
|
||||||
|
|
||||||
r_query = await db_get('standings', params=[('season', current['season']), ('team_abbrev', st_abbrev)])
|
r_query = await db_get('standings', params=[('season', current.season), ('team_abbrev', st_abbrev)])
|
||||||
opp_record = None if r_query['count'] == 0 else r_query['standings'][0]
|
opp_record = None if r_query['count'] == 0 else r_query['standings'][0]
|
||||||
|
|
||||||
if matchup['week'] == current['week']:
|
if matchup['week'] == current.week:
|
||||||
if matchup['hometeam'] == team:
|
if matchup['hometeam'] == team:
|
||||||
this_week_string += f'Week {current["week"]}: vs ' \
|
this_week_string += f'Week {current.week}: vs ' \
|
||||||
f'{matchup["awayteam"]["lname"]} ' \
|
f'{matchup["awayteam"]["lname"]} ' \
|
||||||
f'({opp_record["wins"]}-{opp_record["losses"]})\n'
|
f'({opp_record["wins"]}-{opp_record["losses"]})\n'
|
||||||
else:
|
else:
|
||||||
this_week_string += f'Week {current["week"]}: @ {matchup["hometeam"]["lname"]} ' \
|
this_week_string += f'Week {current.week}: @ {matchup["hometeam"]["lname"]} ' \
|
||||||
f'({opp_record["wins"]}-{opp_record["losses"]})\n'
|
f'({opp_record["wins"]}-{opp_record["losses"]})\n'
|
||||||
else:
|
else:
|
||||||
if matchup['hometeam'] == team:
|
if matchup['hometeam'] == team:
|
||||||
@ -685,7 +686,7 @@ class Players(commands.Cog):
|
|||||||
# Add roster link
|
# Add roster link
|
||||||
embed.add_field(
|
embed.add_field(
|
||||||
name=f'{team["abbrev"]} Roster Page',
|
name=f'{team["abbrev"]} Roster Page',
|
||||||
value=f'https://sba.manticorum.com/teams/{current["season"]}/{team["abbrev"]}',
|
value=f'https://sba.manticorum.com/teams/{current.season}/{team["abbrev"]}',
|
||||||
inline=False
|
inline=False
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -693,8 +694,9 @@ class Players(commands.Cog):
|
|||||||
|
|
||||||
@commands.command(name='player', aliases=['card'], help='Get player overview')
|
@commands.command(name='player', aliases=['card'], help='Get player overview')
|
||||||
async def player_command(self, ctx, *, name):
|
async def player_command(self, ctx, *, name):
|
||||||
current = await db_get('current')
|
current = await get_current()
|
||||||
season = current['season']
|
season = current.season
|
||||||
|
logger.info(f'current: {current}')
|
||||||
|
|
||||||
# if 'strider' in name.lower():
|
# if 'strider' in name.lower():
|
||||||
# await ctx.send(f'Ope. Strider has been reserved for Cal.')
|
# await ctx.send(f'Ope. Strider has been reserved for Cal.')
|
||||||
@ -845,20 +847,20 @@ class Players(commands.Cog):
|
|||||||
await ctx.send(f'This command has been deprecated, please use `/schedule`')
|
await ctx.send(f'This command has been deprecated, please use `/schedule`')
|
||||||
return
|
return
|
||||||
|
|
||||||
current = await db_get('current')
|
current = await get_current()
|
||||||
|
|
||||||
if week is not None:
|
if week is not None:
|
||||||
schedule_week = week
|
schedule_week = week
|
||||||
elif current['week'] < 1:
|
elif current.week < 1:
|
||||||
schedule_week = 1
|
schedule_week = 1
|
||||||
else:
|
else:
|
||||||
schedule_week = current['week']
|
schedule_week = current.week
|
||||||
|
|
||||||
g1_query = await db_get('games', params=[
|
g1_query = await db_get('games', params=[
|
||||||
('season', current['season']), ('week_start', schedule_week), ('week_end', schedule_week)
|
('season', current.season), ('week_start', schedule_week), ('week_end', schedule_week)
|
||||||
])
|
])
|
||||||
g2_query = await db_get('games', params=[
|
g2_query = await db_get('games', params=[
|
||||||
('season', current['season']), ('week_start', schedule_week + 1), ('week_end', schedule_week + 1)
|
('season', current.season), ('week_start', schedule_week + 1), ('week_end', schedule_week + 1)
|
||||||
])
|
])
|
||||||
|
|
||||||
games_played = 0
|
games_played = 0
|
||||||
@ -887,7 +889,7 @@ class Players(commands.Cog):
|
|||||||
'away_wins': 0, 'home_wins': 0, 'away_team': x["away_team"], 'home_team': x["home_team"]
|
'away_wins': 0, 'home_wins': 0, 'away_team': x["away_team"], 'home_team': x["home_team"]
|
||||||
}
|
}
|
||||||
|
|
||||||
embed = get_team_embed(f'Season {current["season"]} | Week {schedule_week} | '
|
embed = get_team_embed(f'Season {current.season} | Week {schedule_week} | '
|
||||||
f'{games_played}/{g1_query["count"]} games played')
|
f'{games_played}/{g1_query["count"]} games played')
|
||||||
|
|
||||||
embed.add_field(name='Full Schedule',
|
embed.add_field(name='Full Schedule',
|
||||||
@ -952,7 +954,7 @@ class Players(commands.Cog):
|
|||||||
value=string_next_week_0,
|
value=string_next_week_0,
|
||||||
inline=False
|
inline=False
|
||||||
)
|
)
|
||||||
embed.title = f'Season {current["season"]} | Week {schedule_week + 1}'
|
embed.title = f'Season {current.season} | Week {schedule_week + 1}'
|
||||||
await ctx.send(content=None, embed=embed)
|
await ctx.send(content=None, embed=embed)
|
||||||
if len(string_next_week_1) > 0:
|
if len(string_next_week_1) > 0:
|
||||||
if len(embed.fields) > 1:
|
if len(embed.fields) > 1:
|
||||||
@ -974,7 +976,7 @@ class Players(commands.Cog):
|
|||||||
@app_commands.checks.has_any_role(SBA_PLAYERS_ROLE_NAME)
|
@app_commands.checks.has_any_role(SBA_PLAYERS_ROLE_NAME)
|
||||||
async def schedule_slash(self, interaction: discord.Interaction, team_abbrev: str = None, week_num: int = None, season: int = SBA_SEASON):
|
async def schedule_slash(self, interaction: discord.Interaction, team_abbrev: str = None, week_num: int = None, season: int = SBA_SEASON):
|
||||||
await interaction.response.defer()
|
await interaction.response.defer()
|
||||||
current = await db_get('current')
|
current = await get_current()
|
||||||
|
|
||||||
this_team = None
|
this_team = None
|
||||||
param_list = [('season', season)]
|
param_list = [('season', season)]
|
||||||
@ -993,7 +995,7 @@ class Players(commands.Cog):
|
|||||||
param_list.append(('week', week_num))
|
param_list.append(('week', week_num))
|
||||||
|
|
||||||
if len(param_list) == 1:
|
if len(param_list) == 1:
|
||||||
param_list.append(('week', current['week']))
|
param_list.append(('week', current.week))
|
||||||
|
|
||||||
g_query = await db_get('games', params=param_list)
|
g_query = await db_get('games', params=param_list)
|
||||||
if g_query['count'] == 0:
|
if g_query['count'] == 0:
|
||||||
@ -1044,7 +1046,7 @@ class Players(commands.Cog):
|
|||||||
away_record = await db_get(f'standings/team/{x["away_team"]["id"]}')
|
away_record = await db_get(f'standings/team/{x["away_team"]["id"]}')
|
||||||
home_record = await db_get(f'standings/team/{x["home_team"]["id"]}')
|
home_record = await db_get(f'standings/team/{x["home_team"]["id"]}')
|
||||||
|
|
||||||
this_line = f'({x["away_wins"]}) [{x["away_team"]["lname"]: >4}]({SBA_BASE_URL}/teams/{current["season"]}/{x["away_team"]["abbrev"]}) ({away_record["wins"]}-{away_record["losses"]})\n@\n({x["home_wins"]}) [{x["home_team"]["lname"]: <4}]({SBA_BASE_URL}/teams/{current["season"]}/{x["home_team"]["abbrev"]}) ({home_record["wins"]}-{home_record["losses"]})\n\n'
|
this_line = f'({x["away_wins"]}) [{x["away_team"]["lname"]: >4}]({SBA_BASE_URL}/teams/{current.season}/{x["away_team"]["abbrev"]}) ({away_record["wins"]}-{away_record["losses"]})\n@\n({x["home_wins"]}) [{x["home_team"]["lname"]: <4}]({SBA_BASE_URL}/teams/{current.season}/{x["home_team"]["abbrev"]}) ({home_record["wins"]}-{home_record["losses"]})\n\n'
|
||||||
|
|
||||||
logger.info(f'standings_slash - this_line:\n{this_line}')
|
logger.info(f'standings_slash - this_line:\n{this_line}')
|
||||||
embed.add_field(
|
embed.add_field(
|
||||||
@ -1057,7 +1059,7 @@ class Players(commands.Cog):
|
|||||||
# string_this_week += this_line
|
# string_this_week += this_line
|
||||||
# logger.info(f'Adding to string_this_week:\n{this_line}')
|
# logger.info(f'Adding to string_this_week:\n{this_line}')
|
||||||
|
|
||||||
embed.description = f'Games Played: {games_played} / {"32" if current["week"] <= 18 else "??"}'
|
embed.description = f'Games Played: {games_played} / {"32" if current.week <= 18 else "??"}'
|
||||||
await interaction.edit_original_response(
|
await interaction.edit_original_response(
|
||||||
content=None,
|
content=None,
|
||||||
embed=embed
|
embed=embed
|
||||||
@ -1134,31 +1136,31 @@ class Players(commands.Cog):
|
|||||||
|
|
||||||
@commands.command(name='weather', help='Roll ballpark weather')
|
@commands.command(name='weather', help='Roll ballpark weather')
|
||||||
async def weather_command(self, ctx, team_abbrev=None):
|
async def weather_command(self, ctx, team_abbrev=None):
|
||||||
current = await db_get('current')
|
current = await get_current()
|
||||||
|
|
||||||
if team_abbrev is not None:
|
if team_abbrev is not None:
|
||||||
t_query = await db_get('teams', params=[('season', current['season']), ('team_abbrev', team_abbrev)])
|
t_query = await db_get('teams', params=[('season', current.season), ('team_abbrev', team_abbrev)])
|
||||||
else:
|
else:
|
||||||
t_query = await db_get('teams', params=[
|
t_query = await db_get('teams', params=[
|
||||||
('season', current['season']), ('team_abbrev', ctx.channel.name.split('-')[0])
|
('season', current.season), ('team_abbrev', ctx.channel.name.split('-')[0])
|
||||||
])
|
])
|
||||||
if t_query['count'] == 0:
|
if t_query['count'] == 0:
|
||||||
t_query = await db_get('teams', params=[('season', current['season']), ('owner_id', ctx.author.id)])
|
t_query = await db_get('teams', params=[('season', current.season), ('owner_id', ctx.author.id)])
|
||||||
|
|
||||||
if t_query['count'] == 0:
|
if t_query['count'] == 0:
|
||||||
await ctx.send(f'I could not find a weather chart for you.')
|
await ctx.send(f'I could not find a weather chart for you.')
|
||||||
|
|
||||||
team = t_query['teams'][0]
|
team = t_query['teams'][0]
|
||||||
g_query = await db_get('games', params=[('team1_id', team['id']), ('week', current['week'])])
|
g_query = await db_get('games', params=[('team1_id', team['id']), ('week', current.week)])
|
||||||
|
|
||||||
night_str = '\U0001F319 Night'
|
night_str = '\U0001F319 Night'
|
||||||
day_str = '\U0001F31E Day'
|
day_str = '\U0001F31E Day'
|
||||||
|
|
||||||
is_div_week = current['week'] in [1, 3, 6, 14, 16, 18]
|
is_div_week = current.week in [1, 3, 6, 14, 16, 18]
|
||||||
season_str = f'\U0001F3D6 **Summer**'
|
season_str = f'\U0001F3D6 **Summer**'
|
||||||
if current['week'] <= 5:
|
if current.week <= 5:
|
||||||
season_str = f'\U0001F33C **Spring**'
|
season_str = f'\U0001F33C **Spring**'
|
||||||
elif current['week'] > 14:
|
elif current.week > 14:
|
||||||
season_str = f'\U0001F342 **Fall**'
|
season_str = f'\U0001F342 **Fall**'
|
||||||
|
|
||||||
d_twenty = random.randint(1, 20)
|
d_twenty = random.randint(1, 20)
|
||||||
@ -1189,19 +1191,19 @@ class Players(commands.Cog):
|
|||||||
|
|
||||||
async def get_division_standings(self, current) -> discord.Embed:
|
async def get_division_standings(self, current) -> discord.Embed:
|
||||||
d1_query = await db_get('standings', params=[
|
d1_query = await db_get('standings', params=[
|
||||||
('season', current['season']), ('division_abbrev', 'SD')
|
('season', current.season), ('division_abbrev', 'SD')
|
||||||
])
|
])
|
||||||
div_one = d1_query['standings']
|
div_one = d1_query['standings']
|
||||||
d2_query = await db_get('standings', params=[
|
d2_query = await db_get('standings', params=[
|
||||||
('season', current['season']), ('division_abbrev', 'DC')
|
('season', current.season), ('division_abbrev', 'DC')
|
||||||
])
|
])
|
||||||
div_two = d2_query['standings']
|
div_two = d2_query['standings']
|
||||||
d3_query = await db_get('standings', params=[
|
d3_query = await db_get('standings', params=[
|
||||||
('season', current['season']), ('division_abbrev', 'FIP')
|
('season', current.season), ('division_abbrev', 'FIP')
|
||||||
])
|
])
|
||||||
div_three = d3_query['standings']
|
div_three = d3_query['standings']
|
||||||
d4_query = await db_get('standings', params=[
|
d4_query = await db_get('standings', params=[
|
||||||
('season', current['season']), ('division_abbrev', 'DOC')
|
('season', current.season), ('division_abbrev', 'DOC')
|
||||||
])
|
])
|
||||||
div_four = d4_query['standings']
|
div_four = d4_query['standings']
|
||||||
|
|
||||||
@ -1227,7 +1229,7 @@ class Players(commands.Cog):
|
|||||||
|
|
||||||
progress = await self.game_progress(current)
|
progress = await self.game_progress(current)
|
||||||
|
|
||||||
embed = discord.Embed(title=f'Season {current["season"]} | Week {current["week"]} | '
|
embed = discord.Embed(title=f'Season {current.season} | Week {current.week} | '
|
||||||
f'{progress["games_played"]}/{progress["game_count"]} games played',
|
f'{progress["games_played"]}/{progress["game_count"]} games played',
|
||||||
color=0xB70000)
|
color=0xB70000)
|
||||||
embed.add_field(name=f'**Full Standings**', value=SBA_STANDINGS_URL, inline=False)
|
embed.add_field(name=f'**Full Standings**', value=SBA_STANDINGS_URL, inline=False)
|
||||||
@ -1240,11 +1242,11 @@ class Players(commands.Cog):
|
|||||||
|
|
||||||
async def get_wildcard_standings(self, current) -> discord.Embed:
|
async def get_wildcard_standings(self, current) -> discord.Embed:
|
||||||
a_query = await db_get('standings', params=[
|
a_query = await db_get('standings', params=[
|
||||||
('season', current['season']), ('league_abbrev', 'SBa')
|
('season', current.season), ('league_abbrev', 'SBa')
|
||||||
])
|
])
|
||||||
al_teams = a_query['standings']
|
al_teams = a_query['standings']
|
||||||
# n_query = await db_get('standings', params=[
|
# n_query = await db_get('standings', params=[
|
||||||
# ('season', current['season']), ('league_abbrev', 'nl')
|
# ('season', current.season), ('league_abbrev', 'nl')
|
||||||
# ])
|
# ])
|
||||||
# nl_teams = n_query['standings']
|
# nl_teams = n_query['standings']
|
||||||
|
|
||||||
@ -1260,7 +1262,7 @@ class Players(commands.Cog):
|
|||||||
|
|
||||||
progress = await self.game_progress(current)
|
progress = await self.game_progress(current)
|
||||||
|
|
||||||
embed = discord.Embed(title=f'Season {current["season"]} | Week {current["week"]} | '
|
embed = discord.Embed(title=f'Season {current.season} | Week {current.week} | '
|
||||||
f'{progress["games_played"]}/{progress["game_count"]} games played',
|
f'{progress["games_played"]}/{progress["game_count"]} games played',
|
||||||
color=0xB70000)
|
color=0xB70000)
|
||||||
embed.add_field(name=f'**Full Standings**', value=SBA_STANDINGS_URL, inline=False)
|
embed.add_field(name=f'**Full Standings**', value=SBA_STANDINGS_URL, inline=False)
|
||||||
@ -1271,7 +1273,7 @@ class Players(commands.Cog):
|
|||||||
|
|
||||||
async def standings_button_loop(self, ctx, start: Literal['division', 'wildcard']):
|
async def standings_button_loop(self, ctx, start: Literal['division', 'wildcard']):
|
||||||
async with ctx.typing():
|
async with ctx.typing():
|
||||||
current = await db_get('current')
|
current = await get_current()
|
||||||
div_embed = await self.get_division_standings(current)
|
div_embed = await self.get_division_standings(current)
|
||||||
wc_embed = await self.get_wildcard_standings(current)
|
wc_embed = await self.get_wildcard_standings(current)
|
||||||
logger.info(f'div_embed: {div_embed}\nwc_embed: {wc_embed}')
|
logger.info(f'div_embed: {div_embed}\nwc_embed: {wc_embed}')
|
||||||
@ -1341,9 +1343,9 @@ class Players(commands.Cog):
|
|||||||
return
|
return
|
||||||
|
|
||||||
await interaction.response.defer()
|
await interaction.response.defer()
|
||||||
current = await db_get('current')
|
current = await get_current()
|
||||||
|
|
||||||
p_query = await db_get('players', params=[('name', player_name), ('season', current['season'])])
|
p_query = await db_get('players', params=[('name', player_name), ('season', current.season)])
|
||||||
if p_query['count'] == 0:
|
if p_query['count'] == 0:
|
||||||
await interaction.edit_original_response(content=f'I did not find anybody named **{player_name}**.')
|
await interaction.edit_original_response(content=f'I did not find anybody named **{player_name}**.')
|
||||||
return
|
return
|
||||||
@ -1351,7 +1353,7 @@ class Players(commands.Cog):
|
|||||||
player = p_query['players'][0]
|
player = p_query['players'][0]
|
||||||
|
|
||||||
# Check if player is on owner's team
|
# Check if player is on owner's team
|
||||||
team = await get_team_by_owner(current['season'], interaction.user.id)
|
team = await get_team_by_owner(current.season, interaction.user.id)
|
||||||
if not player['team'] == team and not player['team']['abbrev'][:len(team['abbrev'])] == team['abbrev']:
|
if not player['team'] == team and not player['team']['abbrev'][:len(team['abbrev'])] == team['abbrev']:
|
||||||
await interaction.edit_original_response(
|
await interaction.edit_original_response(
|
||||||
content=f'Is this some kind of tom foolery? {player["name"]} is on {player["team"]["abbrev"]} aka '
|
content=f'Is this some kind of tom foolery? {player["name"]} is on {player["team"]["abbrev"]} aka '
|
||||||
@ -1383,7 +1385,7 @@ class Players(commands.Cog):
|
|||||||
)
|
)
|
||||||
|
|
||||||
await db_post('injuries', payload={
|
await db_post('injuries', payload={
|
||||||
'season': current['season'],
|
'season': current.season,
|
||||||
'player_id': player['id'],
|
'player_id': player['id'],
|
||||||
'total_games': inj_games,
|
'total_games': inj_games,
|
||||||
'start_week': this_week if this_game != 4 else this_week + 1,
|
'start_week': this_week if this_game != 4 else this_week + 1,
|
||||||
@ -1402,9 +1404,9 @@ class Players(commands.Cog):
|
|||||||
@app_commands.checks.has_any_role(SBA_PLAYERS_ROLE_NAME)
|
@app_commands.checks.has_any_role(SBA_PLAYERS_ROLE_NAME)
|
||||||
async def clear_injury_slash(self, interaction: discord.Interaction, player_name: str):
|
async def clear_injury_slash(self, interaction: discord.Interaction, player_name: str):
|
||||||
await interaction.response.defer()
|
await interaction.response.defer()
|
||||||
current = await db_get('current')
|
current = await get_current()
|
||||||
|
|
||||||
p_query = await db_get('players', params=[('name', player_name), ('season', current['season'])])
|
p_query = await db_get('players', params=[('name', player_name), ('season', current.season)])
|
||||||
if p_query['count'] == 0:
|
if p_query['count'] == 0:
|
||||||
await interaction.response.send_message(f'I did not find anybody named **{player_name}**.')
|
await interaction.response.send_message(f'I did not find anybody named **{player_name}**.')
|
||||||
return
|
return
|
||||||
@ -1416,7 +1418,7 @@ class Players(commands.Cog):
|
|||||||
await interaction.edit_original_response(content='Huh? He isn\'t injured, numb nuts.')
|
await interaction.edit_original_response(content='Huh? He isn\'t injured, numb nuts.')
|
||||||
return
|
return
|
||||||
|
|
||||||
team = await get_team_by_owner(current['season'], interaction.user.id)
|
team = await get_team_by_owner(current.season, interaction.user.id)
|
||||||
if not player['team'] == team and not player['team']['abbrev'][:len(team['abbrev'])] == team['abbrev']:
|
if not player['team'] == team and not player['team']['abbrev'][:len(team['abbrev'])] == team['abbrev']:
|
||||||
await interaction.edit_original_response(
|
await interaction.edit_original_response(
|
||||||
content=f'Is this some kind of tom foolery? {player["name"]} is on {player["team"]["abbrev"]} aka '
|
content=f'Is this some kind of tom foolery? {player["name"]} is on {player["team"]["abbrev"]} aka '
|
||||||
@ -1498,7 +1500,7 @@ class Players(commands.Cog):
|
|||||||
@app_commands.command(name='sba-submit', description='Submit scorecard and game result')
|
@app_commands.command(name='sba-submit', description='Submit scorecard and game result')
|
||||||
@app_commands.checks.has_any_role(SBA_PLAYERS_ROLE_NAME)
|
@app_commands.checks.has_any_role(SBA_PLAYERS_ROLE_NAME)
|
||||||
async def submit_slash(self, interaction: discord.Interaction, sheet_url: str):
|
async def submit_slash(self, interaction: discord.Interaction, sheet_url: str):
|
||||||
current = await db_get('current')
|
current = await get_current()
|
||||||
|
|
||||||
# Go get scorecard
|
# Go get scorecard
|
||||||
await interaction.response.send_message(content='I\'ll go grab that card now...')
|
await interaction.response.send_message(content='I\'ll go grab that card now...')
|
||||||
@ -1518,7 +1520,7 @@ class Players(commands.Cog):
|
|||||||
setup_tab = scorecard.worksheet_by_title('Setup')
|
setup_tab = scorecard.worksheet_by_title('Setup')
|
||||||
|
|
||||||
scorecard_version = setup_tab.get_value('V35')
|
scorecard_version = setup_tab.get_value('V35')
|
||||||
if int(scorecard_version) != current['bet_week']:
|
if int(scorecard_version) != current.bet_week:
|
||||||
await interaction.edit_original_response(
|
await interaction.edit_original_response(
|
||||||
content=f'It looks like this scorecard is out of date. Did you create a new card at the start of the '
|
content=f'It looks like this scorecard is out of date. Did you create a new card at the start of the '
|
||||||
f'game? If you did, let Cal know about this error. If not, I\'ll need you to use an up to '
|
f'game? If you did, let Cal know about this error. If not, I\'ll need you to use an up to '
|
||||||
@ -1534,8 +1536,8 @@ class Players(commands.Cog):
|
|||||||
ht_abbrev = g_data[4][0]
|
ht_abbrev = g_data[4][0]
|
||||||
away_mgr_name = g_data[3][1]
|
away_mgr_name = g_data[3][1]
|
||||||
home_mgr_name = g_data[4][1]
|
home_mgr_name = g_data[4][1]
|
||||||
away_team = await get_team_by_abbrev(at_abbrev, current['season'])
|
away_team = await get_team_by_abbrev(at_abbrev, current.season)
|
||||||
home_team = await get_team_by_abbrev(ht_abbrev, current['season'])
|
home_team = await get_team_by_abbrev(ht_abbrev, current.season)
|
||||||
logger.info(f'away_manager: {away_mgr_name} / home_manager: {home_mgr_name}')
|
logger.info(f'away_manager: {away_mgr_name} / home_manager: {home_mgr_name}')
|
||||||
if away_team['manager2'] is not None and away_team['manager2']['name'].lower() == away_mgr_name.lower():
|
if away_team['manager2'] is not None and away_team['manager2']['name'].lower() == away_mgr_name.lower():
|
||||||
away_manager = away_team['manager2']
|
away_manager = away_team['manager2']
|
||||||
@ -1549,7 +1551,7 @@ class Players(commands.Cog):
|
|||||||
logger.info(f'gdata: {g_data}\nweek/game: {week_num}/{game_num}')
|
logger.info(f'gdata: {g_data}\nweek/game: {week_num}/{game_num}')
|
||||||
|
|
||||||
# Confirm submitting GM
|
# Confirm submitting GM
|
||||||
if await get_team_by_owner(current['season'], interaction.user.id) not in [home_team, away_team] and \
|
if await get_team_by_owner(current.season, interaction.user.id) not in [home_team, away_team] and \
|
||||||
interaction.user.id != self.bot.owner_id:
|
interaction.user.id != self.bot.owner_id:
|
||||||
await interaction.edit_original_response(
|
await interaction.edit_original_response(
|
||||||
content=f'{await get_emoji(interaction, "squint")} Only a GM of the two teams can submit scorecards.'
|
content=f'{await get_emoji(interaction, "squint")} Only a GM of the two teams can submit scorecards.'
|
||||||
@ -1558,7 +1560,7 @@ class Players(commands.Cog):
|
|||||||
|
|
||||||
# Confirm teams and matchup
|
# Confirm teams and matchup
|
||||||
dupe_g_query = await db_get('games', params=[
|
dupe_g_query = await db_get('games', params=[
|
||||||
('season', current['season']), ('week', week_num), ('game_num', game_num),
|
('season', current.season), ('week', week_num), ('game_num', game_num),
|
||||||
('away_team_id', away_team['id']), ('home_team_id', home_team['id'])
|
('away_team_id', away_team['id']), ('home_team_id', home_team['id'])
|
||||||
])
|
])
|
||||||
if dupe_g_query['count'] != 0:
|
if dupe_g_query['count'] != 0:
|
||||||
@ -1592,7 +1594,7 @@ class Players(commands.Cog):
|
|||||||
return
|
return
|
||||||
|
|
||||||
g_query = await db_get('games', params=[
|
g_query = await db_get('games', params=[
|
||||||
('season', current['season']), ('week', week_num), ('away_team_id', away_team['id']),
|
('season', current.season), ('week', week_num), ('away_team_id', away_team['id']),
|
||||||
('home_team_id', home_team['id']), ('played', False)
|
('home_team_id', home_team['id']), ('played', False)
|
||||||
])
|
])
|
||||||
if g_query['count'] == 0:
|
if g_query['count'] == 0:
|
||||||
@ -1730,7 +1732,7 @@ class Players(commands.Cog):
|
|||||||
return
|
return
|
||||||
|
|
||||||
# Post scorecard to news channel
|
# Post scorecard to news channel
|
||||||
card_url = f'<{SBA_BASE_URL}/games/{current["season"]}/{week_num}/{game_num}' \
|
card_url = f'<{SBA_BASE_URL}/games/{current.season}/{week_num}/{game_num}' \
|
||||||
f'/{away_team["abbrev"]}/{home_team["abbrev"]}>'
|
f'/{away_team["abbrev"]}/{home_team["abbrev"]}>'
|
||||||
extras = ''
|
extras = ''
|
||||||
if int(final_inning) > 9:
|
if int(final_inning) > 9:
|
||||||
@ -1994,7 +1996,7 @@ class Players(commands.Cog):
|
|||||||
)
|
)
|
||||||
|
|
||||||
update = await interaction.channel.send('I\'m tallying standings now...')
|
update = await interaction.channel.send('I\'m tallying standings now...')
|
||||||
if await db_post(f'standings/s{current["season"]}/recalculate', timeout=8):
|
if await db_post(f'standings/s{current.season}/recalculate', timeout=8):
|
||||||
await update.delete()
|
await update.delete()
|
||||||
await interaction.edit_original_response(content='You are all set!')
|
await interaction.edit_original_response(content='You are all set!')
|
||||||
|
|
||||||
@ -2029,9 +2031,9 @@ class Players(commands.Cog):
|
|||||||
mil_color_hex: str = None, mil_team_image_url: str = None, mil_team_name: str = None,
|
mil_color_hex: str = None, mil_team_image_url: str = None, mil_team_name: str = None,
|
||||||
dice_color_hex: str = None):
|
dice_color_hex: str = None):
|
||||||
await interaction.response.defer()
|
await interaction.response.defer()
|
||||||
current = await db_get('current')
|
current = await get_current()
|
||||||
team = await get_team_by_owner(current['season'], interaction.user.id)
|
team = await get_team_by_owner(current.season, interaction.user.id)
|
||||||
mil_team = await get_team_by_abbrev(f'{team["abbrev"]}MiL', current['season'])
|
mil_team = await get_team_by_abbrev(f'{team["abbrev"]}MiL', current.season)
|
||||||
team_role = get_team_role(interaction, team)
|
team_role = get_team_role(interaction, team)
|
||||||
errors = []
|
errors = []
|
||||||
show_mil = False
|
show_mil = False
|
||||||
@ -2151,8 +2153,8 @@ class Players(commands.Cog):
|
|||||||
@commands.command(name='private', help='Get private vc')
|
@commands.command(name='private', help='Get private vc')
|
||||||
@commands.has_any_role(SBA_PLAYERS_ROLE_NAME)
|
@commands.has_any_role(SBA_PLAYERS_ROLE_NAME)
|
||||||
async def private_vc_command(self, ctx):
|
async def private_vc_command(self, ctx):
|
||||||
current = await db_get('current')
|
current = await get_current()
|
||||||
this_team = await get_team_by_owner(current['season'], ctx.author.id)
|
this_team = await get_team_by_owner(current.season, ctx.author.id)
|
||||||
|
|
||||||
async def get_other_team():
|
async def get_other_team():
|
||||||
prompt = f'Please enter the abbrev of the team you are playing.'
|
prompt = f'Please enter the abbrev of the team you are playing.'
|
||||||
@ -2163,7 +2165,7 @@ class Players(commands.Cog):
|
|||||||
await ctx.send('You keep thinking about it and hit me up later if you figure it out.')
|
await ctx.send('You keep thinking about it and hit me up later if you figure it out.')
|
||||||
return None
|
return None
|
||||||
else:
|
else:
|
||||||
other_team = await get_team_by_abbrev(resp, current['season'])
|
other_team = await get_team_by_abbrev(resp, current.season)
|
||||||
if not other_team:
|
if not other_team:
|
||||||
await ctx.send(f'What\'s a **{resp}**? If you could go ahead and run this command again, that\'d '
|
await ctx.send(f'What\'s a **{resp}**? If you could go ahead and run this command again, that\'d '
|
||||||
f'be great.')
|
f'be great.')
|
||||||
@ -2176,7 +2178,7 @@ class Players(commands.Cog):
|
|||||||
return
|
return
|
||||||
|
|
||||||
g_query = await db_get('games', params=[
|
g_query = await db_get('games', params=[
|
||||||
('season', current['season']), ('week', current['week']), ('team1_id', this_team['id'])
|
('season', current.season), ('week', current.week), ('team1_id', this_team['id'])
|
||||||
])
|
])
|
||||||
if g_query['count'] == 0:
|
if g_query['count'] == 0:
|
||||||
other_team = await get_other_team()
|
other_team = await get_other_team()
|
||||||
@ -2238,8 +2240,8 @@ class Players(commands.Cog):
|
|||||||
await ctx.send('Not in season 6 chat, dumbass.')
|
await ctx.send('Not in season 6 chat, dumbass.')
|
||||||
return
|
return
|
||||||
|
|
||||||
current = await db_get('current')
|
current = await get_current()
|
||||||
this_team = await get_team_by_owner(current['season'], ctx.author.id)
|
this_team = await get_team_by_owner(current.season, ctx.author.id)
|
||||||
|
|
||||||
if not this_team:
|
if not this_team:
|
||||||
await ctx.send('Hmm...I can\'t find your team. Are you from around here?')
|
await ctx.send('Hmm...I can\'t find your team. Are you from around here?')
|
||||||
@ -2248,7 +2250,7 @@ class Players(commands.Cog):
|
|||||||
p_name = await fuzzy_player_search(
|
p_name = await fuzzy_player_search(
|
||||||
ctx, ctx.channel, self.bot, player_name, self.player_list.keys(), author=ctx.author
|
ctx, ctx.channel, self.bot, player_name, self.player_list.keys(), author=ctx.author
|
||||||
)
|
)
|
||||||
player = await get_player_by_name(current['season'], p_name)
|
player = await get_player_by_name(current.season, p_name)
|
||||||
if player is None:
|
if player is None:
|
||||||
await ctx.send(random_gif('it didn\'t work'))
|
await ctx.send(random_gif('it didn\'t work'))
|
||||||
return
|
return
|
||||||
@ -2274,8 +2276,8 @@ class Players(commands.Cog):
|
|||||||
await ctx.send('Not in season 6 chat, dumbass.')
|
await ctx.send('Not in season 6 chat, dumbass.')
|
||||||
return
|
return
|
||||||
|
|
||||||
current = await db_get('current')
|
current = await get_current()
|
||||||
this_team = await get_team_by_owner(current['season'], ctx.author.id)
|
this_team = await get_team_by_owner(current.season, ctx.author.id)
|
||||||
|
|
||||||
if not this_team:
|
if not this_team:
|
||||||
await ctx.send('Hmm...I can\'t find your team. Are you from around here?')
|
await ctx.send('Hmm...I can\'t find your team. Are you from around here?')
|
||||||
@ -2284,7 +2286,7 @@ class Players(commands.Cog):
|
|||||||
p_name = await fuzzy_player_search(
|
p_name = await fuzzy_player_search(
|
||||||
ctx, ctx.channel, self.bot, player_name, self.player_list.keys(), author=ctx.author
|
ctx, ctx.channel, self.bot, player_name, self.player_list.keys(), author=ctx.author
|
||||||
)
|
)
|
||||||
player = await get_player_by_name(current['season'], p_name)
|
player = await get_player_by_name(current.season, p_name)
|
||||||
if player is None:
|
if player is None:
|
||||||
await ctx.send(random_gif('it didn\'t work'))
|
await ctx.send(random_gif('it didn\'t work'))
|
||||||
return
|
return
|
||||||
@ -2310,8 +2312,8 @@ class Players(commands.Cog):
|
|||||||
await ctx.send('Not in season 5 chat, dumbass.')
|
await ctx.send('Not in season 5 chat, dumbass.')
|
||||||
return
|
return
|
||||||
|
|
||||||
current = await db_get('current')
|
current = await get_current()
|
||||||
this_team = await get_team_by_owner(current['season'], ctx.author.id)
|
this_team = await get_team_by_owner(current.season, ctx.author.id)
|
||||||
|
|
||||||
if not this_team:
|
if not this_team:
|
||||||
await ctx.send('Hmm...I can\'t find your team. Are you from around here?')
|
await ctx.send('Hmm...I can\'t find your team. Are you from around here?')
|
||||||
@ -2320,11 +2322,11 @@ class Players(commands.Cog):
|
|||||||
p_name = await fuzzy_player_search(
|
p_name = await fuzzy_player_search(
|
||||||
ctx, ctx.channel, self.bot, player_name, self.player_list.keys(), author=ctx.author
|
ctx, ctx.channel, self.bot, player_name, self.player_list.keys(), author=ctx.author
|
||||||
)
|
)
|
||||||
player = await get_player_by_name(current['season'], p_name)
|
player = await get_player_by_name(current.season, p_name)
|
||||||
|
|
||||||
p_query = await db_get('players', params=[('season', current['season'] - 1), ('name', p_name)])
|
p_query = await db_get('players', params=[('season', current.season - 1), ('name', p_name)])
|
||||||
if p_query['count'] == 0:
|
if p_query['count'] == 0:
|
||||||
await ctx.send(f'I could not find **{p_name}** from Season {current["season"] - 1}')
|
await ctx.send(f'I could not find **{p_name}** from Season {current.season - 1}')
|
||||||
return
|
return
|
||||||
|
|
||||||
player['vanity_card'] = p_query['players'][0]['vanity_card']
|
player['vanity_card'] = p_query['players'][0]['vanity_card']
|
||||||
@ -2391,8 +2393,8 @@ class Players(commands.Cog):
|
|||||||
# self, interaction: discord.Interaction, team_abbrev: str, keep1: str = None, keep2: str = None,
|
# self, interaction: discord.Interaction, team_abbrev: str, keep1: str = None, keep2: str = None,
|
||||||
# keep3: str = None, keep4: str = None, keep5: str = None, keep6: str = None, keep7: str = None):
|
# keep3: str = None, keep4: str = None, keep5: str = None, keep6: str = None, keep7: str = None):
|
||||||
# await interaction.response.defer()
|
# await interaction.response.defer()
|
||||||
# current = await db_get('current')
|
# current = await get_current()
|
||||||
# team = await get_team_by_abbrev(team_abbrev, current['season'])
|
# team = await get_team_by_abbrev(team_abbrev, current.season)
|
||||||
#
|
#
|
||||||
# keepers = []
|
# keepers = []
|
||||||
# keeper_string = ''
|
# keeper_string = ''
|
||||||
@ -2414,7 +2416,7 @@ class Players(commands.Cog):
|
|||||||
# p_name = await fuzzy_player_search(
|
# p_name = await fuzzy_player_search(
|
||||||
# interaction, interaction.channel, self.bot, x, self.player_list.keys(), author=interaction.user
|
# interaction, interaction.channel, self.bot, x, self.player_list.keys(), author=interaction.user
|
||||||
# )
|
# )
|
||||||
# this_p = await get_player_by_name(current['season'], p_name)
|
# this_p = await get_player_by_name(current.season, p_name)
|
||||||
# keepers.append(this_p)
|
# keepers.append(this_p)
|
||||||
# keeper_string += f'{get_pos_abbrev(this_p["pos_1"])} - {this_p["name"]} ({this_p["wara"]:.2f})\n'
|
# keeper_string += f'{get_pos_abbrev(this_p["pos_1"])} - {this_p["name"]} ({this_p["wara"]:.2f})\n'
|
||||||
# keeper_swar += this_p['wara']
|
# keeper_swar += this_p['wara']
|
||||||
@ -2423,7 +2425,7 @@ class Players(commands.Cog):
|
|||||||
# all_players = await db_get('players', api_ver=3, params=[('team_abbrev', team['abbrev'])])
|
# all_players = await db_get('players', api_ver=3, params=[('team_abbrev', team['abbrev'])])
|
||||||
# logger.info(f'all_players: {all_players}')
|
# logger.info(f'all_players: {all_players}')
|
||||||
#
|
#
|
||||||
# fa = await get_team_by_abbrev('FA', current['season'])
|
# fa = await get_team_by_abbrev('FA', current.season)
|
||||||
# for y in all_players['players']:
|
# for y in all_players['players']:
|
||||||
# if y not in keepers:
|
# if y not in keepers:
|
||||||
# y['team'] = fa
|
# y['team'] = fa
|
||||||
@ -2625,8 +2627,8 @@ class Players(commands.Cog):
|
|||||||
await interaction.channel.send(content=None, embed=embed)
|
await interaction.channel.send(content=None, embed=embed)
|
||||||
|
|
||||||
# this_roll = {
|
# this_roll = {
|
||||||
# 'season': self.current['season'],
|
# 'season': self.current.season,
|
||||||
# 'week': self.current['week'],
|
# 'week': self.current.week,
|
||||||
# 'team_id': team["id"] if team else None,
|
# 'team_id': team["id"] if team else None,
|
||||||
# 'roller': interaction.user.id,
|
# 'roller': interaction.user.id,
|
||||||
# 'threedsix': d_six_one + d_six_two + d_six_three
|
# 'threedsix': d_six_one + d_six_two + d_six_three
|
||||||
@ -2829,9 +2831,9 @@ class Players(commands.Cog):
|
|||||||
|
|
||||||
await interaction.response.defer()
|
await interaction.response.defer()
|
||||||
|
|
||||||
current = await db_get('current')
|
current = await get_current()
|
||||||
new_season = 10
|
new_season = 10
|
||||||
this_team = await get_team_by_owner(current['season'], interaction.user.id)
|
this_team = await get_team_by_owner(current.season, interaction.user.id)
|
||||||
|
|
||||||
if not this_team:
|
if not this_team:
|
||||||
await interaction.edit_original_response(content='Hmm...I can\'t find your team. Are you from around here?')
|
await interaction.edit_original_response(content='Hmm...I can\'t find your team. Are you from around here?')
|
||||||
|
|||||||
@ -2,6 +2,7 @@ import re
|
|||||||
import copy
|
import copy
|
||||||
|
|
||||||
from helpers import *
|
from helpers import *
|
||||||
|
from api_calls.current import get_current
|
||||||
from db_calls import db_get, db_patch, get_team_by_owner, get_team_by_abbrev, get_player_by_name, put_player, db_post
|
from db_calls import db_get, db_patch, get_team_by_owner, get_team_by_abbrev, get_player_by_name, put_player, db_post
|
||||||
from discord.ext import commands, tasks
|
from discord.ext import commands, tasks
|
||||||
OFFSEASON_FLAG = True
|
OFFSEASON_FLAG = True
|
||||||
@ -17,7 +18,7 @@ class SBaTransaction:
|
|||||||
self.channel = channel
|
self.channel = channel
|
||||||
self.gms = []
|
self.gms = []
|
||||||
self.current = current
|
self.current = current
|
||||||
self.effective_week = current['week'] + 1 if not this_week else current['week']
|
self.effective_week = current.week + 1 if not this_week else current.week
|
||||||
self.move_type = move_type
|
self.move_type = move_type
|
||||||
|
|
||||||
if first_team and team_role:
|
if first_team and team_role:
|
||||||
@ -125,13 +126,13 @@ class SBaTransaction:
|
|||||||
async def get_player_moves(self, player, this_week):
|
async def get_player_moves(self, player, this_week):
|
||||||
if this_week:
|
if this_week:
|
||||||
t_query = await db_get('transactions', params=[
|
t_query = await db_get('transactions', params=[
|
||||||
('season', self.current['season']), ('week_start', self.current['week']),
|
('season', self.current.season), ('week_start', self.current.week),
|
||||||
('week_end', self.current['season']), ('player_id', player['id'])
|
('week_end', self.current.season), ('player_id', player['id'])
|
||||||
])
|
])
|
||||||
return t_query['transactions']
|
return t_query['transactions']
|
||||||
else:
|
else:
|
||||||
t_query = await db_get('transactions', params=[
|
t_query = await db_get('transactions', params=[
|
||||||
('season', self.current['season']), ('week_start', self.effective_week),
|
('season', self.current.season), ('week_start', self.effective_week),
|
||||||
('week_end', self.effective_week), ('player_id', player['id'])
|
('week_end', self.effective_week), ('player_id', player['id'])
|
||||||
])
|
])
|
||||||
return t_query['transactions']
|
return t_query['transactions']
|
||||||
@ -140,19 +141,19 @@ class SBaTransaction:
|
|||||||
wara = 0
|
wara = 0
|
||||||
mil_wara = 0
|
mil_wara = 0
|
||||||
this_team = self.teams[team]['team']
|
this_team = self.teams[team]['team']
|
||||||
# team_roster = await get_players(self.current['season'], this_team['abbrev'])
|
# team_roster = await get_players(self.current.season, this_team['abbrev'])
|
||||||
t_query = await db_get('players', params=[
|
t_query = await db_get('players', params=[
|
||||||
('season', self.current['season']), ('team_id', this_team['id'])
|
('season', self.current.season), ('team_id', this_team['id'])
|
||||||
])
|
])
|
||||||
team_roster = t_query['players']
|
team_roster = t_query['players']
|
||||||
|
|
||||||
ml_query = await db_get('teams', params=[
|
ml_query = await db_get('teams', params=[
|
||||||
('season', self.current['season']), ('team_abbrev', f'{this_team["abbrev"]}MiL')
|
('season', self.current.season), ('team_abbrev', f'{this_team["abbrev"]}MiL')
|
||||||
])
|
])
|
||||||
# mil_roster = await get_players(self.current['season'], f'{this_team["abbrev"]}MiL')
|
# mil_roster = await get_players(self.current.season, f'{this_team["abbrev"]}MiL')
|
||||||
mil_team = await get_team_by_abbrev(f'{this_team["abbrev"]}MiL', season=this_team['season'])
|
mil_team = await get_team_by_abbrev(f'{this_team["abbrev"]}MiL', season=this_team['season'])
|
||||||
m_query = await db_get('players', params=[
|
m_query = await db_get('players', params=[
|
||||||
('season', self.current['season']), ('team_id', mil_team['id'])
|
('season', self.current.season), ('team_id', mil_team['id'])
|
||||||
])
|
])
|
||||||
mil_roster = m_query['players']
|
mil_roster = m_query['players']
|
||||||
|
|
||||||
@ -162,22 +163,22 @@ class SBaTransaction:
|
|||||||
mil_wara += player['wara']
|
mil_wara += player['wara']
|
||||||
|
|
||||||
logger.info(f'checking future moves')
|
logger.info(f'checking future moves')
|
||||||
if self.effective_week > self.current['week']:
|
if self.effective_week > self.current.week:
|
||||||
# set_moves = await get_transactions(
|
# set_moves = await get_transactions(
|
||||||
# self.current['season'], team_abbrev=this_team['abbrev'], week_start=self.effective_week,
|
# self.current.season, team_abbrev=this_team['abbrev'], week_start=self.effective_week,
|
||||||
# week_end=self.effective_week
|
# week_end=self.effective_week
|
||||||
# )
|
# )
|
||||||
t_query = await db_get('transactions', params=[
|
t_query = await db_get('transactions', params=[
|
||||||
('season', self.current['season']), ('week_start', self.effective_week),
|
('season', self.current.season), ('week_start', self.effective_week),
|
||||||
('week_end', self.effective_week), ('team_abbrev', this_team['abbrev'])
|
('week_end', self.effective_week), ('team_abbrev', this_team['abbrev'])
|
||||||
])
|
])
|
||||||
set_moves = t_query['transactions']
|
set_moves = t_query['transactions']
|
||||||
# freeze_moves = await get_transactions(
|
# freeze_moves = await get_transactions(
|
||||||
# self.current['season'], team_abbrev=this_team['abbrev'], week_start=self.effective_week,
|
# self.current.season, team_abbrev=this_team['abbrev'], week_start=self.effective_week,
|
||||||
# week_end=self.effective_week, frozen=True
|
# week_end=self.effective_week, frozen=True
|
||||||
# )
|
# )
|
||||||
t_query = await db_get('transactions', params=[
|
t_query = await db_get('transactions', params=[
|
||||||
('season', self.current['season']), ('week_start', self.effective_week),
|
('season', self.current.season), ('week_start', self.effective_week),
|
||||||
('week_end', self.effective_week), ('team_abbrev', this_team['abbrev']), ('frozen', True)
|
('week_end', self.effective_week), ('team_abbrev', this_team['abbrev']), ('frozen', True)
|
||||||
])
|
])
|
||||||
freeze_moves = t_query['transactions']
|
freeze_moves = t_query['transactions']
|
||||||
@ -223,7 +224,7 @@ class SBaTransaction:
|
|||||||
# logger.info(f'team roster: {team_roster}')
|
# logger.info(f'team roster: {team_roster}')
|
||||||
team_roster.remove(self.players[x]['player'])
|
team_roster.remove(self.players[x]['player'])
|
||||||
# 06-13: COMMENTED OUT TO RESOLVE MID-WEEK IL REPLACEMENT BEING SENT BACK DOWN
|
# 06-13: COMMENTED OUT TO RESOLVE MID-WEEK IL REPLACEMENT BEING SENT BACK DOWN
|
||||||
# if self.effective_week != self.current['week']:
|
# if self.effective_week != self.current.week:
|
||||||
wara -= self.players[x]['player']['wara']
|
wara -= self.players[x]['player']['wara']
|
||||||
|
|
||||||
# If player is leaving MiL team next week, remove from roster and subtract WARa
|
# If player is leaving MiL team next week, remove from roster and subtract WARa
|
||||||
@ -231,7 +232,7 @@ class SBaTransaction:
|
|||||||
logger.info(f'minor league player')
|
logger.info(f'minor league player')
|
||||||
mil_roster.remove(self.players[x]['player'])
|
mil_roster.remove(self.players[x]['player'])
|
||||||
# logger.info(f'mil roster: {mil_roster}')
|
# logger.info(f'mil roster: {mil_roster}')
|
||||||
if self.effective_week != self.current['week']:
|
if self.effective_week != self.current.week:
|
||||||
mil_wara -= self.players[x]['player']['wara']
|
mil_wara -= self.players[x]['player']['wara']
|
||||||
|
|
||||||
return {'roster': team_roster, 'wara': wara, 'mil_roster': mil_roster, 'mil_wara': mil_wara}
|
return {'roster': team_roster, 'wara': wara, 'mil_roster': mil_roster, 'mil_wara': mil_wara}
|
||||||
@ -239,18 +240,18 @@ class SBaTransaction:
|
|||||||
# async def check_minor_league_errors(self, ml_team_id):
|
# async def check_minor_league_errors(self, ml_team_id):
|
||||||
# wara = 0
|
# wara = 0
|
||||||
# this_team = await get_one_team(ml_team_id + 2)
|
# this_team = await get_one_team(ml_team_id + 2)
|
||||||
# team_roster = await get_players(self.current['season'], this_team['abbrev'])
|
# team_roster = await get_players(self.current.season, this_team['abbrev'])
|
||||||
#
|
#
|
||||||
# for player in team_roster:
|
# for player in team_roster:
|
||||||
# wara += team_roster[player]['wara']
|
# wara += team_roster[player]['wara']
|
||||||
#
|
#
|
||||||
# if self.effective_week > self.current['week']:
|
# if self.effective_week > self.current.week:
|
||||||
# set_moves = await get_transactions(
|
# set_moves = await get_transactions(
|
||||||
# self.current['season'], team_abbrev=this_team['abbrev'], week_start=self.effective_week,
|
# self.current.season, team_abbrev=this_team['abbrev'], week_start=self.effective_week,
|
||||||
# week_end=self.effective_week
|
# week_end=self.effective_week
|
||||||
# )
|
# )
|
||||||
# freeze_moves = await get_transactions(
|
# freeze_moves = await get_transactions(
|
||||||
# self.current['season'], team_abbrev=this_team['abbrev'], week_start=self.effective_week,
|
# self.current.season, team_abbrev=this_team['abbrev'], week_start=self.effective_week,
|
||||||
# week_end=self.effective_week, frozen=True
|
# week_end=self.effective_week, frozen=True
|
||||||
# )
|
# )
|
||||||
# moves = {**set_moves, **freeze_moves}
|
# moves = {**set_moves, **freeze_moves}
|
||||||
@ -274,19 +275,19 @@ class SBaTransaction:
|
|||||||
# # If player is leaving this team next week, remove from roster and subtract WARa
|
# # If player is leaving this team next week, remove from roster and subtract WARa
|
||||||
# elif self.players[x]['player']['team'] == this_team:
|
# elif self.players[x]['player']['team'] == this_team:
|
||||||
# team_roster.pop(self.players[x]['player']['name'], None)
|
# team_roster.pop(self.players[x]['player']['name'], None)
|
||||||
# if self.effective_week != self.current['week']:
|
# if self.effective_week != self.current.week:
|
||||||
# wara -= self.players[x]['player']['wara']
|
# wara -= self.players[x]['player']['wara']
|
||||||
#
|
#
|
||||||
# return {'roster': team_roster, 'wara': wara}
|
# return {'roster': team_roster, 'wara': wara}
|
||||||
|
|
||||||
async def send_transaction(self):
|
async def send_transaction(self):
|
||||||
team_id = list(self.teams.keys())[0]
|
team_id = list(self.teams.keys())[0]
|
||||||
moveid = f'Season-{self.current["season"]:03d}-Week-{self.effective_week:0>2}-{datetime.datetime.now().strftime("%d-%H:%M:%S")}'
|
moveid = f'Season-{self.current.season:03d}-Week-{self.effective_week:0>2}-{datetime.datetime.now().strftime("%d-%H:%M:%S")}'
|
||||||
moves = []
|
moves = []
|
||||||
|
|
||||||
logger.warning(f'move_id: {moveid} / move_type: {self.move_type} / avoid_freeze: {self.avoid_freeze} / '
|
logger.warning(f'move_id: {moveid} / move_type: {self.move_type} / avoid_freeze: {self.avoid_freeze} / '
|
||||||
f'week: {self.current["week"]}')
|
f'week: {self.current.week}')
|
||||||
if self.current['freeze'] and not self.avoid_freeze:
|
if self.current.freeze and not self.avoid_freeze:
|
||||||
frozen = True
|
frozen = True
|
||||||
else:
|
else:
|
||||||
frozen = False
|
frozen = False
|
||||||
@ -297,7 +298,7 @@ class SBaTransaction:
|
|||||||
'player_id': self.players[x]['player']['id'],
|
'player_id': self.players[x]['player']['id'],
|
||||||
'oldteam_id': self.players[x]['player']['team']['id'],
|
'oldteam_id': self.players[x]['player']['team']['id'],
|
||||||
'newteam_id': self.players[x]['to']['id'],
|
'newteam_id': self.players[x]['to']['id'],
|
||||||
'season': self.current['season'],
|
'season': self.current.season,
|
||||||
'moveid': moveid,
|
'moveid': moveid,
|
||||||
'frozen': frozen
|
'frozen': frozen
|
||||||
})
|
})
|
||||||
@ -344,19 +345,19 @@ class Transactions(commands.Cog):
|
|||||||
if OFFSEASON_FLAG:
|
if OFFSEASON_FLAG:
|
||||||
return
|
return
|
||||||
|
|
||||||
current = await db_get('current')
|
current = await get_current()
|
||||||
now = datetime.datetime.now()
|
now = datetime.datetime.now()
|
||||||
logger.debug(f'Datetime: {now} / weekday: {now.weekday()}')
|
logger.debug(f'Datetime: {now} / weekday: {now.weekday()}')
|
||||||
|
|
||||||
# Begin Freeze
|
# Begin Freeze
|
||||||
# if now.weekday() == 0 and now.hour == 5 and not current['freeze']: # Spring/Summer
|
# if now.weekday() == 0 and now.hour == 5 and not current.freeze: # Spring/Summer
|
||||||
if now.weekday() == 0 and now.hour == 0 and not current['freeze']: # Fall/Winter
|
if now.weekday() == 0 and now.hour == 0 and not current.freeze: # Fall/Winter
|
||||||
current['week'] += 1
|
current.week += 1
|
||||||
await db_patch('current', object_id=current['id'], params=[('week', current['week']), ('freeze', True)])
|
await db_patch('current', object_id=current['id'], params=[('week', current.week), ('freeze', True)])
|
||||||
await self.run_transactions(current)
|
await self.run_transactions(current)
|
||||||
|
|
||||||
logger.debug(f'Building freeze string')
|
logger.debug(f'Building freeze string')
|
||||||
week_num = f'Week {current["week"]}'
|
week_num = f'Week {current.week}'
|
||||||
stars = f'{"":*<32}'
|
stars = f'{"":*<32}'
|
||||||
freeze_message = f'```\n' \
|
freeze_message = f'```\n' \
|
||||||
f'{stars}\n'\
|
f'{stars}\n'\
|
||||||
@ -365,15 +366,15 @@ class Transactions(commands.Cog):
|
|||||||
logger.debug(f'Freeze string:\n\n{freeze_message}')
|
logger.debug(f'Freeze string:\n\n{freeze_message}')
|
||||||
await send_to_channel(self.bot, 'transaction-log', freeze_message)
|
await send_to_channel(self.bot, 'transaction-log', freeze_message)
|
||||||
|
|
||||||
if current['week'] > 0 and current['week'] <= 18:
|
if current.week > 0 and current.week <= 18:
|
||||||
await self.post_weekly_info(current)
|
await self.post_weekly_info(current)
|
||||||
|
|
||||||
# End Freeze
|
# End Freeze
|
||||||
# elif now.weekday() == 5 and now.hour == 5 and current['freeze']: # Spring/Summer
|
# elif now.weekday() == 5 and now.hour == 5 and current.freeze: # Spring/Summer
|
||||||
elif now.weekday() == 5 and now.hour == 0 and current['freeze']: # Fall/Winter
|
elif now.weekday() == 5 and now.hour == 0 and current.freeze: # Fall/Winter
|
||||||
await db_patch('current', object_id=current['id'], params=[('freeze', False)])
|
await db_patch('current', object_id=current['id'], params=[('freeze', False)])
|
||||||
|
|
||||||
week_num = f'Week {current["week"]}'
|
week_num = f'Week {current.week}'
|
||||||
stars = f'{"":*<30}'
|
stars = f'{"":*<30}'
|
||||||
freeze_message = f'```\n' \
|
freeze_message = f'```\n' \
|
||||||
f'{stars}\n'\
|
f'{stars}\n'\
|
||||||
@ -389,7 +390,7 @@ class Transactions(commands.Cog):
|
|||||||
|
|
||||||
async def run_transactions(self, current):
|
async def run_transactions(self, current):
|
||||||
m_query = await db_get('transactions', params=[
|
m_query = await db_get('transactions', params=[
|
||||||
('season', current['season']), ('week_start', current['week']), ('week_end', current['week'])
|
('season', current.season), ('week_start', current.week), ('week_end', current.week)
|
||||||
])
|
])
|
||||||
if m_query['count'] == 0:
|
if m_query['count'] == 0:
|
||||||
return
|
return
|
||||||
@ -399,9 +400,9 @@ class Transactions(commands.Cog):
|
|||||||
# try:
|
# try:
|
||||||
# if (move['newteam']['abbrev'][-3:] == 'MiL' and move['oldteam']['abbrev'] == 'FA') or \
|
# if (move['newteam']['abbrev'][-3:] == 'MiL' and move['oldteam']['abbrev'] == 'FA') or \
|
||||||
# move['newteam']['abbrev'][-2:] == 'IL' or move['newteam']['abbrev'].lower() == 'fa':
|
# move['newteam']['abbrev'][-2:] == 'IL' or move['newteam']['abbrev'].lower() == 'fa':
|
||||||
# dem_week = current['week']
|
# dem_week = current.week
|
||||||
# else:
|
# else:
|
||||||
# dem_week = current['week'] + 1
|
# dem_week = current.week + 1
|
||||||
#
|
#
|
||||||
# await patch_player(
|
# await patch_player(
|
||||||
# move['player']['id'],
|
# move['player']['id'],
|
||||||
@ -414,9 +415,9 @@ class Transactions(commands.Cog):
|
|||||||
for x in all_moves:
|
for x in all_moves:
|
||||||
if (x['newteam']['abbrev'][-3:] == 'MiL' and x['oldteam']['abbrev'] == 'FA') or \
|
if (x['newteam']['abbrev'][-3:] == 'MiL' and x['oldteam']['abbrev'] == 'FA') or \
|
||||||
x['newteam']['abbrev'][-2:] == 'IL' or x['newteam']['abbrev'] == 'FA':
|
x['newteam']['abbrev'][-2:] == 'IL' or x['newteam']['abbrev'] == 'FA':
|
||||||
dem_week = current['week']
|
dem_week = current.week
|
||||||
else:
|
else:
|
||||||
dem_week = current['week'] + 1
|
dem_week = current.week + 1
|
||||||
|
|
||||||
x['player']['team'] = x['newteam']
|
x['player']['team'] = x['newteam']
|
||||||
x['player']['demotion_week'] = dem_week
|
x['player']['demotion_week'] = dem_week
|
||||||
@ -444,17 +445,17 @@ class Transactions(commands.Cog):
|
|||||||
|
|
||||||
async def process_freeze_moves(self, current):
|
async def process_freeze_moves(self, current):
|
||||||
# all_moves = await get_transactions(
|
# all_moves = await get_transactions(
|
||||||
# season=current['season'],
|
# season=current.season,
|
||||||
# week_start=current['week'],
|
# week_start=current.week,
|
||||||
# week_end=current['week'] + 1,
|
# week_end=current.week + 1,
|
||||||
# frozen=True
|
# frozen=True
|
||||||
# )
|
# )
|
||||||
m_query = await db_get('transactions', params=[
|
m_query = await db_get('transactions', params=[
|
||||||
('season', current['season']), ('week_start', current['week']), ('week_end', current['week'] + 1),
|
('season', current.season), ('week_start', current.week), ('week_end', current.week + 1),
|
||||||
('frozen', True)
|
('frozen', True)
|
||||||
])
|
])
|
||||||
if m_query['count'] == 0:
|
if m_query['count'] == 0:
|
||||||
logger.warning(f'No transactions to process for the freeze in week {current["week"]}')
|
logger.warning(f'No transactions to process for the freeze in week {current.week}')
|
||||||
return
|
return
|
||||||
|
|
||||||
moves = m_query['transactions']
|
moves = m_query['transactions']
|
||||||
@ -466,16 +467,16 @@ class Transactions(commands.Cog):
|
|||||||
|
|
||||||
for move in moves:
|
for move in moves:
|
||||||
if move['newteam']['abbrev'][-3:] == 'MiL':
|
if move['newteam']['abbrev'][-3:] == 'MiL':
|
||||||
new_team = await get_team_by_abbrev(move['newteam']['abbrev'][:-3], current['season'])
|
new_team = await get_team_by_abbrev(move['newteam']['abbrev'][:-3], current.season)
|
||||||
else:
|
else:
|
||||||
new_team = move['newteam']
|
new_team = move['newteam']
|
||||||
# team_record = await get_team_record(new_team, week_num=current["week"])
|
# team_record = await get_team_record(new_team, week_num=current.week)
|
||||||
|
|
||||||
if new_team['abbrev'] == 'FA':
|
if new_team['abbrev'] == 'FA':
|
||||||
win_pct = 0
|
win_pct = 0
|
||||||
else:
|
else:
|
||||||
r_query = await db_get('standings', params=[
|
r_query = await db_get('standings', params=[
|
||||||
('season', current['season']), ('team_id', new_team['id'])
|
('season', current.season), ('team_id', new_team['id'])
|
||||||
])
|
])
|
||||||
win_pct = r_query['standings'][0]['wins'] / (
|
win_pct = r_query['standings'][0]['wins'] / (
|
||||||
r_query['standings'][0]['wins'] + r_query['standings'][0]['losses'])
|
r_query['standings'][0]['wins'] + r_query['standings'][0]['losses'])
|
||||||
@ -515,13 +516,13 @@ class Transactions(commands.Cog):
|
|||||||
|
|
||||||
# Post transactions that are not cancelled
|
# Post transactions that are not cancelled
|
||||||
# final_moves = await get_transactions(
|
# final_moves = await get_transactions(
|
||||||
# season=current['season'],
|
# season=current.season,
|
||||||
# week_start=current["week"],
|
# week_start=current.week,
|
||||||
# week_end=current["week"] + 1,
|
# week_end=current.week + 1,
|
||||||
# frozen=True
|
# frozen=True
|
||||||
# )
|
# )
|
||||||
m_query = await db_get('transactions', params=[
|
m_query = await db_get('transactions', params=[
|
||||||
('season', current['season']), ('week_start', current['week']), ('week_end', current['week'] + 1),
|
('season', current.season), ('week_start', current.week), ('week_end', current.week + 1),
|
||||||
('frozen', True)
|
('frozen', True)
|
||||||
])
|
])
|
||||||
final_moves = m_query['transactions']
|
final_moves = m_query['transactions']
|
||||||
@ -538,13 +539,13 @@ class Transactions(commands.Cog):
|
|||||||
await self.post_move_to_transaction_log(move_id)
|
await self.post_move_to_transaction_log(move_id)
|
||||||
|
|
||||||
async def post_move_to_transaction_log(self, move_id):
|
async def post_move_to_transaction_log(self, move_id):
|
||||||
current = await db_get('current')
|
current = await get_current()
|
||||||
# all_moves = await get_transactions(
|
# all_moves = await get_transactions(
|
||||||
# season=current['season'],
|
# season=current.season,
|
||||||
# move_id=move_id
|
# move_id=move_id
|
||||||
# )
|
# )
|
||||||
m_query = await db_get('transactions', params=[
|
m_query = await db_get('transactions', params=[
|
||||||
('season', current['season']), ('move_id', move_id)
|
('season', current.season), ('move_id', move_id)
|
||||||
])
|
])
|
||||||
all_moves = m_query['transactions']
|
all_moves = m_query['transactions']
|
||||||
|
|
||||||
@ -584,12 +585,12 @@ class Transactions(commands.Cog):
|
|||||||
day_str = '\U0001F31E Day'
|
day_str = '\U0001F31E Day'
|
||||||
|
|
||||||
season_str = f'\U0001F3D6 **Summer**'
|
season_str = f'\U0001F3D6 **Summer**'
|
||||||
if current['week'] <= 5:
|
if current.week <= 5:
|
||||||
season_str = f'\U0001F33C **Spring**'
|
season_str = f'\U0001F33C **Spring**'
|
||||||
elif current['week'] > 14:
|
elif current.week > 14:
|
||||||
season_str = f'\U0001F342 **Fall**'
|
season_str = f'\U0001F342 **Fall**'
|
||||||
|
|
||||||
is_div_week = current['week'] in [1, 3, 6, 14, 16, 18]
|
is_div_week = current.week in [1, 3, 6, 14, 16, 18]
|
||||||
|
|
||||||
weekly_str = f'**Season**: {season_str}\n' \
|
weekly_str = f'**Season**: {season_str}\n' \
|
||||||
f'**Time of Day**: {night_str} / {night_str if is_div_week else day_str} / ' \
|
f'**Time of Day**: {night_str} / {night_str if is_div_week else day_str} / ' \
|
||||||
@ -615,14 +616,14 @@ class Transactions(commands.Cog):
|
|||||||
@commands.command(name='run_transactions')
|
@commands.command(name='run_transactions')
|
||||||
@commands.is_owner()
|
@commands.is_owner()
|
||||||
async def run_transactions_helper_command(self, ctx):
|
async def run_transactions_helper_command(self, ctx):
|
||||||
current = await db_get('current')
|
current = await get_current()
|
||||||
await self.run_transactions(current)
|
await self.run_transactions(current)
|
||||||
await ctx.send(new_rand_conf_gif())
|
await ctx.send(new_rand_conf_gif())
|
||||||
|
|
||||||
@commands.command(name='process_freeze')
|
@commands.command(name='process_freeze')
|
||||||
@commands.is_owner()
|
@commands.is_owner()
|
||||||
async def process_freeze_helper_command(self, ctx):
|
async def process_freeze_helper_command(self, ctx):
|
||||||
current = await db_get('current')
|
current = await get_current()
|
||||||
await self.process_freeze_moves(current)
|
await self.process_freeze_moves(current)
|
||||||
await ctx.send(random_conf_gif())
|
await ctx.send(random_conf_gif())
|
||||||
|
|
||||||
@ -635,19 +636,19 @@ class Transactions(commands.Cog):
|
|||||||
name='trade', aliases=['tradeplz', 'pleasetrade', 'tradeplease', 'plztrade'], help='Trade players')
|
name='trade', aliases=['tradeplz', 'pleasetrade', 'tradeplease', 'plztrade'], help='Trade players')
|
||||||
@commands.has_any_role(SBA_PLAYERS_ROLE_NAME)
|
@commands.has_any_role(SBA_PLAYERS_ROLE_NAME)
|
||||||
async def trade_command(self, ctx):
|
async def trade_command(self, ctx):
|
||||||
current = await db_get('current')
|
current = await get_current()
|
||||||
|
|
||||||
if current['week'] > current['trade_deadline']:
|
if current.week > current.trade_deadline:
|
||||||
await ctx.send(await get_emoji(ctx, 'oof', False))
|
await ctx.send(await get_emoji(ctx, 'oof', False))
|
||||||
await ctx.send(f'The trade deadline is **week {current["trade_deadline"]}**. Since it is currently **week '
|
await ctx.send(f'The trade deadline is **week {current.trade_deadline}**. Since it is currently **week '
|
||||||
f'{current["week"]}** I am just going to stop you right there.')
|
f'{current.week}** I am just going to stop you right there.')
|
||||||
return
|
return
|
||||||
if current['week'] < -2:
|
if current.week < -2:
|
||||||
await ctx.send(await get_emoji(ctx, 'oof', False))
|
await ctx.send(await get_emoji(ctx, 'oof', False))
|
||||||
await ctx.send(f'Patience, grasshopper. Trades open soon.')
|
await ctx.send(f'Patience, grasshopper. Trades open soon.')
|
||||||
return
|
return
|
||||||
|
|
||||||
team = await get_team_by_owner(current['season'], ctx.author.id)
|
team = await get_team_by_owner(current.season, ctx.author.id)
|
||||||
if team is None:
|
if team is None:
|
||||||
await ctx.send(f'Who are you? Why are you talking to me, you don\'t have a team.')
|
await ctx.send(f'Who are you? Why are you talking to me, you don\'t have a team.')
|
||||||
return
|
return
|
||||||
@ -721,7 +722,7 @@ class Transactions(commands.Cog):
|
|||||||
await trade.timed_delete()
|
await trade.timed_delete()
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
next_team = await get_team_by_abbrev(resp, current['season'])
|
next_team = await get_team_by_abbrev(resp, current.season)
|
||||||
if next_team is None:
|
if next_team is None:
|
||||||
await trade.send('Who the fuck even is that? Try again.')
|
await trade.send('Who the fuck even is that? Try again.')
|
||||||
else:
|
else:
|
||||||
@ -753,7 +754,7 @@ class Transactions(commands.Cog):
|
|||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
player = await get_player_by_name(
|
player = await get_player_by_name(
|
||||||
current['season'],
|
current.season,
|
||||||
await fuzzy_player_search(ctx, trade.channel, self.bot, resp, player_cog.player_list.keys())
|
await fuzzy_player_search(ctx, trade.channel, self.bot, resp, player_cog.player_list.keys())
|
||||||
)
|
)
|
||||||
except ValueError as e:
|
except ValueError as e:
|
||||||
@ -778,7 +779,7 @@ class Transactions(commands.Cog):
|
|||||||
await trade.send('RIP this move. Maybe next time.')
|
await trade.send('RIP this move. Maybe next time.')
|
||||||
await trade.timed_delete()
|
await trade.timed_delete()
|
||||||
else:
|
else:
|
||||||
dest_team = await get_team_by_abbrev(resp, current['season'])
|
dest_team = await get_team_by_abbrev(resp, current.season)
|
||||||
if dest_team is None:
|
if dest_team is None:
|
||||||
await trade.send(f'{await get_emoji(ctx, "facepalm")} They aren\'t even part of '
|
await trade.send(f'{await get_emoji(ctx, "facepalm")} They aren\'t even part of '
|
||||||
f'this trade. Come on.')
|
f'this trade. Come on.')
|
||||||
@ -795,12 +796,12 @@ class Transactions(commands.Cog):
|
|||||||
await trade.show_moves()
|
await trade.show_moves()
|
||||||
|
|
||||||
# Get pick trades
|
# Get pick trades
|
||||||
# while True and current['pick_trade_end'] >= current['week'] >= current['pick_trade_start']:
|
# while True and current.pick_trade_end >= current.week >= current.pick_trade_start:
|
||||||
# prompt = f'Are you trading any draft picks?'
|
# prompt = f'Are you trading any draft picks?'
|
||||||
# this_q = Question(self.bot, trade.channel, prompt, 'yesno', 300)
|
# this_q = Question(self.bot, trade.channel, prompt, 'yesno', 300)
|
||||||
# resp = await this_q.ask(trade.get_gms(self.bot))
|
# resp = await this_q.ask(trade.get_gms(self.bot))
|
||||||
# effective_season = current['season'] if OFFSEASON_FLAG else current['season'] + 1
|
# effective_season = current.season if OFFSEASON_FLAG else current.season + 1
|
||||||
# team_season = current['season']
|
# team_season = current.season
|
||||||
#
|
#
|
||||||
# if resp is None:
|
# if resp is None:
|
||||||
# await trade.send('RIP this move. Maybe next time.')
|
# await trade.send('RIP this move. Maybe next time.')
|
||||||
@ -878,7 +879,7 @@ class Transactions(commands.Cog):
|
|||||||
|
|
||||||
# FA drops per team
|
# FA drops per team
|
||||||
|
|
||||||
if current['week'] > 0:
|
if current.week > 0:
|
||||||
for team in trade.teams:
|
for team in trade.teams:
|
||||||
while True:
|
while True:
|
||||||
this_q.prompt = f'{trade.teams[team]["role"].mention}\nAre you making an FA drop?'
|
this_q.prompt = f'{trade.teams[team]["role"].mention}\nAre you making an FA drop?'
|
||||||
@ -903,7 +904,7 @@ class Transactions(commands.Cog):
|
|||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
player = await get_player_by_name(
|
player = await get_player_by_name(
|
||||||
current['season'],
|
current.season,
|
||||||
await fuzzy_player_search(ctx, trade.channel, self.bot, resp, player_cog.player_list.keys())
|
await fuzzy_player_search(ctx, trade.channel, self.bot, resp, player_cog.player_list.keys())
|
||||||
)
|
)
|
||||||
except ValueError as e:
|
except ValueError as e:
|
||||||
@ -916,11 +917,11 @@ class Transactions(commands.Cog):
|
|||||||
if not trade.included_team(player['team']):
|
if not trade.included_team(player['team']):
|
||||||
await t_channel.send(f'It looks like {player.name} is on {player.team.abbrev} '
|
await t_channel.send(f'It looks like {player.name} is on {player.team.abbrev} '
|
||||||
f'so I can\'t let you do that.')
|
f'so I can\'t let you do that.')
|
||||||
# elif player['demotion_week'] > current['week']:
|
# elif player['demotion_week'] > current.week:
|
||||||
# await trade.send(f'Oof. {player["name"]} cannot be dropped until week '
|
# await trade.send(f'Oof. {player["name"]} cannot be dropped until week '
|
||||||
# f'{player["demotion_week"]}.')
|
# f'{player["demotion_week"]}.')
|
||||||
else:
|
else:
|
||||||
dest_team = await get_team_by_abbrev('FA', current['season'])
|
dest_team = await get_team_by_abbrev('FA', current.season)
|
||||||
await trade.add_player(player, dest_team)
|
await trade.add_player(player, dest_team)
|
||||||
|
|
||||||
await trade.show_moves()
|
await trade.show_moves()
|
||||||
@ -983,7 +984,7 @@ class Transactions(commands.Cog):
|
|||||||
await trade.send(f'All done! Your transaction id is: {trans_id}')
|
await trade.send(f'All done! Your transaction id is: {trans_id}')
|
||||||
try:
|
try:
|
||||||
choas = get_role(ctx, 'CHOAS ALERT')
|
choas = get_role(ctx, 'CHOAS ALERT')
|
||||||
await send_to_channel(self.bot, f'season-{current["season"]}-chat', f'{choas.mention}')
|
await send_to_channel(self.bot, f'season-{current.season}-chat', f'{choas.mention}')
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(f'Couldn\'t ping chaos for a trade')
|
logger.error(f'Couldn\'t ping chaos for a trade')
|
||||||
await trade.timed_delete()
|
await trade.timed_delete()
|
||||||
@ -991,9 +992,9 @@ class Transactions(commands.Cog):
|
|||||||
# @commands.command(name='picktrade', help='Trade draft picks', hidden=True)
|
# @commands.command(name='picktrade', help='Trade draft picks', hidden=True)
|
||||||
# @commands.is_owner()
|
# @commands.is_owner()
|
||||||
# async def pick_trade_command(self, ctx):
|
# async def pick_trade_command(self, ctx):
|
||||||
# current = await db_get('current')
|
# current = await get_current()
|
||||||
#
|
#
|
||||||
# if current['week'] < -2:
|
# if current.week < -2:
|
||||||
# await ctx.send(await get_emoji(ctx, 'oof', False))
|
# await ctx.send(await get_emoji(ctx, 'oof', False))
|
||||||
# await ctx.send(f'Patience, grasshopper. Trades open up Monday.')
|
# await ctx.send(f'Patience, grasshopper. Trades open up Monday.')
|
||||||
# return
|
# return
|
||||||
@ -1002,7 +1003,7 @@ class Transactions(commands.Cog):
|
|||||||
# await ctx.send(f'You\'ll have to wait, hoss. No pick trades until the offseason.')
|
# await ctx.send(f'You\'ll have to wait, hoss. No pick trades until the offseason.')
|
||||||
# return
|
# return
|
||||||
#
|
#
|
||||||
# team = await get_team_by_owner(current['season'], ctx.author.id)
|
# team = await get_team_by_owner(current.season, ctx.author.id)
|
||||||
# team_role = get_team_role(ctx, team)
|
# team_role = get_team_role(ctx, team)
|
||||||
# player_cog = self.bot.get_cog('Players')
|
# player_cog = self.bot.get_cog('Players')
|
||||||
#
|
#
|
||||||
@ -1062,7 +1063,7 @@ class Transactions(commands.Cog):
|
|||||||
# return
|
# return
|
||||||
# else:
|
# else:
|
||||||
# try:
|
# try:
|
||||||
# next_team = await get_team_by_abbrev(resp, current['season'])
|
# next_team = await get_team_by_abbrev(resp, current.season)
|
||||||
# except ValueError:
|
# except ValueError:
|
||||||
# await trade.send('Who the fuck even is that? Try again.')
|
# await trade.send('Who the fuck even is that? Try again.')
|
||||||
# else:
|
# else:
|
||||||
@ -1077,8 +1078,8 @@ class Transactions(commands.Cog):
|
|||||||
# prompt = f'Are you trading any draft picks?'
|
# prompt = f'Are you trading any draft picks?'
|
||||||
# this_q = Question(self.bot, trade.channel, prompt, 'yesno', 300)
|
# this_q = Question(self.bot, trade.channel, prompt, 'yesno', 300)
|
||||||
# resp = await this_q.ask(trade.get_gms(self.bot))
|
# resp = await this_q.ask(trade.get_gms(self.bot))
|
||||||
# effective_season = current['season'] if OFFSEASON_FLAG else current['season'] + 1
|
# effective_season = current.season if OFFSEASON_FLAG else current.season + 1
|
||||||
# team_season = current['season']
|
# team_season = current.season
|
||||||
#
|
#
|
||||||
# if resp is None:
|
# if resp is None:
|
||||||
# await trade.send('RIP this move. Maybe next time.')
|
# await trade.send('RIP this move. Maybe next time.')
|
||||||
@ -1198,7 +1199,7 @@ class Transactions(commands.Cog):
|
|||||||
# await trade.send(f'All done! Your transaction id is: {trans_id}')
|
# await trade.send(f'All done! Your transaction id is: {trans_id}')
|
||||||
# try:
|
# try:
|
||||||
# choas = get_role(ctx, 'CHOAS ALERT')
|
# choas = get_role(ctx, 'CHOAS ALERT')
|
||||||
# await send_to_channel(self.bot, f'season-{current["season"]}-chat', f'{choas.mention}')
|
# await send_to_channel(self.bot, f'season-{current.season}-chat', f'{choas.mention}')
|
||||||
# except Exception as e:
|
# except Exception as e:
|
||||||
# logger.error('I was not able to ping CHOAS ALERT')
|
# logger.error('I was not able to ping CHOAS ALERT')
|
||||||
# await trade.timed_delete()
|
# await trade.timed_delete()
|
||||||
@ -1206,22 +1207,22 @@ class Transactions(commands.Cog):
|
|||||||
@commands.command(name='dropadd', aliases=['drop', 'add', 'adddrop', 'longil'], help='FA/MiL moves')
|
@commands.command(name='dropadd', aliases=['drop', 'add', 'adddrop', 'longil'], help='FA/MiL moves')
|
||||||
@commands.has_any_role(SBA_PLAYERS_ROLE_NAME)
|
@commands.has_any_role(SBA_PLAYERS_ROLE_NAME)
|
||||||
async def drop_add_command(self, ctx):
|
async def drop_add_command(self, ctx):
|
||||||
current = await db_get('current')
|
current = await get_current()
|
||||||
team = await get_team_by_owner(current['season'], ctx.author.id)
|
team = await get_team_by_owner(current.season, ctx.author.id)
|
||||||
# team_schedule = await get_schedule(
|
# team_schedule = await get_schedule(
|
||||||
# current['season'],
|
# current.season,
|
||||||
# team_abbrev1=team["abbrev"],
|
# team_abbrev1=team["abbrev"],
|
||||||
# week_start=current['week'] + 1,
|
# week_start=current.week + 1,
|
||||||
# week_end=current['week'] + 1,
|
# week_end=current.week + 1,
|
||||||
# )
|
# )
|
||||||
s_query = await db_get('games', params=[
|
s_query = await db_get('games', params=[
|
||||||
('season', current['season']), ('team1_id', team['id']), ('week', current['week'] + 1)
|
('season', current.season), ('team1_id', team['id']), ('week', current.week + 1)
|
||||||
])
|
])
|
||||||
team_role = get_team_role(ctx, team)
|
team_role = get_team_role(ctx, team)
|
||||||
player_cog = self.bot.get_cog('Players')
|
player_cog = self.bot.get_cog('Players')
|
||||||
poke_role = get_role(ctx, 'Pokétwo')
|
poke_role = get_role(ctx, 'Pokétwo')
|
||||||
|
|
||||||
if s_query['count'] == 0 and not OFFSEASON_FLAG and current['week'] != 18:
|
if s_query['count'] == 0 and not OFFSEASON_FLAG and current.week != 18:
|
||||||
await ctx.send('It looks like your season is over so transactions are locked.')
|
await ctx.send('It looks like your season is over so transactions are locked.')
|
||||||
return
|
return
|
||||||
|
|
||||||
@ -1247,7 +1248,7 @@ class Transactions(commands.Cog):
|
|||||||
await dropadd.send(f'Let\'s start here, {team_role.mention}')
|
await dropadd.send(f'Let\'s start here, {team_role.mention}')
|
||||||
await ctx.send(f'Take my hand... {dropadd.channel.mention}')
|
await ctx.send(f'Take my hand... {dropadd.channel.mention}')
|
||||||
await dropadd.send(f'This transaction is for __next week__. It will go into effect for '
|
await dropadd.send(f'This transaction is for __next week__. It will go into effect for '
|
||||||
f'week {current["week"] + 1}.')
|
f'week {current.week + 1}.')
|
||||||
|
|
||||||
# Get MiL moves
|
# Get MiL moves
|
||||||
while True and not OFFSEASON_FLAG:
|
while True and not OFFSEASON_FLAG:
|
||||||
@ -1273,7 +1274,7 @@ class Transactions(commands.Cog):
|
|||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
player = await get_player_by_name(
|
player = await get_player_by_name(
|
||||||
current['season'],
|
current.season,
|
||||||
await fuzzy_player_search(ctx, dropadd.channel, self.bot, resp, player_cog.player_list.keys())
|
await fuzzy_player_search(ctx, dropadd.channel, self.bot, resp, player_cog.player_list.keys())
|
||||||
)
|
)
|
||||||
except ValueError as e:
|
except ValueError as e:
|
||||||
@ -1283,16 +1284,16 @@ class Transactions(commands.Cog):
|
|||||||
await dropadd.send(f'{await get_emoji(ctx, "squint")}')
|
await dropadd.send(f'{await get_emoji(ctx, "squint")}')
|
||||||
await dropadd.send('Who even is that? Try again.')
|
await dropadd.send('Who even is that? Try again.')
|
||||||
else:
|
else:
|
||||||
fa_team = await get_team_by_abbrev('FA', current['season'])
|
fa_team = await get_team_by_abbrev('FA', current.season)
|
||||||
dest_team = await get_team_by_abbrev(f'{team["abbrev"]}MiL', current['season'])
|
dest_team = await get_team_by_abbrev(f'{team["abbrev"]}MiL', current.season)
|
||||||
if current['week'] >= FA_LOCK_WEEK and player['team'] == fa_team:
|
if current.week >= FA_LOCK_WEEK and player['team'] == fa_team:
|
||||||
await dropadd.send(f'FA transactions are locked starting in Week {FA_LOCK_WEEK} so I gotta say no. For more information, search for Rule 34 Draft.')
|
await dropadd.send(f'FA transactions are locked starting in Week {FA_LOCK_WEEK} so I gotta say no. For more information, search for Rule 34 Draft.')
|
||||||
elif not dropadd.included_team(player['team']) and player['team'] != fa_team:
|
elif not dropadd.included_team(player['team']) and player['team'] != fa_team:
|
||||||
await t_channel.send(f'It looks like {player["name"]} is on {player["team"]["abbrev"]} '
|
await t_channel.send(f'It looks like {player["name"]} is on {player["team"]["abbrev"]} '
|
||||||
f'so I can\'t let you do that.')
|
f'so I can\'t let you do that.')
|
||||||
elif await dropadd.not_available(player):
|
elif await dropadd.not_available(player):
|
||||||
await dropadd.send(f'Uh oh, looks like {player["name"]} is already on the move next week.')
|
await dropadd.send(f'Uh oh, looks like {player["name"]} is already on the move next week.')
|
||||||
elif player['demotion_week'] > current['week']:
|
elif player['demotion_week'] > current.week:
|
||||||
await dropadd.send(f'Oof. {player["name"]} cannot be dropped until week '
|
await dropadd.send(f'Oof. {player["name"]} cannot be dropped until week '
|
||||||
f'{player["demotion_week"]}.')
|
f'{player["demotion_week"]}.')
|
||||||
else:
|
else:
|
||||||
@ -1326,7 +1327,7 @@ class Transactions(commands.Cog):
|
|||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
player = await get_player_by_name(
|
player = await get_player_by_name(
|
||||||
current['season'],
|
current.season,
|
||||||
await fuzzy_player_search(ctx, dropadd.channel, self.bot, resp, player_cog.player_list.keys())
|
await fuzzy_player_search(ctx, dropadd.channel, self.bot, resp, player_cog.player_list.keys())
|
||||||
)
|
)
|
||||||
except ValueError as e:
|
except ValueError as e:
|
||||||
@ -1343,8 +1344,8 @@ class Transactions(commands.Cog):
|
|||||||
else:
|
else:
|
||||||
await dropadd.add_player(player, team)
|
await dropadd.add_player(player, team)
|
||||||
else:
|
else:
|
||||||
fa_team = await get_team_by_abbrev('FA', current['season'])
|
fa_team = await get_team_by_abbrev('FA', current.season)
|
||||||
if current['week'] >= FA_LOCK_WEEK and player['team'] == fa_team:
|
if current.week >= FA_LOCK_WEEK and player['team'] == fa_team:
|
||||||
await dropadd.send(f'FA transactions are locked starting in Week {FA_LOCK_WEEK} so I gotta say no. For more information, run !rule34 <player name>.')
|
await dropadd.send(f'FA transactions are locked starting in Week {FA_LOCK_WEEK} so I gotta say no. For more information, run !rule34 <player name>.')
|
||||||
elif player['team'] != fa_team and not self.on_team_il(team, player):
|
elif player['team'] != fa_team and not self.on_team_il(team, player):
|
||||||
await t_channel.send(f'It looks like {player["name"]} is on {player["team"]["abbrev"]} '
|
await t_channel.send(f'It looks like {player["name"]} is on {player["team"]["abbrev"]} '
|
||||||
@ -1352,7 +1353,7 @@ class Transactions(commands.Cog):
|
|||||||
elif await dropadd.not_available(player):
|
elif await dropadd.not_available(player):
|
||||||
await dropadd.send(f'Uh oh, looks like {player["name"]} is already on the move '
|
await dropadd.send(f'Uh oh, looks like {player["name"]} is already on the move '
|
||||||
f'next week.')
|
f'next week.')
|
||||||
elif player['demotion_week'] > current['week']:
|
elif player['demotion_week'] > current.week:
|
||||||
await dropadd.send(f'Oof. {player["name"]} cannot be dropped until week '
|
await dropadd.send(f'Oof. {player["name"]} cannot be dropped until week '
|
||||||
f'{player["demotion_week"]}.')
|
f'{player["demotion_week"]}.')
|
||||||
else:
|
else:
|
||||||
@ -1386,7 +1387,7 @@ class Transactions(commands.Cog):
|
|||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
player = await get_player_by_name(
|
player = await get_player_by_name(
|
||||||
current['season'],
|
current.season,
|
||||||
await fuzzy_player_search(ctx, dropadd.channel, self.bot, resp, player_cog.player_list.keys())
|
await fuzzy_player_search(ctx, dropadd.channel, self.bot, resp, player_cog.player_list.keys())
|
||||||
)
|
)
|
||||||
except ValueError as e:
|
except ValueError as e:
|
||||||
@ -1401,11 +1402,11 @@ class Transactions(commands.Cog):
|
|||||||
f'so I can\'t let you do that.')
|
f'so I can\'t let you do that.')
|
||||||
elif await dropadd.not_available(player):
|
elif await dropadd.not_available(player):
|
||||||
await dropadd.send(f'Uh oh, looks like {player["name"]} is already on the move next week.')
|
await dropadd.send(f'Uh oh, looks like {player["name"]} is already on the move next week.')
|
||||||
elif player['demotion_week'] > current['week']:
|
elif player['demotion_week'] > current.week:
|
||||||
await dropadd.send(f'Oof. {player["name"]} cannot be dropped until week '
|
await dropadd.send(f'Oof. {player["name"]} cannot be dropped until week '
|
||||||
f'{player["demotion_week"]}.')
|
f'{player["demotion_week"]}.')
|
||||||
else:
|
else:
|
||||||
dest_team = await get_team_by_abbrev('FA', current['season'])
|
dest_team = await get_team_by_abbrev('FA', current.season)
|
||||||
await dropadd.add_player(player, dest_team)
|
await dropadd.add_player(player, dest_team)
|
||||||
|
|
||||||
await dropadd.show_moves()
|
await dropadd.show_moves()
|
||||||
@ -1438,7 +1439,7 @@ class Transactions(commands.Cog):
|
|||||||
errors.append(f'- This is the roster I have for {dropadd.teams[team]["team"]["abbrev"]}:\n'
|
errors.append(f'- This is the roster I have for {dropadd.teams[team]["team"]["abbrev"]}:\n'
|
||||||
f'```\n{roster_string}```')
|
f'```\n{roster_string}```')
|
||||||
|
|
||||||
mil_cap = 6 if current['week'] <= FA_LOCK_WEEK else 14
|
mil_cap = 6 if current.week <= FA_LOCK_WEEK else 14
|
||||||
if len(data['mil_roster']) > mil_cap:
|
if len(data['mil_roster']) > mil_cap:
|
||||||
errors.append(
|
errors.append(
|
||||||
f'- {dropadd.teams[team]["team"]["abbrev"]}MiL would have {len(data["mil_roster"])} players'
|
f'- {dropadd.teams[team]["team"]["abbrev"]}MiL would have {len(data["mil_roster"])} players'
|
||||||
@ -1469,7 +1470,7 @@ class Transactions(commands.Cog):
|
|||||||
# Run moves
|
# Run moves
|
||||||
trans_id = await dropadd.send_transaction()
|
trans_id = await dropadd.send_transaction()
|
||||||
|
|
||||||
if not current['freeze'] or dropadd.avoid_freeze:
|
if not current.freeze or dropadd.avoid_freeze:
|
||||||
await send_to_channel(self.bot, 'transaction-log', embed=await dropadd.show_moves(here=False))
|
await send_to_channel(self.bot, 'transaction-log', embed=await dropadd.show_moves(here=False))
|
||||||
|
|
||||||
await dropadd.send(f'All done! Your transaction id is: {trans_id}')
|
await dropadd.send(f'All done! Your transaction id is: {trans_id}')
|
||||||
@ -1492,7 +1493,7 @@ class Transactions(commands.Cog):
|
|||||||
@commands.command(name='ilmove', help='IL move')
|
@commands.command(name='ilmove', help='IL move')
|
||||||
@commands.has_any_role(SBA_PLAYERS_ROLE_NAME)
|
@commands.has_any_role(SBA_PLAYERS_ROLE_NAME)
|
||||||
async def il_move_command(self, ctx):
|
async def il_move_command(self, ctx):
|
||||||
current = await db_get('current')
|
current = await get_current()
|
||||||
|
|
||||||
if OFFSEASON_FLAG:
|
if OFFSEASON_FLAG:
|
||||||
await ctx.send(await get_emoji(ctx, 'oof', False))
|
await ctx.send(await get_emoji(ctx, 'oof', False))
|
||||||
@ -1500,12 +1501,12 @@ class Transactions(commands.Cog):
|
|||||||
f'trade and drop players to FA, though!')
|
f'trade and drop players to FA, though!')
|
||||||
return
|
return
|
||||||
|
|
||||||
team = await get_team_by_owner(current['season'], ctx.author.id)
|
team = await get_team_by_owner(current.season, ctx.author.id)
|
||||||
# team = await get_team_by_abbrev('VA', current['season'])
|
# team = await get_team_by_abbrev('VA', current.season)
|
||||||
s_query = await db_get('games', params=[
|
s_query = await db_get('games', params=[
|
||||||
('season', current['season']), ('team1_id', team['id']), ('week', current['week'])
|
('season', current.season), ('team1_id', team['id']), ('week', current.week)
|
||||||
])
|
])
|
||||||
if s_query['count'] == 0 and current['week'] != 18:
|
if s_query['count'] == 0 and current.week != 18:
|
||||||
await ctx.send('It looks like your season is over so transactions are locked.')
|
await ctx.send('It looks like your season is over so transactions are locked.')
|
||||||
return
|
return
|
||||||
|
|
||||||
@ -1533,7 +1534,7 @@ class Transactions(commands.Cog):
|
|||||||
|
|
||||||
await dropadd.send(f'Let\'s start here, {team_role.mention}')
|
await dropadd.send(f'Let\'s start here, {team_role.mention}')
|
||||||
await ctx.send(f'Take my hand... {dropadd.channel.mention}')
|
await ctx.send(f'Take my hand... {dropadd.channel.mention}')
|
||||||
await dropadd.send(f'This transaction is for __this week__. It will go into effect for week {current["week"]}.')
|
await dropadd.send(f'This transaction is for __this week__. It will go into effect for week {current.week}.')
|
||||||
|
|
||||||
# Get IL moves
|
# Get IL moves
|
||||||
while True:
|
while True:
|
||||||
@ -1559,7 +1560,7 @@ class Transactions(commands.Cog):
|
|||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
player = await get_player_by_name(
|
player = await get_player_by_name(
|
||||||
current['season'],
|
current.season,
|
||||||
await fuzzy_player_search(ctx, dropadd.channel, self.bot, resp, player_cog.player_list.keys())
|
await fuzzy_player_search(ctx, dropadd.channel, self.bot, resp, player_cog.player_list.keys())
|
||||||
)
|
)
|
||||||
except ValueError as e:
|
except ValueError as e:
|
||||||
@ -1573,7 +1574,7 @@ class Transactions(commands.Cog):
|
|||||||
await t_channel.send(f'It looks like {player["name"]} is on {player["team"]["abbrev"]} '
|
await t_channel.send(f'It looks like {player["name"]} is on {player["team"]["abbrev"]} '
|
||||||
f'so I can\'t let you do that.')
|
f'so I can\'t let you do that.')
|
||||||
else:
|
else:
|
||||||
dest_team = await get_team_by_abbrev(f'{team["abbrev"]}IL', current['season'])
|
dest_team = await get_team_by_abbrev(f'{team["abbrev"]}IL', current.season)
|
||||||
await dropadd.add_player(player, dest_team)
|
await dropadd.add_player(player, dest_team)
|
||||||
|
|
||||||
await dropadd.show_moves()
|
await dropadd.show_moves()
|
||||||
@ -1602,7 +1603,7 @@ class Transactions(commands.Cog):
|
|||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
player = await get_player_by_name(
|
player = await get_player_by_name(
|
||||||
current['season'],
|
current.season,
|
||||||
await fuzzy_player_search(ctx, dropadd.channel, self.bot, resp, player_cog.player_list.keys())
|
await fuzzy_player_search(ctx, dropadd.channel, self.bot, resp, player_cog.player_list.keys())
|
||||||
)
|
)
|
||||||
except ValueError as e:
|
except ValueError as e:
|
||||||
@ -1644,7 +1645,7 @@ class Transactions(commands.Cog):
|
|||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
player = await get_player_by_name(
|
player = await get_player_by_name(
|
||||||
current['season'],
|
current.season,
|
||||||
await fuzzy_player_search(ctx, dropadd.channel, self.bot, resp, player_cog.player_list.keys())
|
await fuzzy_player_search(ctx, dropadd.channel, self.bot, resp, player_cog.player_list.keys())
|
||||||
)
|
)
|
||||||
except ValueError as e:
|
except ValueError as e:
|
||||||
@ -1657,11 +1658,11 @@ class Transactions(commands.Cog):
|
|||||||
if not dropadd.included_team(player['team']):
|
if not dropadd.included_team(player['team']):
|
||||||
await t_channel.send(f'It looks like {player["name"]} is on {player["team"]["abbrev"]} '
|
await t_channel.send(f'It looks like {player["name"]} is on {player["team"]["abbrev"]} '
|
||||||
f'so I can\'t let you do that.')
|
f'so I can\'t let you do that.')
|
||||||
# elif player['demotion_week'] > current['week']:
|
# elif player['demotion_week'] > current.week:
|
||||||
# await dropadd.send(f'Oof. {player["name"]} cannot be dropped until week '
|
# await dropadd.send(f'Oof. {player["name"]} cannot be dropped until week '
|
||||||
# f'{player["demotion_week"]}.')
|
# f'{player["demotion_week"]}.')
|
||||||
else:
|
else:
|
||||||
dest_team = await get_team_by_abbrev(f'{team["abbrev"]}MiL', current['season'])
|
dest_team = await get_team_by_abbrev(f'{team["abbrev"]}MiL', current.season)
|
||||||
await dropadd.add_player(player, dest_team)
|
await dropadd.add_player(player, dest_team)
|
||||||
|
|
||||||
await dropadd.show_moves()
|
await dropadd.show_moves()
|
||||||
@ -1690,7 +1691,7 @@ class Transactions(commands.Cog):
|
|||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
player = await get_player_by_name(
|
player = await get_player_by_name(
|
||||||
current['season'],
|
current.season,
|
||||||
await fuzzy_player_search(ctx, dropadd.channel, self.bot, resp, player_cog.player_list.keys())
|
await fuzzy_player_search(ctx, dropadd.channel, self.bot, resp, player_cog.player_list.keys())
|
||||||
)
|
)
|
||||||
except ValueError as e:
|
except ValueError as e:
|
||||||
@ -1703,11 +1704,11 @@ class Transactions(commands.Cog):
|
|||||||
if not dropadd.included_team(player['team']):
|
if not dropadd.included_team(player['team']):
|
||||||
await t_channel.send(f'It looks like {player["name"]} is on {player["team"]["abbrev"]} '
|
await t_channel.send(f'It looks like {player["name"]} is on {player["team"]["abbrev"]} '
|
||||||
f'so I can\'t let you do that.')
|
f'so I can\'t let you do that.')
|
||||||
# elif player['demotion_week'] > current['week']:
|
# elif player['demotion_week'] > current.week:
|
||||||
# await dropadd.send(f'Oof. {player["name"]} cannot be dropped until week '
|
# await dropadd.send(f'Oof. {player["name"]} cannot be dropped until week '
|
||||||
# f'{player["demotion_week"]}.')
|
# f'{player["demotion_week"]}.')
|
||||||
else:
|
else:
|
||||||
dest_team = await get_team_by_abbrev('FA', current['season'])
|
dest_team = await get_team_by_abbrev('FA', current.season)
|
||||||
await dropadd.add_player(player, dest_team)
|
await dropadd.add_player(player, dest_team)
|
||||||
|
|
||||||
await dropadd.show_moves()
|
await dropadd.show_moves()
|
||||||
@ -1767,7 +1768,7 @@ class Transactions(commands.Cog):
|
|||||||
for player_move in [*dropadd.players.values()]:
|
for player_move in [*dropadd.players.values()]:
|
||||||
this_guy = copy.deepcopy(player_move['player'])
|
this_guy = copy.deepcopy(player_move['player'])
|
||||||
this_guy['team'] = player_move['to']
|
this_guy['team'] = player_move['to']
|
||||||
this_guy['demotion_week'] = current['week']
|
this_guy['demotion_week'] = current.week
|
||||||
await put_player(this_guy)
|
await put_player(this_guy)
|
||||||
|
|
||||||
await send_to_channel(self.bot, 'transaction-log', embed=await dropadd.show_moves(here=False))
|
await send_to_channel(self.bot, 'transaction-log', embed=await dropadd.show_moves(here=False))
|
||||||
@ -1778,35 +1779,35 @@ class Transactions(commands.Cog):
|
|||||||
@commands.command(name='mymoves', help='Show upcoming moves')
|
@commands.command(name='mymoves', help='Show upcoming moves')
|
||||||
@commands.has_any_role(SBA_PLAYERS_ROLE_NAME)
|
@commands.has_any_role(SBA_PLAYERS_ROLE_NAME)
|
||||||
async def my_moves_command(self, ctx):
|
async def my_moves_command(self, ctx):
|
||||||
current = await db_get('current')
|
current = await get_current()
|
||||||
team = await get_team_by_owner(current['season'], ctx.author.id)
|
team = await get_team_by_owner(current.season, ctx.author.id)
|
||||||
# set_moves = await get_transactions(
|
# set_moves = await get_transactions(
|
||||||
# current['season'],
|
# current.season,
|
||||||
# team_abbrev=team['abbrev'],
|
# team_abbrev=team['abbrev'],
|
||||||
# week_start=current['week']+1,
|
# week_start=current.week+1,
|
||||||
# week_end=current['week']+1
|
# week_end=current.week+1
|
||||||
# )
|
# )
|
||||||
t_query = await db_get('transactions', params=[
|
t_query = await db_get('transactions', params=[
|
||||||
('season', current['season']), ('week_start', current['week']),
|
('season', current.season), ('week_start', current.week),
|
||||||
('week_end', current['season']), ('team_abbrev', team['abbrev'])
|
('week_end', current.season), ('team_abbrev', team['abbrev'])
|
||||||
])
|
])
|
||||||
set_moves = t_query['transactions']
|
set_moves = t_query['transactions']
|
||||||
# frozen_moves = await get_transactions(
|
# frozen_moves = await get_transactions(
|
||||||
# current['season'],
|
# current.season,
|
||||||
# team_abbrev=team['abbrev'],
|
# team_abbrev=team['abbrev'],
|
||||||
# week_start=current['week']+1,
|
# week_start=current.week+1,
|
||||||
# week_end=current['week']+1,
|
# week_end=current.week+1,
|
||||||
# frozen=True
|
# frozen=True
|
||||||
# )
|
# )
|
||||||
t_query = await db_get('transactions', params=[
|
t_query = await db_get('transactions', params=[
|
||||||
('season', current['season']), ('week_start', current['week']),
|
('season', current.season), ('week_start', current.week),
|
||||||
('week_end', current['season']), ('team_abbrev', team['abbrev']), ('frozen', True)
|
('week_end', current.season), ('team_abbrev', team['abbrev']), ('frozen', True)
|
||||||
])
|
])
|
||||||
frozen_moves = t_query['transactions']
|
frozen_moves = t_query['transactions']
|
||||||
logger.info(f'Num Moves: {len(set_moves)}')
|
logger.info(f'Num Moves: {len(set_moves)}')
|
||||||
|
|
||||||
embed = get_team_embed(f'{team["lname"]} Guaranteed Transactions', team=team)
|
embed = get_team_embed(f'{team["lname"]} Guaranteed Transactions', team=team)
|
||||||
embed.description = f'Week {current["week"] + 1} Moves'
|
embed.description = f'Week {current.week + 1} Moves'
|
||||||
guaranteed = {}
|
guaranteed = {}
|
||||||
frozen = {}
|
frozen = {}
|
||||||
|
|
||||||
@ -1843,11 +1844,11 @@ class Transactions(commands.Cog):
|
|||||||
@commands.command(name='legal', help='Check roster legality')
|
@commands.command(name='legal', help='Check roster legality')
|
||||||
@commands.has_any_role(SBA_PLAYERS_ROLE_NAME)
|
@commands.has_any_role(SBA_PLAYERS_ROLE_NAME)
|
||||||
async def legal_command(self, ctx, team_abbrev: str):
|
async def legal_command(self, ctx, team_abbrev: str):
|
||||||
current = await db_get('current')
|
current = await get_current()
|
||||||
if team_abbrev:
|
if team_abbrev:
|
||||||
this_team = await get_team_by_abbrev(team_abbrev, current['season'])
|
this_team = await get_team_by_abbrev(team_abbrev, current.season)
|
||||||
else:
|
else:
|
||||||
this_team = await get_team_by_owner(current['season'], ctx.author.id)
|
this_team = await get_team_by_owner(current.season, ctx.author.id)
|
||||||
|
|
||||||
# this_week_team = await get_team_roster(this_team, 'current')
|
# this_week_team = await get_team_roster(this_team, 'current')
|
||||||
# next_week_team = await get_team_roster(this_team, 'next')
|
# next_week_team = await get_team_roster(this_team, 'next')
|
||||||
@ -1860,9 +1861,9 @@ class Transactions(commands.Cog):
|
|||||||
for roster in [this_week_team, next_week_team]:
|
for roster in [this_week_team, next_week_team]:
|
||||||
embed = get_team_embed(f'{this_team["lname"]} Roster Check', team=this_team)
|
embed = get_team_embed(f'{this_team["lname"]} Roster Check', team=this_team)
|
||||||
if count == 0:
|
if count == 0:
|
||||||
embed.description = f'Week {current["week"]}'
|
embed.description = f'Week {current.week}'
|
||||||
else:
|
else:
|
||||||
embed.description = f'Week {current["week"] + 1}'
|
embed.description = f'Week {current.week + 1}'
|
||||||
|
|
||||||
errors = []
|
errors = []
|
||||||
|
|
||||||
@ -1909,11 +1910,11 @@ class Transactions(commands.Cog):
|
|||||||
@commands.command(name='tomil', help='Post-draft demotions')
|
@commands.command(name='tomil', help='Post-draft demotions')
|
||||||
@commands.has_any_role(SBA_PLAYERS_ROLE_NAME)
|
@commands.has_any_role(SBA_PLAYERS_ROLE_NAME)
|
||||||
async def to_mil_command(self, ctx, *player_list):
|
async def to_mil_command(self, ctx, *player_list):
|
||||||
current = await db_get('current')
|
current = await get_current()
|
||||||
team = await get_team_by_owner(current['season'], owner_id=ctx.author.id)
|
team = await get_team_by_owner(current.season, owner_id=ctx.author.id)
|
||||||
il_team = await get_team_by_abbrev(f'{team["abbrev"]}MiL', current['season'])
|
il_team = await get_team_by_abbrev(f'{team["abbrev"]}MiL', current.season)
|
||||||
|
|
||||||
if current['week'] != 0:
|
if current.week != 0:
|
||||||
logger.info('entering the thot check')
|
logger.info('entering the thot check')
|
||||||
await react_and_reply(ctx, '👀', 'https://c.tenor.com/FCAj8xDvEHwAAAAC/be-gone-thot.gif')
|
await react_and_reply(ctx, '👀', 'https://c.tenor.com/FCAj8xDvEHwAAAAC/be-gone-thot.gif')
|
||||||
player_role = get_role(ctx, SBA_PLAYERS_ROLE_NAME)
|
player_role = get_role(ctx, SBA_PLAYERS_ROLE_NAME)
|
||||||
@ -1947,7 +1948,7 @@ class Transactions(commands.Cog):
|
|||||||
logger.error(f'Could not demote {x} for {team["abbrev"]}: {e}')
|
logger.error(f'Could not demote {x} for {team["abbrev"]}: {e}')
|
||||||
errors.append(x)
|
errors.append(x)
|
||||||
else:
|
else:
|
||||||
player = await get_player_by_name(current['season'], player_name)
|
player = await get_player_by_name(current.season, player_name)
|
||||||
if player['team']['id'] != team['id']:
|
if player['team']['id'] != team['id']:
|
||||||
await ctx.send(f'Omg stop trying to make {player["name"]} happen. It\'s not going to happen.')
|
await ctx.send(f'Omg stop trying to make {player["name"]} happen. It\'s not going to happen.')
|
||||||
else:
|
else:
|
||||||
@ -1958,8 +1959,8 @@ class Transactions(commands.Cog):
|
|||||||
'player_id': player['id'],
|
'player_id': player['id'],
|
||||||
'oldteam_id': team['id'],
|
'oldteam_id': team['id'],
|
||||||
'newteam_id': il_team['id'],
|
'newteam_id': il_team['id'],
|
||||||
'season': current['season'],
|
'season': current.season,
|
||||||
'moveid': f's{current["season"]}-draft-tomil-{team["abbrev"]}'
|
'moveid': f's{current.season}-draft-tomil-{team["abbrev"]}'
|
||||||
})
|
})
|
||||||
|
|
||||||
if len(moves) == 0:
|
if len(moves) == 0:
|
||||||
@ -1978,8 +1979,8 @@ class Transactions(commands.Cog):
|
|||||||
|
|
||||||
@commands.command(name='calisamazing', help='Make up for your idiocy')
|
@commands.command(name='calisamazing', help='Make up for your idiocy')
|
||||||
async def cal_is_amazing_command(self, ctx):
|
async def cal_is_amazing_command(self, ctx):
|
||||||
current = await db_get('current')
|
current = await get_current()
|
||||||
team = await get_team_by_owner(current['season'], owner_id=ctx.author.id)
|
team = await get_team_by_owner(current.season, owner_id=ctx.author.id)
|
||||||
|
|
||||||
if not team:
|
if not team:
|
||||||
await ctx.send(random_conf_gif())
|
await ctx.send(random_conf_gif())
|
||||||
|
|||||||
21
helpers.py
21
helpers.py
@ -655,7 +655,7 @@ async def team_emoji(ctx, team):
|
|||||||
return emoji
|
return emoji
|
||||||
|
|
||||||
|
|
||||||
async def fuzzy_player_search(ctx, channel, bot, name, master_list, author = None):
|
async def fuzzy_player_search(ctx, channel, bot, name, master_list, author = None) -> str:
|
||||||
"""
|
"""
|
||||||
Takes a name to search and returns the name of the best match
|
Takes a name to search and returns the name of the best match
|
||||||
|
|
||||||
@ -702,7 +702,7 @@ async def fuzzy_player_search(ctx, channel, bot, name, master_list, author = Non
|
|||||||
if not resp:
|
if not resp:
|
||||||
return None
|
return None
|
||||||
if resp < count:
|
if resp < count:
|
||||||
return matches[resp - 1]
|
return matches[resp - 1] # type: ignore
|
||||||
else:
|
else:
|
||||||
raise ValueError(f'{resp} is not a valid response.')
|
raise ValueError(f'{resp} is not a valid response.')
|
||||||
|
|
||||||
@ -790,6 +790,7 @@ def get_role(ctx, role_name, bot=None):
|
|||||||
|
|
||||||
|
|
||||||
def get_team_role(ctx, team, bot=None):
|
def get_team_role(ctx, team, bot=None):
|
||||||
|
logger.info(f'getting team role for: {team}')
|
||||||
return get_role(ctx, team['lname'], bot)
|
return get_role(ctx, team['lname'], bot)
|
||||||
|
|
||||||
|
|
||||||
@ -811,7 +812,7 @@ async def send_to_channel(bot, channel_name, content=None, embed=None):
|
|||||||
|
|
||||||
async def get_player_embed(player, current, ctx=None, season=None):
|
async def get_player_embed(player, current, ctx=None, season=None):
|
||||||
if season is None:
|
if season is None:
|
||||||
season = current['season']
|
season = current.season
|
||||||
player_name = player['name']
|
player_name = player['name']
|
||||||
if player['il_return']:
|
if player['il_return']:
|
||||||
if player['team']['abbrev'][-2:].lower() == 'il':
|
if player['team']['abbrev'][-2:].lower() == 'il':
|
||||||
@ -819,7 +820,7 @@ async def get_player_embed(player, current, ctx=None, season=None):
|
|||||||
else:
|
else:
|
||||||
player_name = f'{await get_emoji(ctx, "WeenieHut", False)}{player_name}'
|
player_name = f'{await get_emoji(ctx, "WeenieHut", False)}{player_name}'
|
||||||
embed = get_team_embed(f'{player_name}', player["team"])
|
embed = get_team_embed(f'{player_name}', player["team"])
|
||||||
embed.set_footer(text=f'SBa Season {current["season"]}', icon_url=LOGO)
|
embed.set_footer(text=f'SBa Season {current.season}', icon_url=LOGO)
|
||||||
embed.add_field(name='Player ID', value=f'{player["id"]}')
|
embed.add_field(name='Player ID', value=f'{player["id"]}')
|
||||||
embed.set_image(url=player['image'])
|
embed.set_image(url=player['image'])
|
||||||
# embed.description = f'Player ID {player["id"]}'
|
# embed.description = f'Player ID {player["id"]}'
|
||||||
@ -834,11 +835,11 @@ async def get_player_embed(player, current, ctx=None, season=None):
|
|||||||
embed.set_thumbnail(url=player_photo)
|
embed.set_thumbnail(url=player_photo)
|
||||||
|
|
||||||
t_query = await db_get('transactions', params=[
|
t_query = await db_get('transactions', params=[
|
||||||
('season', current['season']), ('week_start', current['week']), ('week_end', current['week'] + 1),
|
('season', current.season), ('week_start', current.week), ('week_end', current.week + 1),
|
||||||
('player_id', player['id'])
|
('player_id', player['id'])
|
||||||
])
|
])
|
||||||
d_query = await db_get('draftpicks', params=[
|
d_query = await db_get('draftpicks', params=[
|
||||||
('season', current['season']), ('player_id', player['id'])
|
('season', current.season), ('player_id', player['id'])
|
||||||
])
|
])
|
||||||
|
|
||||||
positions = get_player_positions(player)
|
positions = get_player_positions(player)
|
||||||
@ -876,14 +877,14 @@ async def get_player_embed(player, current, ctx=None, season=None):
|
|||||||
major_team = await get_team_by_abbrev(player['team']['abbrev'][:-3], season=player['season'])
|
major_team = await get_team_by_abbrev(player['team']['abbrev'][:-3], season=player['season'])
|
||||||
embed.add_field(name='SBa Affiliate', value=major_team['sname'])
|
embed.add_field(name='SBa Affiliate', value=major_team['sname'])
|
||||||
if player['demotion_week'] is not None:
|
if player['demotion_week'] is not None:
|
||||||
if player['demotion_week'] > current['week']:
|
if player['demotion_week'] > current.week:
|
||||||
embed.add_field(name='Dem Week', value=player["demotion_week"])
|
embed.add_field(name='Dem Week', value=player["demotion_week"])
|
||||||
if player['il_return']:
|
if player['il_return']:
|
||||||
embed.add_field(name='IL Return', value=player['il_return'])
|
embed.add_field(name='IL Return', value=player['il_return'])
|
||||||
for x in t_query['transactions']:
|
for x in t_query['transactions']:
|
||||||
if x['week'] == current['week']:
|
if x['week'] == current.week:
|
||||||
embed.add_field(name='Last Week', value=f'{x["oldteam"]["sname"]}')
|
embed.add_field(name='Last Week', value=f'{x["oldteam"]["sname"]}')
|
||||||
if x['week'] == current['week'] + 1:
|
if x['week'] == current.week + 1:
|
||||||
embed.add_field(name='Next Week', value=f'To {x["newteam"]["sname"]}')
|
embed.add_field(name='Next Week', value=f'To {x["newteam"]["sname"]}')
|
||||||
|
|
||||||
if player['season'] < 8:
|
if player['season'] < 8:
|
||||||
@ -1103,7 +1104,7 @@ async def log_injury(current: dict, inj_dict: dict) -> None:
|
|||||||
crange=f'A{current["injury_count"]+2}',
|
crange=f'A{current["injury_count"]+2}',
|
||||||
values=[[
|
values=[[
|
||||||
datetime.datetime.now().strftime('%Y-%m-%d, %H:%M:%S'), inj_dict['player']['name'], inj_dict['type'],
|
datetime.datetime.now().strftime('%Y-%m-%d, %H:%M:%S'), inj_dict['player']['name'], inj_dict['type'],
|
||||||
inj_dict['player']['team']['abbrev'], current['week'], inj_dict['current_game'],
|
inj_dict['player']['team']['abbrev'], current.week, inj_dict['current_game'],
|
||||||
inj_dict['injury_length']
|
inj_dict['injury_length']
|
||||||
]]
|
]]
|
||||||
)
|
)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user