From 683d5b53d5ef67540963ac5a377b1ab941811f71 Mon Sep 17 00:00:00 2001 From: ChrisChrome Date: Wed, 31 Jul 2024 23:37:01 -0600 Subject: [PATCH] splig phone code up --- index.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index f1d6adb..58d1e9f 100644 --- a/index.js +++ b/index.js @@ -127,6 +127,11 @@ function sendVerificationCode(account) { }); } +function generatePhoneCode() { + // generate 6 digit + return Math.floor(100000 + Math.random() * 900000).toString().split("").join(" "); +} + client.on("ready", async () => { console.log(`${colors.cyan("[Discord]")} Logged in as ${client.user.tag}`); @@ -166,7 +171,7 @@ client.on("interactionCreate", async (interaction) => { interaction.reply("You already have an unverified account. Please verify it before creating a new one."); } else { accountNumber = generateAccountNumber(); - verification_code = generateTransactionNumber(); + verification_code = generatePhoneCode(); db.run("INSERT INTO accounts (id, discord_id, verification_code, phone) VALUES (?, ?, ?, ?)", accountNumber, interaction.user.id, verification_code, phone_number, (err) => { if (err) { console.error(err); @@ -269,8 +274,8 @@ client.on("interactionCreate", async (interaction) => { interaction.reply("Invalid phone number. Please enter one of the following:\n- A 4 digit LiteNet extension.\n- A 7 digit TandmX number\n- An 10 digit US phone number.\n- An 11 digit US phone number"); return; } - verificationCode = generateTransactionNumber(); - db.run("UPDATE accounts SET phone = ?, verified = 0, verification_code = ? WHERE id = ?", phone_number, accountNumber, verificationCode, (err) => { + verification_code = generatePhoneCode(); + db.run("UPDATE accounts SET phone = ?, verified = 0, verification_code = ? WHERE id = ?", phone_number, accountNumber, verification_code, (err) => { if (err) { console.error(err); } else {