Compare commits
No commits in common. "328baba353402042a1b997426bcc3fb322cd4838" and "3b86e362b50ee31a653cfc72340c9e4e96fc4372" have entirely different histories.
328baba353
...
3b86e362b5
|
@ -1,49 +0,0 @@
|
|||
const { SlashCommandBuilder, EmbedBuilder } = require('discord.js');
|
||||
const { getUserRegistration, getBeatenGames } = require('../../databaseHelperFunctions.js');
|
||||
|
||||
module.exports = {
|
||||
data: new SlashCommandBuilder()
|
||||
.setName('estimatedfinishdate')
|
||||
.setDescription('Get an estimated date as to when a user will finish the 100 games challenge.')
|
||||
.addUserOption(option => option.setName('user').setDescription('The user to check')),
|
||||
async execute(interaction) {
|
||||
await interaction.reply({ content: 'Searching for user...', ephemeral: true });
|
||||
|
||||
let user = interaction.user;
|
||||
const userOption = interaction.options.getUser('user');
|
||||
|
||||
if (userOption) {
|
||||
user = userOption;
|
||||
}
|
||||
|
||||
const userDatabaseEntry = await getUserRegistration(user);
|
||||
if (!userDatabaseEntry) return interaction.followUp({ content: `Issue checking registration with "${user.username}".`, ephemeral: true });
|
||||
|
||||
const beatenGamesDatabaseEntries = await getBeatenGames(userDatabaseEntry.id);
|
||||
let desc = '';
|
||||
|
||||
if (!beatenGamesDatabaseEntries || beatenGamesDatabaseEntries.length == 0) {
|
||||
desc = `${user.displayName} has not beaten any games yet.`;
|
||||
} else {
|
||||
const today = new Date();
|
||||
const start = new Date(2024, 1, 1);
|
||||
const days = (today - start) / (1000 * 3600 * 24);
|
||||
const timepergame = days / beatenGamesDatabaseEntries.length;
|
||||
const finishdate = new Date();
|
||||
finishdate.setDate(start.getDate() + (timepergame * 100));
|
||||
const formatteddate = finishdate.toLocaleDateString('en-GB', { year: 'numeric', month: '2-digit', day: '2-digit' }).replace(/\//g, '/');
|
||||
desc = `${user.displayName} is estimated to finish the 100 Games Challenge on **${formatteddate}**.`;
|
||||
}
|
||||
|
||||
const embed = new EmbedBuilder()
|
||||
.setColor(0x6441a5)
|
||||
.setAuthor({ name: `${user.displayName}`, iconURL: user.avatarURL() })
|
||||
.setThumbnail(user.avatarURL())
|
||||
.setTitle(`${user.displayName}'s Estimated Finish Date`)
|
||||
.setDescription(desc)
|
||||
.setFooter({ text: 'The Ochulus • 100 Games Challenge', iconURL: interaction.client.user.avatarURL() })
|
||||
.setTimestamp();
|
||||
|
||||
return interaction.followUp({ embeds: [embed] });
|
||||
},
|
||||
};
|
|
@ -1,41 +0,0 @@
|
|||
const { SlashCommandBuilder, EmbedBuilder } = require('discord.js');
|
||||
const { getAllBeatenGames, checkGameStorageId, getUserFromId } = require('../../databaseHelperFunctions.js');
|
||||
const { getGameJson } = require('../../igdbHelperFunctions.js');
|
||||
|
||||
module.exports = {
|
||||
data: new SlashCommandBuilder()
|
||||
.setName('globalbeatlist')
|
||||
.setDescription('Show a list of all games beaten for the 100 games challenge in chronological order.'),
|
||||
async execute(interaction) {
|
||||
await interaction.reply({ content: 'Searching for games...', ephemeral: true });
|
||||
|
||||
const user = interaction.user;
|
||||
|
||||
const beatenGamesDatabaseEntries = await getAllBeatenGames();
|
||||
let desc = '';
|
||||
|
||||
if (!beatenGamesDatabaseEntries || beatenGamesDatabaseEntries.length == 0) {
|
||||
desc = 'No games beaten 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];
|
||||
const userentry = await getUserFromId(beatenGamesDatabaseEntries[i].userId);
|
||||
const date = beatenGamesDatabaseEntries[i].updatedAt.toLocaleDateString('en-GB', { year: 'numeric', month: '2-digit', day: '2-digit' }).replace(/\//g, '/');
|
||||
desc = desc.concat('**', date, '**: \t', game.name, ' \t*(', userentry.username, ')*\n');
|
||||
}
|
||||
}
|
||||
|
||||
const embed = new EmbedBuilder()
|
||||
.setColor(0x6441a5)
|
||||
.setAuthor({ name: `${user.displayName}`, iconURL: user.avatarURL() })
|
||||
.setThumbnail(interaction.client.user.avatarURL())
|
||||
.setTitle('Global Beat List')
|
||||
.setDescription(desc)
|
||||
.setFooter({ text: 'The Ochulus • 100 Games Challenge', iconURL: interaction.client.user.avatarURL() })
|
||||
.setTimestamp();
|
||||
|
||||
return interaction.followUp({ embeds: [embed] });
|
||||
},
|
||||
};
|
|
@ -35,17 +35,6 @@ async function getUserRegistration(user) {
|
|||
return null;
|
||||
}
|
||||
|
||||
async function getUserFromId(id) {
|
||||
const u = await Users.findOne({ where: { id: id } })
|
||||
.catch((err) => {
|
||||
console.log(err);
|
||||
});
|
||||
|
||||
if (u) return u;
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
async function checkGameStorage(game) {
|
||||
let g = await Games.findOne({ where: { igdb_id: game.id, name: game.name } })
|
||||
.catch((err) => {
|
||||
|
@ -303,17 +292,6 @@ async function getGames(id, status) {
|
|||
return false;
|
||||
}
|
||||
|
||||
async function getAllBeatenGames() {
|
||||
const gameEntries = await LoggedGames.findAll({ where: { status: 'beat' }, order: [ [ 'updatedAt', 'ASC' ]] })
|
||||
.catch((err) => {
|
||||
console.log(err);
|
||||
});
|
||||
|
||||
if (gameEntries) return gameEntries;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
async function backupDatabase() {
|
||||
const date = new Date().toJSON().slice(0, 10);
|
||||
|
||||
|
@ -328,7 +306,6 @@ async function backupDatabase() {
|
|||
module.exports = {
|
||||
checkUserRegistration,
|
||||
getUserRegistration,
|
||||
getUserFromId,
|
||||
checkGameStorage,
|
||||
createPlanningGameEntry,
|
||||
createPlayingGameEntry,
|
||||
|
@ -354,6 +331,5 @@ module.exports = {
|
|||
getPlayingGames,
|
||||
getBeatenGames,
|
||||
getGames,
|
||||
getAllBeatenGames,
|
||||
backupDatabase,
|
||||
};
|
Loading…
Reference in New Issue