← back to browse
goat command

remove

No description

0
views
0
likes
0
installs
raw source
module.exports = {
	config: {
		name: "remove",
		version: "1.0",
		author: "mamun",
		countDown: 5,
		role: 2,
		description: {
			en: "Remove members from the group (Bot Admin only)",
			vi: "Xóa thành viên khỏi nhóm (Chỉ Bot Admin)"
		},
		category: "box chat",
		guide: {
			en: "{pn} @tag\n{pn} (reply)",
			vi: "{pn} @tag\n{pn} (reply)"
		}
	},

	langs: {
		en: {
			needAdmin: "⚠️ Bot needs to be admin to remove members.",
			success: "✅ Successfully removed.",
			failed: "❌ Failed to remove this user.",
			noTarget: "⚠️ Please tag or reply to the user you want to remove."
		},
		vi: {
			needAdmin: "⚠️ Bot cần quyền quản trị viên để xóa thành viên.",
			success: "✅ Đã xóa thành công.",
			failed: "❌ Không thể xóa người này.",
			noTarget: "⚠️ Vui lòng tag hoặc reply người cần xóa."
		}
	},

	onStart: async function ({ api, event, message, args, threadsData, getLang }) {
		const botID = api.getCurrentUserID();
		const adminIDs = await threadsData.get(event.threadID, "adminIDs") || [];

		if (!adminIDs.includes(botID)) {
			return message.reply(getLang("needAdmin"));
		}

		const removeUser = async (uid) => {
			try {
				await api.removeUserFromGroup(uid, event.threadID);
				return true;
			} catch (e) {
				return false;
			}
		};

		// Reply mode
		if (event.messageReply) {
			const uid = event.messageReply.senderID;
			const success = await removeUser(uid);
			return message.reply(success ? getLang("success") : getLang("failed"));
		}

		// Tag mode
		const mentions = Object.keys(event.mentions || {});
		if (mentions.length === 0) {
			return message.reply(getLang("noTarget"));
		}

		let successCount = 0;
		for (const uid of mentions) {
			const success = await removeUser(uid);
			if (success) successCount++;
		}

		if (successCount > 0) {
			message.reply(`\( {getLang("success")} ( \){successCount}/${mentions.length})`);
		} else {
			message.reply(getLang("failed"));
		}
	}
};

View raw file