adityajat/SaarvamAI_botPublic · Bot Template

ProfileTelegram

AISarvam AI is a multi‑purpose Telegram bot that lets users ask questions, get explanations, convert text to speech, and translate messages using the Sarvam AI API. It also offers group administration commands such as warn, mute, ban, pin, delete, and announcements, and can clear personal or group AI memory. The bot uses the TeleBotHost TBL framework with Bot, Api, db, and HTTP calls, and provides inline keyboards for language and voice selection.

Ai Assistantaivoicetranslatemoderationadminsarvam
34 commands4 envUpdated 15d agoCreated Sep 14, 2026
Back to folder

commands/_mute.js

javascript · 112 lines

Raw
1/**#command2name: /mute3answer: 4keyboard: 5parse_mode: markdown6aliases: 7allow_only_group: false8need_reply: false9is_web: 010#command**/11 12// ==========================================13// /mute14// ==========================================15 16if (!isGroupChatNow()) {17  return;18}19 20 21if (!(await callerIsAdmin())) {22 23  await Api.sendMessage({24    text:25      "⛔ Only administrators can use /mute."26  });27 28  return;29}30 31 32let target =33  getTargetAndRest();34 35 36if (!target) {37 38  await Api.sendMessage({39    text:40      "Reply to a member with:\n\n" +41      "/mute 10m\n" +42      "/mute 1h\n" +43      "/mute 1d"44  });45 46  return;47}48 49 50if (51  await targetIsAdmin(target.id)52) {53 54  await Api.sendMessage({55    text:56      "⚠️ I can't mute a group administrator."57  });58 59  return;60}61 62 63let seconds =64  parseDurationSeconds(65    target.rest66      ? target.rest.split(/\s+/)[0]67      : ""68  );69 70 71let until =72  Math.floor(73    Date.now() / 100074  ) + seconds;75 76 77let r =78  await Api.call(79    "restrictChatMember",80    {81      chat_id: chat.id,82      user_id: target.id,83 84      permissions: {85        can_send_messages: false86      },87 88      until_date:89        until,90 91      use_independent_chat_permissions:92        true93    }94  );95 96 97if (!r || !r.ok) {98 99  await Api.sendMessage({100    text:101      "❌ Telegram could not mute this member.\n\n" +102      "Make sure the bot is an administrator with permission to restrict members."103  });104 105  return;106}107 108 109await Api.sendMessage({110  text:111    "🔇 Member muted successfully."112});