|
const { cmd } = require('../command'); |
|
|
|
cmd({ |
|
pattern: "block", |
|
desc: "Blocks a person", |
|
category: "owner", |
|
react: "π«", |
|
filename: __filename |
|
}, |
|
async (conn, m, { reply, q, react }) => { |
|
|
|
const botOwner = conn.user.id.split(":")[0] + "@s.whatsapp.net"; |
|
|
|
if (m.sender !== botOwner) { |
|
await react("β"); |
|
return reply("Only the bot owner can use this command."); |
|
} |
|
|
|
let jid; |
|
if (m.quoted) { |
|
jid = m.quoted.sender; |
|
} else if (m.mentionedJid.length > 0) { |
|
jid = m.mentionedJid[0]; |
|
} else if (q && q.includes("@")) { |
|
jid = q.replace(/[@\s]/g, '') + "@s.whatsapp.net"; |
|
} else { |
|
await react("β"); |
|
return reply("Please mention a user or reply to their message."); |
|
} |
|
|
|
try { |
|
await conn.updateBlockStatus(jid, "block"); |
|
await react("β
"); |
|
reply(`*@${jid.split("@")[0]} SUCCESSFULLY BLOCKED β*`, { mentions: [jid] }); |
|
} catch (error) { |
|
console.error("Block command error:", error); |
|
await react("β"); |
|
reply("Failed to block the user."); |
|
} |
|
}); |
|
|
|
cmd({ |
|
pattern: "unblock", |
|
desc: "Unblocks a person", |
|
category: "owner", |
|
react: "π", |
|
filename: __filename |
|
}, |
|
async (conn, m, { reply, q, react }) => { |
|
|
|
const botOwner = conn.user.id.split(":")[0] + "@s.whatsapp.net"; |
|
|
|
if (m.sender !== botOwner) { |
|
await react("β"); |
|
return reply("Only the bot owner can use this command."); |
|
} |
|
|
|
let jid; |
|
if (m.quoted) { |
|
jid = m.quoted.sender; |
|
} else if (m.mentionedJid.length > 0) { |
|
jid = m.mentionedJid[0]; |
|
} else if (q && q.includes("@")) { |
|
jid = q.replace(/[@\s]/g, '') + "@s.whatsapp.net"; |
|
} else { |
|
await react("β"); |
|
return reply("Please mention a user or reply to their message."); |
|
} |
|
|
|
try { |
|
await conn.updateBlockStatus(jid, "unblock"); |
|
await react("β
"); |
|
reply(`*@${jid.split("@")[0]} SUCCESSFULLY UNBLOCKED β
*`, { mentions: [jid] }); |
|
} catch (error) { |
|
console.error("Unblock command error:", error); |
|
await react("β"); |
|
reply("Failed to unblock the user."); |
|
} |
|
}); |
|
|