57 lines
1.6 KiB
JavaScript
57 lines
1.6 KiB
JavaScript
|
const { Client, Collection } = require('discord.js');
|
||
|
const { readdirSync: read } = require('fs');
|
||
|
|
||
|
const server = require('../../server/server');
|
||
|
|
||
|
module.exports = class Musik extends Client {
|
||
|
constructor(config, shards) {
|
||
|
super({
|
||
|
disableEveryone: true,
|
||
|
disabledEvents: ['TYPING_START'],
|
||
|
shardCount: shards,
|
||
|
totalShardCount: shards
|
||
|
});
|
||
|
|
||
|
this.commands = new Collection();
|
||
|
this.cooldowns = new Collection();
|
||
|
this.queues = new Collection();
|
||
|
this.config = config;
|
||
|
|
||
|
this.lastEval = null;
|
||
|
|
||
|
this.load();
|
||
|
this.login(config.token);
|
||
|
}
|
||
|
|
||
|
async load() {
|
||
|
const events = await read('./events');
|
||
|
const modules = await read('./modules');
|
||
|
|
||
|
// server(this)
|
||
|
|
||
|
events.filter(f => f.endsWith('.js')).forEach(file => {
|
||
|
try {
|
||
|
const event = require(`../../events/${file}`);
|
||
|
|
||
|
this.on(event.name, event.run.bind(null, this));
|
||
|
} catch(err) {
|
||
|
console.error(err);
|
||
|
}
|
||
|
});
|
||
|
|
||
|
modules.filter(f => !f.endsWith('.js')).forEach(async (module) => {
|
||
|
const commands = await read(`./modules/${module}`);
|
||
|
|
||
|
commands.filter(f => f.endsWith('.js')).forEach(command => {
|
||
|
try {
|
||
|
const file = require(`../../modules/${module}/${command}`);
|
||
|
const Command = new file();
|
||
|
|
||
|
this.commands.set(Command.name, Command);
|
||
|
} catch(err) {
|
||
|
console.error(err);
|
||
|
}
|
||
|
});
|
||
|
});
|
||
|
}
|
||
|
}
|