Add extra game search queries when no results are returned on first search

This commit is contained in:
baz 2023-11-28 22:06:19 +00:00
parent 2d20201ba2
commit d986b2cb7f
1 changed files with 4 additions and 3 deletions

View File

@ -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));