Merge branch 'main' into dev

This commit is contained in:
TrèsAbhi committed 2024-02-23 16:05:46 -06:00
1 parent 23a33c7722
commit a637dca083
1 file changed
+10 -26
+10 -26
View File
@@ -1,34 +1,19 @@
import { import { SlashCommandBuilder, SlashCommandSubcommandBuilder } from 'discord.js';
SlashCommandBuilder,
SlashCommandSubcommandBuilder,
SlashCommandSubcommandGroupBuilder,
} from 'discord.js';
import { TREE_TYPE_NAMES, TreeType } from '../../components/Tanks'; import { TREE_TYPE_NAMES, TreeType } from '../../components/Tanks';
import { encyclopediaInfo } from '../blitz/encyclopediaInfo'; import { EncyclopediaInfo } from '../blitz/encyclopediaInfo';
import addPeriodSubCommands from './addPeriodSubCommands';
import addTankChoices from './addTankChoices'; import addTankChoices from './addTankChoices';
import addTierChoices from './addTierChoices'; import addTierChoices from './addTierChoices';
export default async function addFilterOptions< export function addFilterOptions<
OptionType extends SlashCommandBuilder | SlashCommandSubcommandGroupBuilder, Option extends SlashCommandBuilder | SlashCommandSubcommandBuilder,
>( >(option: Option, encyclopediaInfo: EncyclopediaInfo) {
option: OptionType,
extra: (
option: SlashCommandSubcommandBuilder,
) => SlashCommandSubcommandBuilder = (option) => option,
): Promise<OptionType> {
const awaitedEncyclopediaInfo = await encyclopediaInfo;
addPeriodSubCommands(option, (option) => {
extra(option);
return option return option
.addStringOption((option) => .addStringOption((option) =>
option option
.setName('nation') .setName('nation')
.setDescription('Nation') .setDescription('Nation')
.addChoices( .addChoices(
...Object.entries(awaitedEncyclopediaInfo.vehicle_nations).map( ...Object.entries(encyclopediaInfo.vehicle_nations).map(
([type, name]) => ({ name, value: type }), ([type, name]) => ({ name, value: type }),
), ),
) )
@@ -40,7 +25,7 @@ export default async function addFilterOptions<
.setName('tank-type') .setName('tank-type')
.setDescription('Tank type') .setDescription('Tank type')
.addChoices( .addChoices(
...Object.entries(awaitedEncyclopediaInfo.vehicle_types).map( ...Object.entries(encyclopediaInfo.vehicle_types).map(
([type, name]) => ({ ([type, name]) => ({
name: name.replace(' Tank', ''), name: name.replace(' Tank', ''),
value: type, value: type,
@@ -69,8 +54,7 @@ export default async function addFilterOptions<
) )
.setRequired(false), .setRequired(false),
) )
.addStringOption((option) => addTankChoices(option).setRequired(false)); .addStringOption((option) =>
}); addTankChoices(option).setRequired(false),
) as Option;
return option;
} }