mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-24 20:19:49 +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 {
|
return {
|
||||||
name,
|
name,
|
||||||
value: `${clan.clan_id}`,
|
value: `${clan.region}/${clan.clan_id}`,
|
||||||
} satisfies ApplicationCommandOptionChoiceData<string>;
|
} 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 { ChatInputCommandInteraction } from 'discord.js';
|
||||||
import markdownEscape from 'markdown-escape';
|
import markdownEscape from 'markdown-escape';
|
||||||
import { UserError } from '../blitzkit/userError';
|
import { UserError } from '../blitzkit/userError';
|
||||||
import { translator } from '../localization/translator';
|
import { translator } from '../localization/translator';
|
||||||
|
|
||||||
|
export const serverAndIdPattern = /(com|eu|asia)\/[0-9]+/;
|
||||||
|
|
||||||
export async function resolveClanFromCommand(
|
export async function resolveClanFromCommand(
|
||||||
interaction: ChatInputCommandInteraction,
|
interaction: ChatInputCommandInteraction,
|
||||||
) {
|
) {
|
||||||
const { translate } = translator(interaction.locale);
|
const { translate } = translator(interaction.locale);
|
||||||
const clan = interaction.options.getString('clan', true);
|
const clan = interaction.options.getString('clan', true);
|
||||||
const id = parseInt(clan);
|
|
||||||
|
|
||||||
if (isNaN(id)) {
|
if (serverAndIdPattern.test(clan)) {
|
||||||
const region = idToRegion(id);
|
const [server, accountId] = clan.split('/');
|
||||||
return { region, id };
|
return { region: server as Region, id: Number(accountId) };
|
||||||
} else {
|
} else {
|
||||||
const accounts = await searchClansAcrossRegions(clan);
|
const accounts = await searchClansAcrossRegions(clan);
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user