Compare commits
No commits in common. "921246961615a06488d6022cb806dd155572c638" and "13b08256276daa0bd5fdb075b224a079b60d6dd3" have entirely different histories.
9212469616
...
13b0825627
|
@ -1,6 +1,5 @@
|
||||||
const { SlashCommandBuilder, EmbedBuilder } = require('discord.js');
|
const { SlashCommandBuilder } = require('discord.js');
|
||||||
const { getUserRegistration, deleteBeatenGameNum, checkGameStorageId, getRecentGameEntry, deleteBeatenGameId, getBeatenGameCount } = require('../../databaseHelperFunctions.js');
|
const { getUserRegistration, deleteBeatenGameNum, checkGameStorageId } = require('../../databaseHelperFunctions.js');
|
||||||
const { getCoverURL, getGameJson } = require('../../igdbHelperFunctions.js');
|
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
data: new SlashCommandBuilder()
|
data: new SlashCommandBuilder()
|
||||||
|
@ -17,32 +16,14 @@ module.exports = {
|
||||||
result = await deleteBeatenGameNum(beatGameNumber, userDatabaseEntry);
|
result = await deleteBeatenGameNum(beatGameNumber, userDatabaseEntry);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
const recentGame = await getRecentGameEntry(userDatabaseEntry.id);
|
// TODO: Delete most recent game entry.
|
||||||
result = await deleteBeatenGameId(recentGame.id, userDatabaseEntry);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (result) {
|
if (result) {
|
||||||
const gameDatabaseEntry = await checkGameStorageId(result.gameId);
|
const game = await checkGameStorageId(result.gameId);
|
||||||
const body = `where id = ${ gameDatabaseEntry.igdb_id }; fields *;`;
|
return interaction.reply(`${game.name} successfully deleted`);
|
||||||
const res = await getGameJson(body);
|
|
||||||
if (!res) return interaction.reply({ content: 'No game found.', ephemeral: true });
|
|
||||||
const game = res[0];
|
|
||||||
|
|
||||||
const num = await getBeatenGameCount(userDatabaseEntry);
|
|
||||||
const coverUrl = await getCoverURL(game.cover);
|
|
||||||
|
|
||||||
const embed = new EmbedBuilder()
|
|
||||||
.setColor(0xFF0000)
|
|
||||||
.setAuthor({ name: `${interaction.user.displayName} deleted a game!`, iconURL: interaction.user.avatarURL() })
|
|
||||||
.setTitle(`${game.name} deleted!`)
|
|
||||||
.setThumbnail(`${coverUrl}`)
|
|
||||||
.setDescription(`${interaction.user.displayName} has beaten ${num} games, they have ${100 - num} games remaining.`)
|
|
||||||
.setFooter({ text: 'The Ochulus • 100 Games Challenge', iconURL: interaction.client.user.avatarURL() })
|
|
||||||
.setTimestamp();
|
|
||||||
|
|
||||||
return interaction.reply({ embeds: [embed] });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return interaction.reply({ content: 'Unable to delete entry / No entry found.', ephemeral: true });
|
return interaction.reply({ content: 'Unable to delete entry / No entry found.', ephemeral: true });
|
||||||
},
|
},
|
||||||
};
|
};
|
|
@ -101,7 +101,7 @@ async function getBeatenGameCount(user) {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function deleteBeatenGameId(id, user) {
|
async function deleteBeatenGameId(id, user) {
|
||||||
const bg = await BeatenGames.findOne({ where: { gameId: id, userId: user.id } })
|
const bg = await BeatenGames.findOne({ where: { id: id, userId: user.id } })
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue