Compare commits
No commits in common. "08ca63b12045a45b4eb9e9a2957a8ca98f185e6c" and "313a43abc5af5b073f706cec1cdb2cb889101932" have entirely different histories.
08ca63b120
...
313a43abc5
|
@ -24,7 +24,7 @@ module.exports = {
|
||||||
body = body.concat('where id = ', gameid, '; ');
|
body = body.concat('where id = ', gameid, '; ');
|
||||||
} else if (gamename) {
|
} else if (gamename) {
|
||||||
body = body.concat('search "', gamename, '"; ');
|
body = body.concat('search "', gamename, '"; ');
|
||||||
body = body.concat('limit 25; where (category = 0 | category = 4 | category = 8 | category = 9) & version_parent = null;');
|
body = body.concat('limit 25; where (category = 0 | category = 4) & version_parent = null;');
|
||||||
}
|
}
|
||||||
|
|
||||||
body = body.concat('fields *;');
|
body = body.concat('fields *;');
|
||||||
|
|
|
@ -1,46 +0,0 @@
|
||||||
const { SlashCommandBuilder, EmbedBuilder } = require('discord.js');
|
|
||||||
const { getUserRegistration, getGames, checkGameStorageId } = require('../../databaseHelperFunctions.js');
|
|
||||||
const { getGameJson } = require('../../igdbHelperFunctions.js');
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
data: new SlashCommandBuilder()
|
|
||||||
.setName('beatlist')
|
|
||||||
.setDescription('Show the list of games you have beaten.')
|
|
||||||
.addUserOption(option => option.setName('user').setDescription('The user to check')),
|
|
||||||
async execute(interaction) {
|
|
||||||
let user = interaction.user;
|
|
||||||
const userOption = interaction.options.getUser('user');
|
|
||||||
|
|
||||||
if (userOption) {
|
|
||||||
user = userOption;
|
|
||||||
}
|
|
||||||
|
|
||||||
const userDatabaseEntry = await getUserRegistration(user);
|
|
||||||
if (!userDatabaseEntry) return interaction.reply({ content: `Issue checking registration with "${user.username}".`, ephemeral: true });
|
|
||||||
|
|
||||||
await interaction.reply({ content: `Searching for ${user.username}...`, ephemeral: true });
|
|
||||||
|
|
||||||
const beatenGamesDatabaseEntries = await getGames(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');
|
|
||||||
}
|
|
||||||
|
|
||||||
const embed = new EmbedBuilder()
|
|
||||||
.setColor(0x6441a5)
|
|
||||||
.setAuthor({ name: `${user.displayName}`, iconURL: user.avatarURL() })
|
|
||||||
.setTitle(`${interaction.user.username}'s beaten games`)
|
|
||||||
.setDescription(desc)
|
|
||||||
.setFooter({ text: 'The Ochulus • 100 Games Challenge', iconURL: interaction.client.user.avatarURL() })
|
|
||||||
.setTimestamp();
|
|
||||||
|
|
||||||
return interaction.followUp({ embeds: [embed] });
|
|
||||||
},
|
|
||||||
};
|
|
|
@ -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, getRecentGameEntry, getBeatenGameCount } = require('../../databaseHelperFunctions.js');
|
const { getUserRegistration, getRecentGameEntry } = require('../../databaseHelperFunctions.js');
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
data: new SlashCommandBuilder()
|
data: new SlashCommandBuilder()
|
||||||
|
@ -27,7 +27,6 @@ module.exports = {
|
||||||
const game = res[0];
|
const game = res[0];
|
||||||
|
|
||||||
const coverUrl = await getCoverURL(game.cover);
|
const coverUrl = await getCoverURL(game.cover);
|
||||||
const num = await getBeatenGameCount(userDatabaseEntry);
|
|
||||||
|
|
||||||
const embed = new EmbedBuilder()
|
const embed = new EmbedBuilder()
|
||||||
.setColor(0xFFD700)
|
.setColor(0xFFD700)
|
||||||
|
@ -36,7 +35,7 @@ module.exports = {
|
||||||
.setThumbnail(`${coverUrl}`)
|
.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.`);
|
.addFields({ name: 'Description', value: `${game.summary}` });
|
||||||
|
|
||||||
return interaction.reply({ embeds: [embed] });
|
return interaction.reply({ embeds: [embed] });
|
||||||
},
|
},
|
||||||
|
|
|
@ -41,7 +41,7 @@ module.exports = {
|
||||||
|
|
||||||
async function searchGamesWithMinimumReview(gamename) {
|
async function searchGamesWithMinimumReview(gamename) {
|
||||||
let body = `search "${gamename}"; `;
|
let body = `search "${gamename}"; `;
|
||||||
body = await body.concat('fields *; limit 25; where (category = 0 | category = 4 | category = 8 | category = 9) & version_parent = null & total_rating_count > 0;');
|
body = await body.concat('fields *; limit 25; where (category = 0 | category = 4) & version_parent = null & total_rating_count > 0;');
|
||||||
|
|
||||||
const games = await getGameJson(body);
|
const games = await getGameJson(body);
|
||||||
|
|
||||||
|
|
|
@ -172,17 +172,6 @@ async function getRecentGameEntry(userId) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getGames(id) {
|
|
||||||
const beatenGameEntry = await BeatenGames.findAll({ where: { userId: id } })
|
|
||||||
.catch((err) => {
|
|
||||||
console.log(err);
|
|
||||||
});
|
|
||||||
|
|
||||||
if (beatenGameEntry) return beatenGameEntry;
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
checkUserRegistration,
|
checkUserRegistration,
|
||||||
getUserRegistration,
|
getUserRegistration,
|
||||||
|
@ -194,5 +183,4 @@ module.exports = {
|
||||||
checkGameStorageId,
|
checkGameStorageId,
|
||||||
getLeaderboardEntries,
|
getLeaderboardEntries,
|
||||||
getRecentGameEntry,
|
getRecentGameEntry,
|
||||||
getGames,
|
|
||||||
};
|
};
|
Loading…
Reference in New Issue