From 448b008884c0fd3a8a693bab0461a960f53ff664 Mon Sep 17 00:00:00 2001 From: baz Date: Sun, 9 Jun 2024 21:58:41 +0100 Subject: [PATCH] Use local database for game names Closes #16 --- commands/100-games/beatlist.js | 5 +---- commands/100-games/currentlyplaying.js | 5 +---- commands/100-games/plannedGames.js | 5 +---- 3 files changed, 3 insertions(+), 12 deletions(-) diff --git a/commands/100-games/beatlist.js b/commands/100-games/beatlist.js index 89d126d..847cf43 100644 --- a/commands/100-games/beatlist.js +++ b/commands/100-games/beatlist.js @@ -1,6 +1,5 @@ const { SlashCommandBuilder, EmbedBuilder } = require('discord.js'); const { getUserRegistration, getBeatenGames, checkGameStorageId } = require('../../databaseHelperFunctions.js'); -const { getGameJson } = require('../../igdbHelperFunctions.js'); module.exports = { data: new SlashCommandBuilder() @@ -29,9 +28,7 @@ module.exports = { desc = desc.concat('__Total: ', beatenGamesDatabaseEntries.length, '/100__\n'); for (let i = 0; i < beatenGamesDatabaseEntries.length; i++) { - const gameid = await checkGameStorageId(beatenGamesDatabaseEntries[i].gameId); - const res = await getGameJson(`where id = ${ gameid.igdb_id }; fields *;`); - const game = res[0]; + const game = await checkGameStorageId(beatenGamesDatabaseEntries[i].gameId); const date = beatenGamesDatabaseEntries[i].updatedAt.toLocaleDateString('en-GB', { year: 'numeric', month: '2-digit', day: '2-digit' }).replace(/\//g, '/'); desc = desc.concat('**#', (i + 1), ' (', date, ')**: ', game.name, '\n'); } diff --git a/commands/100-games/currentlyplaying.js b/commands/100-games/currentlyplaying.js index c475950..08459e0 100644 --- a/commands/100-games/currentlyplaying.js +++ b/commands/100-games/currentlyplaying.js @@ -1,6 +1,5 @@ const { SlashCommandBuilder, EmbedBuilder } = require('discord.js'); const { getUserRegistration, getPlayingGames, checkGameStorageId } = require('../../databaseHelperFunctions.js'); -const { getGameJson } = require('../../igdbHelperFunctions.js'); module.exports = { data: new SlashCommandBuilder() @@ -29,9 +28,7 @@ module.exports = { desc = desc.concat('__Total: ', databaseEntries.length, '__\n'); for (let i = 0; i < databaseEntries.length; i++) { - const gameid = await checkGameStorageId(databaseEntries[i].gameId); - const res = await getGameJson(`where id = ${ gameid.igdb_id }; fields *;`); - const game = res[0]; + const game = await checkGameStorageId(databaseEntries[i].gameId); const date = databaseEntries[i].updatedAt.toLocaleDateString('en-GB', { year: 'numeric', month: '2-digit', day: '2-digit' }).replace(/\//g, '/'); desc = desc.concat('**#', (i + 1), ' (', date, ')**: ', game.name, '\n'); } diff --git a/commands/100-games/plannedGames.js b/commands/100-games/plannedGames.js index d04caca..3f8fa20 100644 --- a/commands/100-games/plannedGames.js +++ b/commands/100-games/plannedGames.js @@ -1,6 +1,5 @@ const { SlashCommandBuilder, EmbedBuilder } = require('discord.js'); const { getUserRegistration, getPlanningGames, checkGameStorageId } = require('../../databaseHelperFunctions.js'); -const { getGameJson } = require('../../igdbHelperFunctions.js'); module.exports = { data: new SlashCommandBuilder() @@ -29,9 +28,7 @@ module.exports = { desc = desc.concat('__Total: ', databaseEntries.length, '__\n'); for (let i = 0; i < databaseEntries.length; i++) { - const gameid = await checkGameStorageId(databaseEntries[i].gameId); - const res = await getGameJson(`where id = ${ gameid.igdb_id }; fields *;`); - const game = res[0]; + const game = await checkGameStorageId(databaseEntries[i].gameId); desc = desc.concat('**#', (i + 1), '** ', game.name, '\n'); } }