Reorganize este código JS mantendo a lógica, mas melhorando a estrutura: hora: new…
- User
Reorganize este código JS mantendo a lógica, mas melhorando a estrutura:
hora: new Date().toLocaleTimeString(), nomedogp: groupMetadata.subject, numerodele: `@${num.participants[0].split('@')[0]}`, numerobot: `@${cleanNumber}`, prefixo: '!', descrição: groupDesc }; const farewellMsg = formatMessage(farewellMsgTemplate, placeholders); if (farewellMsg && farewellMsg.trim()) { client.sendMessage(num.id, { text: farewellMsg, mentions: [num.participants[0]] }); } else { console.log(`Mensagem de saída não definida para o grupo ${num.id}.`); } }} }, 0) });
//[====================] //CLIENT PARA VÊ QUEM TA ONLINE ETC //[====================]
let presenceData = {}; client.ev.on('presence.update', json => { const groupId = json.id; if (!presenceData[groupId]) { presenceData[groupId] = {}; }
for (const [userId, presenceInfo] of Object.entries(json.presences)) { presenceData[groupId][userId] = presenceInfo.lastKnownPresence; }});
client.ev.on('messages.upsert', async (msg) => { setTimeout(async () => { function getGroupAdmins(participants) { admins = [] for (let i of participants) { if(i.admin == 'admin') admins.push(i.id) if(i.admin == 'superadmin') admins.push(i.id) } return admins } try { const getRandom = (ext) => { return
${Math.floor(Math.random() * 10000)}${ext}} const getExtension = async (type) => { return await mimetype.extension(type) } const getBuffer = (url, options) => new Promise(async (resolve, reject) => { options ? options : {} await axios({method: "get", url, headers: {"DNT": 1, "Upgrade-Insecure-Request": 1}, ...options, responseType: "arraybuffer"}).then((res) => { resolve(res.data) }).catch(reject) })//[====================] //FUNÇÕES //[====================]
const donoOficial = [
@s.whatsapp.net] const info = msg.messages[0] if (!info.message) return if (info.key && info.key.remoteJid == 'status@broadcast') return - Assistant