mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-21 10:47:04 +02:00
feat: extracted sub command groups
This commit is contained in:
1 parent
70145abe86
commit
3e8e198c88
4 files changed
+41
-52
No files matched your search
@@ -15,12 +15,11 @@ import { tankopedia } from '../core/blitz/tankopedia.js';
|
||||
import getTankHistories from '../core/blitzstars/getTankHistories.js';
|
||||
import cmdName from '../core/interaction/cmdName.js';
|
||||
import { supportBlitzStars } from '../core/interaction/supportBlitzStars.js';
|
||||
import addPeriodSubCommands, {
|
||||
import {
|
||||
Period,
|
||||
RELATIVE_PERIOD_NAMES,
|
||||
} from '../core/options/addPeriodSubCommands.js';
|
||||
import addTankChoices from '../core/options/addTankChoices.js';
|
||||
import addUsernameOption from '../core/options/addUsernameOption.js';
|
||||
import addStatsSubCommandGroups from '../core/options/addStatsSubCommandGroups.js';
|
||||
import getPeriodDataFromSubcommand from '../core/options/getPeriodDataFromSubcommand.js';
|
||||
import { WARGAMING_APPLICATION_ID } from '../core/process/args.js';
|
||||
import { CommandRegistry } from '../events/interactionCreate.js';
|
||||
@@ -32,25 +31,11 @@ export default {
|
||||
inDevelopment: true,
|
||||
inPublic: true,
|
||||
|
||||
command: new SlashCommandBuilder()
|
||||
.setName(cmdName('evolution'))
|
||||
.setDescription('Evolution of statistics')
|
||||
.addSubcommandGroup((option) =>
|
||||
addPeriodSubCommands(option, (option) =>
|
||||
option.addStringOption(addUsernameOption),
|
||||
)
|
||||
.setName('player')
|
||||
.setDescription("Player's statistics"),
|
||||
)
|
||||
.addSubcommandGroup((option) =>
|
||||
addPeriodSubCommands(option, (option) =>
|
||||
option
|
||||
.addStringOption(addTankChoices)
|
||||
.addStringOption(addUsernameOption),
|
||||
)
|
||||
.setName('tank')
|
||||
.setDescription("Tank's statistics"),
|
||||
),
|
||||
command: addStatsSubCommandGroups(
|
||||
new SlashCommandBuilder()
|
||||
.setName(cmdName('evolution'))
|
||||
.setDescription('Evolution of statistics'),
|
||||
),
|
||||
|
||||
async execute(interaction) {
|
||||
const commandGroup = interaction.options.getSubcommandGroup()!;
|
||||
|
||||
+7
-28
@@ -18,9 +18,7 @@ import { Tier, tankopedia } from '../core/blitz/tankopedia.js';
|
||||
import getTankStatsOverTime from '../core/blitzstars/getTankStatsOverTime.js';
|
||||
import { tankAverages } from '../core/blitzstars/tankAverages.js';
|
||||
import cmdName from '../core/interaction/cmdName.js';
|
||||
import addPeriodSubCommands from '../core/options/addPeriodSubCommands.js';
|
||||
import addTankChoices from '../core/options/addTankChoices.js';
|
||||
import addUsernameOption from '../core/options/addUsernameOption.js';
|
||||
import addStatsSubCommandGroups from '../core/options/addStatsSubCommandGroups.js';
|
||||
import getPeriodDataFromSubcommand from '../core/options/getPeriodDataFromSubcommand.js';
|
||||
import { WARGAMING_APPLICATION_ID } from '../core/process/args.js';
|
||||
import { CommandRegistry } from '../events/interactionCreate.js';
|
||||
@@ -36,26 +34,11 @@ export default {
|
||||
inDevelopment: true,
|
||||
inPublic: true,
|
||||
|
||||
command: new SlashCommandBuilder()
|
||||
// TODO: embed cmdName into interaction create
|
||||
.setName(cmdName('stats'))
|
||||
.setDescription('In-game statistics')
|
||||
.addSubcommandGroup((option) =>
|
||||
addPeriodSubCommands(option, (option) =>
|
||||
option.addStringOption(addUsernameOption),
|
||||
)
|
||||
.setName('player')
|
||||
.setDescription("Player's statistics"),
|
||||
)
|
||||
.addSubcommandGroup((option) =>
|
||||
addPeriodSubCommands(option, (option) =>
|
||||
option
|
||||
.addStringOption(addTankChoices)
|
||||
.addStringOption(addUsernameOption),
|
||||
)
|
||||
.setName('tank')
|
||||
.setDescription("Tank's statistics"),
|
||||
),
|
||||
command: addStatsSubCommandGroups(
|
||||
new SlashCommandBuilder()
|
||||
.setName(cmdName('stats'))
|
||||
.setDescription('In-game statistics'),
|
||||
),
|
||||
|
||||
async execute(interaction) {
|
||||
const commandGroup = interaction.options.getSubcommandGroup()!;
|
||||
@@ -81,11 +64,7 @@ export default {
|
||||
image = tankopedia[tankId].images.normal;
|
||||
}
|
||||
|
||||
const {
|
||||
statsName,
|
||||
start,
|
||||
end,
|
||||
} = getPeriodDataFromSubcommand(interaction);
|
||||
const { statsName, start, end } = getPeriodDataFromSubcommand(interaction);
|
||||
|
||||
const tankStats = await getTankStatsOverTime(server, id, start, end);
|
||||
let stats: AllStats;
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
import { SlashCommandBuilder } from 'discord.js';
|
||||
import addPeriodSubCommands from './addPeriodSubCommands.js';
|
||||
import addTankChoices from './addTankChoices.js';
|
||||
import addUsernameOption from './addUsernameOption.js';
|
||||
|
||||
export default function addStatsSubCommandGroups(option: SlashCommandBuilder) {
|
||||
return option
|
||||
.addSubcommandGroup((option) =>
|
||||
addPeriodSubCommands(option, (option) =>
|
||||
option.addStringOption(addUsernameOption),
|
||||
)
|
||||
.setName('player')
|
||||
.setDescription("Player's statistics"),
|
||||
)
|
||||
.addSubcommandGroup((option) =>
|
||||
addPeriodSubCommands(option, (option) =>
|
||||
option
|
||||
.addStringOption(addTankChoices)
|
||||
.addStringOption(addUsernameOption),
|
||||
)
|
||||
.setName('tank')
|
||||
.setDescription("Tank's statistics"),
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user