From fb5c3fdddd1d7fa319a9c2dc87447d765ed5dff5 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..8e15e1f 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..59aef48 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..b4cfaf6 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 });