Compare commits
No commits in common. "e73ceee0740d79716f035324961a8ca179e6a4dd" and "3cbeb7df68ecbfe3d63acf3d25fc9dafe8db09ea" have entirely different histories.
e73ceee074
...
3cbeb7df68
|
@ -1,49 +0,0 @@
|
|||
const { SlashCommandBuilder, EmbedBuilder } = require('discord.js');
|
||||
const { getUserRegistration, getChangelog, checkGameStorageId } = require('../../databaseHelperFunctions.js');
|
||||
|
||||
module.exports = {
|
||||
data: new SlashCommandBuilder()
|
||||
.setName('changelog')
|
||||
.setDescription('Show your recent activity')
|
||||
.addUserOption(option => option.setName('user').setDescription('The user to check')),
|
||||
async execute(interaction) {
|
||||
await interaction.deferReply();
|
||||
|
||||
let user = interaction.user;
|
||||
const userOption = interaction.options.getUser('user');
|
||||
|
||||
if (userOption) {
|
||||
user = userOption;
|
||||
}
|
||||
|
||||
const userDatabaseEntry = await getUserRegistration(user);
|
||||
if (!userDatabaseEntry) return interaction.editReply({ content: `Issue checking registration with "${user.username}".`, ephemeral: true });
|
||||
|
||||
const changelogEntries = await getChangelog(userDatabaseEntry.id);
|
||||
let desc = '';
|
||||
|
||||
for (const entry of changelogEntries) {
|
||||
const game = await checkGameStorageId(entry.gameId);
|
||||
|
||||
if (entry.newStatus == 'planning') {
|
||||
desc = desc.concat(`:pencil: planned **${game.name}** *(${entry.createdAt.toLocaleDateString('en-GB', { year: 'numeric', month: '2-digit', day: '2-digit' }).replace(/\//g, '/')})*\n`);
|
||||
} else if (entry.newStatus == 'playing') {
|
||||
desc = desc.concat(`:video_game: started playing **${game.name}** *(${entry.createdAt.toLocaleDateString('en-GB', { year: 'numeric', month: '2-digit', day: '2-digit' }).replace(/\//g, '/')})*\n`);
|
||||
} else if (entry.newStatus == 'beat') {
|
||||
desc = desc.concat(`:white_check_mark: beat **${game.name}** *(${entry.createdAt.toLocaleDateString('en-GB', { year: 'numeric', month: '2-digit', day: '2-digit' }).replace(/\//g, '/')})*\n`);
|
||||
} else if (!entry.newStatus) {
|
||||
desc = desc.concat(`:x: deleted **${game.name}** from **${entry.oldStatus}** *(${entry.createdAt.toLocaleDateString('en-GB', { year: 'numeric', month: '2-digit', day: '2-digit' }).replace(/\//g, '/')})*\n`);
|
||||
}
|
||||
}
|
||||
|
||||
const embed = new EmbedBuilder()
|
||||
.setColor(0x6441a5)
|
||||
.setThumbnail(user.avatarURL())
|
||||
.setTitle(`${user.displayName}'s Changelog`)
|
||||
.setDescription(desc)
|
||||
.setFooter({ text: 'The Ochulus • 100 Games Challenge', iconURL: interaction.client.user.avatarURL() })
|
||||
.setTimestamp();
|
||||
|
||||
return interaction.editReply({ embeds: [embed] });
|
||||
},
|
||||
};
|
|
@ -1,38 +0,0 @@
|
|||
const { SlashCommandBuilder, EmbedBuilder } = require('discord.js');
|
||||
const { getAllChangelog, checkGameStorageId, getUserFromId } = require('../../databaseHelperFunctions.js');
|
||||
|
||||
module.exports = {
|
||||
data: new SlashCommandBuilder()
|
||||
.setName('globalchangelog')
|
||||
.setDescription('Show all recent activity'),
|
||||
async execute(interaction) {
|
||||
await interaction.deferReply();
|
||||
const changelogEntries = await getAllChangelog();
|
||||
let desc = '';
|
||||
|
||||
for (const entry of changelogEntries) {
|
||||
const game = await checkGameStorageId(entry.gameId);
|
||||
const user = await getUserFromId(entry.userId);
|
||||
|
||||
if (entry.newStatus == 'planning') {
|
||||
desc = desc.concat(`:pencil: *${user.username}* planned **${game.name}** *(${entry.createdAt.toLocaleDateString('en-GB', { year: 'numeric', month: '2-digit', day: '2-digit' }).replace(/\//g, '/')})*\n`);
|
||||
} else if (entry.newStatus == 'playing') {
|
||||
desc = desc.concat(`:video_game: *${user.username}* started playing **${game.name}** *(${entry.createdAt.toLocaleDateString('en-GB', { year: 'numeric', month: '2-digit', day: '2-digit' }).replace(/\//g, '/')})*\n`);
|
||||
} else if (entry.newStatus == 'beat') {
|
||||
desc = desc.concat(`:white_check_mark: *${user.username}* beat **${game.name}** *(${entry.createdAt.toLocaleDateString('en-GB', { year: 'numeric', month: '2-digit', day: '2-digit' }).replace(/\//g, '/')})*\n`);
|
||||
} else if (!entry.newStatus) {
|
||||
desc = desc.concat(`:x: *${user.username}* deleted **${game.name}** from **${entry.oldStatus}** *(${entry.createdAt.toLocaleDateString('en-GB', { year: 'numeric', month: '2-digit', day: '2-digit' }).replace(/\//g, '/')})*\n`);
|
||||
}
|
||||
}
|
||||
|
||||
const embed = new EmbedBuilder()
|
||||
.setColor(0x6441a5)
|
||||
.setThumbnail(interaction.client.user.avatarURL())
|
||||
.setTitle('Global Changelog')
|
||||
.setDescription(desc)
|
||||
.setFooter({ text: 'The Ochulus • 100 Games Challenge', iconURL: interaction.client.user.avatarURL() })
|
||||
.setTimestamp();
|
||||
|
||||
return interaction.editReply({ embeds: [embed] });
|
||||
},
|
||||
};
|
|
@ -391,28 +391,6 @@ async function backupDatabase() {
|
|||
}
|
||||
}
|
||||
|
||||
async function getChangelog(id) {
|
||||
const changelogEntries = await Changelog.findAll({where: {userId: id}, order: [ [ 'updatedAt', 'DESC' ]] })
|
||||
.catch((err) => {
|
||||
console.log(err);
|
||||
});
|
||||
|
||||
if (changelogEntries) return changelogEntries;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
async function getAllChangelog() {
|
||||
const changelogEntries = await Changelog.findAll({ order: [ [ 'updatedAt', 'DESC' ]] })
|
||||
.catch((err) => {
|
||||
console.log(err);
|
||||
});
|
||||
|
||||
if (changelogEntries) return changelogEntries;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
checkUserRegistration,
|
||||
getUserRegistration,
|
||||
|
@ -445,6 +423,4 @@ module.exports = {
|
|||
getGames,
|
||||
getAllBeatenGames,
|
||||
backupDatabase,
|
||||
getChangelog,
|
||||
getAllChangelog,
|
||||
};
|
Loading…
Reference in New Issue