2019-09-15 06:18:33 +00:00
|
|
|
const Discord = require('discord.js');
|
|
|
|
const client = new Discord.Client({ disableEveryone: true, disabledEvents: ['TYPING_START'] });
|
2019-10-10 13:43:04 +00:00
|
|
|
const DBL = require("dblapi.js");
|
2019-10-11 11:27:20 +00:00
|
|
|
const dbl = new DBL(process.env.DBLTOKEN, client);
|
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-10-10 13:43:04 +00:00
|
|
|
client.global = {
|
|
|
|
db: {
|
|
|
|
guilds: {},
|
2019-10-12 14:40:00 +00:00
|
|
|
playlists: {},
|
2019-10-10 13:43:04 +00:00
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
client.commands = new Discord.Collection();
|
|
|
|
client.events = new Discord.Collection();
|
|
|
|
client.cooldowns = new Discord.Collection();
|
2019-08-02 08:32:00 +00:00
|
|
|
client.queue = new Map();
|
2019-09-15 06:18:33 +00:00
|
|
|
client.funcs = {};
|
|
|
|
|
|
|
|
client.funcs.handleVideo = require('./funcs/handleVideo.js');
|
|
|
|
client.funcs.play = require('./funcs/play.js');
|
2019-10-10 13:43:04 +00:00
|
|
|
client.funcs.msToTime = require('./funcs/msToTime.js');
|
|
|
|
client.funcs.dbget = require('./funcs/dbget.js');
|
2019-09-15 06:18:33 +00:00
|
|
|
|
2019-08-02 08:32:00 +00:00
|
|
|
client.config = {
|
2019-10-13 18:07:46 +00:00
|
|
|
token: process.env.TOKEN,
|
2019-10-13 07:33:59 +00:00
|
|
|
apikey: process.env.API_KEY,
|
2019-09-15 06:18:33 +00:00
|
|
|
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));
|
2019-10-10 13:43:04 +00:00
|
|
|
event.execute(client, dbl);
|
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));
|
2019-10-10 13:43:04 +00:00
|
|
|
event.execute(client, message, Discord);
|
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-10-10 13:43:04 +00:00
|
|
|
dbl.on('error', error => {
|
|
|
|
console.log(`Error with DBL! ${error}`);
|
|
|
|
})
|
2019-08-02 08:32:00 +00:00
|
|
|
|
2019-10-10 13:43:04 +00:00
|
|
|
client.login(client.config.token).catch(err => { console.log('- Failed To Login -> ' + err); });
|