mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-23 11:39:50 +02:00
feat: express responses
This commit is contained in:
1 parent
0f46f333b5
commit
f2ae698438
45 files changed
+153
-93
No files matched your search
@@ -5,7 +5,7 @@ import { tankopedia } from '../core/blitz/tankopedia.js';
|
||||
import { tankAverages } from '../core/blitzstars/tankAverages.js';
|
||||
import cleanTable from '../core/interaction/cleanTable.js';
|
||||
import infoEmbed from '../core/interaction/infoEmbed.js';
|
||||
import getClientId from '../core/process/getClientId.js';
|
||||
import getClientId from '../core/node/getClientId.js';
|
||||
import { CommandRegistry } from '../events/interactionCreate/index.js';
|
||||
|
||||
const executionStart = new Date().getTime();
|
||||
@@ -19,7 +19,7 @@ export default {
|
||||
.setName('debug')
|
||||
.setDescription('Debug information about the bot'),
|
||||
|
||||
execute(interaction) {
|
||||
handler(interaction) {
|
||||
const currentTime = new Date().getTime();
|
||||
const uptime = currentTime - executionStart;
|
||||
|
||||
|
||||
@@ -10,9 +10,9 @@ import { tankAverages } from '../core/blitzstars/tankAverages.js';
|
||||
import cleanTable, { TableInput } from '../core/interaction/cleanTable.js';
|
||||
import negativeEmbed from '../core/interaction/negativeEmbed.js';
|
||||
import positiveEmbed from '../core/interaction/positiveEmbed.js';
|
||||
import { WARGAMING_APPLICATION_ID } from '../core/node/args.js';
|
||||
import addUsernameOption from '../core/options/addUsernameOption.js';
|
||||
import resolvePlayer from '../core/options/resolvePlayer.js';
|
||||
import { WARGAMING_APPLICATION_ID } from '../core/process/args.js';
|
||||
import { CommandRegistry } from '../events/interactionCreate/index.js';
|
||||
import { AccountInfo } from '../types/accountInfo.js';
|
||||
|
||||
@@ -46,7 +46,7 @@ export default {
|
||||
)
|
||||
.addStringOption(addUsernameOption),
|
||||
|
||||
async execute(interaction) {
|
||||
async handler(interaction) {
|
||||
const clan = interaction.options.getString('clan') as SkilledClan;
|
||||
const { id, server } = await resolvePlayer(interaction);
|
||||
const accountInfo = await getWargamingResponse<AccountInfo>(
|
||||
|
||||
@@ -2,8 +2,8 @@ import { SlashCommandBuilder } from 'discord.js';
|
||||
import tanksAutocomplete from '../core/autocomplete/tanks.js';
|
||||
import usernameAutocomplete from '../core/autocomplete/username.js';
|
||||
import resolveTankId from '../core/blitz/resolveTankId.js';
|
||||
import resolvePeriodFromCommand from '../core/interaction/resolvePeriodFromCommand.js';
|
||||
import addStatsSubCommandGroups from '../core/options/addStatsSubCommandGroups.js';
|
||||
import resolvePeriod from '../core/options/resolvePeriod.js';
|
||||
import resolvePlayer from '../core/options/resolvePlayer.js';
|
||||
import { CommandRegistry } from '../events/interactionCreate/index.js';
|
||||
import evolution from '../renderers/evolution.js';
|
||||
@@ -20,12 +20,12 @@ export default {
|
||||
.setDescription('Evolution of statistics'),
|
||||
),
|
||||
|
||||
async execute(interaction) {
|
||||
async handler(interaction) {
|
||||
const commandGroup = interaction.options.getSubcommandGroup(
|
||||
true,
|
||||
) as StatType;
|
||||
const player = await resolvePlayer(interaction);
|
||||
const period = resolvePeriod(interaction);
|
||||
const period = resolvePeriodFromCommand(interaction);
|
||||
const tankIdRaw = interaction.options.getString('tank')!;
|
||||
const tankId = commandGroup === 'tank' ? resolveTankId(tankIdRaw) : 0;
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ export default {
|
||||
.setName('help')
|
||||
.setDescription('All the help you need about the bot'),
|
||||
|
||||
execute(interaction) {
|
||||
handler(interaction) {
|
||||
return infoEmbed(
|
||||
`${client.user?.username} help`,
|
||||
`**About**\n${
|
||||
|
||||
@@ -8,8 +8,8 @@ import { BLITZ_SERVERS } from '../constants/servers.js';
|
||||
import clanAutocomplete from '../core/autocomplete/clan.js';
|
||||
import getBlitzClan from '../core/blitz/getBlitzClan.js';
|
||||
import getWargamingResponse from '../core/blitz/getWargamingResponse.js';
|
||||
import { WARGAMING_APPLICATION_ID } from '../core/node/args.js';
|
||||
import addClanChoices from '../core/options/addClanChoices.js';
|
||||
import { WARGAMING_APPLICATION_ID } from '../core/process/args.js';
|
||||
import { CommandRegistry } from '../events/interactionCreate/index.js';
|
||||
import { AccountInfo } from '../types/accountInfo.js';
|
||||
import { ClanInfo } from '../types/clanInfo.js';
|
||||
@@ -34,7 +34,7 @@ export default {
|
||||
.setMinValue(0),
|
||||
),
|
||||
|
||||
async execute(interaction) {
|
||||
async handler(interaction) {
|
||||
const clanName = interaction.options.getString('clan')!;
|
||||
const { server, id } = await getBlitzClan(interaction, clanName);
|
||||
const threshold =
|
||||
|
||||
@@ -13,9 +13,9 @@ import {
|
||||
Tier,
|
||||
tankopedia,
|
||||
} from '../core/blitz/tankopedia.js';
|
||||
import { WARGAMING_APPLICATION_ID } from '../core/node/args.js';
|
||||
import addUsernameOption from '../core/options/addUsernameOption.js';
|
||||
import resolvePlayer from '../core/options/resolvePlayer.js';
|
||||
import { WARGAMING_APPLICATION_ID } from '../core/process/args.js';
|
||||
import { CommandRegistry } from '../events/interactionCreate/index.js';
|
||||
import { AccountInfo } from '../types/accountInfo.js';
|
||||
import { PlayerClanData } from '../types/playerClanData.js';
|
||||
@@ -69,7 +69,7 @@ export default {
|
||||
)
|
||||
.addStringOption(addUsernameOption),
|
||||
|
||||
async execute(interaction) {
|
||||
async handler(interaction) {
|
||||
const tier = Number(interaction.options.getString('tier'));
|
||||
const account = await resolvePlayer(interaction);
|
||||
const { id, server } = account;
|
||||
|
||||
@@ -17,7 +17,7 @@ export default {
|
||||
option.setName('blitz').setDescription('Ping Blitz'),
|
||||
),
|
||||
|
||||
async execute(interaction) {
|
||||
async handler(interaction) {
|
||||
const subcommand = interaction.options.getSubcommand();
|
||||
const executionStart = Date.now();
|
||||
|
||||
|
||||
@@ -5,9 +5,9 @@ import usernameAutocomplete from '../core/autocomplete/username.js';
|
||||
import getWargamingResponse from '../core/blitz/getWargamingResponse.js';
|
||||
import cleanTable, { TableInputEntry } from '../core/interaction/cleanTable.js';
|
||||
import infoEmbed from '../core/interaction/infoEmbed.js';
|
||||
import { WARGAMING_APPLICATION_ID } from '../core/node/args.js';
|
||||
import addUsernameOption from '../core/options/addUsernameOption.js';
|
||||
import resolvePlayer from '../core/options/resolvePlayer.js';
|
||||
import { WARGAMING_APPLICATION_ID } from '../core/process/args.js';
|
||||
import { CommandRegistry } from '../events/interactionCreate/index.js';
|
||||
import { AccountAchievements } from '../types/accountAchievements.js';
|
||||
import { AccountInfo } from '../types/accountInfo.js';
|
||||
@@ -33,7 +33,7 @@ export default {
|
||||
),
|
||||
),
|
||||
|
||||
async execute(interaction) {
|
||||
async handler(interaction) {
|
||||
const sortBy = (interaction.options.getString('sort') ?? 'name') as SortBy;
|
||||
const account = await resolvePlayer(interaction);
|
||||
const { id, server } = account;
|
||||
|
||||
@@ -4,9 +4,9 @@ import usernameAutocomplete from '../core/autocomplete/username.js';
|
||||
import getWargamingResponse from '../core/blitz/getWargamingResponse.js';
|
||||
import cleanTable from '../core/interaction/cleanTable.js';
|
||||
import infoEmbed from '../core/interaction/infoEmbed.js';
|
||||
import { WARGAMING_APPLICATION_ID } from '../core/node/args.js';
|
||||
import addUsernameOption from '../core/options/addUsernameOption.js';
|
||||
import resolvePlayer from '../core/options/resolvePlayer.js';
|
||||
import { WARGAMING_APPLICATION_ID } from '../core/process/args.js';
|
||||
import { CommandRegistry } from '../events/interactionCreate/index.js';
|
||||
import { AccountInfo } from '../types/accountInfo.js';
|
||||
|
||||
@@ -20,7 +20,7 @@ export default {
|
||||
.setDescription('Basic information about a player')
|
||||
.addStringOption(addUsernameOption),
|
||||
|
||||
async execute(interaction) {
|
||||
async handler(interaction) {
|
||||
const account = await resolvePlayer(interaction);
|
||||
const { id, server } = account;
|
||||
const accounts = await getWargamingResponse<AccountInfo>(
|
||||
|
||||
@@ -3,9 +3,9 @@ import markdownEscape from 'markdown-escape';
|
||||
import { BLITZ_SERVERS, BlitzServer } from '../constants/servers.js';
|
||||
import getWargamingResponse from '../core/blitz/getWargamingResponse.js';
|
||||
import infoEmbed from '../core/interaction/infoEmbed.js';
|
||||
import { WARGAMING_APPLICATION_ID } from '../core/node/args.js';
|
||||
import addClanChoices from '../core/options/addClanChoices.js';
|
||||
import addServerChoices from '../core/options/addServerChoices.js';
|
||||
import { WARGAMING_APPLICATION_ID } from '../core/process/args.js';
|
||||
import { CommandRegistry } from '../events/interactionCreate/index.js';
|
||||
import { ClanList } from '../types/clanList.js';
|
||||
|
||||
@@ -27,7 +27,7 @@ export default {
|
||||
.setMaxValue(100),
|
||||
),
|
||||
|
||||
async execute(interaction) {
|
||||
async handler(interaction) {
|
||||
const server = interaction.options.getString('server') as BlitzServer;
|
||||
const clan = interaction.options.getString('clan')!;
|
||||
const limit = interaction.options.getInteger('limit') ?? 25;
|
||||
|
||||
@@ -4,9 +4,9 @@ import { BLITZ_SERVERS, BlitzServer } from '../constants/servers.js';
|
||||
import getWargamingResponse from '../core/blitz/getWargamingResponse.js';
|
||||
import { usernamePattern } from '../core/blitz/listAccountsPanServer.js';
|
||||
import infoEmbed from '../core/interaction/infoEmbed.js';
|
||||
import { WARGAMING_APPLICATION_ID } from '../core/node/args.js';
|
||||
import addServerChoices from '../core/options/addServerChoices.js';
|
||||
import addUsernameOption from '../core/options/addUsernameOption.js';
|
||||
import { WARGAMING_APPLICATION_ID } from '../core/process/args.js';
|
||||
import { CommandRegistry } from '../events/interactionCreate/index.js';
|
||||
import { AccountList } from '../types/accountList.js';
|
||||
|
||||
@@ -30,7 +30,7 @@ export default {
|
||||
.setMaxValue(100),
|
||||
),
|
||||
|
||||
async execute(interaction) {
|
||||
async handler(interaction) {
|
||||
const server = interaction.options.getString('server') as BlitzServer;
|
||||
const name = interaction.options.getString('username')!;
|
||||
const limit = interaction.options.getInteger('limit') ?? 25;
|
||||
|
||||
@@ -23,7 +23,7 @@ export default {
|
||||
.setMaxValue(100),
|
||||
),
|
||||
|
||||
async execute(interaction) {
|
||||
async handler(interaction) {
|
||||
const tank = interaction.options.getString('tank')!;
|
||||
const limit = interaction.options.getInteger('limit') ?? 25;
|
||||
const results = go(tank, TANK_NAMES, { limit }).map(
|
||||
|
||||
@@ -6,9 +6,9 @@ import resolveTankId from '../core/blitz/resolveTankId.js';
|
||||
import interactionToURL from '../core/interaction/interactionToURL.js';
|
||||
import linkButton from '../core/interaction/linkButton.js';
|
||||
import primaryButton from '../core/interaction/primaryButton.js';
|
||||
import resolvePeriodFromCommand from '../core/interaction/resolvePeriodFromCommand.js';
|
||||
import { Period } from '../core/options/addPeriodSubCommands.js';
|
||||
import addStatsSubCommandGroups from '../core/options/addStatsSubCommandGroups.js';
|
||||
import resolvePeriod from '../core/options/resolvePeriod.js';
|
||||
import resolvePlayer from '../core/options/resolvePlayer.js';
|
||||
import { CommandRegistry } from '../events/interactionCreate/index.js';
|
||||
import stats, { StatType } from '../renderers/stats.js';
|
||||
@@ -24,13 +24,13 @@ export default {
|
||||
.setDescription('In-game statistics'),
|
||||
),
|
||||
|
||||
async execute(interaction) {
|
||||
async handler(interaction) {
|
||||
const commandGroup = interaction.options.getSubcommandGroup(
|
||||
true,
|
||||
) as StatType;
|
||||
const subcommand = interaction.options.getSubcommand() as Period;
|
||||
const player = await resolvePlayer(interaction);
|
||||
const period = resolvePeriod(interaction);
|
||||
const period = resolvePeriodFromCommand(interaction);
|
||||
const tankIdRaw = interaction.options.getString('tank')!;
|
||||
const tankId = commandGroup === 'tank' ? resolveTankId(tankIdRaw) : 0;
|
||||
const start = interaction.options.getInteger('start');
|
||||
@@ -57,7 +57,7 @@ export default {
|
||||
const url = new URL(`${CYCLIC_API}/${interaction.customId}`);
|
||||
const path = url.pathname.split('/').filter(Boolean);
|
||||
const commandGroup = path[1] as StatType;
|
||||
const period = resolvePeriod(interaction);
|
||||
const period = resolvePeriodFromCommand(interaction);
|
||||
const player = await resolvePlayer(interaction);
|
||||
|
||||
return await stats(
|
||||
|
||||
@@ -15,7 +15,7 @@ export default {
|
||||
.setDescription('A general daily breakdown of your performance')
|
||||
.addStringOption(addUsernameOption),
|
||||
|
||||
async execute(interaction) {
|
||||
async handler(interaction) {
|
||||
const player = await resolvePlayer(interaction);
|
||||
|
||||
return await today(player);
|
||||
|
||||
@@ -5,9 +5,9 @@ import usernameAutocomplete from '../core/autocomplete/username.js';
|
||||
import getWargamingResponse from '../core/blitz/getWargamingResponse.js';
|
||||
import negativeEmbed from '../core/interaction/negativeEmbed.js';
|
||||
import positiveEmbed from '../core/interaction/positiveEmbed.js';
|
||||
import { WARGAMING_APPLICATION_ID } from '../core/node/args.js';
|
||||
import addUsernameOption from '../core/options/addUsernameOption.js';
|
||||
import resolvePlayer from '../core/options/resolvePlayer.js';
|
||||
import { WARGAMING_APPLICATION_ID } from '../core/process/args.js';
|
||||
import { CommandRegistry } from '../events/interactionCreate/index.js';
|
||||
import { AccountInfo } from '../types/accountInfo.js';
|
||||
import { PlayerClanData } from '../types/playerClanData.js';
|
||||
@@ -22,7 +22,7 @@ export default {
|
||||
.setDescription("Set's the user's username to their in-game name")
|
||||
.addStringOption((option) => addUsernameOption(option).setRequired(true)),
|
||||
|
||||
async execute(interaction) {
|
||||
async handler(interaction) {
|
||||
const blitzAccount = await resolvePlayer(interaction);
|
||||
const { id, server } = blitzAccount;
|
||||
const accountInfo = await getWargamingResponse<AccountInfo>(
|
||||
|
||||
Reference in new issue
Block a user