mmm / plugins /block-upblock.js
ravenbs1's picture
Upload 140 files
046b271 verified
const { cmd } = require('../command');
cmd({
pattern: "block",
desc: "Blocks a person",
category: "owner",
react: "🚫",
filename: __filename
},
async (conn, m, { reply, q, react }) => {
// Get the bot owner's number dynamically
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; // If replying to a message, get sender JID
} else if (m.mentionedJid.length > 0) {
jid = m.mentionedJid[0]; // If mentioning a user, get their JID
} else if (q && q.includes("@")) {
jid = q.replace(/[@\s]/g, '') + "@s.whatsapp.net"; // If manually typing a JID
} 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 }) => {
// Get the bot owner's number dynamically
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.");
}
});