From 0ea6f952fc10b43507707a9a2d7204067df3270f Mon Sep 17 00:00:00 2001 From: baz Date: Wed, 14 Feb 2024 19:48:39 +0000 Subject: [PATCH] Filter games more --- commands/100-games/beatGame.js | 4 +++- commands/100-games/planGame.js | 4 +++- commands/100-games/startplaying.js | 4 +++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/commands/100-games/beatGame.js b/commands/100-games/beatGame.js index e2e151c..d3784c5 100644 --- a/commands/100-games/beatGame.js +++ b/commands/100-games/beatGame.js @@ -34,7 +34,9 @@ module.exports = { body = body.concat('fields *;'); - const res = await getGameJson(body); + let res = await getGameJson(body); + res = res.filter(entry => entry.status == 6); + res.sort((a, b) => parseInt(b.total_rating_count) - parseInt(a.total_rating_count)); if (!res[0]) return interaction.followUp({ content: 'No game found for the options supplied.', ephemeral: true }); diff --git a/commands/100-games/planGame.js b/commands/100-games/planGame.js index ed37c7e..943e6b0 100644 --- a/commands/100-games/planGame.js +++ b/commands/100-games/planGame.js @@ -31,7 +31,9 @@ module.exports = { body = body.concat('fields *;'); - const res = await getGameJson(body); + let res = await getGameJson(body); + res = res.filter(entry => entry.status == 6); + res.sort((a, b) => parseInt(b.total_rating_count) - parseInt(a.total_rating_count)); if (!res[0]) return interaction.followUp({ content: 'No game found for the options supplied.', ephemeral: true }); diff --git a/commands/100-games/startplaying.js b/commands/100-games/startplaying.js index fbb8fc8..41d795a 100644 --- a/commands/100-games/startplaying.js +++ b/commands/100-games/startplaying.js @@ -31,7 +31,9 @@ module.exports = { body = body.concat('fields *;'); - const res = await getGameJson(body); + let res = await getGameJson(body); + res = res.filter(entry => entry.status == 6); + res.sort((a, b) => parseInt(b.total_rating_count) - parseInt(a.total_rating_count)); if (!res[0]) return interaction.followUp({ content: 'No game found for the options supplied.', ephemeral: true });