sus

sus
mail@pastecode.io avatar
unknown
javascript
2 years ago
2.2 kB
2
Indexable
Never
const { Client, Collection } = require("discord.js");
const { readdirSync } = require("fs");
require("./util/extenders")
const { token } = require("./config.json");
const db = require("mongoose")
const client = new Client({
    partials: ["USER", "CHANNEL", "GUILD_MEMBER", "MESSAGE", "REACTION"],
    intents: [
        "GUILD_MEMBERS",
        "GUILDS",
        "GUILD_VOICE_STATES",
        "GUILD_MESSAGES",
        "GUILD_MESSAGE_REACTIONS",
        "GUILD_BANS",
        "GUILD_INVITES",
        "GUILD_VOICE_STATES",
        "DIRECT_MESSAGES",
        "GUILD_INTEGRATIONS",
        "GUILD_WEBHOOKS",
        "GUILD_MESSAGE_TYPING",
        "DIRECT_MESSAGES",
        "DIRECT_MESSAGE_REACTIONS",
        "DIRECT_MESSAGE_TYPING",
        "GUILD_MESSAGE_REACTIONS",
    ],
});

client.commands = new Collection();
client.alias = new Collection();
client.slashs = new Collection();

let m1 = Date.now();
readdirSync("./events").forEach(dir => {
    readdirSync(`./events/${dir}`).forEach(evt => {
        const file = require(`./events/${dir}/${evt}`);
        client.on(dir, file.bind(null, client))
    })
})
let m2 = Date.now();
console.log(`[BOT] Le client à chargé les évenements en ${m2 - m1}ms.`);

m1 = Date.now();
readdirSync("./commands").forEach(dir => {
    readdirSync(`./commands/${dir}`).forEach(cmd => {
        const file = require(`./commands/${dir}/${cmd}`);
        client.commands.set(file.help.name, file);
        if (file.help.alias) {
            file.help.alias.forEach(alias => {
                client.alias.set(alias, file)
            })
        };
    });
});
readdirSync("./Slash-commands").forEach(dir => {
    readdirSync(`./Slash-commands/${dir}`).forEach(cmd => {
        const file = require(`./Slash-commands/${dir}/${cmd}`);
        client.slashs.set(file.data.name, file);
    });
});
m2 = Date.now();
console.log(`[BOT] Le client à chargé les commandes en ${m2 - m1}ms.`);
m1 = Date.now();
db.connect("sus").then(db => {
    m2 = Date.now();
    console.log(`[BOT] Le client s'est connecté a la database "${db.connections[0].name}" en ${m2 - m1}ms.`)

    client.login(token).catch(() => { console.log() });
}).catch(console.error)