diff --git a/packages/bot/src/commands.ts b/packages/bot/src/commands.ts index ae42f85..8a78b9d 100644 --- a/packages/bot/src/commands.ts +++ b/packages/bot/src/commands.ts @@ -88,6 +88,7 @@ export const appCommands: Record< }, standings: { handlers: { BASE: standingsCallback }, + autocompleteHandlers: { BASE: seasonAutocomplete }, }, whois: { handlers: { BASE: whoisCallback }, diff --git a/packages/bot/src/commands/standings.ts b/packages/bot/src/commands/standings.ts index dd46a97..bb27974 100644 --- a/packages/bot/src/commands/standings.ts +++ b/packages/bot/src/commands/standings.ts @@ -149,7 +149,7 @@ export const getHtStandings = async ( // The KHL proxy won't return non-career seasons so // we can just use the latest one sid = "latest"; - } else { + } else if (seasonId === undefined) { const seasons = (await client.getSeasonList()).SiteKit.Seasons; if (seasons.length === 0 && seasonId === undefined) { return null; @@ -199,9 +199,14 @@ export const standingsCallback: ChatInputAppCommandCallback = async (ctx) => { return ctx.reply(utils.standings!()); } const sort = ctx.getStringOption("sort").value || undefined; + const seasonId = ctx.getStringOption("season").value || undefined; const client = getHtClient(league, getHtLocale(ctx)); - const standings = await getHtStandings(client, sort); + const standings = await getHtStandings( + client, + sort, + seasonId ? Number(seasonId) : undefined, + ); if (!standings) { return ctx.reply({ content: s(ctx, "noSeasons"), diff --git a/packages/bot/src/register.ts b/packages/bot/src/register.ts index c0b95a6..59d1eb9 100644 --- a/packages/bot/src/register.ts +++ b/packages/bot/src/register.ts @@ -305,6 +305,14 @@ const payload: RESTPutAPIApplicationCommandsJSONBody = [ }, ], }, + { + type: ApplicationCommandOptionType.String, + name: "season", + description: + "The season to get standings for. If not specified, uses the current season", + required: false, + autocomplete: true, + }, ], }, {