v3 api updates

This commit is contained in:
Cal Corum 2023-07-09 16:36:51 -05:00
parent 0ccc60deb4
commit 6ed2f43421
7 changed files with 1079 additions and 1049 deletions

View File

@ -14,8 +14,8 @@ class Admins(commands.Cog):
def __init__(self, bot):
self.bot = bot
async def cog_command_error(self, ctx, error):
await ctx.send(f'{error}')
# async def cog_command_error(self, ctx, error):
# await ctx.send(f'{error}')
@commands.command(name='current', help='Current db info')
@commands.is_owner()
@ -86,94 +86,98 @@ class Admins(commands.Cog):
current = await db_get('current')
await ctx.send(f'Current: {current}')
@commands.command(name='sendmoves', help='Send moves to sheets')
@commands.is_owner()
async def send_moves_command(self, ctx):
current = await db_get('current')
await ctx.send('Authenticating with sheets...')
sheets = pygsheets.authorize(service_file='storage/major-domo-service-creds.json')
trans_tab = sheets.open_by_key(SBA_ROSTER_KEY).worksheet_by_title('Transactions')
await ctx.send('Collecting transactions...')
all_vals = []
all_moves = await get_transactions(
season=current['season'],
timeout=30
)
await ctx.send(f'Processing transactions ({len(all_moves)} found)...')
total_moves = len(all_moves)
# @commands.command(name='sendmoves', help='Send moves to sheets')
# @commands.is_owner()
# async def send_moves_command(self, ctx):
# current = await db_get('current')
# await ctx.send('Authenticating with sheets...')
# sheets = pygsheets.authorize(service_file='storage/major-domo-service-creds.json')
# trans_tab = sheets.open_by_key(SBA_ROSTER_KEY).worksheet_by_title('Transactions')
# await ctx.send('Collecting transactions...')
# all_vals = []
# all_moves = await get_transactions(
# season=current['season'],
# timeout=30
# )
# await ctx.send(f'Processing transactions ({len(all_moves)} found)...')
# total_moves = len(all_moves)
#
# counter = 0
# for move in [*all_moves.values()]:
# all_vals.insert(
# 0,
# [
# move['player']['name'],
# move['oldteam']['sname'],
# move['newteam']['sname'],
# move['week'],
# total_moves + 416 - counter
# ]
# )
# counter += 1
# logging.warning(f'all_vals samples:\n0: {all_vals[0]}\n100: {all_vals[100]}\n1000: {all_vals[1000]}\n'
# f'2000: {all_vals[2000]}')
#
# await ctx.send('Sending transactions to sheets...')
# try:
# trans_tab.update_values(
# crange=f'A420',
# values=all_vals
# )
# await ctx.send('All done!')
# except Exception as e:
# await ctx.send('Failed sending to sheets')
counter = 0
for move in [*all_moves.values()]:
all_vals.insert(
0,
[
move['player']['name'],
move['oldteam']['sname'],
move['newteam']['sname'],
move['week'],
total_moves + 416 - counter
]
)
counter += 1
logging.warning(f'all_vals samples:\n0: {all_vals[0]}\n100: {all_vals[100]}\n1000: {all_vals[1000]}\n'
f'2000: {all_vals[2000]}')
# @commands.command(name='xpick', help='Expansion pick')
# @commands.is_owner()
# async def expansion_pick_command(self, ctx, team_abbrev, *, name):
# current = await db_get('current')
# player_cog = self.bot.get_cog('Players')
# player_name = await fuzzy_player_search(ctx, ctx.channel, self.bot, name, player_cog.player_list.keys())
# player = await get_one_player(player_name)
# team = await get_one_team(team_abbrev)
# old_team = copy.deepcopy(player["team"])
#
# if not team:
# await ctx.send(f'Who the fuck is **{team_abbrev}**? Get your shit together - it\'s DRAFT TIME!!!')
# return
#
# if old_team['id'] == 99:
# await ctx.send(f'Tell that bastard they\'re an idiot. {player["name"]} is a Free Agent.')
# return
#
# await patch_player(player['id'], team_id=team['id'])
# await ctx.send(content=None, embed=await get_player_embed(await get_one_player(player['id']), current))
# await send_to_channel(
# self.bot,
# 's4-draft-picks',
# f'Expansion Draft: {await get_emoji(ctx, team["sname"])}{team["sname"]} select **{player["name"]}** from '
# f'{await get_emoji(ctx, old_team["sname"])}{old_team["abbrev"]}'
# )
await ctx.send('Sending transactions to sheets...')
try:
trans_tab.update_values(
crange=f'A420',
values=all_vals
)
await ctx.send('All done!')
except Exception as e:
await ctx.send('Failed sending to sheets')
@commands.command(name='xpick', help='Expansion pick')
@commands.is_owner()
async def expansion_pick_command(self, ctx, team_abbrev, *, name):
current = await db_get('current')
player_cog = self.bot.get_cog('Players')
player_name = await fuzzy_player_search(ctx, ctx.channel, self.bot, name, player_cog.player_list.keys())
player = await get_one_player(player_name)
team = await get_one_team(team_abbrev)
old_team = copy.deepcopy(player["team"])
if not team:
await ctx.send(f'Who the fuck is **{team_abbrev}**? Get your shit together - it\'s DRAFT TIME!!!')
return
if old_team['id'] == 99:
await ctx.send(f'Tell that bastard they\'re an idiot. {player["name"]} is a Free Agent.')
return
await patch_player(player['id'], team_id=team['id'])
await ctx.send(content=None, embed=await get_player_embed(await get_one_player(player['id']), current))
await send_to_channel(
self.bot,
's4-draft-picks',
f'Expansion Draft: {await get_emoji(ctx, team["sname"])}{team["sname"]} select **{player["name"]}** from '
f'{await get_emoji(ctx, old_team["sname"])}{old_team["abbrev"]}'
)
@commands.command(name='injimport')
@commands.is_owner()
async def injury_import_command(self, ctx):
sheets = pygsheets.authorize(service_file='storage/major-domo-service-creds.json')
inj_tab = sheets.open_by_key('1uKRf7YwTcEfp8D7gUutQRwnOHW37hl6XcBbtqw3PbN4').worksheet_by_title('Sheet1')
raw_data = inj_tab.get_values('A1', 'B545')
for line in raw_data:
player = await get_one_player(line[0])
await patch_player(player['id'], pitcher_injury=line[1])
# @commands.command(name='injimport')
# @commands.is_owner()
# async def injury_import_command(self, ctx):
# sheets = pygsheets.authorize(service_file='storage/major-domo-service-creds.json')
# inj_tab = sheets.open_by_key('1uKRf7YwTcEfp8D7gUutQRwnOHW37hl6XcBbtqw3PbN4').worksheet_by_title('Sheet1')
# raw_data = inj_tab.get_values('A1', 'B545')
#
# for line in raw_data:
# player = await get_one_player(line[0])
# await patch_player(player['id'], pitcher_injury=line[1])
@commands.command(name='setdemweek', help='Set player\'s demotion week')
@commands.is_owner()
async def set_dem_week_command(self, ctx, week_num, *, player_name):
current = await db_get('current')
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 = 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)])
player = p_query['players'][0]
player['demotion_week'] = week_num
await patch_player(player['id'], demotion_week=week_num)
await patch_player(player)
await ctx.send(random_conf_gif())

View File

@ -1,7 +1,7 @@
import re
from helpers import *
from db_calls import *
from db_calls import get_team_by_abbrev
import discord
from discord.ext import commands, tasks
from discord import app_commands
@ -15,16 +15,16 @@ class Dice(commands.Cog):
self.rolls = []
self.current = None
self.updates.start()
# self.updates.start()
async def cog_command_error(self, ctx, error):
await ctx.send(f'{error}')
# async def cog_command_error(self, ctx, error):
# await ctx.send(f'{error}')
async def get_dice_embed(self, channel, title, message):
try:
team_abbrev = re.split('-', channel.name)
if len(team_abbrev[0]) <= 4 and team_abbrev not in ['the', 'city']:
team = await get_one_team(team_abbrev[0], timeout=1)
team = await get_team_by_abbrev(team_abbrev[0])
else:
team = None
except (ValueError, AttributeError, requests.ReadTimeout) as e:
@ -45,13 +45,13 @@ class Dice(commands.Cog):
return embed
@tasks.loop(minutes=5)
async def updates(self):
self.current = await db_get('current')
if len(self.rolls) > 0:
all_rolls = self.rolls
self.rolls = []
await post_dice(all_rolls)
# @tasks.loop(minutes=5)
# async def updates(self):
# self.current = await db_get('current')
# if len(self.rolls) > 0:
# all_rolls = self.rolls
# self.rolls = []
# await post_dice(all_rolls)
@commands.command(name='ab', aliases=['atbat', 'swing', 'pa'], help='ab, atbat, or swing')
async def ab_roll(self, ctx):
@ -104,16 +104,16 @@ class Dice(commands.Cog):
content=None,
embed=await self.get_dice_embed(ctx.channel, f'At bat roll for {ctx.author.name}', roll_message)
)
this_roll = {
'season': self.current['season'],
'week': self.current['week'],
'team_id': team["id"] if team else None,
'roller': ctx.author.id,
'dsix': d_six_one,
'twodsix': d_six_two + d_six_three,
'dtwenty': d_twenty
}
self.rolls.append(this_roll)
# this_roll = {
# 'season': self.current['season'],
# 'week': self.current['week'],
# 'team_id': team["id"] if team else None,
# 'roller': ctx.author.id,
# 'dsix': d_six_one,
# 'twodsix': d_six_two + d_six_three,
# 'dtwenty': d_twenty
# }
# self.rolls.append(this_roll)
@commands.command(name='1d20', aliases=['d20'], help='1d20 or d20')
async def dtwenty_roll(self, ctx):
@ -130,14 +130,14 @@ class Dice(commands.Cog):
content=None,
embed=await self.get_dice_embed(ctx.channel, f'd20 roll for {ctx.author.name}', roll_message)
)
this_roll = {
'season': self.current['season'],
'week': self.current['week'],
'team_id': team["id"] if team else None,
'roller': ctx.author.id,
'dtwenty': d_twenty
}
self.rolls.append(this_roll)
# this_roll = {
# 'season': self.current['season'],
# 'week': self.current['week'],
# 'team_id': team["id"] if team else None,
# 'roller': ctx.author.id,
# 'dtwenty': d_twenty
# }
# self.rolls.append(this_roll)
@commands.command(name='af', aliases=['fielding'], help='Advanced fielding')
async def fielding_roll(self, ctx, *args):
@ -183,16 +183,16 @@ class Dice(commands.Cog):
embed=await self.get_dice_embed(ctx.channel, f'Fielding roll for {ctx.author.name}', roll_message)
)
this_roll = {
'season': self.current['season'],
'week': self.current['week'],
'team_id': team["id"] if team else None,
'roller': ctx.author.id,
'dsix': d_six_one,
'twodsix': d_six_two + d_six_three,
'dtwenty': d_twenty
}
self.rolls.append(this_roll)
# this_roll = {
# 'season': self.current['season'],
# 'week': self.current['week'],
# 'team_id': team["id"] if team else None,
# 'roller': ctx.author.id,
# 'dsix': d_six_one,
# 'twodsix': d_six_two + d_six_three,
# 'dtwenty': d_twenty
# }
# self.rolls.append(this_roll)
@commands.command(name='i', aliases=['injury'], help='i or injury')
async def injury_roll(self, ctx):
@ -210,14 +210,14 @@ class Dice(commands.Cog):
if d_twenty > 8:
await ctx.send(random_salute_gif())
this_roll = {
'season': self.current['season'],
'week': self.current['week'],
'team_id': team["id"] if team else None,
'roller': ctx.author.id,
'dtwenty': d_twenty
}
self.rolls.append(this_roll)
# this_roll = {
# 'season': self.current['season'],
# 'week': self.current['week'],
# 'team_id': team["id"] if team else None,
# 'roller': ctx.author.id,
# 'dtwenty': d_twenty
# }
# self.rolls.append(this_roll)
@app_commands.command(name='injury', description='Make an injury check; rating = left of "p", games = right')
@app_commands.guilds(discord.Object(id=os.environ.get('GUILD_ID')))
@ -418,15 +418,15 @@ class Dice(commands.Cog):
content=None,
embed=await self.get_dice_embed(ctx.channel, f'Jump roll for {ctx.author.name}', roll_message)
)
this_roll = {
'season': self.current['season'],
'week': self.current['week'],
'team_id': team["id"] if team else None,
'roller': ctx.author.id,
'twodsix': d_six_two + d_six_one,
'dtwenty': d_twenty
}
self.rolls.append(this_roll)
# this_roll = {
# 'season': self.current['season'],
# 'week': self.current['week'],
# 'team_id': team["id"] if team else None,
# 'roller': ctx.author.id,
# 'twodsix': d_six_two + d_six_one,
# 'dtwenty': d_twenty
# }
# self.rolls.append(this_roll)
@commands.command(name='f', aliases=['safielding', 'saf'], help='f or safielding')
async def sa_fielding_roll(self, ctx, *args):
@ -1279,76 +1279,76 @@ class Dice(commands.Cog):
)
)
this_roll = {
'season': self.current['season'],
'week': self.current['week'],
'team_id': team["id"] if team else None,
'roller': ctx.author.id,
'threedsix': d_six_one + d_six_two + d_six_three,
'dtwenty': d_twenty
}
self.rolls.append(this_roll)
# this_roll = {
# 'season': self.current['season'],
# 'week': self.current['week'],
# 'team_id': team["id"] if team else None,
# 'roller': ctx.author.id,
# 'threedsix': d_six_one + d_six_two + d_six_three,
# 'dtwenty': d_twenty
# }
# self.rolls.append(this_roll)
@commands.command(name='s', aliases=['shift'])
async def shift_roll(self, ctx):
"""
Make an infield shift roll.
"""
team = None
d_six_one = random.randint(1, 6)
d_twenty = random.randint(1, 20)
d_twenty_two = random.randint(1, 20)
embed = None
if d_twenty < 3:
roll_message = f'```md\nHit into shift, consult chart```\n' \
f'At bat roll for {ctx.author.name}\n```md\n# {d_six_one},{d_twenty_two}' \
f'\nDetails:[1d6;1d20 ({d_six_one} - {d_twenty_two})]```'
embed = await self.get_dice_embed(ctx.channel, None, None)
embed.title = 'Hit Into Shift Results'
embed.set_image(url='https://lh3.googleusercontent.com/rouutaPsSd58B7XhGMc_uyo1CIP6I9QGRLnD0ZilizVoyaenKA'
'GxHETVfsNisQ3rfxbIRYcRuiBxpMZVG-7lH0TvDHgipV6UW2XH7eWhDS4egEAXOyrjuOgqZVi72Uc2TItcIo'
'hV8y5neRrck_N6juJzIsSm2YlZz5Pqyk_jRckK2qqyI5t15uBpoY9XbjmvgkJDNyaKBQYh7TgHd42BMzanYo'
'Gr0gmCgLpiRcYxA3qEpSnxEzL7XGYODczTj6kiPOknFc6vQtcLoZ75wYqqU1AG9u5URKOckIworz0uJxrFaR'
'PwewW5Fnxj36tf6bO37zl-RuH-veLBADtFmdEUT0pGt8eCmoB7YD6WtFG048Ox0n7U_QI3xIsvpMsnIVjml_'
'sKQ55cHqsMZbnJLFXIO73Fl4xQFS1eqI-FjzwvK_kmslPznxfb0uz-WtBQ3fTUV--07ya-b_n4O0H38IVKKa'
'eQqKzdTjU6Uv0uV8375UsNdSif5cbsfBp7_qlrZx4zFWc-IafCNh3h5R_NqLBV_-VQVqQdyu15Mbjr3s7kwB'
'DANYsk9zv3grE1yoKzzAPtRILXxPpJz6MkXDPNSTDPOd6ZXR7uoyevt5BvvcWnf7Htgai8WtKHp3Zcd_bIGJ'
'sGhohp4g3JO8zK5WMKN3-Za-KxH9XxDwrik-dc05x5VeX99m2A9eKClNbQGdE4TaI=w632-h292-no?authu'
'ser=0')
else:
roll_message = f'```md\n'
if d_twenty < 9 and d_six_one > 3:
roll_message += f'Swing away, HR becomes 2B if beating the shift```\n'
else:
roll_message += f'Swing away, no effect```\n'
await ctx.channel.send(
content=None,
embed=await self.get_dice_embed(
ctx.channel,
f'Shift roll for {ctx.author.name}',
roll_message
)
)
this_roll = {
'season': self.current['season'],
'week': self.current['week'],
'team_id': team["id"] if team else None,
'roller': ctx.author.id,
'dsix': d_six_one,
'dtwenty': d_twenty
}
self.rolls.append(this_roll)
this_roll = {
'season': self.current['season'],
'week': self.current['week'],
'team_id': team["id"] if team else None,
'roller': ctx.author.id,
'dtwenty': d_twenty_two
}
self.rolls.append(this_roll)
# @commands.command(name='s', aliases=['shift'])
# async def shift_roll(self, ctx):
# """
# Make an infield shift roll.
# """
# team = None
# d_six_one = random.randint(1, 6)
# d_twenty = random.randint(1, 20)
# d_twenty_two = random.randint(1, 20)
# embed = None
#
# if d_twenty < 3:
# roll_message = f'```md\nHit into shift, consult chart```\n' \
# f'At bat roll for {ctx.author.name}\n```md\n# {d_six_one},{d_twenty_two}' \
# f'\nDetails:[1d6;1d20 ({d_six_one} - {d_twenty_two})]```'
# embed = await self.get_dice_embed(ctx.channel, None, None)
# embed.title = 'Hit Into Shift Results'
# embed.set_image(url='https://lh3.googleusercontent.com/rouutaPsSd58B7XhGMc_uyo1CIP6I9QGRLnD0ZilizVoyaenKA'
# 'GxHETVfsNisQ3rfxbIRYcRuiBxpMZVG-7lH0TvDHgipV6UW2XH7eWhDS4egEAXOyrjuOgqZVi72Uc2TItcIo'
# 'hV8y5neRrck_N6juJzIsSm2YlZz5Pqyk_jRckK2qqyI5t15uBpoY9XbjmvgkJDNyaKBQYh7TgHd42BMzanYo'
# 'Gr0gmCgLpiRcYxA3qEpSnxEzL7XGYODczTj6kiPOknFc6vQtcLoZ75wYqqU1AG9u5URKOckIworz0uJxrFaR'
# 'PwewW5Fnxj36tf6bO37zl-RuH-veLBADtFmdEUT0pGt8eCmoB7YD6WtFG048Ox0n7U_QI3xIsvpMsnIVjml_'
# 'sKQ55cHqsMZbnJLFXIO73Fl4xQFS1eqI-FjzwvK_kmslPznxfb0uz-WtBQ3fTUV--07ya-b_n4O0H38IVKKa'
# 'eQqKzdTjU6Uv0uV8375UsNdSif5cbsfBp7_qlrZx4zFWc-IafCNh3h5R_NqLBV_-VQVqQdyu15Mbjr3s7kwB'
# 'DANYsk9zv3grE1yoKzzAPtRILXxPpJz6MkXDPNSTDPOd6ZXR7uoyevt5BvvcWnf7Htgai8WtKHp3Zcd_bIGJ'
# 'sGhohp4g3JO8zK5WMKN3-Za-KxH9XxDwrik-dc05x5VeX99m2A9eKClNbQGdE4TaI=w632-h292-no?authu'
# 'ser=0')
# else:
# roll_message = f'```md\n'
# if d_twenty < 9 and d_six_one > 3:
# roll_message += f'Swing away, HR becomes 2B if beating the shift```\n'
# else:
# roll_message += f'Swing away, no effect```\n'
#
# await ctx.channel.send(
# content=None,
# embed=await self.get_dice_embed(
# ctx.channel,
# f'Shift roll for {ctx.author.name}',
# roll_message
# )
# )
#
# this_roll = {
# 'season': self.current['season'],
# 'week': self.current['week'],
# 'team_id': team["id"] if team else None,
# 'roller': ctx.author.id,
# 'dsix': d_six_one,
# 'dtwenty': d_twenty
# }
# self.rolls.append(this_roll)
# this_roll = {
# 'season': self.current['season'],
# 'week': self.current['week'],
# 'team_id': team["id"] if team else None,
# 'roller': ctx.author.id,
# 'dtwenty': d_twenty_two
# }
# self.rolls.append(this_roll)
@commands.command(
name='lookups', help='Fielding chart lookup',

View File

@ -165,8 +165,8 @@ class Fun(commands.Cog):
logging.info(f'Deleted {del_counter} commands; sent deletion notifications to {len(del_notifs)} users; '
f'sent warnings to {len(warn_notifs)} users')
async def cog_command_error(self, ctx, error):
await ctx.send(f'{error}')
# async def cog_command_error(self, ctx, error):
# await ctx.send(f'{error}')
@commands.Cog.listener(name='on_message')
async def on_message_listener(self, message):

View File

@ -10,8 +10,7 @@ from discord.app_commands import Choice
from db_calls_gameplay import get_one_game
from helpers import *
from db_calls import db_get, db_patch, db_post, db_delete, get_team_by_abbrev, get_team_by_owner, patch_player, \
get_player_by_name
from db_calls import db_get, db_patch, get_team_by_abbrev, get_team_by_owner, patch_player, get_player_by_name
from typing import Literal
@ -1825,36 +1824,36 @@ class Players(commands.Cog):
async def picks_command(self, ctx, *team_abbrev):
await ctx.send('Go away.')
return
current = await db_get('current')
if team_abbrev:
team = await get_one_team(team_abbrev[0])
else:
team = await get_team_by_owner(current['season'], ctx.author.id)
if not team:
await ctx.send('I don\'t know what team you\'re looking for.')
return
raw_picks = await get_draftpicks(season=5, owner_team=team, team_season=5)
logging.info(f'raw_picks: {raw_picks}')
try:
all_picks = dict(sorted(raw_picks.items(), key=lambda item: item[1]["overall"]))
except TypeError as e:
all_picks = dict(sorted(raw_picks.items(), key=lambda item: item[1]["round"]))
pick_string = ''
for x in all_picks:
squiggles = '~~' if all_picks[x]['player'] else ''
selection = f'- {all_picks[x]["player"]["name"]}' if all_picks[x]["player"] else ''
overall = f'#{all_picks[x]["overall"]} - ' if all_picks[x]["overall"] else ''
pick_string += f'{squiggles}{overall}{all_picks[x]["origowner"]["abbrev"]} {all_picks[x]["round"]}' \
f'{squiggles} {selection}\n'
embed = get_team_embed(f'{team["lname"]}', team=team)
embed.add_field(name=f'Season {current["season"]} Draft Picks', value=pick_string)
await ctx.send(content=None, embed=embed)
# current = await db_get('current')
#
# if team_abbrev:
# team = await get_one_team(team_abbrev[0])
# else:
# team = await get_team_by_owner(current['season'], ctx.author.id)
#
# if not team:
# await ctx.send('I don\'t know what team you\'re looking for.')
# return
#
# raw_picks = await get_draftpicks(season=5, owner_team=team, team_season=5)
# logging.info(f'raw_picks: {raw_picks}')
# try:
# all_picks = dict(sorted(raw_picks.items(), key=lambda item: item[1]["overall"]))
# except TypeError as e:
# all_picks = dict(sorted(raw_picks.items(), key=lambda item: item[1]["round"]))
# pick_string = ''
#
# for x in all_picks:
# squiggles = '~~' if all_picks[x]['player'] else ''
# selection = f'- {all_picks[x]["player"]["name"]}' if all_picks[x]["player"] else ''
# overall = f'#{all_picks[x]["overall"]} - ' if all_picks[x]["overall"] else ''
# pick_string += f'{squiggles}{overall}{all_picks[x]["origowner"]["abbrev"]} {all_picks[x]["round"]}' \
# f'{squiggles} {selection}\n'
#
# embed = get_team_embed(f'{team["lname"]}', team=team)
# embed.add_field(name=f'Season {current["season"]} Draft Picks', value=pick_string)
#
# await ctx.send(content=None, embed=embed)
# @commands.command(name='fixscore', help='Change result')
# @commands.has_any_role(SBA_PLAYERS_ROLE_NAME)

View File

@ -2,7 +2,7 @@ import re
import copy
from helpers import *
from db_calls import db_get, db_patch, get_team_by_owner, get_team_by_abbrev, get_player_by_name, patch_player
from db_calls import db_get, db_patch, get_team_by_owner, get_team_by_abbrev, get_player_by_name, patch_player, db_post
from discord.ext import commands, tasks
OFFSEASON_FLAG = True

File diff suppressed because it is too large Load Diff

View File

@ -2,7 +2,7 @@ import datetime
import pygsheets
from db_calls import db_get, db_patch, db_post, db_delete, get_player_headshot
from db_calls import db_get, get_player_headshot, get_team_by_abbrev, get_team_by_owner
# from db_calls import *
import asyncio
@ -835,7 +835,7 @@ async def get_player_embed(player, current, ctx=None, season=None):
if len(positions) > 0:
embed.add_field(name=f'Position{"s" if len(positions) > 1 else ""}', value=",".join(positions))
if player['team']['abbrev'][-3:].lower() == 'mil':
major_team = await get_one_team(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'])
if player['last_game']:
embed.add_field(name='Last G', value=player['last_game'])
@ -987,7 +987,7 @@ async def create_channel(
async def get_major_team(team):
if 'Il' in team['abbrev'][len(team['abbrev']) - 2:].lower():
return await get_one_team(team['abbrev'][:-2])
return await get_team_by_abbrev(team['abbrev'][:-2], team['season'])
else:
return team