76 lines
2.9 KiB
Python
76 lines
2.9 KiB
Python
# Paperdex Module - Fixed Implementation
|
|
# Contains collection tracking and statistics from the original players.py
|
|
|
|
from discord.ext import commands
|
|
from discord import app_commands
|
|
import discord
|
|
from typing import Optional
|
|
|
|
# Import specific utilities needed by this module
|
|
import logging
|
|
from api_calls import db_get
|
|
from helpers import (
|
|
PD_PLAYERS_ROLE_NAME, get_team_embed, get_team_by_owner, legal_channel,
|
|
paperdex_cardset_embed, paperdex_team_embed, embed_pagination
|
|
)
|
|
from helpers.search_utils import cardset_search
|
|
from discord_ui import SelectPaperdexCardset, SelectPaperdexTeam, SelectView
|
|
from helpers.constants import ALL_MLB_TEAMS
|
|
|
|
logger = logging.getLogger('discord_app')
|
|
|
|
|
|
class Paperdex(commands.Cog):
|
|
"""Collection tracking and statistics functionality for Paper Dynasty."""
|
|
|
|
def __init__(self, bot):
|
|
self.bot = bot
|
|
|
|
group_paperdex = app_commands.Group(name='paperdex', description='Check your card collection statistics')
|
|
|
|
@group_paperdex.command(name='cardset', description='Check your collection of a specific cardset')
|
|
@app_commands.checks.has_any_role(PD_PLAYERS_ROLE_NAME)
|
|
@commands.check(legal_channel)
|
|
async def paperdex_cardset_command(self, interaction: discord.Interaction):
|
|
"""Check collection statistics for a specific cardset using dropdown selection."""
|
|
|
|
team = await get_team_by_owner(interaction.user.id)
|
|
if not team:
|
|
await interaction.response.send_message('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='You have 15 seconds to select a cardset.',
|
|
view=view,
|
|
ephemeral=True
|
|
)
|
|
|
|
await view.wait()
|
|
await interaction.delete_original_response()
|
|
|
|
@group_paperdex.command(name='team', description='Check your collection of a specific MLB franchise')
|
|
@app_commands.checks.has_any_role(PD_PLAYERS_ROLE_NAME)
|
|
@commands.check(legal_channel)
|
|
async def paperdex_team_command(self, interaction: discord.Interaction):
|
|
"""Check collection statistics for a specific MLB franchise using dropdown selection."""
|
|
|
|
team = await get_team_by_owner(interaction.user.id)
|
|
if not team:
|
|
await interaction.response.send_message('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()
|
|
|
|
|
|
async def setup(bot):
|
|
"""Setup function for the Paperdex cog."""
|
|
await bot.add_cog(Paperdex(bot)) |