const crypto = require('crypto'); const { cmd } = require('../command'); cmd({ pattern: "gpass", desc: "Generate a strong password.", category: "other", react: "🔐", filename: __filename }, async (conn, mek, m, { from, quoted, body, isCmd, command, args, q, isGroup, sender, senderNumber, botNumber2, botNumber, pushname, isMe, isOwner, groupMetadata, groupName, participants, groupAdmins, isBotAdmins, isAdmins, reply }) => { try { const length = args[0] ? parseInt(args[0]) : 12; // Default length is 12 if not provided if (isNaN(length) || length < 8) { return reply('Please provide a valid length for the password (Minimum 08 Characters💦).'); } const generatePassword = (len) => { const charset = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()_+[]{}|;:,.<>?'; let password = ''; for (let i = 0; i < len; i++) { const randomIndex = crypto.randomInt(0, charset.length); password += charset[randomIndex]; } return password; }; const password = generatePassword(length); const message = `🔐 *Your Strong Password* 🔐\n\nPlease find your generated password below:\n\n *BY ALI-MD*`; // Send initial notification message await conn.sendMessage(from, { text: message }, { quoted: mek }); // Send the password in a separate message await conn.sendMessage(from, { text: password }, { quoted: mek }); } catch (e) { console.log(e); reply(`❌ Error generating password🤕: ${e.message}`); } });