Add extra game search queries when no results are returned on first search
This commit is contained in:
parent
2d20201ba2
commit
d986b2cb7f
|
@ -10,10 +10,11 @@ module.exports = {
|
||||||
const gamename = interaction.options.getString('gamename');
|
const gamename = interaction.options.getString('gamename');
|
||||||
await interaction.reply(`Searching for ${gamename}...`);
|
await interaction.reply(`Searching for ${gamename}...`);
|
||||||
|
|
||||||
let body = `search "${gamename}"; `;
|
let games = await searchGamesWithMinimumReview(gamename);
|
||||||
body = await body.concat('fields *; limit 25; where (category = 0 | category = 4) & version_parent = null;');
|
|
||||||
|
|
||||||
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));
|
await games.sort((a, b) => parseInt(b.total_rating_count) - parseInt(a.total_rating_count));
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue