goat
command
prefix
Show bot and group prefix
0
views
0
likes
0
installs
raw source
const axios = require("axios");
const fs = require("fs-extra");
const path = require("path");
module.exports = {
config: {
name: "prefix",
version: "3.1.1",
author: "SUJON FIX UPDATED",
countDown: 5,
role: 0,
shortDescription: "Show bot and group prefix",
longDescription: "Show bot and group prefix with time, day and ping",
category: "system",
guide: {
body: "{pn}"
}
},
// ==========================================
// AUTO RESPONSE: prefix
// ==========================================
onChat: async function ({ message, event, threadsData }) {
try {
const body = event.body;
if (!body) return;
// শুধু "prefix" লিখলে কাজ করবে
if (body.toLowerCase().trim() !== "prefix")
return;
const threadID = event.threadID;
// Ping
const ping = Date.now() - event.timestamp;
// Bangladesh Time
const now = new Date();
const day = now.toLocaleDateString("en-US", {
weekday: "long",
timeZone: "Asia/Dhaka"
});
const time = now.toLocaleTimeString("en-US", {
timeZone: "Asia/Dhaka",
hour12: true
});
// ==========================================
// BOT PREFIX
// ==========================================
const BOTPREFIX =
global.GoatBot?.config?.prefix ||
global.config?.PREFIX ||
"!";
let GROUPPREFIX = BOTPREFIX;
// ==========================================
// GROUP PREFIX
// ==========================================
try {
if (threadsData) {
const threadData = await threadsData.get(threadID);
if (
threadData &&
threadData.prefix &&
typeof threadData.prefix === "string" &&
threadData.prefix.trim() !== ""
) {
GROUPPREFIX = threadData.prefix;
}
}
} catch (e) {
GROUPPREFIX = BOTPREFIX;
}
// ==========================================
// BOT NAME
// ==========================================
const BOTNAME =
global.GoatBot?.config?.botName ||
global.config?.BOTNAME ||
"Sujon Chat Bot";
// ==========================================
// MESSAGE
// ==========================================
const msg =
`🌟 PREFIX INFO 🌟
🕒 Time: ${time}
📅 Day: ${day}
⚡ Ping: ${ping}ms
🤖 Bot Name: ${BOTNAME}
💠 Bot Prefix: ${BOTPREFIX}
💬 Group Prefix: ${GROUPPREFIX}
`;
// ==========================================
// RANDOM IMAGE
// ==========================================
const imageList = [
"https://i.postimg.cc/FR6Tdrnv/received_1461582061731133.jpg",
"https://i.postimg.cc/JnzBCPst/20250330_234834.jpg",
"https://i.postimg.cc/GpjckzNd/1677672960289.jpg"
];
const randomImage =
imageList[
Math.floor(Math.random() * imageList.length)
];
// ==========================================
// CACHE FOLDER
// ==========================================
const cachePath = path.join(__dirname, "cache");
await fs.ensureDir(cachePath);
const filePath = path.join(
cachePath,
`prefix_${Date.now()}.jpg`
);
// ==========================================
// DOWNLOAD IMAGE
// ==========================================
const res = await axios.get(randomImage, {
responseType: "arraybuffer",
timeout: 30000
});
await fs.writeFile(
filePath,
Buffer.from(res.data)
);
// ==========================================
// SEND MESSAGE
// ==========================================
return message.reply(
{
body: msg,
attachment: fs.createReadStream(filePath)
},
() => {
// Delete image after sending
setTimeout(async () => {
try {
if (await fs.pathExists(filePath)) {
await fs.remove(filePath);
}
} catch (e) {}
}, 3000);
}
);
} catch (error) {
console.error(
"PREFIX COMMAND ERROR:",
error
);
return message.reply(
"❌ Prefix information দেখাতে সমস্যা হয়েছে।"
);
}
},
// ==========================================
// NORMAL COMMAND
// ==========================================
onStart: async function ({ message }) {
return message.reply(
"💠 Bot Prefix এবং Group Prefix জানতে শুধু `prefix` লিখুন।"
);
}
};