Move commands to deferReply/editReply workflows

This commit is contained in:
baz 2024-03-28 21:12:28 +00:00
parent 99367354a2
commit cec6c1730a
20 changed files with 84 additions and 77 deletions

View File

@ -10,18 +10,18 @@ module.exports = {
.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) {
await interaction.reply({ content: 'Attempting to log game.', ephemeral: true }); await interaction.deferReply();
const userDatabaseEntry = await getUserRegistration(interaction.user); const userDatabaseEntry = await getUserRegistration(interaction.user);
if (!userDatabaseEntry) return interaction.followUp({ content: `Issue checking registration with "${interaction.user.username}".`, ephemeral: true }); if (!userDatabaseEntry) return interaction.editReply({ content: `Issue checking registration with "${interaction.user.username}".`, ephemeral: true });
const oldnum = await getBeatenGameCount(userDatabaseEntry); const oldnum = await getBeatenGameCount(userDatabaseEntry);
if (oldnum >= 100) return interaction.followUp({ content: 'You have already completed the 100 Games Challenge.', ephemeral: true }); if (oldnum >= 100) return interaction.editReply({ content: 'You have already completed the 100 Games Challenge.', ephemeral: true });
const gamename = interaction.options.getString('gamename'); const gamename = interaction.options.getString('gamename');
const gameid = interaction.options.getNumber('gameid'); const gameid = interaction.options.getNumber('gameid');
if (!gamename && !gameid) return interaction.followUp({ content: 'No gamename or gameid supplied, please supply an option to register a game!', ephemeral: true }); if (!gamename && !gameid) return interaction.editReply({ content: 'No gamename or gameid supplied, please supply an option to register a game!', ephemeral: true });
let body = ''; let body = '';
@ -38,15 +38,15 @@ module.exports = {
res = res.filter(entry => entry.status !== 6); res = res.filter(entry => entry.status !== 6);
res.sort((a, b) => parseInt(b.total_rating_count) - parseInt(a.total_rating_count)); res.sort((a, b) => parseInt(b.total_rating_count) - parseInt(a.total_rating_count));
if (!res[0]) return interaction.followUp({ content: 'No game found for the options supplied.', ephemeral: true }); if (!res[0]) return interaction.editReply({ content: 'No game found for the options supplied.', ephemeral: true });
const game = res[0]; const game = res[0];
const release_date = game.first_release_date; const release_date = game.first_release_date;
if (!release_date || (release_date * 1000) > Date.now()) return interaction.followUp({ content: `${game.name} is not yet released.`, ephemeral: true }); if (!release_date || (release_date * 1000) > Date.now()) return interaction.editReply({ content: `${game.name} is not yet released.`, ephemeral: true });
const gameDatabaseEntry = await checkGameStorage(game); const gameDatabaseEntry = await checkGameStorage(game);
if (!(await createBeatenGameEntry(userDatabaseEntry, gameDatabaseEntry))) return interaction.followUp({ content: `${game.name} already beaten.`, ephemeral: true }); if (!(await createBeatenGameEntry(userDatabaseEntry, gameDatabaseEntry))) return interaction.editReply({ content: `${game.name} already beaten.`, ephemeral: true });
const beatNum = await getBeatenGameCount(userDatabaseEntry); const beatNum = await getBeatenGameCount(userDatabaseEntry);
const planNum = await getPlanningGameCount(userDatabaseEntry); const planNum = await getPlanningGameCount(userDatabaseEntry);
@ -68,7 +68,7 @@ module.exports = {
embed.addFields({ name: 'Now Playing', value: `${playNum} game(s)`, inline: true }); embed.addFields({ name: 'Now Playing', value: `${playNum} game(s)`, inline: true });
embed.addFields({ name: 'Beaten', value: `${beatNum}/100 (${100 - beatNum} game(s) remaining)`, inline: true }); embed.addFields({ name: 'Beaten', value: `${beatNum}/100 (${100 - beatNum} game(s) remaining)`, inline: true });
await interaction.followUp({ embeds: [embed] }); await interaction.editReply({ embeds: [embed] });
if (beatNum == 100) { if (beatNum == 100) {
const challengeCompletedEmbed = new EmbedBuilder() const challengeCompletedEmbed = new EmbedBuilder()
@ -79,7 +79,7 @@ module.exports = {
.setTimestamp() .setTimestamp()
.setImage('https://c.tenor.com/82zAqfFm7OMAAAAC/tenor.gif'); .setImage('https://c.tenor.com/82zAqfFm7OMAAAAC/tenor.gif');
await interaction.followUp({ embeds: [challengeCompletedEmbed] }); await interaction.editReply({ embeds: [challengeCompletedEmbed] });
} }
}, },
}; };

View File

@ -8,7 +8,7 @@ module.exports = {
.setDescription('Show the list of games you have beaten.') .setDescription('Show the list of games you have beaten.')
.addUserOption(option => option.setName('user').setDescription('The user to check')), .addUserOption(option => option.setName('user').setDescription('The user to check')),
async execute(interaction) { async execute(interaction) {
await interaction.reply({ content: 'Searching for user...', ephemeral: true }); await interaction.deferReply();
let user = interaction.user; let user = interaction.user;
const userOption = interaction.options.getUser('user'); const userOption = interaction.options.getUser('user');
@ -18,7 +18,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.editReply({ content: `Issue checking registration with "${user.username}".`, ephemeral: true });
const beatenGamesDatabaseEntries = await getBeatenGames(userDatabaseEntry.id); const beatenGamesDatabaseEntries = await getBeatenGames(userDatabaseEntry.id);
let desc = ''; let desc = '';
@ -45,6 +45,6 @@ module.exports = {
.setFooter({ text: 'The Ochulus • 100 Games Challenge', iconURL: interaction.client.user.avatarURL() }) .setFooter({ text: 'The Ochulus • 100 Games Challenge', iconURL: interaction.client.user.avatarURL() })
.setTimestamp(); .setTimestamp();
return interaction.followUp({ embeds: [embed] }); return interaction.editReply({ embeds: [embed] });
}, },
}; };

View File

@ -8,7 +8,7 @@ module.exports = {
.setDescription('Show the list of games you are currently playing.') .setDescription('Show the list of games you are currently playing.')
.addUserOption(option => option.setName('user').setDescription('The user to check')), .addUserOption(option => option.setName('user').setDescription('The user to check')),
async execute(interaction) { async execute(interaction) {
await interaction.reply({ content: 'Searching for user...', ephemeral: true }); await interaction.deferReply();
let user = interaction.user; let user = interaction.user;
const userOption = interaction.options.getUser('user'); const userOption = interaction.options.getUser('user');
@ -18,7 +18,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.editReply({ content: `Issue checking registration with "${user.username}".`, ephemeral: true });
const databaseEntries = await getPlayingGames(userDatabaseEntry.id); const databaseEntries = await getPlayingGames(userDatabaseEntry.id);
let desc = ''; let desc = '';
@ -45,6 +45,6 @@ module.exports = {
.setFooter({ text: 'The Ochulus • 100 Games Challenge', iconURL: interaction.client.user.avatarURL() }) .setFooter({ text: 'The Ochulus • 100 Games Challenge', iconURL: interaction.client.user.avatarURL() })
.setTimestamp(); .setTimestamp();
return interaction.followUp({ embeds: [embed] }); return interaction.editReply({ embeds: [embed] });
}, },
}; };

View File

@ -8,7 +8,7 @@ module.exports = {
.setDescription('Delete a game that you have beaten from the 100 game challenge!') .setDescription('Delete a game that you have beaten from the 100 game challenge!')
.addNumberOption(option => option.setName('beatgamenumber').setDescription('Index of the game to delete in the list of beaten games.').setMinValue(1).setMaxValue(100)), .addNumberOption(option => option.setName('beatgamenumber').setDescription('Index of the game to delete in the list of beaten games.').setMinValue(1).setMaxValue(100)),
async execute(interaction) { async execute(interaction) {
await interaction.reply({ content: 'Searching for user...', ephemeral: true }); await interaction.deferReply();
const beatGameNumber = interaction.options.getNumber('beatgamenumber'); const beatGameNumber = interaction.options.getNumber('beatgamenumber');
@ -27,7 +27,7 @@ module.exports = {
const gameDatabaseEntry = await checkGameStorageId(result.gameId); const gameDatabaseEntry = await checkGameStorageId(result.gameId);
const body = `where id = ${ gameDatabaseEntry.igdb_id }; fields *;`; const body = `where id = ${ gameDatabaseEntry.igdb_id }; fields *;`;
const res = await getGameJson(body); const res = await getGameJson(body);
if (!res) return interaction.followUp({ content: 'No game found.', ephemeral: true }); if (!res) return interaction.editReply({ content: 'No game found.', ephemeral: true });
const game = res[0]; const game = res[0];
const beatNum = await getBeatenGameCount(userDatabaseEntry); const beatNum = await getBeatenGameCount(userDatabaseEntry);
@ -47,9 +47,9 @@ module.exports = {
embed.setThumbnail(`${coverUrl}`); embed.setThumbnail(`${coverUrl}`);
} }
return interaction.followUp({ embeds: [embed] }); return interaction.editReply({ embeds: [embed] });
} }
return interaction.followUp({ content: 'Unable to delete entry / No entry found.', ephemeral: true }); return interaction.editReply({ content: 'Unable to delete entry / No entry found.', ephemeral: true });
}, },
}; };

View File

@ -8,7 +8,7 @@ module.exports = {
.setDescription('Delete a game that you were planning to play!') .setDescription('Delete a game that you were planning to play!')
.addNumberOption(option => option.setName('currentgamenumber').setDescription('Index of the game to delete in the list of planned games.').setMinValue(1)), .addNumberOption(option => option.setName('currentgamenumber').setDescription('Index of the game to delete in the list of planned games.').setMinValue(1)),
async execute(interaction) { async execute(interaction) {
await interaction.reply({ content: 'Searching for user...', ephemeral: true }); await interaction.deferReply();
const beatGameNumber = interaction.options.getNumber('currentgamenumber'); const beatGameNumber = interaction.options.getNumber('currentgamenumber');
@ -27,7 +27,7 @@ module.exports = {
const gameDatabaseEntry = await checkGameStorageId(result.gameId); const gameDatabaseEntry = await checkGameStorageId(result.gameId);
const body = `where id = ${ gameDatabaseEntry.igdb_id }; fields *;`; const body = `where id = ${ gameDatabaseEntry.igdb_id }; fields *;`;
const res = await getGameJson(body); const res = await getGameJson(body);
if (!res) return interaction.followUp({ content: 'No game found.', ephemeral: true }); if (!res) return interaction.editReply({ content: 'No game found.', ephemeral: true });
const game = res[0]; const game = res[0];
const beatNum = await getBeatenGameCount(userDatabaseEntry); const beatNum = await getBeatenGameCount(userDatabaseEntry);
@ -47,9 +47,9 @@ module.exports = {
embed.setThumbnail(`${coverUrl}`); embed.setThumbnail(`${coverUrl}`);
} }
return interaction.followUp({ embeds: [embed] }); return interaction.editReply({ embeds: [embed] });
} }
return interaction.followUp({ content: 'Unable to delete entry / No entry found.', ephemeral: true }); return interaction.editReply({ content: 'Unable to delete entry / No entry found.', ephemeral: true });
}, },
}; };

View File

@ -8,7 +8,7 @@ module.exports = {
.setDescription('Delete a game that you was playing!') .setDescription('Delete a game that you was playing!')
.addNumberOption(option => option.setName('currentgamenumber').setDescription('Index of the game to delete in the list of currently playing games.').setMinValue(1)), .addNumberOption(option => option.setName('currentgamenumber').setDescription('Index of the game to delete in the list of currently playing games.').setMinValue(1)),
async execute(interaction) { async execute(interaction) {
await interaction.reply({ content: 'Searching for user...', ephemeral: true }); await interaction.deferReply();
const beatGameNumber = interaction.options.getNumber('currentgamenumber'); const beatGameNumber = interaction.options.getNumber('currentgamenumber');
@ -27,7 +27,7 @@ module.exports = {
const gameDatabaseEntry = await checkGameStorageId(result.gameId); const gameDatabaseEntry = await checkGameStorageId(result.gameId);
const body = `where id = ${ gameDatabaseEntry.igdb_id }; fields *;`; const body = `where id = ${ gameDatabaseEntry.igdb_id }; fields *;`;
const res = await getGameJson(body); const res = await getGameJson(body);
if (!res) return interaction.followUp({ content: 'No game found.', ephemeral: true }); if (!res) return interaction.editReply({ content: 'No game found.', ephemeral: true });
const game = res[0]; const game = res[0];
const beatNum = await getBeatenGameCount(userDatabaseEntry); const beatNum = await getBeatenGameCount(userDatabaseEntry);
@ -47,9 +47,9 @@ module.exports = {
embed.setThumbnail(`${coverUrl}`); embed.setThumbnail(`${coverUrl}`);
} }
return interaction.followUp({ embeds: [embed] }); return interaction.editReply({ embeds: [embed] });
} }
return interaction.followUp({ content: 'Unable to delete entry / No entry found.', ephemeral: true }); return interaction.editReply({ content: 'Unable to delete entry / No entry found.', ephemeral: true });
}, },
}; };

View File

@ -7,7 +7,7 @@ module.exports = {
.setDescription('Get an estimated date as to when a user will finish the 100 games challenge.') .setDescription('Get an estimated date as to when a user will finish the 100 games challenge.')
.addUserOption(option => option.setName('user').setDescription('The user to check')), .addUserOption(option => option.setName('user').setDescription('The user to check')),
async execute(interaction) { async execute(interaction) {
await interaction.reply({ content: 'Searching for user...', ephemeral: true }); await interaction.deferReply();
let user = interaction.user; let user = interaction.user;
const userOption = interaction.options.getUser('user'); const userOption = interaction.options.getUser('user');
@ -17,7 +17,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.editReply({ content: `Issue checking registration with "${user.username}".`, ephemeral: true });
const beatenGamesDatabaseEntries = await getBeatenGames(userDatabaseEntry.id); const beatenGamesDatabaseEntries = await getBeatenGames(userDatabaseEntry.id);
let desc = ''; let desc = '';
@ -44,6 +44,6 @@ module.exports = {
.setFooter({ text: 'The Ochulus • 100 Games Challenge', iconURL: interaction.client.user.avatarURL() }) .setFooter({ text: 'The Ochulus • 100 Games Challenge', iconURL: interaction.client.user.avatarURL() })
.setTimestamp(); .setTimestamp();
return interaction.followUp({ embeds: [embed] }); return interaction.editReply({ embeds: [embed] });
}, },
}; };

View File

@ -9,19 +9,19 @@ module.exports = {
.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) {
await interaction.deferReply();
const gamename = interaction.options.getString('gamename'); const gamename = interaction.options.getString('gamename');
const gameid = interaction.options.getNumber('gameid'); 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.editReply({ content: 'No gamename or gameid supplied, please supply an option to register a game!', ephemeral: true });
let body = ''; let body = '';
if (gameid) { if (gameid) {
await interaction.reply(`Searching for ${gameid}...`);
body = body.concat('where id = ', gameid, '; '); body = body.concat('where id = ', gameid, '; ');
body = body.concat('fields *;'); body = body.concat('fields *;');
} else if (gamename) { } else if (gamename) {
await interaction.reply(`Searching for ${gamename}...`);
body = body.concat('search "', gamename, '"; '); body = body.concat('search "', gamename, '"; ');
body = body.concat('fields *; limit 25; where (category = 0 | category = 4) & version_parent = null;'); body = body.concat('fields *; limit 25; where (category = 0 | category = 4) & version_parent = null;');
} }

View File

@ -7,7 +7,7 @@ module.exports = {
.setName('globalbeatlist') .setName('globalbeatlist')
.setDescription('Show a list of all games beaten for the 100 games challenge in chronological order.'), .setDescription('Show a list of all games beaten for the 100 games challenge in chronological order.'),
async execute(interaction) { async execute(interaction) {
await interaction.reply({ content: 'Searching for games...', ephemeral: true }); await interaction.deferReply();
const user = interaction.user; const user = interaction.user;
@ -34,6 +34,6 @@ module.exports = {
.setFooter({ text: 'The Ochulus • 100 Games Challenge', iconURL: interaction.client.user.avatarURL() }) .setFooter({ text: 'The Ochulus • 100 Games Challenge', iconURL: interaction.client.user.avatarURL() })
.setTimestamp(); .setTimestamp();
return interaction.followUp({ embeds: [embed] }); return interaction.editReply({ embeds: [embed] });
}, },
}; };

View File

@ -8,8 +8,9 @@ module.exports = {
.setDescription('Show the leaderboard!'), .setDescription('Show the leaderboard!'),
async execute(interaction) { async execute(interaction) {
const leaderboard = await getLeaderboardEntries(); const leaderboard = await getLeaderboardEntries();
await interaction.deferReply();
if (!leaderboard) return interaction.reply({ content: 'There was a problem!', ephemeral: true }); if (!leaderboard) return interaction.editReply({ content: 'There was a problem!', ephemeral: true });
await leaderboard.sort((a, b) => parseInt(b.count) - parseInt(a.count)); await leaderboard.sort((a, b) => parseInt(b.count) - parseInt(a.count));
let desc = ''; let desc = '';
@ -41,6 +42,6 @@ module.exports = {
.setTimestamp(); .setTimestamp();
return interaction.reply({ embeds: [embed] }); return interaction.editReply({ embeds: [embed] });
}, },
}; };

View File

@ -10,15 +10,15 @@ module.exports = {
.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) {
await interaction.reply({ content: 'Attempting to log game.', ephemeral: true }); await interaction.deferReply();
const userDatabaseEntry = await getUserRegistration(interaction.user); const userDatabaseEntry = await getUserRegistration(interaction.user);
if (!userDatabaseEntry) return interaction.followUp({ content: `Issue checking registration with "${interaction.user.username}".`, ephemeral: true }); if (!userDatabaseEntry) return interaction.editReply({ content: `Issue checking registration with "${interaction.user.username}".`, ephemeral: true });
const gamename = interaction.options.getString('gamename'); const gamename = interaction.options.getString('gamename');
const gameid = interaction.options.getNumber('gameid'); const gameid = interaction.options.getNumber('gameid');
if (!gamename && !gameid) return interaction.followUp({ content: 'No gamename or gameid supplied, please supply an option to register a game!', ephemeral: true }); if (!gamename && !gameid) return interaction.editReply({ content: 'No gamename or gameid supplied, please supply an option to register a game!', ephemeral: true });
let body = ''; let body = '';
@ -35,12 +35,12 @@ module.exports = {
res = res.filter(entry => entry.status !== 6); res = res.filter(entry => entry.status !== 6);
res.sort((a, b) => parseInt(b.total_rating_count) - parseInt(a.total_rating_count)); res.sort((a, b) => parseInt(b.total_rating_count) - parseInt(a.total_rating_count));
if (!res[0]) return interaction.followUp({ content: 'No game found for the options supplied.', ephemeral: true }); if (!res[0]) return interaction.editReply({ content: 'No game found for the options supplied.', ephemeral: true });
const game = res[0]; const game = res[0];
const gameDatabaseEntry = await checkGameStorage(game); const gameDatabaseEntry = await checkGameStorage(game);
if (!(await createPlanningGameEntry(userDatabaseEntry, gameDatabaseEntry))) return interaction.followUp({ content: `${game.name} already planned.`, ephemeral: true }); if (!(await createPlanningGameEntry(userDatabaseEntry, gameDatabaseEntry))) return interaction.editReply({ content: `${game.name} already planned.`, ephemeral: true });
const beatNum = await getBeatenGameCount(userDatabaseEntry); const beatNum = await getBeatenGameCount(userDatabaseEntry);
const planNum = await getPlanningGameCount(userDatabaseEntry); const planNum = await getPlanningGameCount(userDatabaseEntry);
@ -62,6 +62,6 @@ module.exports = {
embed.setThumbnail(`${coverUrl}`); embed.setThumbnail(`${coverUrl}`);
} }
await interaction.followUp({ embeds: [embed] }); await interaction.editReply({ embeds: [embed] });
}, },
}; };

View File

@ -8,7 +8,7 @@ module.exports = {
.setDescription('Show the list of games you are currently planning to play.') .setDescription('Show the list of games you are currently planning to play.')
.addUserOption(option => option.setName('user').setDescription('The user to check')), .addUserOption(option => option.setName('user').setDescription('The user to check')),
async execute(interaction) { async execute(interaction) {
await interaction.reply({ content: 'Searching for user...', ephemeral: true }); await interaction.deferReply();
let user = interaction.user; let user = interaction.user;
const userOption = interaction.options.getUser('user'); const userOption = interaction.options.getUser('user');
@ -18,7 +18,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.editReply({ content: `Issue checking registration with "${user.username}".`, ephemeral: true });
const databaseEntries = await getPlanningGames(userDatabaseEntry.id); const databaseEntries = await getPlanningGames(userDatabaseEntry.id);
let desc = ''; let desc = '';
@ -44,6 +44,6 @@ module.exports = {
.setFooter({ text: 'The Ochulus • 100 Games Challenge', iconURL: interaction.client.user.avatarURL() }) .setFooter({ text: 'The Ochulus • 100 Games Challenge', iconURL: interaction.client.user.avatarURL() })
.setTimestamp(); .setTimestamp();
return interaction.followUp({ embeds: [embed] }); return interaction.editReply({ embeds: [embed] });
}, },
}; };

View File

@ -8,7 +8,7 @@ module.exports = {
.addBooleanOption(option => option.setName('madness').setDescription('Let The Ochulus off the rails at your own risk')), .addBooleanOption(option => option.setName('madness').setDescription('Let The Ochulus off the rails at your own risk')),
async execute(interaction) { async execute(interaction) {
await interaction.reply('The Ochulus is pondering its options...'); await interaction.deferReply('The Ochulus is pondering its options...');
let games = []; let games = [];
const count = interaction.options.getBoolean('madness') ? 0 : 27; const count = interaction.options.getBoolean('madness') ? 0 : 27;
@ -87,6 +87,6 @@ module.exports = {
embed.setFooter({ text: 'The Ochulus • 100 Games Challenge', iconURL: interaction.client.user.avatarURL() }); embed.setFooter({ text: 'The Ochulus • 100 Games Challenge', iconURL: interaction.client.user.avatarURL() });
embed.setTimestamp(); embed.setTimestamp();
return interaction.followUp({ embeds: [embed] }); return interaction.editReply({ embeds: [embed] });
}, },
}; };

View File

@ -8,7 +8,7 @@ module.exports = {
.setDescription('Get a random planned game') .setDescription('Get a random planned game')
.addUserOption(option => option.setName('user').setDescription('The user to check')), .addUserOption(option => option.setName('user').setDescription('The user to check')),
async execute(interaction) { async execute(interaction) {
await interaction.reply({ content: 'Searching for user...', ephemeral: true }); await interaction.deferReply();
let user = interaction.user; let user = interaction.user;
const userOption = interaction.options.getUser('user'); const userOption = interaction.options.getUser('user');
@ -18,7 +18,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.editReply({ content: `Issue checking registration with "${user.username}".`, ephemeral: true });
const embed = new EmbedBuilder() const embed = new EmbedBuilder()
.setColor(0x6441a5) .setColor(0x6441a5)
@ -36,7 +36,7 @@ module.exports = {
const randomGame = await checkGameStorageId(randomEntry.gameId); const randomGame = await checkGameStorageId(randomEntry.gameId);
const body = `where id = ${ randomGame.igdb_id }; fields *;`; const body = `where id = ${ randomGame.igdb_id }; fields *;`;
const res = await getGameJson(body); const res = await getGameJson(body);
if (!res) return interaction.reply({ content: 'No game found.', ephemeral: true }); if (!res) return interaction.editReply({ content: 'No game found.', ephemeral: true });
const game = res[0]; const game = res[0];
embed.setTitle('THE OCHULUS HAS SPOKEN'); embed.setTitle('THE OCHULUS HAS SPOKEN');
@ -48,6 +48,6 @@ module.exports = {
} }
embed.setDescription(desc); embed.setDescription(desc);
return interaction.followUp({ embeds: [embed] }); return interaction.editReply({ embeds: [embed] });
}, },
}; };

View File

@ -8,6 +8,8 @@ module.exports = {
.setDescription('Get the most recent game you have beat.') .setDescription('Get the most recent game you have beat.')
.addUserOption(option => option.setName('user').setDescription('The user to check')), .addUserOption(option => option.setName('user').setDescription('The user to check')),
async execute(interaction) { async execute(interaction) {
await interaction.deferReply();
let user = interaction.user; let user = interaction.user;
const userOption = interaction.options.getUser('user'); const userOption = interaction.options.getUser('user');
@ -16,14 +18,14 @@ module.exports = {
} }
const userDatabaseEntry = await getUserRegistration(user); const userDatabaseEntry = await getUserRegistration(user);
if (!userDatabaseEntry) return interaction.reply({ content: `Issue checking registration with "${interaction.user.username}".`, ephemeral: true }); if (!userDatabaseEntry) return interaction.editReply({ content: `Issue checking registration with "${interaction.user.username}".`, ephemeral: true });
const gameDatabaseEntry = await getRecentBeatenGameEntry(userDatabaseEntry.id); const gameDatabaseEntry = await getRecentBeatenGameEntry(userDatabaseEntry.id);
if (!gameDatabaseEntry) return interaction.reply({ content: 'No game found.', ephemeral: true }); if (!gameDatabaseEntry) return interaction.editReply({ content: 'No game found.', ephemeral: true });
const body = `where id = ${ gameDatabaseEntry.igdb_id }; fields *;`; const body = `where id = ${ gameDatabaseEntry.igdb_id }; fields *;`;
const res = await getGameJson(body); const res = await getGameJson(body);
if (!res) return interaction.reply({ content: 'No game found.', ephemeral: true }); if (!res) return interaction.editReply({ content: 'No game found.', ephemeral: true });
const game = res[0]; const game = res[0];
const beatNum = await getBeatenGameCount(userDatabaseEntry); const beatNum = await getBeatenGameCount(userDatabaseEntry);
@ -46,6 +48,6 @@ module.exports = {
embed.addFields({ name: 'Now Playing', value: `${playNum} game(s)`, inline: true }); embed.addFields({ name: 'Now Playing', value: `${playNum} game(s)`, inline: true });
embed.addFields({ name: 'Beaten', value: `${beatNum}/100 (${100 - beatNum} game(s) remaining)`, inline: true }); embed.addFields({ name: 'Beaten', value: `${beatNum}/100 (${100 - beatNum} game(s) remaining)`, inline: true });
return interaction.reply({ embeds: [embed] }); return interaction.editReply({ embeds: [embed] });
}, },
}; };

View File

@ -8,6 +8,8 @@ module.exports = {
.setDescription('Get the most recent game you have planned.') .setDescription('Get the most recent game you have planned.')
.addUserOption(option => option.setName('user').setDescription('The user to check')), .addUserOption(option => option.setName('user').setDescription('The user to check')),
async execute(interaction) { async execute(interaction) {
await interaction.deferReply();
let user = interaction.user; let user = interaction.user;
const userOption = interaction.options.getUser('user'); const userOption = interaction.options.getUser('user');
@ -16,14 +18,14 @@ module.exports = {
} }
const userDatabaseEntry = await getUserRegistration(user); const userDatabaseEntry = await getUserRegistration(user);
if (!userDatabaseEntry) return interaction.reply({ content: `Issue checking registration with "${interaction.user.username}".`, ephemeral: true }); if (!userDatabaseEntry) return interaction.editReply({ content: `Issue checking registration with "${interaction.user.username}".`, ephemeral: true });
const gameDatabaseEntry = await getRecentPlanningGameEntry(userDatabaseEntry.id); const gameDatabaseEntry = await getRecentPlanningGameEntry(userDatabaseEntry.id);
if (!gameDatabaseEntry) return interaction.reply({ content: 'No game found.', ephemeral: true }); if (!gameDatabaseEntry) return interaction.editReply({ content: 'No game found.', ephemeral: true });
const body = `where id = ${ gameDatabaseEntry.igdb_id }; fields *;`; const body = `where id = ${ gameDatabaseEntry.igdb_id }; fields *;`;
const res = await getGameJson(body); const res = await getGameJson(body);
if (!res) return interaction.reply({ content: 'No game found.', ephemeral: true }); if (!res) return interaction.editReply({ content: 'No game found.', ephemeral: true });
const game = res[0]; const game = res[0];
const beatNum = await getBeatenGameCount(userDatabaseEntry); const beatNum = await getBeatenGameCount(userDatabaseEntry);
@ -46,6 +48,6 @@ module.exports = {
embed.addFields({ name: 'Now Playing', value: `${playNum} game(s)`, inline: true }); embed.addFields({ name: 'Now Playing', value: `${playNum} game(s)`, inline: true });
embed.addFields({ name: 'Beaten', value: `${beatNum}/100 (${100 - beatNum} game(s) remaining)`, inline: true }); embed.addFields({ name: 'Beaten', value: `${beatNum}/100 (${100 - beatNum} game(s) remaining)`, inline: true });
return interaction.reply({ embeds: [embed] }); return interaction.editReply({ embeds: [embed] });
}, },
}; };

View File

@ -8,6 +8,8 @@ module.exports = {
.setDescription('Get the most recent game you have started playing.') .setDescription('Get the most recent game you have started playing.')
.addUserOption(option => option.setName('user').setDescription('The user to check')), .addUserOption(option => option.setName('user').setDescription('The user to check')),
async execute(interaction) { async execute(interaction) {
await interaction.deferReply();
let user = interaction.user; let user = interaction.user;
const userOption = interaction.options.getUser('user'); const userOption = interaction.options.getUser('user');
@ -16,14 +18,14 @@ module.exports = {
} }
const userDatabaseEntry = await getUserRegistration(user); const userDatabaseEntry = await getUserRegistration(user);
if (!userDatabaseEntry) return interaction.reply({ content: `Issue checking registration with "${interaction.user.username}".`, ephemeral: true }); if (!userDatabaseEntry) return interaction.editReply({ content: `Issue checking registration with "${interaction.user.username}".`, ephemeral: true });
const gameDatabaseEntry = await getRecentPlayingGameEntry(userDatabaseEntry.id); const gameDatabaseEntry = await getRecentPlayingGameEntry(userDatabaseEntry.id);
if (!gameDatabaseEntry) return interaction.reply({ content: 'No game found.', ephemeral: true }); if (!gameDatabaseEntry) return interaction.editReply({ content: 'No game found.', ephemeral: true });
const body = `where id = ${ gameDatabaseEntry.igdb_id }; fields *;`; const body = `where id = ${ gameDatabaseEntry.igdb_id }; fields *;`;
const res = await getGameJson(body); const res = await getGameJson(body);
if (!res) return interaction.reply({ content: 'No game found.', ephemeral: true }); if (!res) return interaction.editReply({ content: 'No game found.', ephemeral: true });
const game = res[0]; const game = res[0];
const beatNum = await getBeatenGameCount(userDatabaseEntry); const beatNum = await getBeatenGameCount(userDatabaseEntry);
@ -46,6 +48,6 @@ module.exports = {
embed.addFields({ name: 'Now Playing', value: `${playNum} game(s)`, inline: true }); embed.addFields({ name: 'Now Playing', value: `${playNum} game(s)`, inline: true });
embed.addFields({ name: 'Beaten', value: `${beatNum}/100 (${100 - beatNum} game(s) remaining)`, inline: true }); embed.addFields({ name: 'Beaten', value: `${beatNum}/100 (${100 - beatNum} game(s) remaining)`, inline: true });
return interaction.reply({ embeds: [embed] }); return interaction.editReply({ embeds: [embed] });
}, },
}; };

View File

@ -9,13 +9,13 @@ module.exports = {
async execute(interaction) { async execute(interaction) {
const gamename = interaction.options.getString('gamename'); const gamename = interaction.options.getString('gamename');
await interaction.reply({ content: `Searching for ${gamename}...`, ephemeral: true }); await interaction.deferReply();
let games = await searchGamesWithMinimumReview(gamename); let games = await searchGamesWithMinimumReview(gamename);
if (games.length == 0) games = await searchGamesWithoutMinimumReview(gamename); if (games.length == 0) games = await searchGamesWithoutMinimumReview(gamename);
if (games.length == 0) return interaction.followUp({ content: 'No games found.', ephemeral: true }); if (games.length == 0) return interaction.editReply({ content: 'No games found.', ephemeral: true });
await games.sort((a, b) => parseInt(b.total_rating_count) - parseInt(a.total_rating_count)); await games.sort((a, b) => parseInt(b.total_rating_count) - parseInt(a.total_rating_count));
@ -35,7 +35,7 @@ module.exports = {
.setDescription(`${description.slice(0, 1998)}`) .setDescription(`${description.slice(0, 1998)}`)
.setColor(0x6441a5); .setColor(0x6441a5);
await interaction.followUp({ embeds: [embed] }); await interaction.editReply({ embeds: [embed] });
}, },
}; };

View File

@ -10,15 +10,15 @@ module.exports = {
.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) {
await interaction.reply({ content: 'Attempting to log game.', ephemeral: true }); await interaction.deferReply();
const userDatabaseEntry = await getUserRegistration(interaction.user); const userDatabaseEntry = await getUserRegistration(interaction.user);
if (!userDatabaseEntry) return interaction.followUp({ content: `Issue checking registration with "${interaction.user.username}".`, ephemeral: true }); if (!userDatabaseEntry) return interaction.editReply({ content: `Issue checking registration with "${interaction.user.username}".`, ephemeral: true });
const gamename = interaction.options.getString('gamename'); const gamename = interaction.options.getString('gamename');
const gameid = interaction.options.getNumber('gameid'); const gameid = interaction.options.getNumber('gameid');
if (!gamename && !gameid) return interaction.followUp({ content: 'No gamename or gameid supplied, please supply an option to register a game!', ephemeral: true }); if (!gamename && !gameid) return interaction.editReply({ content: 'No gamename or gameid supplied, please supply an option to register a game!', ephemeral: true });
let body = ''; let body = '';
@ -35,15 +35,15 @@ module.exports = {
res = res.filter(entry => entry.status !== 6); res = res.filter(entry => entry.status !== 6);
res.sort((a, b) => parseInt(b.total_rating_count) - parseInt(a.total_rating_count)); res.sort((a, b) => parseInt(b.total_rating_count) - parseInt(a.total_rating_count));
if (!res[0]) return interaction.followUp({ content: 'No game found for the options supplied.', ephemeral: true }); if (!res[0]) return interaction.editReply({ content: 'No game found for the options supplied.', ephemeral: true });
const game = res[0]; const game = res[0];
const release_date = game.first_release_date; const release_date = game.first_release_date;
if (!release_date || (release_date * 1000) > Date.now()) return interaction.followUp({ content: `${game.name} is not yet released.`, ephemeral: true }); if (!release_date || (release_date * 1000) > Date.now()) return interaction.editReply({ content: `${game.name} is not yet released.`, ephemeral: true });
const gameDatabaseEntry = await checkGameStorage(game); const gameDatabaseEntry = await checkGameStorage(game);
if (!(await createPlayingGameEntry(userDatabaseEntry, gameDatabaseEntry))) return interaction.followUp({ content: `${game.name} already currently being played.`, ephemeral: true }); if (!(await createPlayingGameEntry(userDatabaseEntry, gameDatabaseEntry))) return interaction.editReply({ content: `${game.name} already currently being played.`, ephemeral: true });
const beatNum = await getBeatenGameCount(userDatabaseEntry); const beatNum = await getBeatenGameCount(userDatabaseEntry);
const planNum = await getPlanningGameCount(userDatabaseEntry); const planNum = await getPlanningGameCount(userDatabaseEntry);
@ -65,6 +65,6 @@ module.exports = {
embed.setThumbnail(`${coverUrl}`); embed.setThumbnail(`${coverUrl}`);
} }
await interaction.followUp({ embeds: [embed] }); await interaction.editReply({ embeds: [embed] });
}, },
}; };

View File

@ -7,7 +7,7 @@ module.exports = {
.setDescription('Get the users info for the 100 Game Challenge') .setDescription('Get the users info for the 100 Game Challenge')
.addUserOption(option => option.setName('user').setDescription('The user to check')), .addUserOption(option => option.setName('user').setDescription('The user to check')),
async execute(interaction) { async execute(interaction) {
await interaction.reply({ content: 'Searching for user...', ephemeral: true }); await interaction.deferReply();
let user = interaction.user; let user = interaction.user;
const userOption = interaction.options.getUser('user'); const userOption = interaction.options.getUser('user');
@ -17,7 +17,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.editReply({ content: `Issue checking registration with "${user.username}".`, ephemeral: true });
const planNum = await getPlanningGameCount(userDatabaseEntry); const planNum = await getPlanningGameCount(userDatabaseEntry);
const playNum = await getPlayingGameCount(userDatabaseEntry); const playNum = await getPlayingGameCount(userDatabaseEntry);
@ -50,6 +50,6 @@ module.exports = {
if (recentEntry) embed.addFields({ name: 'Last Updated', value: `${recentEntry.updatedAt.toLocaleDateString('en-GB', { year: 'numeric', month: '2-digit', day: '2-digit' }).replace(/\//g, '/')}`, inline: true }); if (recentEntry) embed.addFields({ name: 'Last Updated', value: `${recentEntry.updatedAt.toLocaleDateString('en-GB', { year: 'numeric', month: '2-digit', day: '2-digit' }).replace(/\//g, '/')}`, inline: true });
return interaction.followUp({ embeds: [embed] }); return interaction.editReply({ embeds: [embed] });
}, },
}; };