mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-24 03:59:50 +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 {
|
return {
|
||||||
name,
|
name,
|
||||||
value: `${clan.region}/${clan.clan_id}`,
|
value: `${clan.clan_id}`,
|
||||||
} satisfies ApplicationCommandOptionChoiceData<string>;
|
} satisfies ApplicationCommandOptionChoiceData<string>;
|
||||||
})
|
})
|
||||||
: [],
|
: [],
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ export async function autocompleteUsername(
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
name,
|
name,
|
||||||
value: `${player.region}/${player.account_id}`,
|
value: `${player.account_id}`,
|
||||||
} satisfies ApplicationCommandOptionChoiceData<string>;
|
} 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 { CacheType, ChatInputCommandInteraction } from 'discord.js';
|
||||||
import markdownEscape from 'markdown-escape';
|
import markdownEscape from 'markdown-escape';
|
||||||
import { getBlitzFromDiscord } from '../../blitzkit/getBlitzFromDiscord';
|
import { getBlitzFromDiscord } from '../../blitzkit/getBlitzFromDiscord';
|
||||||
import { translator } from '../../localization/translator';
|
|
||||||
import { serverAndIdPattern } from './constants';
|
|
||||||
import { UserError } from '../../blitzkit/userError';
|
import { UserError } from '../../blitzkit/userError';
|
||||||
|
import { translator } from '../../localization/translator';
|
||||||
|
|
||||||
export interface ResolvedPlayer {
|
export interface ResolvedPlayer {
|
||||||
region: Region;
|
region: Region;
|
||||||
@@ -17,14 +16,12 @@ export async function resolvePlayerFromCommand(
|
|||||||
const { t, translate } = translator(interaction.locale);
|
const { t, translate } = translator(interaction.locale);
|
||||||
const commandUsername = interaction.options.getString('username');
|
const commandUsername = interaction.options.getString('username');
|
||||||
|
|
||||||
if (commandUsername) {
|
if (commandUsername !== null) {
|
||||||
if (serverAndIdPattern.test(commandUsername)) {
|
const id = parseInt(commandUsername);
|
||||||
const [server, accountId] = commandUsername.split('/');
|
|
||||||
|
|
||||||
return {
|
if (!isNaN(id)) {
|
||||||
region: server as Region,
|
const region = idToRegion(id);
|
||||||
id: Number(accountId),
|
return { region, id } satisfies ResolvedPlayer;
|
||||||
} satisfies ResolvedPlayer;
|
|
||||||
} else {
|
} else {
|
||||||
const accounts = await searchPlayersAcrossRegions(commandUsername);
|
const accounts = await searchPlayersAcrossRegions(commandUsername);
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user