millswelbeck148/SireimadeBotPublic · Bot Template

AISireImade appears to be a Telegram automation bot. Commands include /start, /about, /support, /id, /admin, /ban, /unban, /x. Observed in code: messaging, keyboards, games.

Utilityutility
ProfileTelegram
112 commands3 envUpdated 2h agoCreated Aug 27, 2026
Back to folder

commands/_warn.js

javascript · 302 lines

Raw
1/**#command2name: /warn3answer: 4keyboard: 5parse_mode: markdown6aliases: 7allow_only_group: false8need_reply: false9is_web: 010#command**/11 12// ==========================================================13// 💜 GIFT AI — /WARN14// TELEBOTHOST / TBL15//16// • Admin-only17// • Reply to a member's message18// • Accurate admin verification19// • Protects owner + administrators20// • Saves warnings per group/user21// • Replies directly to /warn22// • Fast + error-safe23// ==========================================================24 25 26// ----------------------------------------------------------27// 📌 GROUP ONLY28// ----------------------------------------------------------29 30if (31  !chat ||32  (chat.type !== "group" && chat.type !== "supergroup")33) {34  Api.sendMessage({35    chat_id: chat.id,36    text: "⚠️ This command only works in groups."37  });38  return;39}40 41 42// ----------------------------------------------------------43// 📌 MUST REPLY TO A MESSAGE44// ----------------------------------------------------------45 46if (!request.reply_to_message) {47  Api.sendMessage({48    chat_id: chat.id,49    text: "⚠️ Reply to a member's message with /warn.",50    reply_to_message_id: request.message_id51  });52  return;53}54 55 56// ----------------------------------------------------------57// 👤 GET COMMAND USER + TARGET58// ----------------------------------------------------------59 60var adminId = request.from.id;61var target = request.reply_to_message.from;62 63if (!target || !target.id) {64  Api.sendMessage({65    chat_id: chat.id,66    text: "❌ I couldn't identify the member.",67    reply_to_message_id: request.message_id68  });69  return;70}71 72var targetId = target.id;73 74 75// ----------------------------------------------------------76// 🚫 DON'T WARN YOURSELF77// ----------------------------------------------------------78 79if (String(adminId) === String(targetId)) {80  Api.sendMessage({81    chat_id: chat.id,82    text: "❌ You can't warn yourself.",83    reply_to_message_id: request.message_id84  });85  return;86}87 88 89// ----------------------------------------------------------90// 🔐 CHECK COMMAND USER91// ----------------------------------------------------------92 93var adminCheck;94 95try {96 97  adminCheck = await Api.call("getChatMember", {98    chat_id: chat.id,99    user_id: adminId100  });101 102} catch (e) {103 104  Api.sendMessage({105    chat_id: chat.id,106    text: "⚠️ I couldn't verify your admin status.",107    reply_to_message_id: request.message_id108  });109 110  return;111}112 113 114// ----------------------------------------------------------115// ❌ API FAILURE116// ----------------------------------------------------------117 118if (119  !adminCheck ||120  !adminCheck.ok ||121  !adminCheck.result122) {123  Api.sendMessage({124    chat_id: chat.id,125    text: "⚠️ I couldn't verify your admin status.",126    reply_to_message_id: request.message_id127  });128 129  return;130}131 132 133// ----------------------------------------------------------134// 👑 CHECK ADMIN STATUS135// ----------------------------------------------------------136 137var adminStatus = adminCheck.result.status;138 139if (140  adminStatus !== "administrator" &&141  adminStatus !== "creator"142) {143  Api.sendMessage({144    chat_id: chat.id,145    text: "❌ You're not an admin. You can't warn anyone.",146    reply_to_message_id: request.message_id147  });148 149  return;150}151 152 153// ----------------------------------------------------------154// 🛡 CHECK TARGET STATUS155// ----------------------------------------------------------156 157var targetCheck;158 159try {160 161  targetCheck = await Api.call("getChatMember", {162    chat_id: chat.id,163    user_id: targetId164  });165 166} catch (e) {167 168  Api.sendMessage({169    chat_id: chat.id,170    text: "⚠️ I couldn't verify the member.",171    reply_to_message_id: request.message_id172  });173 174  return;175}176 177 178// ----------------------------------------------------------179// ❌ TARGET CHECK FAILED180// ----------------------------------------------------------181 182if (183  !targetCheck ||184  !targetCheck.ok ||185  !targetCheck.result186) {187  Api.sendMessage({188    chat_id: chat.id,189    text: "⚠️ I couldn't verify the member.",190    reply_to_message_id: request.message_id191  });192 193  return;194}195 196 197var targetStatus = targetCheck.result.status;198 199 200// ----------------------------------------------------------201// 👑 DON'T WARN OWNER202// ----------------------------------------------------------203 204if (targetStatus === "creator") {205  Api.sendMessage({206    chat_id: chat.id,207    text: "👑 You can't warn the group owner.",208    reply_to_message_id: request.message_id209  });210 211  return;212}213 214 215// ----------------------------------------------------------216// 🛡 DON'T WARN ADMIN217// ----------------------------------------------------------218 219if (targetStatus === "administrator") {220  Api.sendMessage({221    chat_id: chat.id,222    text: "🛡️ You can't warn another administrator.",223    reply_to_message_id: request.message_id224  });225 226  return;227}228 229 230// ----------------------------------------------------------231// ⚠️ GET CURRENT WARNINGS232// ----------------------------------------------------------233 234var warnKey = "WARN_" + chat.id + "_" + targetId;235 236var warnings = Bot.getProperty(warnKey);237 238 239// ----------------------------------------------------------240// 🧮 VALIDATE WARNING COUNT241// ----------------------------------------------------------242 243if (244  typeof warnings !== "number" ||245  !isFinite(warnings) ||246  warnings < 0247) {248  warnings = 0;249}250 251 252// ----------------------------------------------------------253// ➕ ADD WARNING254// ----------------------------------------------------------255 256warnings = warnings + 1;257 258 259// ----------------------------------------------------------260// 💾 SAVE WARNING261// ----------------------------------------------------------262 263Bot.setProperty(264  warnKey,265  warnings,266  "integer"267);268 269 270// ----------------------------------------------------------271// 👤 SAFE USER NAME272// ----------------------------------------------------------273 274var name = target.first_name || "User";275 276name = String(name)277  .replace(/&/g, "&amp;")278  .replace(/</g, "&lt;")279  .replace(/>/g, "&gt;")280  .replace(/"/g, "&quot;");281 282 283// ----------------------------------------------------------284// 💜 SEND RESULT285// ----------------------------------------------------------286 287Api.sendMessage({288  chat_id: chat.id,289  text:290    "⚠️ <b>WARNING ISSUED</b>\n\n" +291    "👤 User: <a href=\"tg://user?id=" +292    targetId +293    "\">" +294    name +295    "</a>\n" +296    "⚠️ Warnings: <b>" +297    warnings +298    "</b>\n\n" +299    "💜 Warning recorded successfully.",300  parse_mode: "HTML",301  reply_to_message_id: request.message_id302});