Files
blitzkit/src/core/discord/addPeriodSubCommands.ts
T

52 lines
1.6 KiB
TypeScript
Raw Normal View History

2023-06-19 17:35:28 +00:00
import {
SlashCommandSubcommandBuilder,
SlashCommandSubcommandGroupBuilder,
} from 'discord.js';
2023-06-27 01:46:08 +00:00
import { PERIOD_NAMES } from '../discord/resolvePeriodFromCommand.js';
2023-06-19 17:35:28 +00:00
export type Period = 'today' | '30' | '60' | '90' | 'career' | 'custom';
export default function addPeriodSubCommands(
option: SlashCommandSubcommandGroupBuilder,
extra: (
option: SlashCommandSubcommandBuilder,
) => SlashCommandSubcommandBuilder = (option) => option,
) {
return option
.addSubcommand((option) =>
extra(option.setName('today').setDescription(PERIOD_NAMES.today)),
)
.addSubcommand((option) =>
2023-06-23 01:35:15 +00:00
extra(option.setName('30').setDescription(PERIOD_NAMES[30])),
2023-06-19 17:35:28 +00:00
)
.addSubcommand((option) =>
2023-06-23 01:35:15 +00:00
extra(option.setName('60').setDescription(PERIOD_NAMES[60])),
2023-06-19 17:35:28 +00:00
)
.addSubcommand((option) =>
2023-06-23 01:35:15 +00:00
extra(option.setName('90').setDescription(PERIOD_NAMES[90])),
2023-06-19 17:35:28 +00:00
)
.addSubcommand((option) =>
extra(option.setName('career').setDescription(PERIOD_NAMES.career)),
)
.addSubcommand((option) =>
extra(
option
.setName('custom')
.setDescription(PERIOD_NAMES.custom)
.addIntegerOption((option) =>
option
.setName('start')
.setDescription('Start of period in days ago from today')
.setMinValue(0)
.setRequired(true),
)
.addIntegerOption((option) =>
option
.setName('end')
.setDescription('End of period in days ago from today')
.setMinValue(0)
.setRequired(true),
),
),
);
}