2024-02-16 18:04:29 +01:00
|
|
|
const { SlashCommandBuilder, EmbedBuilder } = require('discord.js');
|
|
|
|
const { getAllBeatenGames, checkGameStorageId, getUserFromId } = require('../../databaseHelperFunctions.js');
|
2024-02-16 18:50:58 +01:00
|
|
|
|
2024-02-16 18:04:29 +01:00
|
|
|
|
|
|
|
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) {
|
2024-03-28 22:12:28 +01:00
|
|
|
await interaction.deferReply();
|
2024-02-16 18:04:29 +01:00
|
|
|
|
|
|
|
const beatenGamesDatabaseEntries = await getAllBeatenGames();
|
|
|
|
let desc = '';
|
|
|
|
|
2024-04-20 17:28:16 +02:00
|
|
|
desc = desc.concat('__Total: ', beatenGamesDatabaseEntries.length, '__\n');
|
|
|
|
|
2024-02-16 18:04:29 +01:00
|
|
|
if (!beatenGamesDatabaseEntries || beatenGamesDatabaseEntries.length == 0) {
|
|
|
|
desc = 'No games beaten yet.';
|
|
|
|
} else {
|
|
|
|
for (let i = 0; i < beatenGamesDatabaseEntries.length; i++) {
|
2024-02-16 18:34:08 +01:00
|
|
|
const game = await checkGameStorageId(beatenGamesDatabaseEntries[i].gameId);
|
2024-02-16 18:04:29 +01:00
|
|
|
const userentry = await getUserFromId(beatenGamesDatabaseEntries[i].userId);
|
2024-07-13 17:38:37 +02:00
|
|
|
const date = beatenGamesDatabaseEntries[i].statusLastChanged.toLocaleDateString('en-GB', { year: 'numeric', month: '2-digit', day: '2-digit' }).replace(/\//g, '/');
|
2024-02-16 18:04:29 +01:00
|
|
|
desc = desc.concat('**', date, '**: \t', game.name, ' \t*(', userentry.username, ')*\n');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const embed = new EmbedBuilder()
|
|
|
|
.setColor(0x6441a5)
|
|
|
|
.setThumbnail(interaction.client.user.avatarURL())
|
2024-04-20 17:28:16 +02:00
|
|
|
.setTitle('The 100 Games Challenge Global Beat List')
|
2024-02-16 18:04:29 +01:00
|
|
|
.setDescription(desc)
|
|
|
|
.setFooter({ text: 'The Ochulus • 100 Games Challenge', iconURL: interaction.client.user.avatarURL() })
|
|
|
|
.setTimestamp();
|
|
|
|
|
2024-03-28 22:12:28 +01:00
|
|
|
return interaction.editReply({ embeds: [embed] });
|
2024-02-16 18:04:29 +01:00
|
|
|
},
|
|
|
|
};
|