From 59822e18fda920b79443b347e71e08c228138e7c Mon Sep 17 00:00:00 2001 From: ChrisChrome Date: Sun, 14 Jun 2026 12:30:42 -0600 Subject: [PATCH] Make that else --- interactions/chatCommand/getnumber.js | 53 ++++++++++++++------------- 1 file changed, 27 insertions(+), 26 deletions(-) diff --git a/interactions/chatCommand/getnumber.js b/interactions/chatCommand/getnumber.js index af7b58b..dbb70ff 100644 --- a/interactions/chatCommand/getnumber.js +++ b/interactions/chatCommand/getnumber.js @@ -49,32 +49,33 @@ module.exports = (interaction, client, bvs) => { delete global.purchaseConfirmations[interaction.user.id]; return interaction.reply({ content: `Cancelled. You can either choose a different DID from the latest run of \`/searchnumbers\` or start a new search by running \`/searchnumbers\` again.`, ephemeral: true }); } - } + } else { - if (!global.tempPurchasableDIDs || !global.tempPurchasableDIDs[interaction.user.id]) { - return interaction.reply({ content: `You must provide a choice from the latest run of \`/searchnumbers\`. Use \`/searchnumbers\` to see available DIDs and their corresponding choices.`, ephemeral: true }); - } - - // Check that the member doesn't already have a number. - bvs.getPremiumDIDs().then(dids => { - const userDIDs = dids.filter(did => did.userId === interaction.user.id); - if (userDIDs.length === 0) { - const dids = global.tempPurchasableDIDs[interaction.user.id]; - const index = parseInt(choice) - 1; - if (isNaN(index) || index < 0 || index >= dids.length) { - return interaction.reply({ content: `Invalid choice. You must provide a choice from the latest run of \`/searchnumbers\`. Use \`/searchnumbers\` to see available DIDs and their corresponding choices.`, ephemeral: true }); - } - - const didToPurchase = dids[index]; - // Store the choice in a global temp variable with the user id so the user can confirm their purchase by running the command again with the same choice. This is a bit janky but it works for now. - global.purchaseConfirmations = global.purchaseConfirmations || {}; - global.purchaseConfirmations[interaction.user.id] = didToPurchase; - return interaction.reply({ content: `You have selected DID \`${bvs.formatPhoneNumber(didToPurchase)}\` for purchase. If you want to proceed with purchasing this DID, run \`/getnumber\` with choice \`1\`. If you want to cancel, run the command again with a different choice or run \`/searchnumbers\` again to start a new search.`, ephemeral: true }); - } else { - interaction.reply({ content: `Your DID is \`${bvs.formatPhoneNumber(userDIDs[0].did)}\``, ephemeral: true }); + if (!global.tempPurchasableDIDs || !global.tempPurchasableDIDs[interaction.user.id]) { + return interaction.reply({ content: `You must provide a choice from the latest run of \`/searchnumbers\`. Use \`/searchnumbers\` to see available DIDs and their corresponding choices.`, ephemeral: true }); } - }).catch(error => { - console.error("Error fetching premium DIDs:", error); - interaction.reply({ content: `There was an error fetching your DID. Please try again later.`, ephemeral: true }); - }); + + // Check that the member doesn't already have a number. + bvs.getPremiumDIDs().then(dids => { + const userDIDs = dids.filter(did => did.userId === interaction.user.id); + if (userDIDs.length === 0) { + const dids = global.tempPurchasableDIDs[interaction.user.id]; + const index = parseInt(choice) - 1; + if (isNaN(index) || index < 0 || index >= dids.length) { + return interaction.reply({ content: `Invalid choice. You must provide a choice from the latest run of \`/searchnumbers\`. Use \`/searchnumbers\` to see available DIDs and their corresponding choices.`, ephemeral: true }); + } + + const didToPurchase = dids[index]; + // Store the choice in a global temp variable with the user id so the user can confirm their purchase by running the command again with the same choice. This is a bit janky but it works for now. + global.purchaseConfirmations = global.purchaseConfirmations || {}; + global.purchaseConfirmations[interaction.user.id] = didToPurchase; + return interaction.reply({ content: `You have selected DID \`${bvs.formatPhoneNumber(didToPurchase)}\` for purchase. If you want to proceed with purchasing this DID, run \`/getnumber\` with choice \`1\`. If you want to cancel, run the command again with a different choice or run \`/searchnumbers\` again to start a new search.`, ephemeral: true }); + } else { + interaction.reply({ content: `Your DID is \`${bvs.formatPhoneNumber(userDIDs[0].did)}\``, ephemeral: true }); + } + }).catch(error => { + console.error("Error fetching premium DIDs:", error); + interaction.reply({ content: `There was an error fetching your DID. Please try again later.`, ephemeral: true }); + }); + } } \ No newline at end of file