ShahriarAbidbd/SmartifyXBotPublic · Bot Template
Do Tasks Smartly with SmartifyX 😎
Utilityutilitydownloaderyoutubefacebookinstagramscreenshot
27 commands2 envUpdated 1mo agoCreated Jul 28, 2026
commands/_broadcast.js
javascript · 146 lines
1/**#command2name: /broadcast3answer: 4keyboard: 5parse_mode: markdown6aliases: 7allow_only_group: false8need_reply: false9is_web: 010#command**/11 12const ADMIN_ID = 716823465013if (user.telegramid != ADMIN_ID) {14 return15}16 17if (!request.reply_to_message) {18 return Bot.sendMessage(19 "❌ Reply to a message with /broadcast"20 )21}22 23if (!params) {24 return Bot.sendMessage("Use: /broadcast [private/group/channel/all]", {25 parse_mode: "html"26 })27}28 29let users = await Bot.getUsers({30 chatType: params31})32 33if (!users?.length) {34 return Bot.sendMessage(35 "❌ No users found"36 )37}38 39let msg = request.reply_to_message40 41let sent = 042let failed = 043 44let status = await Api.sendMessage({45 text: "📢 Broadcast Started\n\n" +46 "👥 Total: " + users.length47})48 49let hasButtons =50 msg.reply_markup?.inline_keyboard51 52let methods = {53 photo: "sendPhoto",54 video: "sendVideo",55 document: "sendDocument",56 animation: "sendAnimation",57 audio: "sendAudio",58 voice: "sendVoice"59}60 61let type = Object.keys(methods)62 .find(x => msg[x])63 64for (let chat_id of users) {65 66 try {67 68 if (!hasButtons) {69 70 await Api.copyMessage({71 chat_id,72 from_chat_id: msg.chat.id,73 message_id: msg.message_id74 })75 76 } else {77 78 let data = {79 chat_id,80 reply_markup: msg.reply_markup81 }82 83 if (type) {84 85 data[type] =86 type === "photo" ?87 msg.photo.at(-1).file_id :88 msg[type].file_id89 90 data.caption = msg.caption91 92 data.caption_entities =93 msg.caption_entities94 95 await Api.call(96 methods[type],97 data98 )99 100 } else {101 102 data.text =103 msg.text ||104 msg.caption ||105 ""106 107 data.entities =108 msg.entities ||109 msg.caption_entities110 111 await Api.sendMessage(data)112 113 }114 115 }116 117 sent++118 119 } catch {120 121 try {122 123 await Api.forwardMessage({124 chat_id,125 from_chat_id: msg.chat.id,126 message_id: msg.message_id127 })128 129 sent++130 131 } catch {132 133 failed++134 135 }136 137 }138 139}140 141await status.editText(142 "📢 Broadcast Completed\n\n" +143 "👥 Total: " + users.length +144 "\n✅ Sent: " + sent +145 "\n❌ Failed: " + failed146)