Merge pull request 'feat: use Discord Choice menus for /refractor status parameters' (#126) from enhancement/refractor-choice-params into main
All checks were successful
Build Docker Image / build (push) Successful in 2m40s
All checks were successful
Build Docker Image / build (push) Successful in 2m40s
This commit is contained in:
commit
48392a9bbe
@ -15,6 +15,7 @@ from typing import Optional
|
|||||||
|
|
||||||
import discord
|
import discord
|
||||||
from discord import app_commands
|
from discord import app_commands
|
||||||
|
from discord.app_commands import Choice
|
||||||
from discord.ext import commands
|
from discord.ext import commands
|
||||||
|
|
||||||
from api_calls import db_get
|
from api_calls import db_get
|
||||||
@ -142,19 +143,34 @@ class Refractor(commands.Cog):
|
|||||||
name="status", description="Show your team's refractor progress"
|
name="status", description="Show your team's refractor progress"
|
||||||
)
|
)
|
||||||
@app_commands.describe(
|
@app_commands.describe(
|
||||||
card_type="Card type filter (batter, sp, rp)",
|
card_type="Filter by card type",
|
||||||
season="Season number (default: current)",
|
tier="Filter by current tier",
|
||||||
tier="Filter by current tier (0-4)",
|
progress="Filter by advancement progress",
|
||||||
progress='Use "close" to show cards within 80% of their next tier',
|
|
||||||
page="Page number (default: 1, 10 cards per page)",
|
page="Page number (default: 1, 10 cards per page)",
|
||||||
)
|
)
|
||||||
|
@app_commands.choices(
|
||||||
|
card_type=[
|
||||||
|
Choice(value="batter", name="Batter"),
|
||||||
|
Choice(value="sp", name="Starting Pitcher"),
|
||||||
|
Choice(value="rp", name="Relief Pitcher"),
|
||||||
|
],
|
||||||
|
tier=[
|
||||||
|
Choice(value="0", name="T0 — Base Card"),
|
||||||
|
Choice(value="1", name="T1 — Base Chrome"),
|
||||||
|
Choice(value="2", name="T2 — Refractor"),
|
||||||
|
Choice(value="3", name="T3 — Gold Refractor"),
|
||||||
|
Choice(value="4", name="T4 — Superfractor"),
|
||||||
|
],
|
||||||
|
progress=[
|
||||||
|
Choice(value="close", name="Close to next tier (≥80%)"),
|
||||||
|
],
|
||||||
|
)
|
||||||
async def refractor_status(
|
async def refractor_status(
|
||||||
self,
|
self,
|
||||||
interaction: discord.Interaction,
|
interaction: discord.Interaction,
|
||||||
card_type: Optional[str] = None,
|
card_type: Optional[Choice[str]] = None,
|
||||||
season: Optional[int] = None,
|
tier: Optional[Choice[str]] = None,
|
||||||
tier: Optional[int] = None,
|
progress: Optional[Choice[str]] = None,
|
||||||
progress: Optional[str] = None,
|
|
||||||
page: int = 1,
|
page: int = 1,
|
||||||
):
|
):
|
||||||
"""Show a paginated view of the invoking user's team refractor progress."""
|
"""Show a paginated view of the invoking user's team refractor progress."""
|
||||||
@ -171,13 +187,11 @@ class Refractor(commands.Cog):
|
|||||||
offset = (page - 1) * PAGE_SIZE
|
offset = (page - 1) * PAGE_SIZE
|
||||||
params = [("team_id", team["id"]), ("limit", PAGE_SIZE), ("offset", offset)]
|
params = [("team_id", team["id"]), ("limit", PAGE_SIZE), ("offset", offset)]
|
||||||
if card_type:
|
if card_type:
|
||||||
params.append(("card_type", card_type))
|
params.append(("card_type", card_type.value))
|
||||||
if season is not None:
|
|
||||||
params.append(("season", season))
|
|
||||||
if tier is not None:
|
if tier is not None:
|
||||||
params.append(("tier", tier))
|
params.append(("tier", tier.value))
|
||||||
if progress:
|
if progress:
|
||||||
params.append(("progress", progress))
|
params.append(("progress", progress.value))
|
||||||
|
|
||||||
data = await db_get("refractor/cards", params=params)
|
data = await db_get("refractor/cards", params=params)
|
||||||
if not data:
|
if not data:
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user