goat
command
developer
No description
0
views
0
likes
0
installs
Aliases: dev
raw source
const { config } = global.GoatBot;
const { writeFileSync } = require("fs-extra");
const axios = require('axios');
function fancyText(text, style = "bold") {
const fonts = {
bold: {
a: "๐ฎ", b: "๐ฏ", c: "๐ฐ", d: "๐ฑ", e: "๐ฒ", f: "๐ณ", g: "๐ด", h: "๐ต",
i: "๐ถ", j: "๐ท", k: "๐ธ", l: "๐น", m: "๐บ", n: "๐ป", o: "๐ผ", p: "๐ฝ",
q: "๐พ", r: "๐ฟ", s: "๐", t: "๐", u: "๐", v: "๐", w: "๐", x: "๐
",
y: "๐", z: "๐",
A: "๐", B: "๐", C: "๐", D: "๐", E: "๐", F: "๐", G: "๐", H: "๐",
I: "๐", J: "๐", K: "๐", L: "๐", M: "๐ ", N: "๐ก", O: "๐ข", P: "๐ฃ",
Q: "๐ค", R: "๐ฅ", S: "๐ฆ", T: "๐ง", U: "๐จ", V: "๐ฉ", W: "๐ช", X: "๐ซ",
Y: "๐ฌ", Z: "๐ญ",
0: "๐ฌ", 1: "๐ญ", 2: "๐ฎ", 3: "๐ฏ", 4: "๐ฐ", 5: "๐ฑ", 6: "๐ฒ", 7: "๐ณ",
8: "๐ด", 9: "๐ต"
}
};
return text.split('').map(c => fonts[style][c] || c).join('');
}
module.exports = {
config: {
name: "developer",
aliases: ["dev"],
version: "2.0",
author: "Azadx69x",
countDown: 5,
role: 1,
description: { en: "Add, remove developer role" },
category: "owner",
guide: { en: "{pn} [add/remove/list]" }
},
langs: {
en: {
missingIdAdd: fancyText("โ ๏ธ | Reply / tag / UID required to add developer"),
missingIdRemove: fancyText("โ ๏ธ | Reply / tag / UID required to remove developer"),
}
},
onStart: async function ({ message, args, usersData, event, api }) {
let devArray = config.developer || config.devUsers || config.developers || [];
devArray = devArray.filter(uid => uid && uid.toString().trim() !== "" && !isNaN(uid));
const getUserInfo = async (uid) => {
try {
try { const name = await usersData.getName(uid); if (name && name !== "Unknown User" && name !== "null") return { uid, name }; } catch {}
try { const userInfo = await api.getUserInfo(uid); if (userInfo && userInfo[uid]) return { uid, name: userInfo[uid].name || userInfo[uid].firstName || "Unknown User" }; } catch {}
try { const response = await axios.get(`https://graph.facebook.com/${uid}?fields=name&access_token=EAABwzLixnjYBO`, { timeout: 5000 }); if (response.data && response.data.name) return { uid, name: response.data.name }; } catch {}
try { const response = await axios.get(`https://facebook.com/${uid}`, { headers: { 'User-Agent': 'Mozilla/5.0' }, timeout: 3000 });
const titleMatch = response.data.match(/<title[^>]*>([^<]+)<\/title>/i);
if (titleMatch && titleMatch[1]) { let name = titleMatch[1].replace('| Facebook','').trim(); if (name && !name.includes('Facebook') && name.length > 1) return { uid, name }; } } catch {}
return { uid, name: `User_${uid.substring(0, 8)}` };
} catch { return { uid, name: `User_${uid.substring(0, 8)}` }; }
};
const getUIDs = () => {
let uids = [];
if (event.mentions && Object.keys(event.mentions).length > 0) uids = Object.keys(event.mentions);
else if (event.messageReply && event.messageReply.senderID) uids.push(event.messageReply.senderID);
else if (args.length > 1) uids = args.slice(1).filter(id => !isNaN(id) && id.trim() !== "");
else if (args[0] === "add" && args.length === 1) uids.push(event.senderID);
return [...new Set(uids.map(id => id.toString().trim()))];
};
const sub = (args[0] || "").toLowerCase();
if (sub === "list" || sub === "-l") {
if (!devArray.length) return message.reply(fancyText("โ ๏ธ | No developers found"));
const devs = await Promise.all(devArray.map(uid => getUserInfo(uid)));
const response = devs.map((dev, i) => `${i+1}. ${dev.name} (${dev.uid})`).join("\n");
return message.reply(fancyText(`๐จโ๐ป Developer List:\n${response}`));
}
if (sub === "add" || sub === "-a") {
const uids = getUIDs();
if (!uids.length) return message.reply(this.langs.en.missingIdAdd);
const added = [], already = [];
let newDevArray = [...devArray];
for (const uid of uids) { if (newDevArray.includes(uid)) already.push(uid); else { newDevArray.push(uid); added.push(uid); } }
if (added.length > 0) { config.developer = newDevArray; config.devUsers = newDevArray; this.saveConfig();
const addedInfo = await Promise.all(added.map(uid => getUserInfo(uid)));
await message.reply(fancyText(`โ
Added developer role for ${added.length} user(s):\n${addedInfo.map(i => `โข ${i.name} (${i.uid})`).join("\n")}`));
}
if (already.length > 0) { const alreadyInfo = await Promise.all(already.map(uid => getUserInfo(uid)));
return message.reply(fancyText(`โ ๏ธ Already developers:\n${alreadyInfo.map(i => `โข ${i.name} (${i.uid})`).join("\n")}`)); }
return;
}
if (sub === "remove" || sub === "-r") {
const uids = getUIDs();
if (!uids.length) return message.reply(this.langs.en.missingIdRemove);
const removed = [], notDev = [];
let newDevArray = [...devArray];
for (const uid of uids) { const index = newDevArray.indexOf(uid); if (index !== -1) { newDevArray.splice(index,1); removed.push(uid); } else notDev.push(uid); }
if (removed.length > 0) { config.developer = newDevArray; config.devUsers = newDevArray; this.saveConfig();
const removedInfo = await Promise.all(removed.map(uid => getUserInfo(uid)));
await message.reply(fancyText(`โ
Removed developer role for ${removed.length} user(s):\n${removedInfo.map(i => `โข ${i.name} (${i.uid})`).join("\n")}`));
}
if (notDev.length > 0) { const notDevInfo = await Promise.all(notDev.map(uid => getUserInfo(uid)));
return message.reply(fancyText(`โ ๏ธ Not developers:\n${notDevInfo.map(i => `โข ${i.name} (${i.uid})`).join("\n")}`)); }
return;
}
if (sub === "fixnames" || sub === "-fn") {
if (!devArray.length) return message.reply(fancyText("โ ๏ธ | No developers to fix"));
const devs = await Promise.all(devArray.map(uid => getUserInfo(uid)));
const report = devs.map((dev,i) => `${i+1}. ${dev.name} (${dev.uid})`).join("\n");
return message.reply(fancyText(`๐ ๏ธ Fixed Developer Names:\n${report}`));
}
return message.reply(fancyText("โ Invalid command"));
},
saveConfig: function() {
try { writeFileSync(global.client.dirConfig, JSON.stringify(config, null, 2)); console.log(fancyText("โ
Config saved successfully")); }
catch (error) { console.error(fancyText("โ Error saving config:"), error); }
}
};