From cec6c1730abde246a62b56ca47b64d8f97064d1b Mon Sep 17 00:00:00 2001 From: baz Date: Thu, 28 Mar 2024 21:12:28 +0000 Subject: [PATCH] Move commands to deferReply/editReply workflows --- commands/100-games/beatGame.js | 18 +++++++++--------- commands/100-games/beatlist.js | 6 +++--- commands/100-games/currentlyplaying.js | 6 +++--- commands/100-games/deletebeatengame.js | 8 ++++---- commands/100-games/deleteplannedgame.js | 8 ++++---- commands/100-games/deleteplayinggame.js | 8 ++++---- commands/100-games/estimatedfinishdate.js | 6 +++--- commands/100-games/gameDetails.js | 6 +++--- commands/100-games/globalbeatlist.js | 4 ++-- commands/100-games/leaderboard.js | 5 +++-- commands/100-games/planGame.js | 12 ++++++------ commands/100-games/plannedGames.js | 6 +++--- commands/100-games/randomgame.js | 4 ++-- commands/100-games/randomplannedgame.js | 8 ++++---- commands/100-games/recentbeat.js | 10 ++++++---- commands/100-games/recentplanned.js | 10 ++++++---- commands/100-games/recentplaying.js | 10 ++++++---- commands/100-games/searchGames.js | 6 +++--- commands/100-games/startplaying.js | 14 +++++++------- commands/100-games/user.js | 6 +++--- 20 files changed, 84 insertions(+), 77 deletions(-) diff --git a/commands/100-games/beatGame.js b/commands/100-games/beatGame.js index 0b75f4d..ece4262 100644 --- a/commands/100-games/beatGame.js +++ b/commands/100-games/beatGame.js @@ -10,18 +10,18 @@ module.exports = { .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 }); + await interaction.deferReply(); 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); - 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 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 = ''; @@ -38,15 +38,15 @@ module.exports = { res = res.filter(entry => entry.status !== 6); 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 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); - 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 planNum = await getPlanningGameCount(userDatabaseEntry); @@ -68,7 +68,7 @@ module.exports = { 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 }); - await interaction.followUp({ embeds: [embed] }); + await interaction.editReply({ embeds: [embed] }); if (beatNum == 100) { const challengeCompletedEmbed = new EmbedBuilder() @@ -79,7 +79,7 @@ module.exports = { .setTimestamp() .setImage('https://c.tenor.com/82zAqfFm7OMAAAAC/tenor.gif'); - await interaction.followUp({ embeds: [challengeCompletedEmbed] }); + await interaction.editReply({ embeds: [challengeCompletedEmbed] }); } }, }; \ No newline at end of file diff --git a/commands/100-games/beatlist.js b/commands/100-games/beatlist.js index d2aeae3..89d126d 100644 --- a/commands/100-games/beatlist.js +++ b/commands/100-games/beatlist.js @@ -8,7 +8,7 @@ module.exports = { .setDescription('Show the list of games you have beaten.') .addUserOption(option => option.setName('user').setDescription('The user to check')), async execute(interaction) { - await interaction.reply({ content: 'Searching for user...', ephemeral: true }); + await interaction.deferReply(); let user = interaction.user; const userOption = interaction.options.getUser('user'); @@ -18,7 +18,7 @@ module.exports = { } 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); let desc = ''; @@ -45,6 +45,6 @@ module.exports = { .setFooter({ text: 'The Ochulus • 100 Games Challenge', iconURL: interaction.client.user.avatarURL() }) .setTimestamp(); - return interaction.followUp({ embeds: [embed] }); + return interaction.editReply({ embeds: [embed] }); }, }; \ No newline at end of file diff --git a/commands/100-games/currentlyplaying.js b/commands/100-games/currentlyplaying.js index d33a2a4..c475950 100644 --- a/commands/100-games/currentlyplaying.js +++ b/commands/100-games/currentlyplaying.js @@ -8,7 +8,7 @@ module.exports = { .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 }); + await interaction.deferReply(); let user = interaction.user; const userOption = interaction.options.getUser('user'); @@ -18,7 +18,7 @@ module.exports = { } 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); let desc = ''; @@ -45,6 +45,6 @@ module.exports = { .setFooter({ text: 'The Ochulus • 100 Games Challenge', iconURL: interaction.client.user.avatarURL() }) .setTimestamp(); - return interaction.followUp({ embeds: [embed] }); + return interaction.editReply({ embeds: [embed] }); }, }; \ No newline at end of file diff --git a/commands/100-games/deletebeatengame.js b/commands/100-games/deletebeatengame.js index fca8e75..f55142e 100644 --- a/commands/100-games/deletebeatengame.js +++ b/commands/100-games/deletebeatengame.js @@ -8,7 +8,7 @@ module.exports = { .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)), async execute(interaction) { - await interaction.reply({ content: 'Searching for user...', ephemeral: true }); + await interaction.deferReply(); const beatGameNumber = interaction.options.getNumber('beatgamenumber'); @@ -27,7 +27,7 @@ module.exports = { const gameDatabaseEntry = await checkGameStorageId(result.gameId); const body = `where id = ${ gameDatabaseEntry.igdb_id }; fields *;`; 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 beatNum = await getBeatenGameCount(userDatabaseEntry); @@ -47,9 +47,9 @@ module.exports = { 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 }); }, }; diff --git a/commands/100-games/deleteplannedgame.js b/commands/100-games/deleteplannedgame.js index c036a01..ecaf638 100644 --- a/commands/100-games/deleteplannedgame.js +++ b/commands/100-games/deleteplannedgame.js @@ -8,7 +8,7 @@ module.exports = { .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)), async execute(interaction) { - await interaction.reply({ content: 'Searching for user...', ephemeral: true }); + await interaction.deferReply(); const beatGameNumber = interaction.options.getNumber('currentgamenumber'); @@ -27,7 +27,7 @@ module.exports = { const gameDatabaseEntry = await checkGameStorageId(result.gameId); const body = `where id = ${ gameDatabaseEntry.igdb_id }; fields *;`; 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 beatNum = await getBeatenGameCount(userDatabaseEntry); @@ -47,9 +47,9 @@ module.exports = { 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 }); }, }; diff --git a/commands/100-games/deleteplayinggame.js b/commands/100-games/deleteplayinggame.js index 1b6e955..5b2f052 100644 --- a/commands/100-games/deleteplayinggame.js +++ b/commands/100-games/deleteplayinggame.js @@ -8,7 +8,7 @@ module.exports = { .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)), async execute(interaction) { - await interaction.reply({ content: 'Searching for user...', ephemeral: true }); + await interaction.deferReply(); const beatGameNumber = interaction.options.getNumber('currentgamenumber'); @@ -27,7 +27,7 @@ module.exports = { const gameDatabaseEntry = await checkGameStorageId(result.gameId); const body = `where id = ${ gameDatabaseEntry.igdb_id }; fields *;`; 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 beatNum = await getBeatenGameCount(userDatabaseEntry); @@ -47,9 +47,9 @@ module.exports = { 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 }); }, }; diff --git a/commands/100-games/estimatedfinishdate.js b/commands/100-games/estimatedfinishdate.js index 36a5233..c2c0720 100644 --- a/commands/100-games/estimatedfinishdate.js +++ b/commands/100-games/estimatedfinishdate.js @@ -7,7 +7,7 @@ module.exports = { .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')), async execute(interaction) { - await interaction.reply({ content: 'Searching for user...', ephemeral: true }); + await interaction.deferReply(); let user = interaction.user; const userOption = interaction.options.getUser('user'); @@ -17,7 +17,7 @@ module.exports = { } 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); let desc = ''; @@ -44,6 +44,6 @@ module.exports = { .setFooter({ text: 'The Ochulus • 100 Games Challenge', iconURL: interaction.client.user.avatarURL() }) .setTimestamp(); - return interaction.followUp({ embeds: [embed] }); + return interaction.editReply({ embeds: [embed] }); }, }; \ No newline at end of file diff --git a/commands/100-games/gameDetails.js b/commands/100-games/gameDetails.js index 6308f70..1acaa0c 100644 --- a/commands/100-games/gameDetails.js +++ b/commands/100-games/gameDetails.js @@ -9,19 +9,19 @@ module.exports = { .addNumberOption(option => option.setName('gameid').setDescription('The IGDB game id.').setMinValue(0)), async execute(interaction) { + await interaction.deferReply(); + 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.editReply({ content: 'No gamename or gameid supplied, please supply an option to register a game!', ephemeral: true }); let body = ''; if (gameid) { - await interaction.reply(`Searching for ${gameid}...`); body = body.concat('where id = ', gameid, '; '); body = body.concat('fields *;'); } else if (gamename) { - await interaction.reply(`Searching for ${gamename}...`); body = body.concat('search "', gamename, '"; '); body = body.concat('fields *; limit 25; where (category = 0 | category = 4) & version_parent = null;'); } diff --git a/commands/100-games/globalbeatlist.js b/commands/100-games/globalbeatlist.js index 18faa77..508239a 100644 --- a/commands/100-games/globalbeatlist.js +++ b/commands/100-games/globalbeatlist.js @@ -7,7 +7,7 @@ module.exports = { .setName('globalbeatlist') .setDescription('Show a list of all games beaten for the 100 games challenge in chronological order.'), async execute(interaction) { - await interaction.reply({ content: 'Searching for games...', ephemeral: true }); + await interaction.deferReply(); const user = interaction.user; @@ -34,6 +34,6 @@ module.exports = { .setFooter({ text: 'The Ochulus • 100 Games Challenge', iconURL: interaction.client.user.avatarURL() }) .setTimestamp(); - return interaction.followUp({ embeds: [embed] }); + return interaction.editReply({ embeds: [embed] }); }, }; \ No newline at end of file diff --git a/commands/100-games/leaderboard.js b/commands/100-games/leaderboard.js index 66c2070..4dbcdec 100644 --- a/commands/100-games/leaderboard.js +++ b/commands/100-games/leaderboard.js @@ -8,8 +8,9 @@ module.exports = { .setDescription('Show the leaderboard!'), async execute(interaction) { 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)); let desc = ''; @@ -41,6 +42,6 @@ module.exports = { .setTimestamp(); - return interaction.reply({ embeds: [embed] }); + return interaction.editReply({ embeds: [embed] }); }, }; \ No newline at end of file diff --git a/commands/100-games/planGame.js b/commands/100-games/planGame.js index 1666bf4..05782ae 100644 --- a/commands/100-games/planGame.js +++ b/commands/100-games/planGame.js @@ -10,15 +10,15 @@ module.exports = { .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 }); + await interaction.deferReply(); 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 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 = ''; @@ -35,12 +35,12 @@ module.exports = { res = res.filter(entry => entry.status !== 6); 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 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 planNum = await getPlanningGameCount(userDatabaseEntry); @@ -62,6 +62,6 @@ module.exports = { embed.setThumbnail(`${coverUrl}`); } - await interaction.followUp({ embeds: [embed] }); + await interaction.editReply({ embeds: [embed] }); }, }; \ No newline at end of file diff --git a/commands/100-games/plannedGames.js b/commands/100-games/plannedGames.js index f24a34c..d04caca 100644 --- a/commands/100-games/plannedGames.js +++ b/commands/100-games/plannedGames.js @@ -8,7 +8,7 @@ module.exports = { .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 }); + await interaction.deferReply(); let user = interaction.user; const userOption = interaction.options.getUser('user'); @@ -18,7 +18,7 @@ module.exports = { } 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); let desc = ''; @@ -44,6 +44,6 @@ module.exports = { .setFooter({ text: 'The Ochulus • 100 Games Challenge', iconURL: interaction.client.user.avatarURL() }) .setTimestamp(); - return interaction.followUp({ embeds: [embed] }); + return interaction.editReply({ embeds: [embed] }); }, }; \ No newline at end of file diff --git a/commands/100-games/randomgame.js b/commands/100-games/randomgame.js index 4549e9c..4604e3d 100644 --- a/commands/100-games/randomgame.js +++ b/commands/100-games/randomgame.js @@ -8,7 +8,7 @@ module.exports = { .addBooleanOption(option => option.setName('madness').setDescription('Let The Ochulus off the rails at your own risk')), async execute(interaction) { - await interaction.reply('The Ochulus is pondering its options...'); + await interaction.deferReply('The Ochulus is pondering its options...'); let games = []; 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.setTimestamp(); - return interaction.followUp({ embeds: [embed] }); + return interaction.editReply({ embeds: [embed] }); }, }; \ No newline at end of file diff --git a/commands/100-games/randomplannedgame.js b/commands/100-games/randomplannedgame.js index c48f86d..8f5345e 100644 --- a/commands/100-games/randomplannedgame.js +++ b/commands/100-games/randomplannedgame.js @@ -8,7 +8,7 @@ module.exports = { .setDescription('Get a random planned game') .addUserOption(option => option.setName('user').setDescription('The user to check')), async execute(interaction) { - await interaction.reply({ content: 'Searching for user...', ephemeral: true }); + await interaction.deferReply(); let user = interaction.user; const userOption = interaction.options.getUser('user'); @@ -18,7 +18,7 @@ module.exports = { } 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() .setColor(0x6441a5) @@ -36,7 +36,7 @@ module.exports = { const randomGame = await checkGameStorageId(randomEntry.gameId); const body = `where id = ${ randomGame.igdb_id }; fields *;`; 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]; embed.setTitle('THE OCHULUS HAS SPOKEN'); @@ -48,6 +48,6 @@ module.exports = { } embed.setDescription(desc); - return interaction.followUp({ embeds: [embed] }); + return interaction.editReply({ embeds: [embed] }); }, }; \ No newline at end of file diff --git a/commands/100-games/recentbeat.js b/commands/100-games/recentbeat.js index 0a76d3f..be53d0f 100644 --- a/commands/100-games/recentbeat.js +++ b/commands/100-games/recentbeat.js @@ -8,6 +8,8 @@ module.exports = { .setDescription('Get the most recent game you have beat.') .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'); @@ -16,14 +18,14 @@ module.exports = { } 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); - 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 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 beatNum = await getBeatenGameCount(userDatabaseEntry); @@ -46,6 +48,6 @@ module.exports = { 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 }); - return interaction.reply({ embeds: [embed] }); + return interaction.editReply({ embeds: [embed] }); }, }; \ No newline at end of file diff --git a/commands/100-games/recentplanned.js b/commands/100-games/recentplanned.js index 11d5b0d..7ce6041 100644 --- a/commands/100-games/recentplanned.js +++ b/commands/100-games/recentplanned.js @@ -8,6 +8,8 @@ module.exports = { .setDescription('Get the most recent game you have planned.') .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'); @@ -16,14 +18,14 @@ module.exports = { } 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); - 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 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 beatNum = await getBeatenGameCount(userDatabaseEntry); @@ -46,6 +48,6 @@ module.exports = { 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 }); - return interaction.reply({ embeds: [embed] }); + return interaction.editReply({ embeds: [embed] }); }, }; \ No newline at end of file diff --git a/commands/100-games/recentplaying.js b/commands/100-games/recentplaying.js index d3df19c..6ffd7f5 100644 --- a/commands/100-games/recentplaying.js +++ b/commands/100-games/recentplaying.js @@ -8,6 +8,8 @@ module.exports = { .setDescription('Get the most recent game you have started playing.') .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'); @@ -16,14 +18,14 @@ module.exports = { } 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); - 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 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 beatNum = await getBeatenGameCount(userDatabaseEntry); @@ -46,6 +48,6 @@ module.exports = { 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 }); - return interaction.reply({ embeds: [embed] }); + return interaction.editReply({ embeds: [embed] }); }, }; \ No newline at end of file diff --git a/commands/100-games/searchGames.js b/commands/100-games/searchGames.js index 6a3ac85..e4f6435 100644 --- a/commands/100-games/searchGames.js +++ b/commands/100-games/searchGames.js @@ -9,13 +9,13 @@ module.exports = { async execute(interaction) { const gamename = interaction.options.getString('gamename'); - await interaction.reply({ content: `Searching for ${gamename}...`, ephemeral: true }); + await interaction.deferReply(); let games = await searchGamesWithMinimumReview(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)); @@ -35,7 +35,7 @@ module.exports = { .setDescription(`${description.slice(0, 1998)}`) .setColor(0x6441a5); - await interaction.followUp({ embeds: [embed] }); + await interaction.editReply({ embeds: [embed] }); }, }; diff --git a/commands/100-games/startplaying.js b/commands/100-games/startplaying.js index 02f3c98..bae144a 100644 --- a/commands/100-games/startplaying.js +++ b/commands/100-games/startplaying.js @@ -10,15 +10,15 @@ module.exports = { .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 }); + await interaction.deferReply(); 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 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 = ''; @@ -35,15 +35,15 @@ module.exports = { res = res.filter(entry => entry.status !== 6); 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 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); - 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 planNum = await getPlanningGameCount(userDatabaseEntry); @@ -65,6 +65,6 @@ module.exports = { embed.setThumbnail(`${coverUrl}`); } - await interaction.followUp({ embeds: [embed] }); + await interaction.editReply({ embeds: [embed] }); }, }; \ No newline at end of file diff --git a/commands/100-games/user.js b/commands/100-games/user.js index a051691..32e9f4d 100644 --- a/commands/100-games/user.js +++ b/commands/100-games/user.js @@ -7,7 +7,7 @@ module.exports = { .setDescription('Get the users info for the 100 Game Challenge') .addUserOption(option => option.setName('user').setDescription('The user to check')), async execute(interaction) { - await interaction.reply({ content: 'Searching for user...', ephemeral: true }); + await interaction.deferReply(); let user = interaction.user; const userOption = interaction.options.getUser('user'); @@ -17,7 +17,7 @@ module.exports = { } 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 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 }); - return interaction.followUp({ embeds: [embed] }); + return interaction.editReply({ embeds: [embed] }); }, }; \ No newline at end of file