1
0
mirror of https://github.com/musix-org/musix-oss synced 2024-11-10 05:10:17 +00:00
musix-oss/index.js

84 lines
2.8 KiB
JavaScript
Raw Normal View History

2019-09-15 06:18:33 +00:00
const Discord = require('discord.js');
2019-08-02 08:32:00 +00:00
const { Collection, Client, RichEmbed } = require('discord.js');
2019-09-15 06:18:33 +00:00
const client = new Discord.Client({ disableEveryone: true, disabledEvents: ['TYPING_START'] });
2019-08-02 08:32:00 +00:00
const ytdl = require('ytdl-core');
2019-09-15 06:18:33 +00:00
const fs = require('fs');
const dotenv = require('dotenv');
const firebase = require('firebase/app');
const admin = require('firebase-admin');
const serviceAccount = require('./serviceAccount.json');
require('dotenv/config');
admin.initializeApp({
credential: admin.credential.cert(serviceAccount),
});
client.db = admin.firestore();
client.db.FieldValue = require('firebase-admin').firestore.FieldValue;
2019-08-02 08:32:00 +00:00
client.commands = new Collection();
2019-09-15 06:18:33 +00:00
client.events = new Collection();
2019-08-02 08:32:00 +00:00
client.cooldowns = new Collection();
client.queue = new Map();
2019-09-15 06:18:33 +00:00
client.funcs = {};
client.funcs.setPrefix = require('./funcs/setPrefix.js');
client.funcs.handleVideo = require('./funcs/handleVideo.js');
client.funcs.play = require('./funcs/play.js');
2019-08-02 08:32:00 +00:00
client.config = {
2019-09-15 06:18:33 +00:00
token: process.env.MUSIX_TOKEN,
apikey: process.env.API_KEY,
prefix: '>',
test: 'success',
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}`);
client.commands.set(command.name, command);
}
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
}
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));
event.execute(client);
2019-08-02 08:32:00 +00:00
});
2019-09-15 06:18:33 +00:00
client.on('message', message => {
const eventName = 'message';
const event = client.events.get(eventName) || client.events.find(ent => ent.aliases && ent.aliases.includes(eventName));
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
2019-09-15 06:18:33 +00:00
client.on('guildDelete', (guild) => {
const eventName = 'guilddelete';
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
2019-09-15 06:18:33 +00:00
client.on('guildMemberRemove', () => {
const eventName = 'guildmemberremove';
const event = client.events.get(eventName) || client.events.find(ent => ent.aliases && ent.aliases.includes(eventName));
event.execute(client);
});
2019-08-02 08:32:00 +00:00
2019-09-15 06:18:33 +00:00
client.on('guildMemberAdd', () => {
const eventName = 'guildmemberadd';
const event = client.events.get(eventName) || client.events.find(ent => ent.aliases && ent.aliases.includes(eventName));
event.execute(client);
});
2019-08-02 08:32:00 +00:00
client.login(client.config.token);