mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-24 20:19:49 +02:00
Merge branch 'main' into dev
This commit is contained in:
1 parent
23a33c7722
commit
a637dca083
1 file changed
+55
-71
@@ -1,76 +1,60 @@
|
|||||||
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,
|
return option
|
||||||
extra: (
|
.addStringOption((option) =>
|
||||||
option: SlashCommandSubcommandBuilder,
|
option
|
||||||
) => SlashCommandSubcommandBuilder = (option) => option,
|
.setName('nation')
|
||||||
): Promise<OptionType> {
|
.setDescription('Nation')
|
||||||
const awaitedEncyclopediaInfo = await encyclopediaInfo;
|
.addChoices(
|
||||||
|
...Object.entries(encyclopediaInfo.vehicle_nations).map(
|
||||||
addPeriodSubCommands(option, (option) => {
|
([type, name]) => ({ name, value: type }),
|
||||||
extra(option);
|
),
|
||||||
|
)
|
||||||
return option
|
.setRequired(false),
|
||||||
.addStringOption((option) =>
|
)
|
||||||
option
|
.addStringOption((option) => addTierChoices(option).setRequired(false))
|
||||||
.setName('nation')
|
.addStringOption((option) =>
|
||||||
.setDescription('Nation')
|
option
|
||||||
.addChoices(
|
.setName('tank-type')
|
||||||
...Object.entries(awaitedEncyclopediaInfo.vehicle_nations).map(
|
.setDescription('Tank type')
|
||||||
([type, name]) => ({ name, value: type }),
|
.addChoices(
|
||||||
),
|
...Object.entries(encyclopediaInfo.vehicle_types).map(
|
||||||
)
|
([type, name]) => ({
|
||||||
.setRequired(false),
|
name: name.replace(' Tank', ''),
|
||||||
)
|
value: type,
|
||||||
.addStringOption((option) => addTierChoices(option).setRequired(false))
|
}),
|
||||||
.addStringOption((option) =>
|
),
|
||||||
option
|
)
|
||||||
.setName('tank-type')
|
.setRequired(false),
|
||||||
.setDescription('Tank type')
|
)
|
||||||
.addChoices(
|
.addStringOption((option) =>
|
||||||
...Object.entries(awaitedEncyclopediaInfo.vehicle_types).map(
|
option
|
||||||
([type, name]) => ({
|
.setName('tree-type')
|
||||||
name: name.replace(' Tank', ''),
|
.setDescription('Tech tree type')
|
||||||
value: type,
|
.addChoices(
|
||||||
}),
|
{
|
||||||
),
|
name: TREE_TYPE_NAMES['researchable'],
|
||||||
)
|
value: 'researchable' satisfies TreeType,
|
||||||
.setRequired(false),
|
},
|
||||||
)
|
{
|
||||||
.addStringOption((option) =>
|
name: TREE_TYPE_NAMES.premium,
|
||||||
option
|
value: 'premium' satisfies TreeType,
|
||||||
.setName('tree-type')
|
},
|
||||||
.setDescription('Tech tree type')
|
{
|
||||||
.addChoices(
|
name: TREE_TYPE_NAMES.collector,
|
||||||
{
|
value: 'collector' satisfies TreeType,
|
||||||
name: TREE_TYPE_NAMES['researchable'],
|
},
|
||||||
value: 'researchable' satisfies TreeType,
|
)
|
||||||
},
|
.setRequired(false),
|
||||||
{
|
)
|
||||||
name: TREE_TYPE_NAMES.premium,
|
.addStringOption((option) =>
|
||||||
value: 'premium' satisfies TreeType,
|
addTankChoices(option).setRequired(false),
|
||||||
},
|
) as Option;
|
||||||
{
|
|
||||||
name: TREE_TYPE_NAMES.collector,
|
|
||||||
value: 'collector' satisfies TreeType,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
.setRequired(false),
|
|
||||||
)
|
|
||||||
.addStringOption((option) => addTankChoices(option).setRequired(false));
|
|
||||||
});
|
|
||||||
|
|
||||||
return option;
|
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user