mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-11-14 05:06:11 +01:00
feat: core chunk 4
This commit is contained in:
1 parent
b827f7f730
commit
9bdb14e13a
22 files changed
+46
-31
No files matched your search
@@ -1,6 +1,6 @@
|
||||
import { SlashCommandStringOption } from 'discord.js';
|
||||
import { range } from 'lodash';
|
||||
import numberToRomanNumeral from '../blitz/numberToRomanNumeral';
|
||||
import numberToRomanNumeral from '../../core/math/numberToRomanNumeral';
|
||||
|
||||
export default function addTierChoices(option: SlashCommandStringOption) {
|
||||
return option
|
||||
|
||||
@@ -4,7 +4,7 @@ import {
|
||||
CacheType,
|
||||
} from 'discord.js';
|
||||
import { REGION_NAMES } from '../../constants/regions';
|
||||
import listClans from '../blitz/listClans';
|
||||
import searchClansAcrossRegions from '../../core/blitz/searchClansAcrossRegions';
|
||||
|
||||
export default async function autocompleteClan(
|
||||
interaction: AutocompleteInteraction<CacheType>,
|
||||
@@ -12,7 +12,7 @@ export default async function autocompleteClan(
|
||||
const focusedOption = interaction.options.getFocused(true);
|
||||
if (focusedOption.name !== 'clan') return;
|
||||
if (focusedOption.value.length < 2) return interaction.respond([]);
|
||||
const players = await listClans(focusedOption.value);
|
||||
const players = await searchClansAcrossRegions(focusedOption.value);
|
||||
|
||||
await interaction.respond(
|
||||
players
|
||||
|
||||
@@ -4,14 +4,14 @@ import {
|
||||
CacheType,
|
||||
} from 'discord.js';
|
||||
import { REGION_NAMES } from '../../constants/regions';
|
||||
import listPlayers from '../blitz/listPlayers';
|
||||
import searchPlayersAcrossRegions from '../../core/blitz/searchPlayersAcrossRegions';
|
||||
|
||||
export default async function autocompleteUsername(
|
||||
interaction: AutocompleteInteraction<CacheType>,
|
||||
) {
|
||||
const focusedOption = interaction.options.getFocused(true);
|
||||
if (focusedOption.name !== 'username') return;
|
||||
const players = await listPlayers(focusedOption.value);
|
||||
const players = await searchPlayersAcrossRegions(focusedOption.value);
|
||||
|
||||
try {
|
||||
await interaction.respond(
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
import { ChatInputCommandInteraction } from 'discord.js';
|
||||
import { TreeTypeString } from '../../components/Tanks';
|
||||
import { StatFilters } from '../../core/statistics/filterStats';
|
||||
import resolveTankId from '../blitz/resolveTankId';
|
||||
|
||||
export function getFiltersFromCommand(
|
||||
export async function getFiltersFromCommand(
|
||||
interaction: ChatInputCommandInteraction,
|
||||
) {
|
||||
const tankRaw = interaction.options.getString('tank');
|
||||
|
||||
return {
|
||||
nation: interaction.options.getString('nation') ?? undefined,
|
||||
tier: parseInt(interaction.options.getString('tier') ?? '0') || undefined,
|
||||
@@ -13,6 +16,6 @@ export function getFiltersFromCommand(
|
||||
(interaction.options.getString('tree-type') as
|
||||
| TreeTypeString
|
||||
| undefined) ?? undefined,
|
||||
tank: parseInt(interaction.options.getString('tank') ?? '0') || undefined,
|
||||
tank: tankRaw === null ? undefined : await resolveTankId(tankRaw),
|
||||
} satisfies StatFilters;
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
import { ChatInputCommandInteraction } from 'discord.js';
|
||||
import { Region } from '../../constants/regions';
|
||||
import listClans from '../blitz/listClans';
|
||||
import searchClansAcrossRegions from '../../core/blitz/searchClansAcrossRegions';
|
||||
import throwError from '../node/throwError';
|
||||
import { serverAndIdPattern } from './resolvePlayerFromCommand';
|
||||
|
||||
@@ -13,7 +13,7 @@ export default async function resolveClanFromCommand(
|
||||
const [server, accountId] = clan.split('/');
|
||||
return { region: server as Region, id: Number(accountId) };
|
||||
} else {
|
||||
const accounts = await listClans(clan);
|
||||
const accounts = await searchClansAcrossRegions(clan);
|
||||
|
||||
if (accounts[0]) {
|
||||
return { region: accounts[0].region, id: accounts[0].clan_id };
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { CacheType, ChatInputCommandInteraction } from 'discord.js';
|
||||
import markdownEscape from 'markdown-escape';
|
||||
import { Region } from '../../constants/regions';
|
||||
import listPlayers from '../blitz/listPlayers';
|
||||
import searchPlayersAcrossRegions from '../../core/blitz/searchPlayersAcrossRegions';
|
||||
import { getBlitzFromDiscord } from '../cockroackdb/discordBlitz';
|
||||
import throwError from '../node/throwError';
|
||||
|
||||
@@ -26,7 +26,7 @@ export default async function resolvePlayerFromCommand(
|
||||
id: Number(accountId),
|
||||
} satisfies ResolvedPlayer;
|
||||
} else {
|
||||
const accounts = await listPlayers(commandUsername);
|
||||
const accounts = await searchPlayersAcrossRegions(commandUsername);
|
||||
|
||||
if (accounts[0]) {
|
||||
return {
|
||||
|
||||
Reference in new issue
Block a user