1
0
mirror of https://github.com/musix-org/musix-oss synced 2024-11-14 03:30:18 +00:00
musix-oss/index.js

51 lines
1.9 KiB
JavaScript
Raw Normal View History

2019-09-15 06:18:33 +00:00
const Discord = require('discord.js');
2024-02-09 09:53:30 +00:00
const MusicClient = require('./Client');
2019-12-05 13:17:15 +00:00
const client = new MusicClient({});
2019-09-15 06:18:33 +00:00
const fs = require('fs');
2019-08-02 08:32:00 +00:00
const commandFiles = fs.readdirSync('./commands/').filter(f => f.endsWith('.js'));
for (const file of commandFiles) {
2019-09-15 06:18:33 +00:00
const command = require(`./commands/${file}`);
2019-11-25 18:48:56 +00:00
command.uses = 0;
2019-09-15 06:18:33 +00:00
client.commands.set(command.name, command);
client.commandAliases.set(command.alias, command);
2019-09-15 06:18:33 +00:00
}
2019-11-01 12:37:31 +00:00
2019-09-15 06:18:33 +00:00
const eventFiles = fs.readdirSync('./events/').filter(f => f.endsWith('.js'));
for (const file of eventFiles) {
const event = require(`./events/${file}`);
client.events.set(event.name, event);
2019-08-02 08:32:00 +00:00
}
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);
}
2019-09-15 06:18:33 +00:00
client.on('ready', async () => {
const eventName = 'ready';
const event = client.events.get(eventName) || client.events.find(ent => ent.aliases && ent.aliases.includes(eventName));
2024-02-09 09:53:30 +00:00
event.execute(client);
2019-08-02 08:32:00 +00:00
});
2024-02-09 09:53:30 +00:00
client.on('messageCreate', message => {
2019-09-15 06:18:33 +00:00
const eventName = 'message';
const event = client.events.get(eventName) || client.events.find(ent => ent.aliases && ent.aliases.includes(eventName));
2024-02-09 09:53:30 +00:00
event.execute(client, message);
2019-08-02 08:32:00 +00:00
});
2019-09-15 06:18:33 +00:00
client.on('guildCreate', async (guild) => {
const eventName = 'guildcreate';
const event = client.events.get(eventName) || client.events.find(ent => ent.aliases && ent.aliases.includes(eventName));
event.execute(client, guild);
});
2019-08-02 08:32:00 +00:00
2024-02-09 09:53:30 +00:00
client.login(client.config.discord_api_token).catch(err => { console.log('- Failed To Login -> ' + err); });