Compare commits
4 Commits
313a43abc5
...
08ca63b120
Author | SHA1 | Date |
---|---|---|
baz | 08ca63b120 | |
baz | 89818275c1 | |
baz | 5edbce160c | |
baz | 662812964f |
|
@ -24,14 +24,14 @@ 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) & version_parent = null;');
|
body = body.concat('limit 25; where (category = 0 | category = 4 | category = 8 | category = 9) & version_parent = null;');
|
||||||
}
|
}
|
||||||
|
|
||||||
body = body.concat('fields *;');
|
body = body.concat('fields *;');
|
||||||
|
|
||||||
const res = await getGameJson(body);
|
const res = await getGameJson(body);
|
||||||
|
|
||||||
if (!res[0]) return interaction.reply({ content: 'No game found for the options supplied.', ephemeral: true});
|
if (!res[0]) return interaction.reply({ content: 'No game found for the options supplied.', ephemeral: true });
|
||||||
|
|
||||||
const game = res[0];
|
const game = res[0];
|
||||||
const release_date = game.first_release_date;
|
const release_date = game.first_release_date;
|
||||||
|
|
|
@ -0,0 +1,46 @@
|
||||||
|
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 } = require('../../databaseHelperFunctions.js');
|
const { getUserRegistration, getRecentGameEntry, getBeatenGameCount } = require('../../databaseHelperFunctions.js');
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
data: new SlashCommandBuilder()
|
data: new SlashCommandBuilder()
|
||||||
|
@ -27,6 +27,7 @@ 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)
|
||||||
|
@ -35,7 +36,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()
|
||||||
.addFields({ name: 'Description', value: `${game.summary}` });
|
.setDescription(`${interaction.user.displayName} has beaten ${num} games, they have ${100 - num} games remaining.`);
|
||||||
|
|
||||||
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) & version_parent = null & total_rating_count > 0;');
|
body = await body.concat('fields *; limit 25; where (category = 0 | category = 4 | category = 8 | category = 9) & version_parent = null & total_rating_count > 0;');
|
||||||
|
|
||||||
const games = await getGameJson(body);
|
const games = await getGameJson(body);
|
||||||
|
|
||||||
|
|
|
@ -172,6 +172,17 @@ 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,
|
||||||
|
@ -183,4 +194,5 @@ module.exports = {
|
||||||
checkGameStorageId,
|
checkGameStorageId,
|
||||||
getLeaderboardEntries,
|
getLeaderboardEntries,
|
||||||
getRecentGameEntry,
|
getRecentGameEntry,
|
||||||
|
getGames,
|
||||||
};
|
};
|
Loading…
Reference in New Issue