mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-22 03:07:04 +02:00
feat: accent-tolerant tank search
This commit is contained in:
1 parent
bb2450eb3c
commit
70575fa9cf
3 files changed
+26
-13
No files matched your search
@@ -4,8 +4,7 @@ import {
|
||||
CacheType,
|
||||
} from 'discord.js';
|
||||
import { go } from 'fuzzysort';
|
||||
import resolveTankName from '../blitz/resolveTankName';
|
||||
import { TANKS } from '../blitz/tankopedia';
|
||||
import { TANKS, TANK_NAMES_DIACRITICS } from '../blitz/tankopedia';
|
||||
|
||||
export default async function autocompleteTanks(
|
||||
interaction: AutocompleteInteraction<CacheType>,
|
||||
@@ -16,16 +15,14 @@ export default async function autocompleteTanks(
|
||||
await interaction.respond(
|
||||
focusedOption.value
|
||||
? await Promise.all(
|
||||
go(focusedOption.value, await TANKS, {
|
||||
keys: ['name'],
|
||||
go(focusedOption.value, await TANK_NAMES_DIACRITICS, {
|
||||
keys: ['combined'],
|
||||
limit: 10,
|
||||
}).map(
|
||||
async (item) =>
|
||||
async (item, index) =>
|
||||
({
|
||||
name: item.obj.name
|
||||
? item.obj.name
|
||||
: await resolveTankName(item.obj.tank_id),
|
||||
value: `${item.obj.tank_id}`,
|
||||
name: item.obj.original,
|
||||
value: `${(await TANKS)[index].tank_id}`,
|
||||
}) satisfies ApplicationCommandOptionChoiceData<string>,
|
||||
),
|
||||
)
|
||||
|
||||
Reference in new issue
Block a user