From 759ce8717e17b368aecc9c5fa6fea856094a97d3 Mon Sep 17 00:00:00 2001 From: Carter Penterman Date: Wed, 24 Apr 2024 11:03:25 -0500 Subject: [PATCH] Use the built-in defer reply method --- commands/submit.js | 10 +++++----- commands/take.js | 14 +++++++++----- common.js | 2 +- 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/commands/submit.js b/commands/submit.js index 8a1674e..6c9e988 100644 --- a/commands/submit.js +++ b/commands/submit.js @@ -85,13 +85,13 @@ async function execute(interaction) { } } - const mapValidatePromise = validateMapAsset(id, game); + // Show "Bot is thinking..." + await interaction.deferReply(); - const message = await interaction.reply("⌛ Validating map..."); - - const validation = await mapValidatePromise; + // Validate and send the validation result + const validation = await validateMapAsset(id, game); const msg = getValidationMessage(validation, game, true); - await message.edit(msg); + await interaction.editReply(msg); if (!validation.valid) { await interaction.followUp("Due to having problems, your map was **NOT submitted**."); diff --git a/commands/take.js b/commands/take.js index b67ba16..edaf778 100644 --- a/commands/take.js +++ b/commands/take.js @@ -51,16 +51,20 @@ async function execute(interaction) { } }; + // Show "Bot is thinking..." + await interaction.deferReply(); + + // Kick off the buy request const buyPromise = noblox.buy({product: productInfo, price: 0}); - const mapValidatePromise = validateMapAsset(id, game); - - const message = await interaction.reply("⌛ Validating map..."); - const validation = await mapValidatePromise; + // Validate and send the validation result + const validation = await validateMapAsset(id, game); const msg = getValidationMessage(validation, game, false); - await message.edit(msg); + await interaction.editReply(msg); + // Make sure the buy request is done await buyPromise; + await interaction.followUp( ` Now that your [map (id: ${id})]() has been taken by the bot you can load it into the [${game} maptest place](<${gamePlaces[game]}>). diff --git a/common.js b/common.js index 933d7d6..f71847a 100644 --- a/common.js +++ b/common.js @@ -177,7 +177,7 @@ async function validateMapAsset(assetId, game) { const values = getMapStringValues(model); if (!values) { - errors.push("Your map is missing a `StringValue` named `Creator` and/or a `StringValue` named `DisplayName`. You must add both to your map and they must be parented directly to the root model. These are used to set the map name and creator in-game."); + errors.push("Your map is missing a `StringValue` named `Creator` and/or a `StringValue` named `DisplayName`. You must add both to your map and they must be parented directly to the root model. These are used to set the map's creator and name in-game."); } else { if (!values.creator) {