From 710f84b1658a850c63a767c60b24dbf85b9f5415 Mon Sep 17 00:00:00 2001 From: baz Date: Wed, 6 Dec 2023 23:45:23 +0000 Subject: [PATCH] Add extra checks to embed builder --- commands/100-games/gameDetails.js | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/commands/100-games/gameDetails.js b/commands/100-games/gameDetails.js index 58dd655..5b31d99 100644 --- a/commands/100-games/gameDetails.js +++ b/commands/100-games/gameDetails.js @@ -50,19 +50,23 @@ module.exports = { genres.push(genre); } - const embed = new EmbedBuilder() - .setColor(0x6441a5) - .setTitle(`${game.name}`) - .setURL(`${game.url}`) - .setThumbnail(`${coverUrl}`) - .addFields({ name: 'Description', value: `${game.summary}` }) - .addFields({ name: 'Developers', value: `${companies.join(', ')}`, inline: true }) - .addFields({ name: 'Release Date', value: `${release_date}`, inline: true }) - .addFields({ name: 'Genres', value: `${genres.join(', ')}`, inline: true }) - .addFields({ name: 'Rating', value: `${game.total_rating.toFixed(0)} / 100, ${game.total_rating_count } ratings`, inline: true }) - .addFields({ name: 'ID', value: `${game.id}`, inline: true }) - .setFooter({ text: 'The Ochulus • 100 Games Challenge', iconURL: interaction.client.user.avatarURL() }) - .setTimestamp(); + const embed = new EmbedBuilder(); + embed.setColor(0x6441a5); + embed.setTitle(`${game.name}`); + embed.setURL(`${game.url}`); + embed.setThumbnail(`${coverUrl}`); + embed.addFields({ name: 'Description', value: `${game.summary}` }); + embed.addFields({ name: 'Developers', value: `${companies.join(', ')}`, inline: true }); + embed.addFields({ name: 'Release Date', value: `${release_date}`, inline: true }); + embed.addFields({ name: 'Genres', value: `${genres.join(', ')}`, inline: true }); + + if (game.total_rating) { + embed.addFields({ name: 'Rating', value: `${game.total_rating.toFixed(0)} / 100, ${game.total_rating_count } ratings`, inline: true }); + } + + embed.addFields({ name: 'ID', value: `${game.id}`, inline: true }); + embed.setFooter({ text: 'The Ochulus • 100 Games Challenge', iconURL: interaction.client.user.avatarURL() }); + embed.setTimestamp(); if (game.franchises) { const franchise = await getFranchise(game.franchises);