Update view command to use fuzzy search instead of direct card number #340

Merged
Vylpes merged 2 commits from feature/154-add-fuzzy-search-2 into develop 2024-08-17 17:26:31 +01:00
2 changed files with 2 additions and 7 deletions
Showing only changes of commit e23ca89b9a - Show all commits

View file

@ -1,10 +1,5 @@
import { AttachmentBuilder, CommandInteraction, DiscordAPIError, SlashCommandBuilder } from "discord.js"; import { CommandInteraction, SlashCommandBuilder } from "discord.js";
import { Command } from "../type/command"; import { Command } from "../type/command";
import { CoreClient } from "../client/client";
import { readFileSync } from "fs";
import path from "path";
import Inventory from "../database/entities/app/Inventory";
import CardDropHelperMetadata from "../helpers/CardDropHelperMetadata";
import AppLogger from "../client/appLogger"; import AppLogger from "../client/appLogger";
import CardSearchHelper from "../helpers/CardSearchHelper"; import CardSearchHelper from "../helpers/CardSearchHelper";

View file

@ -15,7 +15,7 @@ interface ReturnedPage {
export default class CardSearchHelper { export default class CardSearchHelper {
public static async GenerateSearchPage(query: string, userid: string, page: number): Promise<ReturnedPage | undefined> { public static async GenerateSearchPage(query: string, userid: string, page: number): Promise<ReturnedPage | undefined> {
const fzf = new Fuse(CoreClient.Cards.flatMap(x => x.cards), { keys: ['name'] }); const fzf = new Fuse(CoreClient.Cards.flatMap(x => x.cards), { keys: ["name"] });
const entries = fzf.search(query); const entries = fzf.search(query);
const entry = entries[page]; const entry = entries[page];