Welp, one way to see if this mf works ig

This commit is contained in:
Christopher Cookman 2026-06-14 12:41:44 -06:00
parent 59822e18fd
commit c9814cfdc0
3 changed files with 33 additions and 4 deletions

3
bvs.js
View file

@ -207,5 +207,6 @@ module.exports = {
searchDIDs,
searchPurchasableDIDs,
purchaseDID,
formatPhoneNumber
formatPhoneNumber,
deleteDID
}

View file

@ -38,3 +38,5 @@ bvs.searchPurchasableDIDs("910").then(dids => {
}).catch(error => {
console.error("Error fetching DIDs with user ID 610548:", error);
});
console.log(bvs.deleteDID("15803163827"));

View file

@ -36,8 +36,34 @@ module.exports = (interaction, client, bvs) => {
if (results.length === 0) {
return interaction.editReply({ content: `You somehow got this far and don't actually have an extension. Go make one, then try again.`, ephemeral: true });
} else {
// Buy the thing
bvs.purchaseDID(didToPurchase, interaction.user.id).then(() => {
console.log(`Successfully purchased DID ${didToPurchase} for user ${interaction.user.id}`);
const extension = results[0].extension;
return interaction.editReply({ content: `dev: ${extension}` })
// insert into incoming, set extension = "+{did}", destination = from-did-direct,{extension},1, description = "NitroDID For {displayName} ({discordId})"
global.db.query("INSERT INTO incoming (extension, destination, description) VALUES (?, ?, ?)", [`+${didToPurchase}`, `from-did-direct,${extension},1`, `NitroDID For ${interaction.user.displayName} (${interaction.user.id})`]).then(() => {
interaction.editReply({ content: `Successfully purchased DID \`${bvs.formatPhoneNumber(didToPurchase)}\`. It may take a few minutes for the purchase to fully process. Please allow up to 5 hours for the number to become active. If you are having issues, please contact support!`, ephemeral: true });
// Run `fwconsole reload` on host
const { exec } = require("child_process");
exec("fwconsole reload", (error, stdout, stderr) => {
if (error) {
console.error("Error reloading FreePBX:", error);
return;
}
if (stderr) {
console.error("Error output from reloading FreePBX:", stderr);
return;
}
console.log("Successfully reloaded FreePBX:", stdout);
});
}).catch(error => {
console.error("Error inserting into database:", error);
return interaction.editReply({ content: `There was an error setting up your DID in the database. Please contact support!`, ephemeral: true });
});
}).catch(error => {
console.error("Error purchasing DID:", error);
return interaction.editReply({ content: `There was an error purchasing the DID. Please try again later.`, ephemeral: true });
});
}
}).catch(error => {
console.error("Database error:", error);