From d986b2cb7f5203609d852c706276737c999938e2 Mon Sep 17 00:00:00 2001 From: baz Date: Tue, 28 Nov 2023 22:06:19 +0000 Subject: [PATCH] Add extra game search queries when no results are returned on first search --- commands/100-games/searchGame.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/commands/100-games/searchGame.js b/commands/100-games/searchGame.js index b526cc2..1f2f4ac 100644 --- a/commands/100-games/searchGame.js +++ b/commands/100-games/searchGame.js @@ -10,10 +10,11 @@ module.exports = { const gamename = interaction.options.getString('gamename'); await interaction.reply(`Searching for ${gamename}...`); - let body = `search "${gamename}"; `; - body = await body.concat('fields *; limit 25; where (category = 0 | category = 4) & version_parent = null;'); + let games = await searchGamesWithMinimumReview(gamename); - const games = await getGameJson(body); + if (games.length == 0) games = await searchGamesWithoutMinimumReview(gamename); + + if (games.length == 0) return interaction.followUp('No games found.'); await games.sort((a, b) => parseInt(b.total_rating_count) - parseInt(a.total_rating_count));