goat
command
album
๐๐ฅ๐๐ฎ๐ฆ ๐๐ข๐๐๐จ Random
0
views
0
likes
0
installs
Aliases: al
raw source
const axios = require("axios");
const fs = require("fs");
const path = require("path");
const FormData = require("form-data");
module.exports = {
config: {
name: "album",
aliases: ["al"],
version: "5.1.0",
author: "Azadx69x",
countDown: 2,
role: 0,
shortDescription: "๐๐ฅ๐๐ฎ๐ฆ ๐๐ข๐๐๐จ Random",
longDescription: "Random album videos",
category: "media"
},
albumSystem: new Map(),
albumBaseUrl: null,
videoQueue: new Map(),
async loadAlbumBaseUrl() {
if (this.albumBaseUrl) return;
try {
const res = await axios.get(
"https://raw.githubusercontent.com/ncazad/Azad69x/refs/heads/main/baseApiUrl.json"
);
this.albumBaseUrl = res.data.album.replace(/\/$/, "");
console.log("Album API base URL loaded:", this.albumBaseUrl);
} catch (e) {
console.error("Failed to load album base URL:", e.message);
this.albumBaseUrl = null;
}
},
async fetchAlbumVideo(category) {
await this.loadAlbumBaseUrl();
if (!this.albumBaseUrl) return null;
if (!this.videoQueue.has(category) || this.videoQueue.get(category).length === 0) {
try {
const res = await axios.get(`${this.albumBaseUrl}/api/album?category=${encodeURIComponent(category)}`);
let videos = [];
if (res.data?.url) videos.push(res.data.url);
if (res.data?.videos?.length) videos = videos.concat(res.data.videos);
if (!videos.length) return null;
videos = this.shuffleArray(videos);
this.videoQueue.set(category, videos);
} catch (e) {
console.error(`Failed to fetch video for ${category}:`, e.message);
return null;
}
}
const queue = this.videoQueue.get(category);
const videoUrl = queue.shift();
this.videoQueue.set(category, queue);
return videoUrl;
},
shuffleArray(arr) {
for (let i = arr.length - 1; i > 0; i--) {
const j = Math.floor(Math.random() * (i + 1));
[arr[i], arr[j]] = [arr[j], arr[i]];
}
return arr;
},
async uploadToCatbox(videoPath) {
const form = new FormData();
form.append("reqtype", "fileupload");
form.append("fileToUpload", fs.createReadStream(videoPath));
const res = await axios.post("https://catbox.moe/user/api.php", form, { headers: form.getHeaders() });
fs.unlinkSync(videoPath);
return res.data.trim();
},
onStart: async function ({ message, event, args }) {
const displayNames = [
"๐๐๐๐๐69๐๐
๐
๐ผ","๐๐ง๐ข๐ฆ๐ ๐ซ","๐๐จ๐ โก","๐๐ญ๐ญ๐ข๐ญ๐ฎ๐๐ ๐ผ",
"๐๐๐๐ฒ ๐ถ","๐๐๐ญ ๐","๐๐จ๐ฎ๐ฉ๐ฅ๐ ๐","๐๐ซ๐๐ ๐จ๐ง๐๐๐ฅ๐ฅ ๐",
"๐
๐ฅ๐จ๐ฐ๐๐ซ ๐บ","๐
๐จ๐จ๐ญ๐๐๐ฅ๐ฅ โฝ","๐
๐ซ๐๐๐
๐ข๐ซ๐ ๐ฅ","๐
๐ซ๐ข๐๐ง๐๐ฌ ๐ซ",
"๐
๐ฎ๐ง๐ง๐ฒ ๐คฃ","๐๐จ๐ซ๐ง๐ฒ ๐ฆ","๐๐จ๐ญ ๐ฅต","๐๐ฌ๐ฅ๐๐ฆ๐ข๐ ๐",
"๐๐จ๐
๐ ๐ถ","๐๐จ๐ฏ๐ ๐","๐๐ฒ๐ซ๐ข๐๐ฌ ๐ต","๐๐๐ ๐ฟ"
];
const realCategories = [
"Azadx69xff","anime","aot","attitude","baby","cat","couple","dragonball",
"flower","football","freefire","friends","funny","horny","hot","islamic",
"lofi","love","lyrics","sad"
];
if (args[0] && args[0].toLowerCase() === "add" && args[1]) {
const cat = args[1].toLowerCase();
if (!realCategories.includes(cat)) return message.reply("โ Invalid category name.");
if (!this.albumSystem.has(event.senderID)) this.albumSystem.set(event.senderID, []);
this.albumSystem.get(event.senderID).push(cat);
return message.reply(`โ
Album category "${cat}" added to your list.`);
}
const itemsPerPage = 10;
const page = parseInt(args[0]) || 1;
const totalPages = Math.ceil(displayNames.length / itemsPerPage);
if (page < 1 || page > totalPages) return message.reply("โ Invalid page");
const startIndex = (page - 1) * itemsPerPage;
const categoriesToShow = displayNames.slice(startIndex, startIndex + itemsPerPage);
let text = "โญโโ๐๐๐๐๐ ๐๐๐๐๐ ๐๐๐๐โโโฎ\n\n";
categoriesToShow.forEach((cat, i) => text += `โฆ ${i + 1}. ${cat}\n`);
text += `\nโฐโโ ๐๐๐ ๐ : ${page}/${totalPages} โโโฏ\n`;
text += "๐ฌ ๐๐๐ฉ๐ฅ๐ฒ ๐ ๐ง๐ฎ๐ฆ๐๐๐ซ ๐ญ๐จ ๐ ๐๐ญ ๐ ๐ฏ๐ข๐๐๐จ ๐ฑ";
const sent = await message.reply(text);
global.GoatBot.onReply.set(sent.messageID, {
commandName: "album",
author: event.senderID,
pageCategories: categoriesToShow.map((_, i) => realCategories[startIndex + i]),
pageDisplayNames: categoriesToShow,
messageID: sent.messageID
});
},
onReply: async function ({ message, event, Reply }) {
if (event.senderID !== Reply.author) return;
const num = parseInt(event.body);
if (isNaN(num)) return;
const index = num - 1;
const category = Reply.pageCategories[index];
const displayName = Reply.pageDisplayNames[index];
if (!category) return message.reply("โ Invalid number");
const videoUrl = await this.fetchAlbumVideo(category);
if (!videoUrl) return message.reply(`โ No videos found for ${displayName}`);
try { await message.unsend(Reply.messageID); } catch(e){}
await message.reply({
body: `โจ ๐๐๐๐๐ ๐๐๐๐๐ ๐ธ\n\n๐ ๐๐๐ญ๐๐ ๐จ๐ซ๐ฒ : ${displayName}\n\n๐ธ ๐๐ง๐ฃ๐จ๐ฒ ๐๐จ๐ฎ๐ซ ๐๐ข๐๐๐จ ๐ค`,
attachment: await global.utils.getStreamFromURL(videoUrl)
});
}
};