mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-21 10:47:04 +02:00
fix: remove region from autocomplete
This commit is contained in:
1 parent
fa72e8efab
commit
73a51cbb40
3 files changed
+9
-12
No files matched your search
@@ -36,7 +36,7 @@ export async function autocompleteClan(
|
||||
|
||||
return {
|
||||
name,
|
||||
value: `${clan.region}/${clan.clan_id}`,
|
||||
value: `${clan.clan_id}`,
|
||||
} satisfies ApplicationCommandOptionChoiceData<string>;
|
||||
})
|
||||
: [],
|
||||
|
||||
@@ -39,7 +39,7 @@ export async function autocompleteUsername(
|
||||
|
||||
return {
|
||||
name,
|
||||
value: `${player.region}/${player.account_id}`,
|
||||
value: `${player.account_id}`,
|
||||
} satisfies ApplicationCommandOptionChoiceData<string>;
|
||||
})
|
||||
: [],
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
import { Region, searchPlayersAcrossRegions } from '@blitzkit/core';
|
||||
import { idToRegion, Region, searchPlayersAcrossRegions } from '@blitzkit/core';
|
||||
import { CacheType, ChatInputCommandInteraction } from 'discord.js';
|
||||
import markdownEscape from 'markdown-escape';
|
||||
import { getBlitzFromDiscord } from '../../blitzkit/getBlitzFromDiscord';
|
||||
import { translator } from '../../localization/translator';
|
||||
import { serverAndIdPattern } from './constants';
|
||||
import { UserError } from '../../blitzkit/userError';
|
||||
import { translator } from '../../localization/translator';
|
||||
|
||||
export interface ResolvedPlayer {
|
||||
region: Region;
|
||||
@@ -17,14 +16,12 @@ export async function resolvePlayerFromCommand(
|
||||
const { t, translate } = translator(interaction.locale);
|
||||
const commandUsername = interaction.options.getString('username');
|
||||
|
||||
if (commandUsername) {
|
||||
if (serverAndIdPattern.test(commandUsername)) {
|
||||
const [server, accountId] = commandUsername.split('/');
|
||||
if (commandUsername !== null) {
|
||||
const id = parseInt(commandUsername);
|
||||
|
||||
return {
|
||||
region: server as Region,
|
||||
id: Number(accountId),
|
||||
} satisfies ResolvedPlayer;
|
||||
if (!isNaN(id)) {
|
||||
const region = idToRegion(id);
|
||||
return { region, id } satisfies ResolvedPlayer;
|
||||
} else {
|
||||
const accounts = await searchPlayersAcrossRegions(commandUsername);
|
||||
|
||||
|
||||
Reference in new issue
Block a user