Add extra checking
This commit is contained in:
parent
30eb685676
commit
94d73cd542
|
@ -6,20 +6,22 @@ module.exports = {
|
|||
data: new SlashCommandBuilder()
|
||||
.setName('beatgame')
|
||||
.setDescription('Log a game that you have beat towards the 100 game challenge!')
|
||||
.addStringOption(option => option.setName('gamename').setDescription('The name of the game.'))
|
||||
.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)),
|
||||
async execute(interaction) {
|
||||
|
||||
await interaction.reply({ content: 'Attempting to log game.', ephemeral: true });
|
||||
|
||||
const userDatabaseEntry = await getUserRegistration(interaction.user);
|
||||
if (!userDatabaseEntry) return interaction.reply({ content: `Issue checking registration with "${interaction.user.username}".`, ephemeral: true });
|
||||
if (!userDatabaseEntry) return interaction.followUp({ content: `Issue checking registration with "${interaction.user.username}".`, ephemeral: true });
|
||||
|
||||
const oldnum = await getBeatenGameCount(userDatabaseEntry);
|
||||
if (oldnum >= 100) return interaction.reply({ content: 'You have already completed the 100 Games Challenge.', ephemeral: true });
|
||||
if (oldnum >= 100) return interaction.followUp({ content: 'You have already completed the 100 Games Challenge.', ephemeral: true });
|
||||
|
||||
const gamename = interaction.options.getString('gamename');
|
||||
const gameid = interaction.options.getNumber('gameid');
|
||||
|
||||
if (!gamename && !gameid) return interaction.reply({ content: 'No gamename or gameid supplied, please supply an option to register a game!', ephemeral: true });
|
||||
if (!gamename && !gameid) return interaction.followUp({ content: 'No gamename or gameid supplied, please supply an option to register a game!', ephemeral: true });
|
||||
|
||||
let body = '';
|
||||
|
||||
|
@ -34,15 +36,15 @@ module.exports = {
|
|||
|
||||
const res = await getGameJson(body);
|
||||
|
||||
if (!res[0]) return interaction.reply({ content: 'No game found for the options supplied.', ephemeral: true });
|
||||
if (!res[0]) return interaction.followUp({ content: 'No game found for the options supplied.', ephemeral: true });
|
||||
|
||||
const game = res[0];
|
||||
const release_date = game.first_release_date;
|
||||
if (!release_date || (release_date * 1000) > Date.now()) return interaction.reply({ content: `${game.name} is not yet released.`, ephemeral: true });
|
||||
if (!release_date || (release_date * 1000) > Date.now()) return interaction.followUp({ content: `${game.name} is not yet released.`, ephemeral: true });
|
||||
|
||||
const gameDatabaseEntry = await checkGameStorage(game);
|
||||
|
||||
if (!(await createBeatenGameEntry(userDatabaseEntry, gameDatabaseEntry))) return interaction.reply({ content: `${game.name} already beaten.`, ephemeral: true });
|
||||
if (!(await createBeatenGameEntry(userDatabaseEntry, gameDatabaseEntry))) return interaction.followUp({ content: `${game.name} already beaten.`, ephemeral: true });
|
||||
|
||||
const num = await getBeatenGameCount(userDatabaseEntry);
|
||||
const coverUrl = await getCoverURL(game.cover);
|
||||
|
@ -56,7 +58,7 @@ module.exports = {
|
|||
.setFooter({ text: 'The Ochulus • 100 Games Challenge', iconURL: interaction.client.user.avatarURL() })
|
||||
.setTimestamp();
|
||||
|
||||
await interaction.reply({ embeds: [embed] });
|
||||
await interaction.followUp({ embeds: [embed] });
|
||||
|
||||
if (num == 100) {
|
||||
const challengeCompletedEmbed = new EmbedBuilder()
|
||||
|
|
Loading…
Reference in New Issue