← back to browse
goat command

protect

Ultra Hard Lock - Name, Nick, Theme, Emoji

0
views
0
likes
0
installs
raw source
module.exports = {
 config: {
 name: "protect",
 version: "5.0",
 author: "๐Œ๐š๐‘๐ฎ๐… ๐ฑ ๐Œ๐Ž๐‡๐€๐Œ๐Œ๐€๐ƒ ๐€๐Š๐€๐’๐‡",
 role: 1,
 shortDescription: "Ultra Hard Lock - Name, Nick, Theme, Emoji",
 category: "group",
 guide: "{pn} on/off/status"
 },

 onStart: async ({ api, event, message, threadsData, args }) => {
 const { threadID } = event;
 if (!args[0]) return message.reply("โš ๏ธ Usage:\n/protect on - Lock On\n/protect off - Lock Off\n/protect status - Check");

 if (args[0].toLowerCase() === "on") {
 const info = await api.getThreadInfo(threadID);
 const data = {
 enable: true,
 name: info.threadName,
 emoji: info.emoji,
 color: info.color,
 image: info.imageSrc,
 nickname: {},
 time: Date.now(),
 author: event.senderID
 };
 for (const m of info.participantIDs) {
 try {
 const nick = info.nicknames[m] || "";
 data.nickname[m] = nick;
 } catch {}
 }
 await threadsData.set(threadID, data, "data.protect");
 return message.reply(
 "โ•ญโ”€โ”€โ”€ใ€Ž ๐Ÿ›ก๏ธ ULTRA PROTECT ON ใ€โ”€โ”€โ”€โ•ฎ\n" +
 "โ”‚ ๐Ÿ”’ Name Lock: ON\n" +
 "โ”‚ ๐Ÿ”’ Emoji Lock: ON\n" +
 "โ”‚ ๐Ÿ”’ Theme Lock: ON\n" +
 "โ”‚ ๐Ÿ”’ Nickname Lock: ON [HARD]\n" +
 "โ”‚ โšก Action: Instant Revert + Warn\n" +
 "โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ"
 );
 }

 if (args[0].toLowerCase() === "off") {
 await threadsData.set(threadID, { enable: false }, "data.protect");
 return message.reply("๐Ÿ”“ Protect OFF - All Locks Disabled");
 }

 if (args[0].toLowerCase() === "status") {
 const d = await threadsData.get(threadID, "data.protect");
 if (!d?.enable) return message.reply("๐Ÿ”“ Protect is OFF");
 return message.reply(`๐Ÿ›ก๏ธ Protect ON\n๐Ÿ“Œ Name: ${d.name}\n๐Ÿ˜€ Emoji: ${d.emoji}\n๐ŸŽจ Theme: ${d.color}\n๐Ÿ‘ฅ Nick Locked: ${Object.keys(d.nickname).length} users`);
 }
 },

 onEvent: async ({ api, event, threadsData }) => {
 const { threadID, logMessageType, logMessageData, author } = event;
 if (!logMessageType) return;

 const protect = await threadsData.get(threadID, "data.protect");
 if (!protect?.enable) return;
 if (!logMessageData) return;

 const botID = api.getCurrentUserID();
 if (author == botID) return;

 const info = await api.getThreadInfo(threadID);
 const isAdmin = info.adminIDs.some(e => e.id == author);

 // === NON-ADMIN = REVERT HARD ===
 if (!isAdmin) {
 // 1. Name Protect
 if (logMessageType === "log:thread-name") {
 await api.setTitle(protect.name, threadID);
 return api.sendMessage(`โš ๏ธ @${author} Name Change Detected! Reverted.\n๐Ÿ”’ Protect is ON`, threadID, null, { mentions: [{ tag: `@${author}`, id: author }] });
 }
 // 2. Emoji Protect
 if (logMessageType === "log:thread-icon") {
 await api.changeThreadEmoji(protect.emoji, threadID);
 return api.sendMessage(`โš ๏ธ @${author} Emoji Change Detected! Reverted.`, threadID, null, { mentions: [{ tag: `@${author}`, id: author }] });
 }
 // 3. Theme/Color Protect
 if (logMessageType === "log:thread-color") {
 if (protect.color) await api.changeThreadColor(protect.color, threadID);
 return api.sendMessage(`โš ๏ธ @${author} Theme Change Detected! Reverted.`, threadID, null, { mentions: [{ tag: `@${author}`, id: author }] });
 }
 // 4. Nickname Hard Protect
 if (logMessageType === "log:user-nickname") {
 const uid = logMessageData.participant_id;
 const oldNick = protect.nickname[uid] || "";
 await api.changeNickname(oldNick, threadID, uid);
 return api.sendMessage(`โš ๏ธ @${author} Nickname Change Detected!\nVictim: ${uid}\nReverted to: ${oldNick || "Original"}`, threadID, null, { mentions: [{ tag: `@${author}`, id: author }] });
 }
 // 5. Image Protect (if someone changes group photo)
 if (logMessageType === "log:thread-image") {
 return api.sendMessage(`โš ๏ธ @${author} Group Image Changed! Admin Only.`, threadID, null, { mentions: [{ tag: `@${author}`, id: author }] });
 }
 }

 // === ADMIN CHANGED = UPDATE DB (Auto Save) ===
 if (isAdmin) {
 if (logMessageType === "log:thread-name") {
 await threadsData.set(threadID, logMessageData.name, "data.protect.name");
 }
 if (logMessageType === "log:thread-icon") {
 await threadsData.set(threadID, logMessageData.thread_icon, "data.protect.emoji");
 }
 if (logMessageType === "log:thread-color") {
 const newColor = logMessageData.theme_id || logMessageData.theme_color || info.color;
 await threadsData.set(threadID, newColor, "data.protect.color");
 }
 if (logMessageType === "log:user-nickname") {
 await threadsData.set(threadID, logMessageData.nickname || "", `data.protect.nickname.${logMessageData.participant_id}`);
 }
 }
 }
};

View raw file