← back to browse
goat command

admin

๐—”๐—ฑ๐—ฑ, ๐—ฟ๐—ฒ๐—บ๐—ผ๐˜ƒ๐—ฒ ๐—ผ๐—ฟ ๐˜ƒ๐—ถ๐—ฒ๐˜„ ๐˜๐—ต๐—ฒ ๐—ฎ๐—ฑ๐—บ๐—ถ๐—ป ๐—น๐—ถ๐˜€๐˜

0
views
0
likes
0
installs

Aliases: ad

raw source
const { config } = global.GoatBot;
const { writeFileSync } = require("fs-extra");

module.exports = {
    config: {
        name: "admin",
        aliases: ["ad"],
        version: "1.1",
        author: "Azadx69x",
        countDown: 5,
        role: 0,
        shortDescription: {
            en: "๐—”๐—ฑ๐—ฑ, ๐—ฟ๐—ฒ๐—บ๐—ผ๐˜ƒ๐—ฒ ๐—ผ๐—ฟ ๐˜ƒ๐—ถ๐—ฒ๐˜„ ๐˜๐—ต๐—ฒ ๐—ฎ๐—ฑ๐—บ๐—ถ๐—ป ๐—น๐—ถ๐˜€๐˜"
        },
        longDescription: {
            en: "๐— ๐—ฎ๐—ป๐—ฎ๐—ด๐—ฒ ๐—ฏ๐—ผ๐˜ ๐—ฎ๐—ฑ๐—บ๐—ถ๐—ป๐˜€ โ€” ๐—ฎ๐—ฑ๐—ฑ/๐—ฟ๐—ฒ๐—บ๐—ผ๐˜ƒ๐—ฒ/๐˜ƒ๐—ถ๐—ฒ๐˜„"
        },
        category: "admin",
        guide: {
            en:
`๐Ÿ•ต ๐—จ๐˜€๐—ฎ๐—ด๐—ฒ:
{pn} ๐—น๐—ถ๐˜€๐˜
{pn} ๐—ฎ๐—ฑ๐—ฑ <uid|tag|reply>
{pn} ๐—ฟ๐—ฒ๐—บ๐—ผ๐˜ƒ๐—ฒ <uid|tag|reply>`
        }
    },

    langs: {
        en: {
            listAdmin:
`โ•”โ•โ•โ•โ•โ›จ ๐€๐ƒ๐Œ๐ˆ๐ ๐‹๐ˆ๐’๐“ โ›จโ•โ•โ•โ•โ•—
     โœช ๐™พ๐š†๐™ฝ๐™ด๐š: RSโ€ข RIFAT.ยฅ
โ• โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•ฃ
     ๐Ÿ“‹ ๐™ฐ๐š๐š–๐š’๐š— ๐™ป๐š’๐šœ๐š:
%1
โ•šโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•`,

            noAdmin: "โš ๏ธ | ๐™ฝ๐š˜ ๐™ฐ๐š๐š–๐š’๐š—๐šœ ๐™ต๐š˜๐šž๐š—๐š!",

            added:
`โœ” ๐—ก๐—ฒ๐˜„ ๐—”๐—ฑ๐—บ๐—ถ๐—ป๐˜€ ๐—”๐—ฑ๐—ฑ๐—ฒ๐—ฑ:
โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”
%2
โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”`,

            alreadyAdmin:
`โš ๏ธ ๐—”๐—น๐—ฟ๐—ฒ๐—ฎ๐—ฑ๐˜† ๐—”๐—ฑ๐—บ๐—ถ๐—ป:
โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”
%2
โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”`,

            removed:
`โœ” ๐—”๐—ฑ๐—บ๐—ถ๐—ป ๐—ฃ๐—ฟ๐—ถ๐˜ƒ๐—ถ๐—น๐—ฒ๐—ด๐—ฒ ๐—ฅ๐—ฒ๐—บ๐—ผ๐˜ƒ๐—ฒ๐—ฑ:
โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”
%2
โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”`,

            notAdmin:
`โš ๏ธ ๐—ก๐—ผ๐˜ ๐—”๐—ป ๐—”๐—ฑ๐—บ๐—ถ๐—ป:
โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”
%2
โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”`,

            missingIdAdd: "โš ๏ธ | ๐—ง๐—ฎ๐—ด/๐—ฟ๐—ฒ๐—ฝ๐—น๐˜†/๐—จ๐—œ๐—— ๐—ป๐—ฒ๐—ฒ๐—ฑ๐—ฒ๐—ฑ ๐˜๐—ผ ๐—ฎ๐—ฑ๐—ฑ ๐—ฎ๐—ฑ๐—บ๐—ถ๐—ป.",
            missingIdRemove: "โš ๏ธ | ๐—ง๐—ฎ๐—ด/๐—ฟ๐—ฒ๐—ฝ๐—น๐˜†/๐—จ๐—œ๐—— ๐—ป๐—ฒ๐—ฒ๐—ฑ๐—ฒ๐—ฑ ๐˜๐—ผ ๐—ฟ๐—ฒ๐—บ๐—ผ๐˜ƒ๐—ฒ ๐—ฎ๐—ฑ๐—บ๐—ถ๐—ป.",

            notAllowed: "โ›” | ๐—ฌ๐—ผ๐˜‚ ๐—ฎ๐—ฟ๐—ฒ ๐—ป๐—ผ๐˜ ๐—ฎ๐—น๐—น๐—ผ๐˜„๐—ฒ๐—ฑ ๐˜๐—ผ ๐˜‚๐˜€๐—ฒ ๐˜๐—ต๐—ถ๐˜€!"
        }
    },

    onStart: async function ({ message, args, event, usersData, getLang }) {
        const senderID = event.senderID;
        
        if (args[0] === "list" || args[0] === "-l") {
            if (config.adminBot.length === 0)
                return message.reply(getLang("noAdmin"));

            const adminList = await Promise.all(
                config.adminBot.map(async uid => {
                    const name = await usersData.getName(uid);
                    return `โ€ข ${name} (${uid})`;
                })
            );

            return message.reply(getLang("listAdmin", adminList.join("\n")));
        }
        
        if (["add", "-a", "remove", "-r"].includes(args[0])) {
            if (!config.adminBot.includes(senderID))
                return message.reply(getLang("notAllowed"));
        }
        
        if (args[0] === "add" || args[0] === "-a") {
            let uids = [];

            if (Object.keys(event.mentions).length)
                uids = Object.keys(event.mentions);
            else if (event.type === "message_reply")
                uids = [event.messageReply.senderID];
            else
                uids = args.filter(a => !isNaN(a));

            if (!uids.length)
                return message.reply(getLang("missingIdAdd"));

            const newAdmins = [];
            const alreadyAdmins = [];

            for (const uid of uids) {
                if (config.adminBot.includes(uid))
                    alreadyAdmins.push(uid);
                else
                    newAdmins.push(uid);
            }

            config.adminBot.push(...newAdmins);
            writeFileSync(global.client.dirConfig, JSON.stringify(config, null, 2));

            const newNames = await Promise.all(newAdmins.map(uid => usersData.getName(uid)));
            const oldNames = await Promise.all(alreadyAdmins.map(uid => usersData.getName(uid)));

            return message.reply(
                (newNames.length ? getLang("added", newNames.length, newNames.map(n => `โ€ข ${n}`).join("\n")) : "") +
                (alreadyAdmins.length ? "\n" + getLang("alreadyAdmin", alreadyAdmins.length, oldNames.map(n => `โ€ข ${n}`).join("\n")) : "")
            );
        }
        
        if (args[0] === "remove" || args[0] === "-r") {
            let uids = [];

            if (Object.keys(event.mentions).length)
                uids = Object.keys(event.mentions);
            else if (event.type === "message_reply")
                uids = [event.messageReply.senderID];
            else
                uids = args.filter(a => !isNaN(a));

            if (!uids.length)
                return message.reply(getLang("missingIdRemove"));

            const removed = [];
            const notAdmins = [];

            for (const uid of uids) {
                if (config.adminBot.includes(uid)) {
                    removed.push(uid);
                    config.adminBot.splice(config.adminBot.indexOf(uid), 1);
                } else {
                    notAdmins.push(uid);
                }
            }

            writeFileSync(global.client.dirConfig, JSON.stringify(config, null, 2));

            const removedNames = await Promise.all(removed.map(uid => usersData.getName(uid)));
            const notNames = await Promise.all(notAdmins.map(uid => usersData.getName(uid)));

            return message.reply(
                (removed.length ? getLang("removed", removed.length, removedNames.map(n => `โ€ข ${n}`).join("\n")) : "") +
                (notAdmins.length ? "\n" + getLang("notAdmin", notAdmins.length, notNames.map(n => `โ€ข ${n}`).join("\n")) : "")
            );
        }
        
        return message.reply("โš ๏ธ | ๐—จ๐˜€๐—ฒ: ๐—น๐—ถ๐˜€๐˜ / ๐—ฎ๐—ฑ๐—ฑ / ๐—ฟ๐—ฒ๐—บ๐—ผ๐˜ƒ๐—ฒ");
    }
};

View raw file