Update players.py

Replace paperdex functions with new SelectMenu versions
This commit is contained in:
Cal Corum 2023-02-26 15:36:58 -06:00
parent 90d89178f3
commit cdb34e881f

View File

@ -18,7 +18,7 @@ from db_calls import db_get, db_post, db_patch
from helpers import PD_PLAYERS_ROLE_NAME, IMAGES, PD_SEASON, random_conf_gif, fuzzy_player_search, ALL_MLB_TEAMS, \
fuzzy_search, get_channel, display_cards, get_card_embeds, get_team_embed, cardset_search, get_blank_team_card, \
get_team_by_owner, get_rosters, get_roster_sheet, legal_channel, random_conf_word, embed_pagination, get_cal_user, \
team_summary_embed, SelectView, SelectPaperdexCardset
team_summary_embed, SelectView, SelectPaperdexCardset, SelectPaperdexTeam
from typing import Optional, Literal
# date = f'{datetime.datetime.now().year}-{datetime.datetime.now().month}-{datetime.datetime.now().day}'
@ -551,61 +551,34 @@ class Players(commands.Cog):
await interaction.response.send_message(f'Do you even have a team? I don\'t know you.', ephemeral=True)
return
view = SelectView([SelectPaperdexCardset()], timeout=15)
await interaction.response.send_message(
content=None,
view=SelectView(SelectPaperdexCardset(), timeout=15),
content='You have 15 seconds to select a cardset.',
view=view,
ephemeral=True
)
# @commands.hybrid_group(name='paperdex', help='Check your collection counts')
# @commands.has_any_role(PD_PLAYERS_ROLE_NAME)
# @commands.check(legal_channel)
# async def paperdex_command(self, ctx: commands.Context):
# if ctx.invoked_subcommand is None:
# await ctx.send(f'The available dex commands are: `cardset`')
#
# @paperdex_command.command(name='cardset', help='Check your collection of a specific cardset')
# @commands.has_any_role(PD_PLAYERS_ROLE_NAME)
# @commands.check(legal_channel)
# async def paperdex_cardset(
# self, ctx: commands.Context,
# cardset_name: Literal['2013 Season', '2019 Season', '2021 Season', '2022 Season', '2022 Promos',
# 'Sams Choice']):
# team = get_team_by_owner(ctx.author.id)
#
# c_query = db_get('cardsets', params=[('name', cardset_name)])
# if c_query['count'] == 0:
# await ctx.send(f'Ope, I couldn\'t find that cardset. {get_cal_user(ctx).mention} halp.')
# return
# this_cardset = c_query['cardsets'][0]
#
#
#
# await embed_pagination(display_embeds, ctx.channel, ctx.author, timeout=30)
#
# @paperdex_command.command(name='team', help='Check your collection of a specific MLB team')
# @commands.has_any_role(PD_PLAYERS_ROLE_NAME)
# @commands.check(legal_channel)
# async def paperdex_team(self, ctx: commands.Context, team_name: str):
# await interaction.response.defer()
# team = get_team_by_owner(ctx.author.id)
#
# team_choice = None
# if team_name.title() in ALL_MLB_TEAMS.keys():
# team_choice = team_name.title()
# else:
# for x in ALL_MLB_TEAMS:
# if team_name.upper() in ALL_MLB_TEAMS[x] or team_name.title() in ALL_MLB_TEAMS[x]:
# team_choice = x
# break
#
# if not team_choice:
#
#
# p_query = db_get('players', params=[('franchise', team_choice)])
# if p_query['count'] == 0:
# await ctx.send(f'Hmm...I don\'t see any players from the {team_choice}. What\'s up with that '
# f'{get_cal_user(ctx).mention}?')
await view.wait()
await interaction.delete_original_response()
@group_paperdex.command(name='team', description='Check your collection of a specific MLB franchise')
@commands.has_any_role(PD_PLAYERS_ROLE_NAME)
@commands.check(legal_channel)
async def paperdex_cardset_slash(self, interaction: discord.Interaction):
team = get_team_by_owner(interaction.user.id)
if not team:
await interaction.response.send_message(f'Do you even have a team? I don\'t know you.', ephemeral=True)
return
view = SelectView([SelectPaperdexTeam('AL'), SelectPaperdexTeam('NL')], timeout=30)
await interaction.response.send_message(
content='You have 30 seconds to select a team.',
view=view,
ephemeral=True
)
await view.wait()
await interaction.delete_original_response()
@commands.hybrid_command(name='ai-teams', help='Get list of AI teams and abbreviations')
@commands.has_any_role(PD_PLAYERS_ROLE_NAME)
@ -722,11 +695,6 @@ class Players(commands.Cog):
await ctx.send(content=None, embed=embed)
# @paperdex_command.command(name='teams', help='Check your collection based on team')
# @commands.has_any_role(PD_PLAYERS_ROLE_NAME)
# @commands.check(legal_channel)
# async def paperdex_team(self, ctx: commands.Context, team_abbrev: Optional[str]):
@commands.hybrid_command(name='pullroster', help='Pull saved rosters from your team Sheet',
aliases=['roster', 'rosters', 'pullrosters'])
@app_commands.describe(