Skip to content

Commit

Permalink
feat(bot): season arg for /standings
Browse files Browse the repository at this point in the history
  • Loading branch information
shayypy committed Nov 24, 2024
1 parent c686f31 commit 9c83da8
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
1 change: 1 addition & 0 deletions packages/bot/src/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ export const appCommands: Record<
},
standings: {
handlers: { BASE: standingsCallback },
autocompleteHandlers: { BASE: seasonAutocomplete },
},
whois: {
handlers: { BASE: whoisCallback },
Expand Down
9 changes: 7 additions & 2 deletions packages/bot/src/commands/standings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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"),
Expand Down
8 changes: 8 additions & 0 deletions packages/bot/src/register.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
],
},
{
Expand Down

0 comments on commit 9c83da8

Please sign in to comment.