mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-21 02:37:05 +02:00
fix: include server for clans
This commit is contained in:
1 parent
73a51cbb40
commit
755f879192
2 files changed
+7
-6
No files matched your search
@@ -36,7 +36,7 @@ export async function autocompleteClan(
|
||||
|
||||
return {
|
||||
name,
|
||||
value: `${clan.clan_id}`,
|
||||
value: `${clan.region}/${clan.clan_id}`,
|
||||
} satisfies ApplicationCommandOptionChoiceData<string>;
|
||||
})
|
||||
: [],
|
||||
|
||||
@@ -1,19 +1,20 @@
|
||||
import { idToRegion, searchClansAcrossRegions } from '@blitzkit/core';
|
||||
import { Region, searchClansAcrossRegions } from '@blitzkit/core';
|
||||
import { ChatInputCommandInteraction } from 'discord.js';
|
||||
import markdownEscape from 'markdown-escape';
|
||||
import { UserError } from '../blitzkit/userError';
|
||||
import { translator } from '../localization/translator';
|
||||
|
||||
export const serverAndIdPattern = /(com|eu|asia)\/[0-9]+/;
|
||||
|
||||
export async function resolveClanFromCommand(
|
||||
interaction: ChatInputCommandInteraction,
|
||||
) {
|
||||
const { translate } = translator(interaction.locale);
|
||||
const clan = interaction.options.getString('clan', true);
|
||||
const id = parseInt(clan);
|
||||
|
||||
if (isNaN(id)) {
|
||||
const region = idToRegion(id);
|
||||
return { region, id };
|
||||
if (serverAndIdPattern.test(clan)) {
|
||||
const [server, accountId] = clan.split('/');
|
||||
return { region: server as Region, id: Number(accountId) };
|
||||
} else {
|
||||
const accounts = await searchClansAcrossRegions(clan);
|
||||
|
||||
|
||||
Reference in new issue
Block a user