Fix fuzzy /view to be consistent with its pages (#345)
All checks were successful
Deploy To Stage / build (push) Successful in 15s
Deploy To Stage / deploy (push) Successful in 16s

- Fix the `/view` command to have a set amount of cards in its page rotation
- This is done now by updating it so instead of requerying each page turn it instead queries once at the start and passes the top 5 results to the button event

#154

Reviewed-on: #345
Reviewed-by: VylpesTester <tester@vylpes.com>
Co-authored-by: Ethan Lane <ethan@vylpes.com>
Co-committed-by: Ethan Lane <ethan@vylpes.com>
This commit is contained in:
Ethan Lane 2024-08-24 17:26:26 +01:00 committed by Vylpes
parent 79a4d18df3
commit 66243e6742
5 changed files with 153 additions and 14 deletions

View file

@ -5,11 +5,11 @@ import CardSearchHelper from "../helpers/CardSearchHelper.js";
export default class View extends ButtonEvent {
public override async execute(interaction: ButtonInteraction) {
const page = interaction.customId.split(" ")[1];
const query = interaction.customId.split(" ").splice(1).join(" ");
const results = interaction.customId.split(" ").splice(2);
await interaction.deferUpdate();
const searchResult = await CardSearchHelper.GenerateSearchPage(query, interaction.user.id, Number(page));
const searchResult = await CardSearchHelper.GenerateSearchPageFromQuery(results, interaction.user.id, Number(page));
if (!searchResult) {
await interaction.followUp("No results found");