Use local database for game names

Closes #16
This commit is contained in:
baz 2024-06-09 21:58:41 +01:00
parent 6cb710c6a6
commit 448b008884
3 changed files with 3 additions and 12 deletions

View File

@ -1,6 +1,5 @@
const { SlashCommandBuilder, EmbedBuilder } = require('discord.js'); const { SlashCommandBuilder, EmbedBuilder } = require('discord.js');
const { getUserRegistration, getBeatenGames, checkGameStorageId } = require('../../databaseHelperFunctions.js'); const { getUserRegistration, getBeatenGames, checkGameStorageId } = require('../../databaseHelperFunctions.js');
const { getGameJson } = require('../../igdbHelperFunctions.js');
module.exports = { module.exports = {
data: new SlashCommandBuilder() data: new SlashCommandBuilder()
@ -29,9 +28,7 @@ module.exports = {
desc = desc.concat('__Total: ', beatenGamesDatabaseEntries.length, '/100__\n'); desc = desc.concat('__Total: ', beatenGamesDatabaseEntries.length, '/100__\n');
for (let i = 0; i < beatenGamesDatabaseEntries.length; i++) { for (let i = 0; i < beatenGamesDatabaseEntries.length; i++) {
const gameid = await checkGameStorageId(beatenGamesDatabaseEntries[i].gameId); const game = await checkGameStorageId(beatenGamesDatabaseEntries[i].gameId);
const res = await getGameJson(`where id = ${ gameid.igdb_id }; fields *;`);
const game = res[0];
const date = beatenGamesDatabaseEntries[i].updatedAt.toLocaleDateString('en-GB', { year: 'numeric', month: '2-digit', day: '2-digit' }).replace(/\//g, '/'); 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'); desc = desc.concat('**#', (i + 1), ' (', date, ')**: ', game.name, '\n');
} }

View File

@ -1,6 +1,5 @@
const { SlashCommandBuilder, EmbedBuilder } = require('discord.js'); const { SlashCommandBuilder, EmbedBuilder } = require('discord.js');
const { getUserRegistration, getPlayingGames, checkGameStorageId } = require('../../databaseHelperFunctions.js'); const { getUserRegistration, getPlayingGames, checkGameStorageId } = require('../../databaseHelperFunctions.js');
const { getGameJson } = require('../../igdbHelperFunctions.js');
module.exports = { module.exports = {
data: new SlashCommandBuilder() data: new SlashCommandBuilder()
@ -29,9 +28,7 @@ module.exports = {
desc = desc.concat('__Total: ', databaseEntries.length, '__\n'); desc = desc.concat('__Total: ', databaseEntries.length, '__\n');
for (let i = 0; i < databaseEntries.length; i++) { for (let i = 0; i < databaseEntries.length; i++) {
const gameid = await checkGameStorageId(databaseEntries[i].gameId); const game = await checkGameStorageId(databaseEntries[i].gameId);
const res = await getGameJson(`where id = ${ gameid.igdb_id }; fields *;`);
const game = res[0];
const date = databaseEntries[i].updatedAt.toLocaleDateString('en-GB', { year: 'numeric', month: '2-digit', day: '2-digit' }).replace(/\//g, '/'); 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'); desc = desc.concat('**#', (i + 1), ' (', date, ')**: ', game.name, '\n');
} }

View File

@ -1,6 +1,5 @@
const { SlashCommandBuilder, EmbedBuilder } = require('discord.js'); const { SlashCommandBuilder, EmbedBuilder } = require('discord.js');
const { getUserRegistration, getPlanningGames, checkGameStorageId } = require('../../databaseHelperFunctions.js'); const { getUserRegistration, getPlanningGames, checkGameStorageId } = require('../../databaseHelperFunctions.js');
const { getGameJson } = require('../../igdbHelperFunctions.js');
module.exports = { module.exports = {
data: new SlashCommandBuilder() data: new SlashCommandBuilder()
@ -29,9 +28,7 @@ module.exports = {
desc = desc.concat('__Total: ', databaseEntries.length, '__\n'); desc = desc.concat('__Total: ', databaseEntries.length, '__\n');
for (let i = 0; i < databaseEntries.length; i++) { for (let i = 0; i < databaseEntries.length; i++) {
const gameid = await checkGameStorageId(databaseEntries[i].gameId); const game = await checkGameStorageId(databaseEntries[i].gameId);
const res = await getGameJson(`where id = ${ gameid.igdb_id }; fields *;`);
const game = res[0];
desc = desc.concat('**#', (i + 1), '** ', game.name, '\n'); desc = desc.concat('**#', (i + 1), '** ', game.name, '\n');
} }
} }