Compare commits

...

2 Commits

Author SHA1 Message Date
baz b3f78a3f25 Change list outputs to use embed instead 2024-02-14 19:17:02 +00:00
baz fa786d66fe Check if coverart exists before attaching to embed 2024-02-14 19:11:28 +00:00
10 changed files with 68 additions and 42 deletions

View File

@ -49,17 +49,20 @@ module.exports = {
const beatNum = await getBeatenGameCount(userDatabaseEntry);
const planNum = await getPlanningGameCount(userDatabaseEntry);
const playNum = await getPlayingGameCount(userDatabaseEntry);
const coverUrl = await getCoverURL(game.cover);
const embed = new EmbedBuilder()
.setColor(0xFFD700)
.setAuthor({ name: `${interaction.user.displayName} beat a new game!`, iconURL: interaction.user.avatarURL() })
.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.`)
.setFooter({ text: 'The Ochulus • 100 Games Challenge', iconURL: interaction.client.user.avatarURL() })
.setTimestamp();
if (game.cover) {
const coverUrl = await getCoverURL(game.cover);
embed.setThumbnail(`${coverUrl}`);
}
await interaction.followUp({ embeds: [embed] });
if (beatNum == 100) {

View File

@ -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()

View File

@ -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()

View File

@ -33,17 +33,20 @@ module.exports = {
const beatNum = await getBeatenGameCount(userDatabaseEntry);
const planNum = await getPlanningGameCount(userDatabaseEntry);
const playNum = await getPlayingGameCount(userDatabaseEntry);
const coverUrl = await getCoverURL(game.cover);
const embed = new EmbedBuilder()
.setColor(0xFF0000)
.setAuthor({ name: `${interaction.user.displayName} deleted a game!`, iconURL: interaction.user.avatarURL() })
.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.`)
.setFooter({ text: 'The Ochulus • 100 Games Challenge', iconURL: interaction.client.user.avatarURL() })
.setTimestamp();
if (game.cover) {
const coverUrl = await getCoverURL(game.cover);
embed.setThumbnail(`${coverUrl}`);
}
return interaction.followUp({ embeds: [embed] });
}

View File

@ -33,17 +33,20 @@ module.exports = {
const beatNum = await getBeatenGameCount(userDatabaseEntry);
const planNum = await getPlanningGameCount(userDatabaseEntry);
const playNum = await getPlayingGameCount(userDatabaseEntry);
const coverUrl = await getCoverURL(game.cover);
const embed = new EmbedBuilder()
.setColor(0xFF0000)
.setAuthor({ name: `${interaction.user.displayName} deleted a game!`, iconURL: interaction.user.avatarURL() })
.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.`)
.setFooter({ text: 'The Ochulus • 100 Games Challenge', iconURL: interaction.client.user.avatarURL() })
.setTimestamp();
if (game.cover) {
const coverUrl = await getCoverURL(game.cover);
embed.setThumbnail(`${coverUrl}`);
}
return interaction.followUp({ embeds: [embed] });
}

View File

@ -33,17 +33,20 @@ module.exports = {
const beatNum = await getBeatenGameCount(userDatabaseEntry);
const planNum = await getPlanningGameCount(userDatabaseEntry);
const playNum = await getPlayingGameCount(userDatabaseEntry);
const coverUrl = await getCoverURL(game.cover);
const embed = new EmbedBuilder()
.setColor(0xFF0000)
.setAuthor({ name: `${interaction.user.displayName} deleted a game!`, iconURL: interaction.user.avatarURL() })
.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.`)
.setFooter({ text: 'The Ochulus • 100 Games Challenge', iconURL: interaction.client.user.avatarURL() })
.setTimestamp();
if (game.cover) {
const coverUrl = await getCoverURL(game.cover);
embed.setThumbnail(`${coverUrl}`);
}
return interaction.followUp({ embeds: [embed] });
}

View File

@ -43,17 +43,20 @@ module.exports = {
const beatNum = await getBeatenGameCount(userDatabaseEntry);
const planNum = await getPlanningGameCount(userDatabaseEntry);
const playNum = await getPlayingGameCount(userDatabaseEntry);
const coverUrl = await getCoverURL(game.cover);
const embed = new EmbedBuilder()
.setColor(0x43ABEC)
.setAuthor({ name: `${interaction.user.displayName} is planning to beat a game!`, iconURL: interaction.user.avatarURL() })
.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.`)
.setFooter({ text: 'The Ochulus • 100 Games Challenge', iconURL: interaction.client.user.avatarURL() })
.setTimestamp();
if (game.cover) {
const coverUrl = await getCoverURL(game.cover);
embed.setThumbnail(`${coverUrl}`);
}
await interaction.followUp({ embeds: [embed] });
},
};

View File

@ -21,22 +21,23 @@ 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()
.setColor(0x6441a5)
.setAuthor({ name: `${user.displayName}`, iconURL: user.avatarURL() })
.setTitle(`${user.displayName}'s planned games to play`)
.setTitle(`${user.displayName}'s planned games`)
.setDescription(desc)
.setFooter({ text: 'The Ochulus • 100 Games Challenge', iconURL: interaction.client.user.avatarURL() })
.setTimestamp();

View File

@ -1,6 +1,6 @@
const { SlashCommandBuilder, EmbedBuilder } = require('discord.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 = {
data: new SlashCommandBuilder()
@ -26,17 +26,22 @@ module.exports = {
if (!res) return interaction.reply({ content: 'No game found.', ephemeral: true });
const game = res[0];
const coverUrl = await getCoverURL(game.cover);
const num = await getBeatenGameCount(userDatabaseEntry);
const beatNum = await getBeatenGameCount(userDatabaseEntry);
const planNum = await getPlanningGameCount(userDatabaseEntry);
const playNum = await getPlayingGameCount(userDatabaseEntry);
const embed = new EmbedBuilder()
.setColor(0xFFD700)
.setAuthor({ name: `${user.displayName}'s most recent beat game!`, iconURL: user.avatarURL() })
.setTitle(game.name)
.setThumbnail(`${coverUrl}`)
.setFooter({ text: 'The Ochulus • 100 Games Challenge', iconURL: interaction.client.user.avatarURL() })
.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] });
},

View File

@ -46,17 +46,20 @@ module.exports = {
const beatNum = await getBeatenGameCount(userDatabaseEntry);
const planNum = await getPlanningGameCount(userDatabaseEntry);
const playNum = await getPlayingGameCount(userDatabaseEntry);
const coverUrl = await getCoverURL(game.cover);
const embed = new EmbedBuilder()
.setColor(0x00C921)
.setAuthor({ name: `${interaction.user.displayName} has started playing a new game!`, iconURL: interaction.user.avatarURL() })
.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.`)
.setFooter({ text: 'The Ochulus • 100 Games Challenge', iconURL: interaction.client.user.avatarURL() })
.setTimestamp();
if (game.cover) {
const coverUrl = await getCoverURL(game.cover);
embed.setThumbnail(`${coverUrl}`);
}
await interaction.followUp({ embeds: [embed] });
},
};