|
const config = require('../config'); |
|
const { cmd } = require('../command'); |
|
|
|
cmd({ |
|
pattern: "kick", |
|
alias: ["k", "💀"], |
|
desc: "Removes a participant by replying to or mentioning their message. (Admins can also be kicked)", |
|
react: "🚪", |
|
category: "group", |
|
filename: __filename, |
|
}, async (conn, mek, m, { |
|
from, |
|
quoted, |
|
isGroup, |
|
isAdmins, |
|
isOwner, |
|
participants, |
|
isBotAdmins, |
|
reply |
|
}) => { |
|
try { |
|
|
|
if (!isGroup) return reply("❌ This command can only be used in groups."); |
|
|
|
if (!isAdmins && !isOwner) return reply("*📛 σɴℓʏ gʀσᴜᴘ α∂мιɴs σʀ тнє σωɴєʀ ᴄαɴ ᴜsє тнιѕ ᴄσммαɴ∂.*"); |
|
|
|
if (!isBotAdmins) return reply("*📛 ι ɴєє∂ тσ вє αɴ α∂мιɴ тσ кι¢к мємвєʀs.*"); |
|
|
|
|
|
let target; |
|
if (m.quoted) { |
|
target = m.quoted.sender; |
|
} else if (m.mentionedJid && m.mentionedJid.length > 0) { |
|
target = m.mentionedJid[0]; |
|
} else if (m.msg && m.msg.contextInfo && m.msg.contextInfo.mentionedJid && m.msg.contextInfo.mentionedJid.length > 0) { |
|
target = m.msg.contextInfo.mentionedJid[0]; |
|
} |
|
|
|
if (!target) { |
|
return reply("❌ Please mention or reply to the message of the participant to remove."); |
|
} |
|
|
|
|
|
await conn.groupParticipantsUpdate(from, [target], "remove") |
|
.catch(err => { |
|
console.error(`⚠️ Failed to remove ${target}:`, err); |
|
return reply("❌ An error occurred while trying to remove the participant."); |
|
}); |
|
|
|
|
|
const tag = target.split('@')[0]; |
|
reply(`*@${tag} кι¢кє∂ ѕᴜᴄᴄєѕѕfᴜℓℓу!*`, { mentions: [target] }); |
|
} catch (error) { |
|
console.error('Error while executing kick:', error); |
|
reply('❌ An error occurred while executing the command.'); |
|
} |
|
}); |
|
|