<|start_filename|>helpers/initialize.js<|end_filename|>
const fs = require('fs');
const util = require('util');
const readdir = util.promisify(fs.readdir);
const low = require('lowdb');
const { Client } = require('discord.js');
const Tantoony = require('../BASE/Tantoony');
class Initialize {
    /**
     *@param {Tantoony} client
     */
    constructor(client) {
        this.client = client;
        this.project_events();
        this.loader();
    }

    project_events() {
        return [
            readdir(__dirname + '/../events/').then((files) => {
                files.filter((e) => e.endsWith('.js')).forEach((file) => {
                    this.client.logger.log("loading event: " + file, "load");
                    const event = new (require(__dirname + "/../events/" + file))(this.client);
                    this.client.extention.on(file.split(".")[0], (...args) => event.run(...args));
                    delete require.cache[require.resolve(__dirname + "/../events/" + file)];
                });
                return;
            }),
            readdir(__dirname + '/../events/module/').then((files) => {
                files.filter((e) => e.endsWith('.js')).forEach((file) => {
                    this.client.logger.log("loading event: " + file, "load");
                    const event = new (require(__dirname + "/../events/module/" + file))(this.client);
                    this.client.on(file.split(".")[0], (...args) => event.run(...args));
                    delete require.cache[require.resolve(__dirname + "/../events/module/" + file)];
                });
                return;
            })
        ]
    }

    /**
     * @param {Client} client
     */
    hello(client) {
        client = client || this.client;
        //const utils = low(client.adapters('utils')).then(a => a.);
        client.guild = client.guilds.cache.get(client.config.server);
        client.owner = client.users.cache.get(client.config.owner);
        readdir(__dirname.replace('helpers', 'apps') + `/${this.client.name}/src/`).then((appFolders) => {
            appFolders.forEach(async (intType) => {
                readdir(__dirname.replace('helpers', 'apps') + `/${this.client.name}/src/${intType}/`).then((raw_output) => {
                    raw_output.filter((s) => s.endsWith('.js')).map(s => s.slice(0, s.length - ".js".length)).forEach(async (output) => {
                        const response = await client.load_int(output, intType, client);
                        if (response) {
                            client.logger.log(response, "error");
                        }
                    });
                });
            });
        }).catch(reason => {
            client.logger.log(reason, "error");
        });
        if (client) this.client = client;
        //client.channels.cache.get(utils.get("lastCrush").value()).send("**TEKRAR ONLINE!**");
        return this.client;
    }

    async loader() {
        this.client.on("error", (e) => client.logger.log(e, "error"));
        this.client.on("warn", (info) => client.logger.log(info, "warn"));
        const elements = await readdir(__dirname + `/../apps/${this.client.name}/Events/`);
        this.client.logger.log(`Loading ${elements.length} events in ${this.client.name}...`, "category");
        await elements.forEach(async (element) => {
            if (element.endsWith(".js")) {
                this.client.logger.log(`Loading Event: ${element.split(".")[0]}`, "load");
                const event = new (require(__dirname + `/../apps/${this.client.name}/Events/${element}`))(this.client);
                this.client.on(element.split(".")[0], (...args) => event.run(...args));
                delete require.cache[require.resolve(__dirname + `/../apps/${this.client.name}/Events/${element}`)];
            } else {
                const detaileds = await readdir(__dirname + `/../apps/${this.client.name}/Events/${element}/`);
                this.client.logger.log(`Loading ${detaileds.length} details of the event ${element} in ${this.client.name}...`, "category");
                detaileds.forEach((detail) => {
                    this.client.logger.log(`Loading Event: ${detail.split(".")[0]}`, "load");
                    const event = new (require(__dirname + `/../apps/${this.client.name}/Events/${element}/${detail}`))(this.client);
                    this.client.on(element.split(".")[0], (...args) => event.run(...args));
                    delete require.cache[require.resolve(__dirname + `/../apps/${this.client.name}/Events/${element}/${detail}`)];
                });
            }
        });
    }


}

module.exports = Initialize;


<|start_filename|>base/Tantoony.js<|end_filename|>
const { Client, Collection } = require('discord.js');
const FileSync = require('lowdb/adapters/FileSync');
const { EventEmitter } = require('events');
const Lowdb = require('lowdb');

class Tantoony extends Client {
    constructor(options, name) {
        super(options);
        this.name = name;
        this.defaly = require('./class_types');
        this.models = require('./db_models');
        this.config = require('../helpers/config');
        this.logger = require("../helpers/logger");
        this.functions = require("../helpers/functions");
        this.extention = new EventEmitter();
        this.adapters = file => new FileSync(`../../base/_${file}.json`);
        (() => {
            require('dotenv').config({ path: __dirname + '/.env' });
            this.login(process.env[this.config.vars[name]]);
        })();
        this.mongoLogin();
        this.responders = new Collection();
        this.cmdCoodown = new Object();
        this.leaves = new Map();
        this.deleteChnl = new Map();
        this.invites = new Object();
        this.spamwait = new Map();
        this.spamcounts = new Object();
        this.trollwait = new Object();
        this.trollcounts = new Object();
        this.stats = new Object();
        this.banlimit = new Object();
        this.voicecutLimit = new Object();

        this.handler = new (require('../helpers/initialize'))(this);
    };

    mongoLogin() {
        require('mongoose').connect(`mongodb://${process.env.mongo_pass}:${this.config.mongoDB.port}`, {
            user: this.config.mongoDB.user,
            pass: <PASSWORD>,
            authSource: this.config.mongoDB.auth,
            dbName: this.config.mongoDB.name
        }).then(() => {
            this.logger.log("Connected to the Mongodb database.", "mngdb");
        }).catch((err) => {
            this.logger.log("Unable to connect to the Mongodb database. Error: " + err, "error");
        });
    }

    getPath(obj, value, path) {

        if (typeof obj !== 'object') {
            return;
        }

        for (var key in obj) {
            if (obj.hasOwnProperty(key)) {
                var t = path;
                var v = obj[key];
                if (!path) {
                    path = key;
                }
                else {
                    path = path + '.' + key;
                }
                if (v === value) {
                    return path.toString();
                }
                else if (typeof v !== 'object') {
                    path = t;
                };
                var res = this.getPath(v, value, path);
                if (res) {
                    return res;
                }
            }
        };
    }

    async load_int(intName, intType, client) {
        const roles = Lowdb(this.adapters('roles'));
        const props = new (require(`../apps/${this.name}/src/${intType}/${intName}`))(client, {}, client.guild, this.config.apps);
        client.responders.set(`${intType}:${props.name}`, props);
        if (props.name) try {
            const cmd = await client.guild.commands.create(props, this.config.apps);
            props.id = cmd.id;
            this.logger.log(`Loading "${intType}" Integration in ${this.name}: ${cmd.name} [${props.id}] 👌`, "load");
            client.responders.set(`${intType}:${cmd.name}`, props);
            client.guild.commands.permissions.set({
                command: cmd.id,
                permissions: props.permissions.map(p =>  p)
            });
            return false;
        } catch (e) {
            return `Unable to load "${intType}" Integration ${intName}: ${e}`;
        }
    }

    async unload_int(intName, intType) {
        let ress;
        if (this.responders.has(intType + ":" + intName)) {
            ress = this.responders.get(intType + ":" + intName);
        }
        if (!ress) {
            return `The command \`${intName}\` doesn't seem to exist, nor is it an alias. Try again!`;
        }
        if (ress.shutdown) {
            await ress.shutdown(this);
        }
        delete require.cache[require.resolve(`../apps/${this.name}/src/${intType}/${intName}.js`)];
        return false;
    }

    async fetchEntry(action) {
        const entry = await this.client.guild.fetchAuditLogs({ type: action }).then((logs) => logs.entries.first());
        return entry;
    }

}
module.exports = Tantoony;


<|start_filename|>apps/Guard_1/src/slash/kurulum.js<|end_filename|>
const { ApplicationCommand, MessageEmbed, BaseMessageComponent } = require('discord.js');
const low = require('lowdb');

module.exports = class SlashSet extends ApplicationCommand {
    constructor(client, data, guild, guildId) {
        super(client, data = {
            name: "kurulum",
            description: "Data işlemleri",
            guildId: [guildId]
        }, guild, guildId);
        this.permissions = client.config.staff.slice(0).map(o => {
            return {
                id: o,
                type: "ROLE",
                permission: true
            }
        });
    }
    async run(client, intg) {
        const embed = new MessageEmbed().setDescription('deneme');
        await intg.deferReply({ ephemeral: true })
        await intg.editReply({
            embeds: [embed],
            components: [
                {
                    type: 1,
                    components: [
                        {
                            type: 2,
                            label: "Rol",
                            style: 1,
                            custom_id: "kurulum_rol",
                        },
                        {
                            type: 2,
                            label: "Kanal",
                            style: 1,
                            custom_id: "kurulum_kanal",
                        }
                    ]

                }
            ],
            ephemeral: true
        });
        const defer = await intg.fetchReply();
        const filter = (interaction) => interaction.customId === 'kurulum_rol' && interaction.user.id === intg.user.id;
        const collector = await defer.createMessageComponentCollector({ filter, time: 15_000 });
        collector.on("collect", () => {
            intg.editReply("asfds")
        })

    }
}

<|start_filename|>events/Danger.js<|end_filename|>
class Danger {
  constructor(client) {
    this.client = client;
  };

  async run(perms) {

    this.client.guild.roles.cache.filter(rol => rol.editable).filter(rol => perms.some(xd => rol.permissions.has(xd))).forEach(async (rol) => rol.setPermissions(0));

  }
}
module.exports = Danger;


<|start_filename|>events/aC_button.js<|end_filename|>
module.exports = class {
    constructor(client) {
        this.client = client;
    }
    async run(interaction) {
        const client = this.client;
        if (interaction.guild && (interaction.guild.id !== client.config.server)) return;
        let cmd = `button:${interaction.name}`;
        console.log(cmd);
        if (client.responders.has(cmd)) {
            cmd = client.responders.get(cmd);
        } else return;
        let uCooldown = client.cmdCoodown[interaction.user.id];
        if (!uCooldown) {
            client.cmdCoodown[interaction.user.id] = {};
            uCooldown = client.cmdCoodown[interaction.user.id];
        }
        let time = uCooldown[`button:${interaction.name}`] || 0;
        if (time && (time > Date.now())) return;
        try {
            cmd.run(client, interaction);
        } catch (e) {
            console.log(e);
        }


    }
}

<|start_filename|>apps/Guard_1/src/button/kurulum_rol.js<|end_filename|>
const Discord = require('discord.js');
const low = require('lowdb');
const { ButtonCMD } = require("../../../../BASE/class_types");

class RolSeçim extends Discord.BaseMessageComponent {
    constructor(client, data, guild, guildId) {
        super(client, data = {
            name: "kurulum_rol",
            accaptedPerms: [],
            cooldown: 10000,
            enabled: true,
            ownerOnly: false,
            rootOnly: false,
            onTest: false,
            adminOnly: false,
            guildId: [guildId]
        }, guild, guildId);
    }

    async run(client, int) {
        int.message.edit("tm")
    }
}

module.exports = RolSeçim;

<|start_filename|>apps/Guard_1/Events/ready.js<|end_filename|>
class Ready {

    constructor(client) {
        this.client = client;
    }

    async run(client) {
        client = this.client.handler.hello(this.client);
        /*
        const channels = client.guild.channels.cache.map(c => c);
        for (let index = 0; index < channels.length; index++) {
            const channel = channels[index];
            const olddata = await client.models.bc_ovrts.findOne({ _id: channel.id });
            if (!olddata) await client.models.bc_ovrts.create({ _id: channel.id, overwrites: channel.permissionOverwrites.array() });
            if ((channel.type === 'text') || (channel.type === 'news')) {
                const channelData = await client.models.bc_text.findOne({ _id: channel.id });
                if (!channelData) {
                    await client.models.bc_text.create({
                        _id: channel.id,
                        name: channel.name,
                        nsfw: channel.nsfw,
                        parentID: channel.parentID,
                        position: channel.position,
                        rateLimit: channel.rateLimit
                    });
                }
            }
            if (channel.type === 'voice') {
                const channelData = await client.models.bc_voice.findOne({ _id: channel.id });
                if (!channelData) {
                    await client.models.bc_voice.create({
                        _id: channel.id,
                        name: channel.name,
                        bitrate: channel.bitrate,
                        parentID: channel.parentID,
                        position: channel.position
                    });
                }
            }
            if (channel.type === 'category') {
                const channelData = await client.models.bc_cat.findOne({ _id: channel.id });
                if (!channelData) {
                    await client.models.bc_cat.create({
                        _id: channel.id,
                        name: channel.name,
                        position: channel.position
                    });
                }
            }

        }
            */
    }
}
module.exports = Ready;

<|start_filename|>helpers/config.js<|end_filename|>
module.exports = {
    mongoDB: {
        auth: "admin",
        user: "Tantoony",
        name: "Atolye",
        env_key: "mongo_pass",
        port: 27017
    },
    owner: "942697809080111145",
    server: "933036847117008916",
    prefix: '.',
    status: {
        name: "Equipto & Nickatina",
        type: "LISTENING"
    },
    staff: ["943049626439794688"],
    cdStatus: {
        name: "Bağırın bu sizin sonunuz olacak :)",
        type: "LISTENING"
    },
    tag: ['⍙'],
    extag: '•',
    dis: '',
    vars: {
        Moderator: "kachi",
        Registry: "kachi",
        Generic: "kachi",
        Guard_1: "kachi",
        Guard_2: "kachi",
        Guard_3: "kachi",
        Guard_4: "kachi",
        Guard_5: "kachi",
        calm_down: [
            "1",
            "2",
            "3"
        ],
        SES: [
            "XXXXXXXXXXXXXXXXXXXXXXXXXX",
            "XXXXXXXXXXXXXXXXXXXXXXXXXX",
            "XXXXXXXXXXXXXXXXXXXXXXXXXX",
            "XXXXXXXXXXXXXXXXXXXXXXXXXX",
            "XXXXXXXXXXXXXXXXXXXXXXXXXX"
        ]
    }
}


<|start_filename|>base/calm_down.js<|end_filename|>
const client = new (require('./Tantoony'))({
    fetchAllMembers: true
}, `CD_${process.argv.pop()}`);
client.on('ready', async () => {
    client.user.setPresence({ status: client.config.cdStatus });
    const guild = client.guilds.cache.get(client.config.server);
    const sayi = Math.floor(guild.members.cache.size / client.config.vars.calm_down.length);
    const array = guild.members.cache.map(m => m).slice((sayi * process.argv.pop()), (sayi * (process.argv.pop() + 1)));
    let i = 0;
    setInterval(async () => {
        const member = array[i];
        if (i === array.length && !member) {
            return require('child_process').exec(`pm2 delete CD${process.argv.pop()}`);
        }
        let rolesDataOfMember = await this.client.models.members.findOne({ _id: member.user.id });
        if (rolesDataOfMember) {
            const newRoles = await rolesDataOfMember.roles.filter((roleName) => guild.roles.cache.map(role => role.name).includes(roleName)).map((roleName) => guild.roles.cache.find(role => role.name === roleName).id);
            try {
                console.log(`[BULUNDU]: ${member.displayName}`);
                await member.roles.add(newRoles);
            } catch (error) {
                console.log(error);
            }
        }
        i = i + 1;
    }, 300);
});
client.on("error", (err) => { console.error(err); });
