Merge pull request 'Use the built-in defer reply method' (#15) from use-defer-reply into master
All checks were successful
continuous-integration/drone/push Build is passing

Reviewed-on: #15
This commit is contained in:
Quaternions 2024-04-24 22:55:48 +00:00
commit 1a1019b37b
3 changed files with 15 additions and 11 deletions

View File

@ -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..."); // Validate and send the validation result
const validation = await validateMapAsset(id, game);
const validation = await mapValidatePromise;
const msg = getValidationMessage(validation, game, true); const msg = getValidationMessage(validation, game, true);
await message.edit(msg); await interaction.editReply(msg);
if (!validation.valid) { if (!validation.valid) {
await interaction.followUp("Due to having problems, your map was **NOT submitted**."); await interaction.followUp("Due to having problems, your map was **NOT submitted**.");

View File

@ -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 buyPromise = noblox.buy({product: productInfo, price: 0});
const mapValidatePromise = validateMapAsset(id, game);
const message = await interaction.reply("⌛ Validating map..."); // Validate and send the validation result
const validation = await validateMapAsset(id, game);
const validation = await mapValidatePromise;
const msg = getValidationMessage(validation, game, false); const msg = getValidationMessage(validation, game, false);
await message.edit(msg); await interaction.editReply(msg);
// Make sure the buy request is done
await buyPromise; await buyPromise;
await interaction.followUp( await interaction.followUp(
` `
Now that your [map (id: ${id})](<https://create.roblox.com/store/asset/${id}/>) has been taken by the bot you can load it into the [${game} maptest place](<${gamePlaces[game]}>). Now that your [map (id: ${id})](<https://create.roblox.com/store/asset/${id}/>) has been taken by the bot you can load it into the [${game} maptest place](<${gamePlaces[game]}>).

View File

@ -177,7 +177,7 @@ async function validateMapAsset(assetId, game) {
const values = getMapStringValues(model); const values = getMapStringValues(model);
if (!values) { 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 { else {
if (!values.creator) { if (!values.creator) {