1
0
mirror of https://github.com/musix-org/musix-oss synced 2025-08-01 20:54:33 +00:00

Option handler for playlists and settings. Exe function to execute command files. Command aliases updated.

This commit is contained in:
MatteZ02
2019-10-31 20:29:26 +02:00
parent 1899c8647b
commit 8615735431
33 changed files with 392 additions and 277 deletions

View File

@@ -23,6 +23,9 @@ client.global = {
};
client.commands = new Discord.Collection();
client.commandAliases = new Discord.Collection();
client.playlistCmd = new Discord.Collection();
client.settingCmd = new Discord.Collection();
client.events = new Discord.Collection();
client.cooldowns = new Discord.Collection();
client.queue = new Map();
@@ -32,17 +35,21 @@ client.funcs.handleVideo = require('./funcs/handleVideo.js');
client.funcs.play = require('./funcs/play.js');
client.funcs.msToTime = require('./funcs/msToTime.js');
client.funcs.dbget = require('./funcs/dbget.js');
client.funcs.exe = require('./funcs/exe.js');
client.config = {
token: process.env.TOKEN,
apikey: process.env.API_KEY,
botId: "607266889537945605",
devId: "360363051792203779",
prefix: '>',
test: 'success',
};
const commandFiles = fs.readdirSync('./commands/').filter(f => f.endsWith('.js'));
for (const file of commandFiles) {
const command = require(`./commands/${file}`);
client.commands.set(command.name, command);
client.commandAliases.set(command.alias, command);
}
const eventFiles = fs.readdirSync('./events/').filter(f => f.endsWith('.js'));
for (const file of eventFiles) {
@@ -50,6 +57,18 @@ for (const file of eventFiles) {
client.events.set(event.name, event);
}
const playlistFiles = fs.readdirSync('./commands/playlist/').filter(f => f.endsWith('.js'));
for (const file of playlistFiles) {
const option = require(`./commands/playlist/${file}`);
client.playlistCmd.set(option.name, option);
}
const settingFiles = fs.readdirSync('./commands/settings/').filter(f => f.endsWith('.js'));
for (const file of settingFiles) {
const option = require(`./commands/settings/${file}`);
client.settingCmd.set(option.name, option);
}
client.on('ready', async () => {
const eventName = 'ready';
const event = client.events.get(eventName) || client.events.find(ent => ent.aliases && ent.aliases.includes(eventName));