File size: 1,579 Bytes
0704112
aba4d6f
 
 
 
 
 
 
0704112
aba4d6f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0704112
 
 
 
 
 
aba4d6f
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
const { minify } = require('uglify-es'); // Corrected import

const config = require('../config');
const { cmd, commands } = require('../command');
const { fetchJson } = require('../lib/functions'); // Assuming this fetches JSON from a different source

cmd({
  pattern: 'obfuscate',
  alias: ['obf'],
  react: '🗿',
  desc: 'Minifies JavaScript code (using UglifyJS).', // Update description
  category: 'main',
  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 {
    if (!q) return reply('Please provide JavaScript code to minify.');

    await reply('> *Minifying code...*'); // Update message

    // Minify the code using UglifyJS with more aggressive options
    const { code } = minify(q, {
      compress: { 
        drop_console: true, 
        screw_ie8: true, 
        collapse_vars: true, 
        hoist_vars: true 
      },
      mangle: {
        toplevel: true, 
        properties: true, 
        functions: true 
      }
    });

    await conn.sendMessage(m.chat, { text: code }, { quoted: m });
  } catch (error) {
    if (error.message === "Cannot read properties of undefined (reading 'match')") {
      reply("Invalid JavaScript code provided. Please check for syntax errors."); 
    } else {
      console.error(error);
      reply(`An error occurred: ${error.message}`);
    }
  }
});