owner-block-unblock.js 1.1 KB

1234567891011121314151617181920212223
  1. const handler = async (m, {text, conn, usedPrefix, command}) => {
  2. const why = `*⚠️ 𝐄𝐣𝐞𝐦𝐩𝐥𝐨:*\n${usedPrefix + command} @${m.sender.split('@')[0]}`;
  3. const who = m.mentionedJid[0] ? m.mentionedJid[0] : m.quoted ? m.quoted.sender : text ? text.replace(/[^0-9]/g, '') + '@s.whatsapp.net' : false;
  4. if (!who) conn.reply(m.chat, why, m, {mentions: [m.sender]});
  5. const res = [];
  6. switch (command) {
  7. case 'blok': case 'block':
  8. if (who) {
  9. await conn.updateBlockStatus(who, 'block').then(() => {
  10. res.push(who)})} else conn.reply(m.chat, why, m, {mentions: [m.sender]});
  11. break;
  12. case 'unblok': case 'unblock':
  13. if (who) {
  14. await conn.updateBlockStatus(who, 'unblock').then(() => {res.push(who)})} else conn.reply(m.chat, why, m, {mentions: [m.sender]});
  15. break;
  16. }
  17. if (res[0]) conn.reply(m.chat, `*ᴇʟ ᴜsᴜᴀʀɪᴏs ${res ? `${res.map((v) => '@' + v.split('@')[0])}` : ''} ғᴜᴇ ${command} ᴄᴏɴ ᴇ́xɪᴛᴏ*`, m, {mentions: res});
  18. };
  19. handler.help = ["block", "unblock"]
  20. handler.tags = ["owner"]
  21. handler.command = /^(block|unblock)$/i;
  22. handler.rowner = true;
  23. export default handler;