Compare commits
No commits in common. "95c52b7ad5dba6e01f2ce41f6560325a85c6dee5" and "1098cfadaa2e51fbbb22c709b7146a6c45661142" have entirely different histories.
95c52b7ad5
...
1098cfadaa
|
@ -1,5 +1,5 @@
|
||||||
const { SlashCommandBuilder, EmbedBuilder } = require('discord.js');
|
const { SlashCommandBuilder, EmbedBuilder } = require('discord.js');
|
||||||
const { getUserRegistration, getBeatenGames, checkGameStorageId } = require('../../databaseHelperFunctions.js');
|
const { getUserRegistration, getGames, checkGameStorageId } = require('../../databaseHelperFunctions.js');
|
||||||
const { getGameJson } = require('../../igdbHelperFunctions.js');
|
const { getGameJson } = require('../../igdbHelperFunctions.js');
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
@ -20,7 +20,7 @@ module.exports = {
|
||||||
const userDatabaseEntry = await getUserRegistration(user);
|
const userDatabaseEntry = await getUserRegistration(user);
|
||||||
if (!userDatabaseEntry) return interaction.followUp({ content: `Issue checking registration with "${user.username}".`, ephemeral: true });
|
if (!userDatabaseEntry) return interaction.followUp({ content: `Issue checking registration with "${user.username}".`, ephemeral: true });
|
||||||
|
|
||||||
const beatenGamesDatabaseEntries = await getBeatenGames(userDatabaseEntry.id);
|
const beatenGamesDatabaseEntries = await getGames(userDatabaseEntry.id);
|
||||||
if (!beatenGamesDatabaseEntries || beatenGamesDatabaseEntries.length == 0) return interaction.followUp({ content: 'No games found.', ephemeral: true });
|
if (!beatenGamesDatabaseEntries || beatenGamesDatabaseEntries.length == 0) return interaction.followUp({ content: 'No games found.', ephemeral: true });
|
||||||
|
|
||||||
let desc = '';
|
let desc = '';
|
||||||
|
|
|
@ -1,48 +0,0 @@
|
||||||
const { SlashCommandBuilder, EmbedBuilder } = require('discord.js');
|
|
||||||
const { getUserRegistration, getPlayingGames, checkGameStorageId } = require('../../databaseHelperFunctions.js');
|
|
||||||
const { getGameJson } = require('../../igdbHelperFunctions.js');
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
data: new SlashCommandBuilder()
|
|
||||||
.setName('currentlyplaying')
|
|
||||||
.setDescription('Show the list of games you are currently playing.')
|
|
||||||
.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 });
|
|
||||||
|
|
||||||
let databaseEntries = await getPlayingGames(userDatabaseEntry.id);
|
|
||||||
if (!databaseEntries || databaseEntries.length == 0) return interaction.followUp({ content: 'No games found.', ephemeral: true });
|
|
||||||
|
|
||||||
databaseEntries = databaseEntries.reverse();
|
|
||||||
|
|
||||||
let desc = '';
|
|
||||||
|
|
||||||
for (let i = 0; i < databaseEntries.length; i++) {
|
|
||||||
const gameid = await checkGameStorageId(databaseEntries[i].gameId);
|
|
||||||
const res = await getGameJson(`where id = ${ gameid.igdb_id }; fields *;`);
|
|
||||||
const game = res[0];
|
|
||||||
|
|
||||||
desc = desc.concat('-\t', game.name, '\n');
|
|
||||||
}
|
|
||||||
|
|
||||||
const embed = new EmbedBuilder()
|
|
||||||
.setColor(0x6441a5)
|
|
||||||
.setAuthor({ name: `${user.displayName}`, iconURL: user.avatarURL() })
|
|
||||||
.setTitle(`${user.displayName}'s currently playing games`)
|
|
||||||
.setDescription(desc)
|
|
||||||
.setFooter({ text: 'The Ochulus • 100 Games Challenge', iconURL: interaction.client.user.avatarURL() })
|
|
||||||
.setTimestamp();
|
|
||||||
|
|
||||||
return interaction.followUp({ embeds: [embed] });
|
|
||||||
},
|
|
||||||
};
|
|
|
@ -4,8 +4,8 @@ const { checkGameStorage, getUserRegistration, createPlayingGameEntry, getBeaten
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
data: new SlashCommandBuilder()
|
data: new SlashCommandBuilder()
|
||||||
.setName('startplaying')
|
.setName('nowplaying')
|
||||||
.setDescription('Log a game that you have started playing towards the 100 game challenge!')
|
.setDescription('Log a game that you are currently playing towards the 100 game challenge!')
|
||||||
.addStringOption(option => option.setName('gamename').setDescription('The name of the game.').setRequired(true))
|
.addStringOption(option => option.setName('gamename').setDescription('The name of the game.').setRequired(true))
|
||||||
.addNumberOption(option => option.setName('gameid').setDescription('The IGDB game id.').setMinValue(0)),
|
.addNumberOption(option => option.setName('gameid').setDescription('The IGDB game id.').setMinValue(0)),
|
||||||
async execute(interaction) {
|
async execute(interaction) {
|
||||||
|
@ -49,7 +49,7 @@ module.exports = {
|
||||||
const coverUrl = await getCoverURL(game.cover);
|
const coverUrl = await getCoverURL(game.cover);
|
||||||
|
|
||||||
const embed = new EmbedBuilder()
|
const embed = new EmbedBuilder()
|
||||||
.setColor(0x00C921)
|
.setColor(0xFFD700)
|
||||||
.setAuthor({ name: `${interaction.user.displayName} has started playing a new game!`, iconURL: interaction.user.avatarURL() })
|
.setAuthor({ name: `${interaction.user.displayName} has started playing a new game!`, iconURL: interaction.user.avatarURL() })
|
||||||
.setTitle(`${game.name}!`)
|
.setTitle(`${game.name}!`)
|
||||||
.setThumbnail(`${coverUrl}`)
|
.setThumbnail(`${coverUrl}`)
|
|
@ -49,7 +49,7 @@ module.exports = {
|
||||||
const coverUrl = await getCoverURL(game.cover);
|
const coverUrl = await getCoverURL(game.cover);
|
||||||
|
|
||||||
const embed = new EmbedBuilder()
|
const embed = new EmbedBuilder()
|
||||||
.setColor(0x43ABEC)
|
.setColor(0xFFD700)
|
||||||
.setAuthor({ name: `${interaction.user.displayName} is planning to beat a game!`, iconURL: interaction.user.avatarURL() })
|
.setAuthor({ name: `${interaction.user.displayName} is planning to beat a game!`, iconURL: interaction.user.avatarURL() })
|
||||||
.setTitle(`${game.name}!`)
|
.setTitle(`${game.name}!`)
|
||||||
.setThumbnail(`${coverUrl}`)
|
.setThumbnail(`${coverUrl}`)
|
||||||
|
|
|
@ -1,46 +0,0 @@
|
||||||
const { SlashCommandBuilder, EmbedBuilder } = require('discord.js');
|
|
||||||
const { getUserRegistration, getPlanningGames, checkGameStorageId } = require('../../databaseHelperFunctions.js');
|
|
||||||
const { getGameJson } = require('../../igdbHelperFunctions.js');
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
data: new SlashCommandBuilder()
|
|
||||||
.setName('plannedgames')
|
|
||||||
.setDescription('Show the list of games you are currently planning to play.')
|
|
||||||
.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 databaseEntries = await getPlanningGames(userDatabaseEntry.id);
|
|
||||||
if (!databaseEntries || databaseEntries.length == 0) return interaction.followUp({ content: 'No games found.', ephemeral: true });
|
|
||||||
|
|
||||||
let desc = '';
|
|
||||||
|
|
||||||
for (let i = 0; i < databaseEntries.length; i++) {
|
|
||||||
const gameid = await checkGameStorageId(databaseEntries[i].gameId);
|
|
||||||
const res = await getGameJson(`where id = ${ gameid.igdb_id }; fields *;`);
|
|
||||||
const game = res[0];
|
|
||||||
|
|
||||||
desc = desc.concat('-\t', game.name, '\n');
|
|
||||||
}
|
|
||||||
|
|
||||||
const embed = new EmbedBuilder()
|
|
||||||
.setColor(0x6441a5)
|
|
||||||
.setAuthor({ name: `${user.displayName}`, iconURL: user.avatarURL() })
|
|
||||||
.setTitle(`${user.displayName}'s planned games to play`)
|
|
||||||
.setDescription(desc)
|
|
||||||
.setFooter({ text: 'The Ochulus • 100 Games Challenge', iconURL: interaction.client.user.avatarURL() })
|
|
||||||
.setTimestamp();
|
|
||||||
|
|
||||||
return interaction.followUp({ embeds: [embed] });
|
|
||||||
},
|
|
||||||
};
|
|
|
@ -74,9 +74,7 @@ async function createPlanningGameEntry(user, game) {
|
||||||
|
|
||||||
if (entry.status == 'planning') return false;
|
if (entry.status == 'planning') return false;
|
||||||
|
|
||||||
entry.status = 'planning';
|
entry.update({ status: 'planning' });
|
||||||
|
|
||||||
await entry.save();
|
|
||||||
|
|
||||||
return entry;
|
return entry;
|
||||||
}
|
}
|
||||||
|
@ -88,9 +86,7 @@ async function createPlayingGameEntry(user, game) {
|
||||||
|
|
||||||
if (entry.status == 'playing') return false;
|
if (entry.status == 'playing') return false;
|
||||||
|
|
||||||
entry.status = 'playing';
|
entry.save({ status: 'playing' });
|
||||||
|
|
||||||
await entry.save();
|
|
||||||
|
|
||||||
return entry;
|
return entry;
|
||||||
}
|
}
|
||||||
|
@ -102,9 +98,7 @@ async function createBeatenGameEntry(user, game) {
|
||||||
|
|
||||||
if (entry.status == 'beat') return false;
|
if (entry.status == 'beat') return false;
|
||||||
|
|
||||||
entry.status = 'beat';
|
entry.update({ status: 'beat' });
|
||||||
|
|
||||||
await entry.save();
|
|
||||||
|
|
||||||
return entry;
|
return entry;
|
||||||
}
|
}
|
||||||
|
@ -252,7 +246,7 @@ async function getRecentBeatenGameEntry(userId) {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getRecentGameEntry(userId, status) {
|
async function getRecentGameEntry(userId, status) {
|
||||||
const beatenGameEntry = await LoggedGames.findOne({ where: { userId: userId, status: status }, order: [ [ 'updatedAt', 'ASC' ]] })
|
const beatenGameEntry = await LoggedGames.findOne({ where: { userId: userId, status: status }, order: [ [ 'createdAt', 'DESC' ]] })
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
});
|
});
|
||||||
|
@ -269,25 +263,13 @@ async function getRecentGameEntry(userId, status) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getPlanningGames(id) {
|
async function getGames(id) {
|
||||||
return await getGames(id, 'planning');
|
const beatenGameEntry = await LoggedGames.findAll({ where: { userId: id, status: 'beat' } })
|
||||||
}
|
|
||||||
|
|
||||||
async function getPlayingGames(id) {
|
|
||||||
return await getGames(id, 'playing');
|
|
||||||
}
|
|
||||||
|
|
||||||
async function getBeatenGames(id) {
|
|
||||||
return await getGames(id, 'beat');
|
|
||||||
}
|
|
||||||
|
|
||||||
async function getGames(id, status) {
|
|
||||||
const gameEntries = await LoggedGames.findAll({ where: { userId: id, status: status }, order: [ [ 'updatedAt', 'ASC' ]] })
|
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
});
|
});
|
||||||
|
|
||||||
if (gameEntries) return gameEntries;
|
if (beatenGameEntry) return beatenGameEntry;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -327,9 +309,6 @@ module.exports = {
|
||||||
getRecentPlayingGameEntry,
|
getRecentPlayingGameEntry,
|
||||||
getRecentBeatenGameEntry,
|
getRecentBeatenGameEntry,
|
||||||
getRecentGameEntry,
|
getRecentGameEntry,
|
||||||
getPlanningGames,
|
|
||||||
getPlayingGames,
|
|
||||||
getBeatenGames,
|
|
||||||
getGames,
|
getGames,
|
||||||
backupDatabase,
|
backupDatabase,
|
||||||
};
|
};
|
Loading…
Reference in New Issue