Check if coverart exists before attaching to embed
This commit is contained in:
parent
6d2668f5cb
commit
fa786d66fe
|
@ -49,17 +49,20 @@ module.exports = {
|
||||||
const beatNum = await getBeatenGameCount(userDatabaseEntry);
|
const beatNum = await getBeatenGameCount(userDatabaseEntry);
|
||||||
const planNum = await getPlanningGameCount(userDatabaseEntry);
|
const planNum = await getPlanningGameCount(userDatabaseEntry);
|
||||||
const playNum = await getPlayingGameCount(userDatabaseEntry);
|
const playNum = await getPlayingGameCount(userDatabaseEntry);
|
||||||
const coverUrl = await getCoverURL(game.cover);
|
|
||||||
|
|
||||||
const embed = new EmbedBuilder()
|
const embed = new EmbedBuilder()
|
||||||
.setColor(0xFFD700)
|
.setColor(0xFFD700)
|
||||||
.setAuthor({ name: `${interaction.user.displayName} beat a new game!`, iconURL: interaction.user.avatarURL() })
|
.setAuthor({ name: `${interaction.user.displayName} beat a new game!`, iconURL: interaction.user.avatarURL() })
|
||||||
.setTitle(`${game.name} beaten!`)
|
.setTitle(`${game.name} beaten!`)
|
||||||
.setThumbnail(`${coverUrl}`)
|
|
||||||
.setDescription(`${interaction.user.displayName} has ${planNum} games planned, they are playing ${playNum} games, they have beaten ${beatNum} games, they have ${100 - beatNum} games remaining.`)
|
.setDescription(`${interaction.user.displayName} has ${planNum} games planned, they are playing ${playNum} games, they have beaten ${beatNum} games, they have ${100 - beatNum} games remaining.`)
|
||||||
.setFooter({ text: 'The Ochulus • 100 Games Challenge', iconURL: interaction.client.user.avatarURL() })
|
.setFooter({ text: 'The Ochulus • 100 Games Challenge', iconURL: interaction.client.user.avatarURL() })
|
||||||
.setTimestamp();
|
.setTimestamp();
|
||||||
|
|
||||||
|
if (game.cover) {
|
||||||
|
const coverUrl = await getCoverURL(game.cover);
|
||||||
|
embed.setThumbnail(`${coverUrl}`);
|
||||||
|
}
|
||||||
|
|
||||||
await interaction.followUp({ embeds: [embed] });
|
await interaction.followUp({ embeds: [embed] });
|
||||||
|
|
||||||
if (beatNum == 100) {
|
if (beatNum == 100) {
|
||||||
|
|
|
@ -33,17 +33,20 @@ module.exports = {
|
||||||
const beatNum = await getBeatenGameCount(userDatabaseEntry);
|
const beatNum = await getBeatenGameCount(userDatabaseEntry);
|
||||||
const planNum = await getPlanningGameCount(userDatabaseEntry);
|
const planNum = await getPlanningGameCount(userDatabaseEntry);
|
||||||
const playNum = await getPlayingGameCount(userDatabaseEntry);
|
const playNum = await getPlayingGameCount(userDatabaseEntry);
|
||||||
const coverUrl = await getCoverURL(game.cover);
|
|
||||||
|
|
||||||
const embed = new EmbedBuilder()
|
const embed = new EmbedBuilder()
|
||||||
.setColor(0xFF0000)
|
.setColor(0xFF0000)
|
||||||
.setAuthor({ name: `${interaction.user.displayName} deleted a game!`, iconURL: interaction.user.avatarURL() })
|
.setAuthor({ name: `${interaction.user.displayName} deleted a game!`, iconURL: interaction.user.avatarURL() })
|
||||||
.setTitle(`${game.name} deleted!`)
|
.setTitle(`${game.name} deleted!`)
|
||||||
.setThumbnail(`${coverUrl}`)
|
|
||||||
.setDescription(`${interaction.user.displayName} has ${planNum} games planned, they are playing ${playNum} games, they have beaten ${beatNum} games, they have ${100 - beatNum} games remaining.`)
|
.setDescription(`${interaction.user.displayName} has ${planNum} games planned, they are playing ${playNum} games, they have beaten ${beatNum} games, they have ${100 - beatNum} games remaining.`)
|
||||||
.setFooter({ text: 'The Ochulus • 100 Games Challenge', iconURL: interaction.client.user.avatarURL() })
|
.setFooter({ text: 'The Ochulus • 100 Games Challenge', iconURL: interaction.client.user.avatarURL() })
|
||||||
.setTimestamp();
|
.setTimestamp();
|
||||||
|
|
||||||
|
if (game.cover) {
|
||||||
|
const coverUrl = await getCoverURL(game.cover);
|
||||||
|
embed.setThumbnail(`${coverUrl}`);
|
||||||
|
}
|
||||||
|
|
||||||
return interaction.followUp({ embeds: [embed] });
|
return interaction.followUp({ embeds: [embed] });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,17 +33,20 @@ module.exports = {
|
||||||
const beatNum = await getBeatenGameCount(userDatabaseEntry);
|
const beatNum = await getBeatenGameCount(userDatabaseEntry);
|
||||||
const planNum = await getPlanningGameCount(userDatabaseEntry);
|
const planNum = await getPlanningGameCount(userDatabaseEntry);
|
||||||
const playNum = await getPlayingGameCount(userDatabaseEntry);
|
const playNum = await getPlayingGameCount(userDatabaseEntry);
|
||||||
const coverUrl = await getCoverURL(game.cover);
|
|
||||||
|
|
||||||
const embed = new EmbedBuilder()
|
const embed = new EmbedBuilder()
|
||||||
.setColor(0xFF0000)
|
.setColor(0xFF0000)
|
||||||
.setAuthor({ name: `${interaction.user.displayName} deleted a game!`, iconURL: interaction.user.avatarURL() })
|
.setAuthor({ name: `${interaction.user.displayName} deleted a game!`, iconURL: interaction.user.avatarURL() })
|
||||||
.setTitle(`${game.name} deleted!`)
|
.setTitle(`${game.name} deleted!`)
|
||||||
.setThumbnail(`${coverUrl}`)
|
|
||||||
.setDescription(`${interaction.user.displayName} has ${planNum} games planned, they are playing ${playNum} games, they have beaten ${beatNum} games, they have ${100 - beatNum} games remaining.`)
|
.setDescription(`${interaction.user.displayName} has ${planNum} games planned, they are playing ${playNum} games, they have beaten ${beatNum} games, they have ${100 - beatNum} games remaining.`)
|
||||||
.setFooter({ text: 'The Ochulus • 100 Games Challenge', iconURL: interaction.client.user.avatarURL() })
|
.setFooter({ text: 'The Ochulus • 100 Games Challenge', iconURL: interaction.client.user.avatarURL() })
|
||||||
.setTimestamp();
|
.setTimestamp();
|
||||||
|
|
||||||
|
if (game.cover) {
|
||||||
|
const coverUrl = await getCoverURL(game.cover);
|
||||||
|
embed.setThumbnail(`${coverUrl}`);
|
||||||
|
}
|
||||||
|
|
||||||
return interaction.followUp({ embeds: [embed] });
|
return interaction.followUp({ embeds: [embed] });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,17 +33,20 @@ module.exports = {
|
||||||
const beatNum = await getBeatenGameCount(userDatabaseEntry);
|
const beatNum = await getBeatenGameCount(userDatabaseEntry);
|
||||||
const planNum = await getPlanningGameCount(userDatabaseEntry);
|
const planNum = await getPlanningGameCount(userDatabaseEntry);
|
||||||
const playNum = await getPlayingGameCount(userDatabaseEntry);
|
const playNum = await getPlayingGameCount(userDatabaseEntry);
|
||||||
const coverUrl = await getCoverURL(game.cover);
|
|
||||||
|
|
||||||
const embed = new EmbedBuilder()
|
const embed = new EmbedBuilder()
|
||||||
.setColor(0xFF0000)
|
.setColor(0xFF0000)
|
||||||
.setAuthor({ name: `${interaction.user.displayName} deleted a game!`, iconURL: interaction.user.avatarURL() })
|
.setAuthor({ name: `${interaction.user.displayName} deleted a game!`, iconURL: interaction.user.avatarURL() })
|
||||||
.setTitle(`${game.name} deleted!`)
|
.setTitle(`${game.name} deleted!`)
|
||||||
.setThumbnail(`${coverUrl}`)
|
|
||||||
.setDescription(`${interaction.user.displayName} has ${planNum} games planned, they are playing ${playNum} games, they have beaten ${beatNum} games, they have ${100 - beatNum} games remaining.`)
|
.setDescription(`${interaction.user.displayName} has ${planNum} games planned, they are playing ${playNum} games, they have beaten ${beatNum} games, they have ${100 - beatNum} games remaining.`)
|
||||||
.setFooter({ text: 'The Ochulus • 100 Games Challenge', iconURL: interaction.client.user.avatarURL() })
|
.setFooter({ text: 'The Ochulus • 100 Games Challenge', iconURL: interaction.client.user.avatarURL() })
|
||||||
.setTimestamp();
|
.setTimestamp();
|
||||||
|
|
||||||
|
if (game.cover) {
|
||||||
|
const coverUrl = await getCoverURL(game.cover);
|
||||||
|
embed.setThumbnail(`${coverUrl}`);
|
||||||
|
}
|
||||||
|
|
||||||
return interaction.followUp({ embeds: [embed] });
|
return interaction.followUp({ embeds: [embed] });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -43,17 +43,20 @@ module.exports = {
|
||||||
const beatNum = await getBeatenGameCount(userDatabaseEntry);
|
const beatNum = await getBeatenGameCount(userDatabaseEntry);
|
||||||
const planNum = await getPlanningGameCount(userDatabaseEntry);
|
const planNum = await getPlanningGameCount(userDatabaseEntry);
|
||||||
const playNum = await getPlayingGameCount(userDatabaseEntry);
|
const playNum = await getPlayingGameCount(userDatabaseEntry);
|
||||||
const coverUrl = await getCoverURL(game.cover);
|
|
||||||
|
|
||||||
const embed = new EmbedBuilder()
|
const embed = new EmbedBuilder()
|
||||||
.setColor(0x43ABEC)
|
.setColor(0x43ABEC)
|
||||||
.setAuthor({ name: `${interaction.user.displayName} is planning to beat a game!`, iconURL: interaction.user.avatarURL() })
|
.setAuthor({ name: `${interaction.user.displayName} is planning to beat a game!`, iconURL: interaction.user.avatarURL() })
|
||||||
.setTitle(`${game.name}!`)
|
.setTitle(`${game.name}!`)
|
||||||
.setThumbnail(`${coverUrl}`)
|
|
||||||
.setDescription(`${interaction.user.displayName} has ${planNum} games planned, they are playing ${playNum} games, they have beaten ${beatNum} games, they have ${100 - beatNum} games remaining.`)
|
.setDescription(`${interaction.user.displayName} has ${planNum} games planned, they are playing ${playNum} games, they have beaten ${beatNum} games, they have ${100 - beatNum} games remaining.`)
|
||||||
.setFooter({ text: 'The Ochulus • 100 Games Challenge', iconURL: interaction.client.user.avatarURL() })
|
.setFooter({ text: 'The Ochulus • 100 Games Challenge', iconURL: interaction.client.user.avatarURL() })
|
||||||
.setTimestamp();
|
.setTimestamp();
|
||||||
|
|
||||||
|
if (game.cover) {
|
||||||
|
const coverUrl = await getCoverURL(game.cover);
|
||||||
|
embed.setThumbnail(`${coverUrl}`);
|
||||||
|
}
|
||||||
|
|
||||||
await interaction.followUp({ embeds: [embed] });
|
await interaction.followUp({ embeds: [embed] });
|
||||||
},
|
},
|
||||||
};
|
};
|
|
@ -36,7 +36,7 @@ module.exports = {
|
||||||
const embed = new EmbedBuilder()
|
const embed = new EmbedBuilder()
|
||||||
.setColor(0x6441a5)
|
.setColor(0x6441a5)
|
||||||
.setAuthor({ name: `${user.displayName}`, iconURL: user.avatarURL() })
|
.setAuthor({ name: `${user.displayName}`, iconURL: user.avatarURL() })
|
||||||
.setTitle(`${user.displayName}'s planned games to play`)
|
.setTitle(`${user.displayName}'s planned games`)
|
||||||
.setDescription(desc)
|
.setDescription(desc)
|
||||||
.setFooter({ text: 'The Ochulus • 100 Games Challenge', iconURL: interaction.client.user.avatarURL() })
|
.setFooter({ text: 'The Ochulus • 100 Games Challenge', iconURL: interaction.client.user.avatarURL() })
|
||||||
.setTimestamp();
|
.setTimestamp();
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
const { SlashCommandBuilder, EmbedBuilder } = require('discord.js');
|
const { SlashCommandBuilder, EmbedBuilder } = require('discord.js');
|
||||||
const { getCoverURL, getGameJson } = require('../../igdbHelperFunctions.js');
|
const { getCoverURL, getGameJson } = require('../../igdbHelperFunctions.js');
|
||||||
const { getUserRegistration, getRecentBeatenGameEntry, getBeatenGameCount } = require('../../databaseHelperFunctions.js');
|
const { getUserRegistration, getRecentBeatenGameEntry, getBeatenGameCount, getPlanningGameCount, getPlayingGameCount } = require('../../databaseHelperFunctions.js');
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
data: new SlashCommandBuilder()
|
data: new SlashCommandBuilder()
|
||||||
|
@ -26,17 +26,22 @@ module.exports = {
|
||||||
if (!res) return interaction.reply({ content: 'No game found.', ephemeral: true });
|
if (!res) return interaction.reply({ content: 'No game found.', ephemeral: true });
|
||||||
const game = res[0];
|
const game = res[0];
|
||||||
|
|
||||||
const coverUrl = await getCoverURL(game.cover);
|
const beatNum = await getBeatenGameCount(userDatabaseEntry);
|
||||||
const num = await getBeatenGameCount(userDatabaseEntry);
|
const planNum = await getPlanningGameCount(userDatabaseEntry);
|
||||||
|
const playNum = await getPlayingGameCount(userDatabaseEntry);
|
||||||
|
|
||||||
const embed = new EmbedBuilder()
|
const embed = new EmbedBuilder()
|
||||||
.setColor(0xFFD700)
|
.setColor(0xFFD700)
|
||||||
.setAuthor({ name: `${user.displayName}'s most recent beat game!`, iconURL: user.avatarURL() })
|
.setAuthor({ name: `${user.displayName}'s most recent beat game!`, iconURL: user.avatarURL() })
|
||||||
.setTitle(game.name)
|
.setTitle(game.name)
|
||||||
.setThumbnail(`${coverUrl}`)
|
|
||||||
.setFooter({ text: 'The Ochulus • 100 Games Challenge', iconURL: interaction.client.user.avatarURL() })
|
.setFooter({ text: 'The Ochulus • 100 Games Challenge', iconURL: interaction.client.user.avatarURL() })
|
||||||
.setTimestamp()
|
.setTimestamp()
|
||||||
.setDescription(`${interaction.user.displayName} has beaten ${num} games, they have ${100 - num} games remaining.`);
|
.setDescription(`${interaction.user.displayName} has ${planNum} games planned, they are playing ${playNum} games, they have beaten ${beatNum} games, they have ${100 - beatNum} games remaining.`);
|
||||||
|
|
||||||
|
if (game.cover) {
|
||||||
|
const coverUrl = await getCoverURL(game.cover);
|
||||||
|
embed.setThumbnail(`${coverUrl}`);
|
||||||
|
}
|
||||||
|
|
||||||
return interaction.reply({ embeds: [embed] });
|
return interaction.reply({ embeds: [embed] });
|
||||||
},
|
},
|
||||||
|
|
|
@ -46,17 +46,20 @@ module.exports = {
|
||||||
const beatNum = await getBeatenGameCount(userDatabaseEntry);
|
const beatNum = await getBeatenGameCount(userDatabaseEntry);
|
||||||
const planNum = await getPlanningGameCount(userDatabaseEntry);
|
const planNum = await getPlanningGameCount(userDatabaseEntry);
|
||||||
const playNum = await getPlayingGameCount(userDatabaseEntry);
|
const playNum = await getPlayingGameCount(userDatabaseEntry);
|
||||||
const coverUrl = await getCoverURL(game.cover);
|
|
||||||
|
|
||||||
const embed = new EmbedBuilder()
|
const embed = new EmbedBuilder()
|
||||||
.setColor(0x00C921)
|
.setColor(0x00C921)
|
||||||
.setAuthor({ name: `${interaction.user.displayName} has started playing a new game!`, iconURL: interaction.user.avatarURL() })
|
.setAuthor({ name: `${interaction.user.displayName} has started playing a new game!`, iconURL: interaction.user.avatarURL() })
|
||||||
.setTitle(`${game.name}!`)
|
.setTitle(`${game.name}!`)
|
||||||
.setThumbnail(`${coverUrl}`)
|
|
||||||
.setDescription(`${interaction.user.displayName} has ${planNum} games planned, they are playing ${playNum} games, they have beaten ${beatNum} games, they have ${100 - beatNum} games remaining.`)
|
.setDescription(`${interaction.user.displayName} has ${planNum} games planned, they are playing ${playNum} games, they have beaten ${beatNum} games, they have ${100 - beatNum} games remaining.`)
|
||||||
.setFooter({ text: 'The Ochulus • 100 Games Challenge', iconURL: interaction.client.user.avatarURL() })
|
.setFooter({ text: 'The Ochulus • 100 Games Challenge', iconURL: interaction.client.user.avatarURL() })
|
||||||
.setTimestamp();
|
.setTimestamp();
|
||||||
|
|
||||||
|
if (game.cover) {
|
||||||
|
const coverUrl = await getCoverURL(game.cover);
|
||||||
|
embed.setThumbnail(`${coverUrl}`);
|
||||||
|
}
|
||||||
|
|
||||||
await interaction.followUp({ embeds: [embed] });
|
await interaction.followUp({ embeds: [embed] });
|
||||||
},
|
},
|
||||||
};
|
};
|
Loading…
Reference in New Issue