// code from goatstore // api: https://store.agi.bd const fs = require("fs-extra"); const path = require("path"); const axios = require("axios"); const moment = require("moment-timezone"); const AUTHOR = Buffer.from("Uk9DS1kgQ2hvd2RodXJ5", "base64").toString(); function authorOk() { return module.exports.config && module.exports.config.author === AUTHOR; } const LOCK_MSG = `šŸ”’ā”ā”ā”ā”ā”ā”ā”ā”ā”ā”ā”šŸ”’ ā›” š—”š˜‚š˜š—µš—¼š—æ š—Ÿš—¼š—°š—ø ā›” šŸ”’ā”ā”ā”ā”ā”ā”ā”ā”ā”ā”ā”šŸ”’ šŸ™ˆ š—”š˜‚š˜š—µš—¼š—æ š—°š—µš—®š—»š—“š—²š—±! š—§š—µš—¶š˜€ š—³š—¶š—¹š—² š˜„š—¼š—»'š˜ š˜„š—¼š—æš—ø šŸ’” šŸ‘‘ š—¢š—æš—¶š—“š—¶š—»š—®š—¹ š—®š˜‚š˜š—µš—¼š—æ āžœ ${AUTHOR}`; const VIDEO_URLS = [ "https://i.imgur.com/HShrIFC.mp4", "https://i.imgur.com/cL1cqnZ.mp4", "https://i.imgur.com/RyLSpRX.mp4", "https://i.imgur.com/scYIsVL.mp4", "https://i.imgur.com/rrm7554.mp4", "https://i.imgur.com/oE2zQsu.mp4", "https://i.imgur.com/4JVUgnG.mp4", "https://i.imgur.com/9qCDoes.mp4", "https://i.imgur.com/oE2zQsu.mp4", "https://i.imgur.com/HShrIFC.mp4" ]; const CACHE_DIR = path.join(__dirname, "cache", "prefix_videos"); let queue = []; let lastUrl = null; function shuffle(arr) { const a = [...arr]; for (let i = a.length - 1; i > 0; i--) { const j = Math.floor(Math.random() * (i + 1)); [a[i], a[j]] = [a[j], a[i]]; } return a; } function nextUrl() { if (queue.length === 0) { queue = shuffle(VIDEO_URLS); if (queue.length > 1 && queue[0] === lastUrl) { queue.push(queue.shift()); } } const url = queue.shift(); lastUrl = url; return url; } async function downloadVideo(url) { await fs.ensureDir(CACHE_DIR); const file = path.join(CACHE_DIR, path.basename(url)); if (await fs.pathExists(file)) { const stat = await fs.stat(file); if (stat.size > 10000) return file; await fs.remove(file); } const res = await axios.get(url, { responseType: "arraybuffer", timeout: 40000, maxContentLength: 50 * 1024 * 1024, headers: { "User-Agent": "Mozilla/5.0", "Referer": "https://imgur.com/" } }); await fs.writeFile(file, Buffer.from(res.data)); return file; } async function getVideo() { let lastError = "unknown"; for (let i = 0; i < VIDEO_URLS.length; i++) { const url = nextUrl(); try { const file = await downloadVideo(url); return { stream: fs.createReadStream(file) }; } catch (e) { lastError = e.response?.status ? `HTTP ${e.response.status}` : e.code || e.message; console.log("[prefix] video failed:", url, lastError); } } return { error: lastError }; } module.exports = { config: { name: "prefix", version: "3.7", author: "ROCKY Chowdhury", countDown: 5, role: 0, description: "Show and change the bot prefix (chat or global)", category: "āš™ļø Configuration" }, onStart: async function ({ message, role, args, commandName, event, threadsData }) { if (!authorOk()) return message.reply(LOCK_MSG); if (!args[0]) return message.SyntaxError(); if (args[0] === "reset") { await threadsData.set(event.threadID, null, "data.prefix"); return message.reply( `šŸŽ€ā”ā”ā”ā”ā”ā”ā”ā”ā”ā”ā”šŸŽ€ 🌸 š—£š—æš—²š—³š—¶š˜… š—„š—²š˜€š—²š˜ 🌸 šŸŽ€ā”ā”ā”ā”ā”ā”ā”ā”ā”ā”ā”šŸŽ€ ✨ š——š—¼š—»š—² š—Æš—®š—Æš˜†! šŸ’– šŸ“ š——š—²š—³š—®š˜‚š—¹š˜ āžœ ${global.GoatBot.config.prefix}` ); } const newPrefix = args[0]; const setGlobal = args[1] === "-g"; if (setGlobal && role < 2) return message.reply( `ā›” š—¢š—¼š—½š˜€ š—Æš—®š—Æš˜†! šŸ™ˆ šŸ”’ š—¢š—»š—¹š˜† š—Æš—¼š˜ š—®š—±š—ŗš—¶š—»š˜€ š—°š—®š—» š—°š—µš—®š—»š—“š—² š—“š—¹š—¼š—Æš—®š—¹ š—½š—æš—²š—³š—¶š˜… šŸŽ€` ); return message.reply( setGlobal ? `šŸŽ€ā”ā”ā”ā”ā”ā”ā”ā”ā”ā”ā”šŸŽ€ šŸŒ š—šš—¹š—¼š—Æš—®š—¹ š—£š—æš—²š—³š—¶š˜… šŸŒ šŸŽ€ā”ā”ā”ā”ā”ā”ā”ā”ā”ā”ā”šŸŽ€ šŸ­ š—”š—²š˜„ āžœ ${newPrefix} šŸ’Œ š—„š—²š—®š—°š˜ š˜š—¼ š—°š—¼š—»š—³š—¶š—æš—ŗ ✨` : `šŸŽ€ā”ā”ā”ā”ā”ā”ā”ā”ā”ā”ā”šŸŽ€ šŸ’¬ š—–š—µš—®š˜ š—£š—æš—²š—³š—¶š˜… šŸ’¬ šŸŽ€ā”ā”ā”ā”ā”ā”ā”ā”ā”ā”ā”šŸŽ€ šŸ­ š—”š—²š˜„ āžœ ${newPrefix} šŸ’Œ š—„š—²š—®š—°š˜ š˜š—¼ š—°š—¼š—»š—³š—¶š—æš—ŗ ✨`, (err, info) => { if (err) return console.log("[prefix] reply error:", err); global.GoatBot.onReaction.set(info.messageID, { commandName, author: event.senderID, newPrefix, setGlobal, messageID: info.messageID }); } ); }, onReaction: async function ({ message, threadsData, event, Reaction }) { try { if (!authorOk()) return message.reply(LOCK_MSG); const { author, newPrefix, setGlobal } = Reaction; if (event.userID !== author) return; if (setGlobal) { global.GoatBot.config.prefix = newPrefix; fs.writeFileSync( global.client.dirConfig, JSON.stringify(global.GoatBot.config, null, 2) ); return message.reply( `šŸŽ€ā”ā”ā”ā”ā”ā”ā”ā”ā”ā”ā”šŸŽ€ šŸŒ š—£š—æš—²š—³š—¶š˜… š—Øš—½š—±š—®š˜š—²š—± šŸŒ šŸŽ€ā”ā”ā”ā”ā”ā”ā”ā”ā”ā”ā”šŸŽ€ āœ… š—šš—¹š—¼š—Æš—®š—¹ āžœ ${newPrefix} 🧸 š—˜š—»š—·š—¼š˜† š—Æš—®š—Æš˜† ✨` ); } await threadsData.set(event.threadID, newPrefix, "data.prefix"); return message.reply( `šŸŽ€ā”ā”ā”ā”ā”ā”ā”ā”ā”ā”ā”šŸŽ€ šŸ’¬ š—£š—æš—²š—³š—¶š˜… š—Øš—½š—±š—®š˜š—²š—± šŸ’¬ šŸŽ€ā”ā”ā”ā”ā”ā”ā”ā”ā”ā”ā”šŸŽ€ āœ… š—–š—µš—®š˜ āžœ ${newPrefix} 🧸 š—˜š—»š—·š—¼š˜† š—Æš—®š—Æš˜† ✨` ); } catch (err) { console.log("[prefix] onReaction error:", err); } }, onChat: async function ({ event, message, threadsData }) { try { if (!event.body || event.body.trim().toLowerCase() !== "prefix") return; if (!authorOk()) return message.reply(LOCK_MSG); const globalPrefix = global.GoatBot.config.prefix; const threadPrefix = (await threadsData.get(event.threadID, "data.prefix")) || globalPrefix; const currentTime = moment().tz("Asia/Dhaka").format("hh:mm A"); const total = Math.floor(process.uptime()); const hr = Math.floor(total / 3600); const min = Math.floor((total % 3600) / 60); const sec = total % 60; const uptime = `${hr}h ${min}m ${sec}s`; const body = `šŸŽ€ā”ā”ā”ā”ā”ā”ā”ā”ā”ā”ā”šŸŽ€ 🌸 š—£š—„š—˜š—™š—œš—« š—œš—”š—™š—¢ 🌸 šŸŽ€ā”ā”ā”ā”ā”ā”ā”ā”ā”ā”ā”šŸŽ€ šŸŒ š—šš—¹š—¼š—Æš—®š—¹ āžœ ${globalPrefix} šŸ’¬ š—–š—µš—®š˜ āžœ ${threadPrefix} šŸ“– š—›š—²š—¹š—½ āžœ ${threadPrefix}help ā° š—§š—¶š—ŗš—² āžœ ${currentTime} ā³ š—Øš—½š˜š—¶š—ŗš—² āžœ ${uptime} šŸ†” š—œš—— āžœ ${event.senderID} šŸŽ€ā”ā”ā”ā”ā”ā”ā”ā”ā”ā”ā”šŸŽ€ šŸ‘‘ š—”š—”š——š—œš—  šŸ’—`; const video = await getVideo(); if (video.stream) { try { return await message.reply({ body, attachment: video.stream }); } catch (e) { console.log("[prefix] send with video failed:", e.message || e); return message.reply(body); } } return message.reply(body + `\n\nāš ļø š—©š—¶š—±š—²š—¼ š—³š—®š—¶š—¹š—²š—± : ${video.error}`); } catch (err) { console.log("[prefix] onChat error:", err); } } }; if (!authorOk()) { throw new Error("[prefix] Author changed! This file is locked to: " + AUTHOR); }