2020-04-20 16:56:23 +00:00
|
|
|
const {
|
|
|
|
Client,
|
2020-06-08 12:39:32 +00:00
|
|
|
Collection,
|
|
|
|
Intents
|
2020-04-20 16:56:23 +00:00
|
|
|
} = require("discord.js");
|
2020-04-19 17:00:16 +00:00
|
|
|
const admin = require("firebase-admin");
|
|
|
|
const serviceAccount = require("./config/serviceAccount.json");
|
|
|
|
const fs = require("fs");
|
|
|
|
const path = require("path");
|
2020-04-20 16:56:23 +00:00
|
|
|
const events = require("../events/events.js");
|
2020-02-05 20:02:53 +00:00
|
|
|
|
2020-06-08 12:39:32 +00:00
|
|
|
const myIntents = new Intents();
|
|
|
|
myIntents.add(
|
|
|
|
1 << 0, // GUILDS
|
|
|
|
1 << 7, // GUILD_VOICE_STATES
|
|
|
|
1 << 9, // GUILD_MESSAGES
|
|
|
|
);
|
|
|
|
|
2020-02-05 20:02:53 +00:00
|
|
|
module.exports = class extends Client {
|
2020-04-19 17:00:16 +00:00
|
|
|
constructor() {
|
|
|
|
super({
|
|
|
|
disableEveryone: true,
|
|
|
|
disabledEvents: ["TYPING_START"],
|
2020-06-08 12:39:32 +00:00
|
|
|
ws: {
|
|
|
|
intents: myIntents
|
|
|
|
}
|
2020-04-19 17:00:16 +00:00
|
|
|
});
|
2020-03-19 14:45:05 +00:00
|
|
|
|
2020-04-19 17:00:16 +00:00
|
|
|
admin.initializeApp({
|
|
|
|
credential: admin.credential.cert(serviceAccount),
|
|
|
|
});
|
|
|
|
this.commands = new Collection();
|
|
|
|
this.commandAliases = new Collection();
|
|
|
|
this.settingCmd = new Collection();
|
|
|
|
this.queue = new Map();
|
|
|
|
this.funcs = {};
|
|
|
|
this.dispatcher = {};
|
2020-04-21 11:29:36 +00:00
|
|
|
this.config = require("./config/config.js");
|
2020-04-20 16:56:23 +00:00
|
|
|
this.messages = require("./config/messages.js");
|
2020-04-19 17:00:16 +00:00
|
|
|
this.db = admin.firestore();
|
|
|
|
this.db.FieldValue = require("firebase-admin").firestore.FieldValue;
|
2020-04-20 16:56:23 +00:00
|
|
|
this.dispatcher.finish = require("../events/dispatcherEvents/finish.js");
|
|
|
|
this.dispatcher.error = require("../events/dispatcherEvents/error.js");
|
2020-04-19 17:00:16 +00:00
|
|
|
this.global = {
|
|
|
|
db: {
|
|
|
|
guilds: {},
|
|
|
|
},
|
|
|
|
};
|
2020-02-05 20:02:53 +00:00
|
|
|
|
2020-04-19 17:00:16 +00:00
|
|
|
fs.readdirSync(path.join(__dirname, "funcs")).forEach((filename) => {
|
|
|
|
this.funcs[filename.slice(0, -3)] = require(`./funcs/${filename}`);
|
|
|
|
});
|
2020-02-05 20:02:53 +00:00
|
|
|
|
2020-04-19 17:00:16 +00:00
|
|
|
const commandFiles = fs
|
|
|
|
.readdirSync(path.join(path.dirname(__dirname), "commands"))
|
2020-04-20 16:56:23 +00:00
|
|
|
.filter((f) => f.endsWith(".js"));
|
2020-04-19 17:00:16 +00:00
|
|
|
for (const file of commandFiles) {
|
|
|
|
const command = require(`../commands/${file}`);
|
|
|
|
command.uses = 0;
|
|
|
|
this.commands.set(command.name, command);
|
|
|
|
this.commandAliases.set(command.alias, command);
|
|
|
|
}
|
|
|
|
const settingFiles = fs
|
|
|
|
.readdirSync(path.join(path.dirname(__dirname), "commands/settings"))
|
2020-04-20 16:56:23 +00:00
|
|
|
.filter((f) => f.endsWith(".js"));
|
2020-04-19 17:00:16 +00:00
|
|
|
for (const file of settingFiles) {
|
|
|
|
const option = require(`../commands/settings/${file}`);
|
|
|
|
this.settingCmd.set(option.name, option);
|
|
|
|
}
|
|
|
|
if (this.config.devMode) {
|
|
|
|
this.config.token = this.config.devToken;
|
|
|
|
}
|
2020-02-05 20:02:53 +00:00
|
|
|
|
2020-04-19 17:00:16 +00:00
|
|
|
events(this);
|
2020-06-09 19:11:12 +00:00
|
|
|
|
2020-04-19 17:00:16 +00:00
|
|
|
this.login(this.config.token).catch((err) =>
|
|
|
|
console.log("Failed to login: " + err)
|
|
|
|
);
|
|
|
|
}
|
2020-04-20 16:56:23 +00:00
|
|
|
};
|