From b3f78a3f257d0b869272ea74b2f22d48013bb6d1 Mon Sep 17 00:00:00 2001 From: baz Date: Wed, 14 Feb 2024 19:17:02 +0000 Subject: [PATCH] Change list outputs to use embed instead --- commands/100-games/beatlist.js | 17 +++++++++-------- commands/100-games/currentlyplaying.js | 17 +++++++++-------- commands/100-games/plannedGames.js | 17 +++++++++-------- 3 files changed, 27 insertions(+), 24 deletions(-) diff --git a/commands/100-games/beatlist.js b/commands/100-games/beatlist.js index c0f371b..c93509c 100644 --- a/commands/100-games/beatlist.js +++ b/commands/100-games/beatlist.js @@ -21,16 +21,17 @@ module.exports = { if (!userDatabaseEntry) return interaction.followUp({ content: `Issue checking registration with "${user.username}".`, ephemeral: true }); const beatenGamesDatabaseEntries = await getBeatenGames(userDatabaseEntry.id); - if (!beatenGamesDatabaseEntries || beatenGamesDatabaseEntries.length == 0) return interaction.followUp({ content: 'No games found.', ephemeral: true }); - let desc = ''; - 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]; - - desc = desc.concat('#', (i + 1), ' \t', game.name, '\n'); + if (!beatenGamesDatabaseEntries || beatenGamesDatabaseEntries.length == 0) { + desc = `${user.displayName} has not beaten any games yet.`; + } else { + 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]; + desc = desc.concat('#', (i + 1), ' \t', game.name, '\n'); + } } const embed = new EmbedBuilder() diff --git a/commands/100-games/currentlyplaying.js b/commands/100-games/currentlyplaying.js index d3681d1..08b1884 100644 --- a/commands/100-games/currentlyplaying.js +++ b/commands/100-games/currentlyplaying.js @@ -21,16 +21,17 @@ module.exports = { if (!userDatabaseEntry) return interaction.followUp({ content: `Issue checking registration with "${user.username}".`, ephemeral: true }); const databaseEntries = await getPlayingGames(userDatabaseEntry.id); - if (!databaseEntries || databaseEntries.length == 0) return interaction.followUp({ content: 'No games found.', ephemeral: true }); - let desc = ''; - 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]; - - desc = desc.concat('-\t', game.name, '\n'); + if (!databaseEntries || databaseEntries.length == 0) { + desc = `${user.displayName} is currently playing no games.`; + } else { + 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]; + desc = desc.concat('#', (i + 1), ' \t', game.name, '\n'); + } } const embed = new EmbedBuilder() diff --git a/commands/100-games/plannedGames.js b/commands/100-games/plannedGames.js index 2e3f2a3..dcfea2c 100644 --- a/commands/100-games/plannedGames.js +++ b/commands/100-games/plannedGames.js @@ -21,16 +21,17 @@ module.exports = { if (!userDatabaseEntry) return interaction.followUp({ content: `Issue checking registration with "${user.username}".`, ephemeral: true }); const databaseEntries = await getPlanningGames(userDatabaseEntry.id); - if (!databaseEntries || databaseEntries.length == 0) return interaction.followUp({ content: 'No games found.', ephemeral: true }); - let desc = ''; - 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]; - - desc = desc.concat('-\t', game.name, '\n'); + if (!databaseEntries || databaseEntries.length == 0) { + desc = `${user.displayName} currently has no planned games.`; + } else { + 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]; + desc = desc.concat('#', (i + 1), ' \t', game.name, '\n'); + } } const embed = new EmbedBuilder()