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}`);
}
}
}
};