goat
command
album
Manage and view video/photo albums
0
views
0
likes
0
installs
raw source
const axios = require("axios");
const path = require("path");
const fs = require("fs");
const API_CONFIG_URL =
"https://raw.githubusercontent.com/cyber-ullash/cyber-ullash/refs/heads/main/UllashApi.json";
const getApiUrl = async () => {
try {
const response = await axios.get(API_CONFIG_URL);
const albumUrl = response.data.album;
if (!albumUrl) {
throw new Error("Album API URL not found in the JSON data.");
}
return albumUrl;
} catch (error) {
console.error("API URL :", error);
throw new Error("API URL");
}
};
module.exports.config = {
name: "album",
version: "1.0.1",
role: 0,
author: "๐ฉ๐
๐๐ท๐พ๐๐ช ๐๐๐พ",
description: "Manage and view video/photo albums",
usePrefix: true,
prefix: true,
category: "Media",
category: "media",
usages: "Empty to see list, or album [category] to get media.",
countDown: 5,
};
module.exports.onStart = async function ({ api, event, args }) {
const { threadID, messageID, senderID } = event;
const albumOptionsPage1 = [
"funny",
"islamic",
"sad",
"anime",
"cartoon",
"love",
"horny",
"couple",
"flower",
"marvel",
];
const albumOptionsPage2 = [
"aesthetic",
"sigma",
"lyrics",
"cat",
"18plus",
"freefire",
"football",
"girl",
"friends",
"cricket",
];
const toBold = (text) =>
text.replace(/[a-z]/g, (c) =>
String.fromCodePoint(0x1d41a + c.charCodeAt(0) - 97)
);
const toBoldNumber = (num) =>
String(num).replace(/[0-9]/g, (c) =>
String.fromCodePoint(0x1d7ec + parseInt(c))
);
const formatOptions = (options, startIndex = 1) =>
options
.map((opt, i) => `โจ | ${toBoldNumber(i + startIndex)}. ${toBold(opt)}`)
.join("\n");
if (args[0] === "2") {
const message2 =
"๐ซ ๐๐ก๐จ๐จ๐ฌ๐ ๐๐ง ๐๐ฅ๐๐ฎ๐ฆ ๐๐๐ญ๐๐ ๐จ๐ซ๐ฒ ๐๐๐๐ฒ ๐ซ\n" +
"โบโโโโโโโโโโโโโโโโโโบ\n" +
formatOptions(albumOptionsPage2, 11) +
"\nโบโโโโโโโโโโโโโโโโโโบ\n๐ฏ | ๐๐๐ ๐ [๐/๐]\nโบโโโโโโโโโโโโโโโโโโบ";
await api.sendMessage(
{ body: message2 },
threadID,
(error, info) => {
if (!error && info && info.messageID) {
if (global.GoatBot?.onReply) { global.GoatBot.onReply.set(info.messageID, {
name: this.config.name,
type: "reply",
messageID: info.messageID,
author: senderID,
link: albumOptionsPage2,
}); }
}
},
messageID
);
return;
}
if (!args[0] || args[0].toLowerCase() === "list") {
api.setMessageReaction("โข๏ธ", messageID, () => {}, true);
const message =
"๐ซ ๐๐ก๐จ๐จ๐ฌ๐ ๐๐ง ๐๐ฅ๐๐ฎ๐ฆ ๐๐๐ญ๐๐ ๐จ๐ซ๐ฒ ๐๐๐๐ฒ ๐ซ\n" +
"โบโโโโโโโโโโโโโโโโโโบ\n" +
formatOptions(albumOptionsPage1) +
`\nโบโโโโโโโโโโโโโโโโโโบ\n๐ฏ | ๐๐๐ ๐ [๐/๐]\nโน | ๐๐ฒ๐ฉ๐: ${global.config.PREFIX}album 2 - ๐ง๐๐ฑ๐ญ ๐ฉ๐๐ ๐\nโบโโโโโโโโโโโโโโโโโโบ`;
await api.sendMessage(
{ body: message },
threadID,
(error, info) => {
if (!error && info && info.messageID) {
if (global.GoatBot?.onReply) { global.GoatBot.onReply.set(info.messageID, {
name: this.config.name,
type: "reply",
messageID: info.messageID,
author: senderID,
link: albumOptionsPage1,
}); }
}
},
messageID
);
return;
}
const validCategories = [
"cartoon",
"marvel",
"lofi",
"sad",
"islamic",
"funny",
"horny",
"anime",
"love",
"baby",
"lyrics",
"sigma",
"aesthetic",
"cat",
"flower",
"freefire",
"sex",
"girl",
"football",
"friend",
"cricket",
"couple",
"18plus",
"freefire",
];
const command = args[0].toLowerCase();
if (!validCategories.includes(command)) {
return api.sendMessage(
"โ ๐๐ง๐ฏ๐๐ฅ๐ข๐ ๐๐๐ญ๐๐ ๐จ๐ซ๐ฒ! ๐๐ฒ๐ฉ๐ '/album' ๐ญ๐จ ๐ฌ๐๐ ๐ฅ๐ข๐ฌ๐ญ.",
threadID,
messageID
);
}
return api.sendMessage(
`๐ ๐๐จ๐๐๐ข๐ง๐ ๐๐๐ญ๐๐ ๐จ๐ซ๐ฒ: ๐๐ฅ๐๐ฎ๐ฆ - ${command}...`,
threadID,
messageID
);
};
module.exports.onReply = async function ({ api, event, handleReply: _origReply }) {
const handleReply = Reply || _origReply || {};
api.unsendMessage(handleReply.messageID);
const adminID = "100091520325159";
const replyNum = parseInt(event.body);
if (isNaN(replyNum)) {
return api.sendMessage(
"โ ๐๐ฅ๐๐๐ฌ๐ ๐ซ๐๐ฉ๐ฅ๐ฒ ๐ฐ๐ข๐ญ๐ก ๐ ๐ฏ๐๐ฅ๐ข๐ ๐ง๐ฎ๐ฆ๐๐๐ซ.",
event.threadID,
event.messageID
);
}
const categories = [
"funny",
"islamic",
"sad",
"anime",
"cartoon",
"love",
"horny",
"couple",
"flower",
"marvel",
"aesthetic",
"sigma",
"lyrics",
"cat",
"18plus",
"freefire",
"football",
"girl",
"friend",
"cricket",
];
if (replyNum < 1 || replyNum > categories.length) {
return api.sendMessage(
"โ ๐๐ง๐ฏ๐๐ฅ๐ข๐ ๐ฌ๐๐ฅ๐๐๐ญ๐ข๐จ๐ง.",
event.threadID,
event.messageID
);
}
const selectedCategory = categories[replyNum - 1];
if (
(selectedCategory === "horny" || selectedCategory === "18plus") &&
event.senderID !== adminID
) {
return api.sendMessage(
"๐ซ ๐๐จ๐ฎ ๐๐ซ๐ ๐ง๐จ๐ญ ๐๐ฎ๐ญ๐ก๐จ๐ซ๐ข๐ณ๐๐ ๐๐จ๐ซ ๐ญ๐ก๐ข๐ฌ ๐๐๐ญ๐๐ ๐จ๐ซ๐ฒ.",
event.threadID,
event.messageID
);
}
const captions = {
funny: "๐คฃ > ๐๐๐ฐ ๐๐๐๐ฒ ๐
๐ฎ๐ง๐ง๐ฒ ๐ฏ๐ข๐๐๐จ",
islamic: "๐ > ๐๐๐ฐ ๐๐๐๐ฒ ๐๐ฌ๐ฅ๐๐ฆ๐ข๐ ๐ฏ๐ข๐๐๐จ",
sad: "๐ฅบ > ๐๐๐ฐ ๐๐๐๐ฒ ๐๐๐ ๐ฏ๐ข๐๐๐จ",
anime: "๐ > ๐๐๐ฐ ๐๐๐๐ฒ ๐๐ง๐ข๐ฆ๐ ๐ฏ๐ข๐๐๐จ",
cartoon: "๐ > ๐๐๐ฐ ๐๐๐๐ฒ ๐๐๐ซ๐ญ๐จ๐จ๐ง ๐ฏ๐ข๐๐๐จ",
love: "๐ > ๐๐๐ฐ ๐๐๐๐ฒ ๐๐จ๐ฏ๐ ๐ฏ๐ข๐๐๐จ",
horny: "๐ฅต > ๐๐๐ฐ ๐๐๐๐ฒ ๐๐จ๐ซ๐ง๐ฒ ๐ฏ๐ข๐๐๐จ",
couple: "โค๏ธ > ๐๐๐ฐ ๐๐๐๐ฒ ๐๐จ๐ฎ๐ฉ๐ฅ๐ ๐ฏ๐ข๐๐๐จ",
flower: "๐ธ > ๐๐๐ฐ ๐๐๐๐ฒ ๐
๐ฅ๐จ๐ฐ๐๐ซ ๐ฏ๐ข๐๐๐จ",
marvel: "๐ฏ > ๐๐๐ฐ ๐๐๐๐ฒ ๐๐๐ซ๐ฏ๐๐ฅ ๐ฏ๐ข๐๐๐จ",
aesthetic: "๐ > ๐๐๐ฐ ๐๐๐๐ฒ ๐๐๐ฌ๐ญ๐ก๐๐ญ๐ข๐ ๐ฏ๐ข๐๐๐จ",
sigma: "๐ค > ๐๐๐ฐ ๐๐๐๐ฒ ๐๐ข๐ ๐ฆ๐ ๐ฏ๐ข๐๐๐จ",
lyrics: "๐ฅฐ > ๐๐๐ฐ ๐๐๐๐ฒ ๐๐ฒ๐ซ๐ข๐๐ฌ ๐ฏ๐ข๐๐๐จ",
cat: "๐ฑ > ๐๐๐ฐ ๐๐๐๐ฒ ๐๐๐ญ ๐ฏ๐ข๐๐๐จ",
"18plus": "๐ > ๐๐๐ฐ ๐๐๐๐ฒ ๐๐+ ๐ฏ๐ข๐๐๐จ",
freefire: "๐ฎ > ๐๐๐ฐ ๐๐๐๐ฒ ๐
๐ซ๐๐๐๐ข๐ซ๐ ๐ฏ๐ข๐๐๐จ",
football: "โฝ > ๐๐๐ฐ ๐๐๐๐ฒ ๐
๐จ๐จ๐ญ๐๐๐ฅ๐ฅ ๐ฏ๐ข๐๐๐จ",
girl: "๐ง > ๐๐๐ฐ ๐๐๐๐ฒ ๐๐ข๐ซ๐ฅ ๐ฏ๐ข๐๐๐จ",
friend: "๐ซ > ๐๐๐ฐ ๐๐๐๐ฒ ๐
๐ซ๐ข๐๐ง๐๐ฌ ๐ฏ๐ข๐๐๐จ",
cricket: "๐ > ๐๐๐ฐ ๐๐๐๐ฒ ๐๐ซ๐ข๐๐ค๐๐ญ ๐ฏ๐ข๐๐๐จ",
};
try {
const BASE_API_URL = await getApiUrl();
const res = await axios.get(
`${BASE_API_URL}/album?type=${selectedCategory}`
);
const mediaUrl = res.data.data;
if (!mediaUrl) {
return api.sendMessage(
"โ ๏ธ ๐๐จ ๐๐จ๐ง๐ญ๐๐ง๐ญ ๐๐จ๐ฎ๐ง๐ ๐ข๐ง ๐ญ๐ก๐ข๐ฌ ๐๐๐ญ๐๐ ๐จ๐ซ๐ฒ.",
event.threadID,
event.messageID
);
}
const response = await axios({
method: "get",
url: mediaUrl,
responseType: "stream",
});
const filename = path.basename(mediaUrl).split("?")[0];
const filePath = path.join(__dirname, "cache", `${Date.now()}_${filename}`);
const writer = fs.createWriteStream(filePath);
response.data.pipe(writer);
writer.on("finish", () => {
api.sendMessage(
{
body:
captions[selectedCategory] ||
`๐ฌ ๐๐จ๐ฐ ๐๐๐๐ฒ ${selectedCategory} ๐๐จ๐ง๐ญ๐๐ง๐ญ`,
attachment: fs.createReadStream(filePath),
},
event.threadID,
() => fs.unlinkSync(filePath),
event.messageID
);
});
writer.on("error", (err) => {
console.error("Write Error:", err);
api.sendMessage(
"โ ๐
๐๐ข๐ฅ๐๐ ๐ญ๐จ ๐ฌ๐๐ง๐ ๐ฏ๐ข๐๐๐จ.",
event.threadID,
event.messageID
);
});
} catch (err) {
console.error("Axios Error:", err.message);
return api.sendMessage(
"โ ๐๐จ๐ฆ๐๐ญ๐ก๐ข๐ง๐ ๐ฐ๐๐ง๐ญ ๐ฐ๐ซ๐จ๐ง๐ . ๐๐ซ๐ฒ ๐๐ ๐๐ข๐ง!",
event.threadID,
event.messageID
);
}
};