bvs-nitro-did/interactions/chatCommand/getnumber.js

21 lines
1.2 KiB
JavaScript

module.exports = (interaction, client, bvs) => {
const choice = interaction.options.getNumber('choice');
if (!choice) {
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 });
}
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 });
}
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];
return interaction.reply({ content: `Attempting to purchase DID \`${bvs.formatPhoneNumber(didToPurchase)}\`...`, ephemeral: true }).then(() => {
// wait, we are in dev phase, dont buy lol
});
}