Update view command to use fuzzy search instead of direct card number #340
2 changed files with 2 additions and 7 deletions
|
@ -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";
|
||||||
|
|
||||||
|
|
|
@ -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];
|
||||||
|
|
Loading…
Reference in a new issue