2020-03-02 19:38:42 +00:00
|
|
|
const { Client, Collection } = require('discord.js');
|
|
|
|
const Discord = require('discord.js');
|
|
|
|
const fs = require('fs');
|
2020-03-08 23:26:24 +00:00
|
|
|
const path = require('path');
|
2020-04-02 05:40:05 +00:00
|
|
|
const events = './events/';
|
2020-03-31 06:53:58 +00:00
|
|
|
const Datastore = require('./datastore.js');
|
2020-03-02 19:38:42 +00:00
|
|
|
|
2020-08-22 17:19:09 +00:00
|
|
|
const GatewayIntents = new Discord.Intents();
|
|
|
|
GatewayIntents.add(
|
|
|
|
1 << 0, // GUILDS
|
|
|
|
1 << 7, // GUILD_VOICE_STATES
|
|
|
|
1 << 9 // GUILD_MESSAGES
|
|
|
|
);
|
|
|
|
|
2020-03-02 19:38:42 +00:00
|
|
|
module.exports = class extends Client {
|
|
|
|
constructor() {
|
|
|
|
super({
|
|
|
|
disableEveryone: true,
|
2020-08-22 17:19:09 +00:00
|
|
|
disabledEvents: ['TYPING_START'],
|
|
|
|
ws: {
|
|
|
|
intents: GatewayIntents
|
|
|
|
}
|
2020-03-02 19:38:42 +00:00
|
|
|
});
|
|
|
|
this.commands = new Collection();
|
|
|
|
this.commandAliases = new Collection();
|
|
|
|
this.radio = new Map();
|
2020-04-02 05:13:51 +00:00
|
|
|
|
2020-03-02 19:38:42 +00:00
|
|
|
this.funcs = {};
|
2020-04-02 05:40:05 +00:00
|
|
|
this.funcs.check = require('./funcs/check.js');
|
2020-04-04 23:29:39 +00:00
|
|
|
this.funcs.checkFetchStatus = require('./funcs/checkFetchStatus.js');
|
|
|
|
this.funcs.isDev = require('./funcs/isDev.js');
|
2020-04-02 05:40:05 +00:00
|
|
|
this.funcs.msToTime = require('./funcs/msToTime.js');
|
|
|
|
this.funcs.statisticsUpdate = require('./funcs/statisticsUpdate.js');
|
2020-04-02 05:13:51 +00:00
|
|
|
|
2020-04-02 07:07:27 +00:00
|
|
|
this.config = require('../config.js');
|
2020-03-12 22:53:23 +00:00
|
|
|
this.messages = require('./messages.js');
|
2020-03-02 19:38:42 +00:00
|
|
|
|
2020-04-02 07:15:08 +00:00
|
|
|
const commandFiles = fs.readdirSync('./client/commands/').filter(f => f.endsWith('.js'));
|
2020-03-02 19:38:42 +00:00
|
|
|
for (const file of commandFiles) {
|
2020-04-02 05:40:05 +00:00
|
|
|
const command = require(`./commands/${file}`);
|
2020-03-02 19:38:42 +00:00
|
|
|
command.uses = 0;
|
|
|
|
this.commands.set(command.name, command);
|
|
|
|
this.commandAliases.set(command.alias, command);
|
|
|
|
}
|
|
|
|
|
|
|
|
this.on('ready', () => {
|
|
|
|
require(`${events}ready`).execute(this, Discord);
|
2020-03-31 06:53:58 +00:00
|
|
|
this.datastore = new Datastore();
|
2020-03-02 19:38:42 +00:00
|
|
|
});
|
|
|
|
this.on('message', (msg) => {
|
|
|
|
require(`${events}msg`).execute(this, msg, Discord);
|
|
|
|
});
|
2020-03-07 20:07:54 +00:00
|
|
|
this.on('voiceStateUpdate', (oldState, newState) => {
|
|
|
|
require(`${events}voiceStateUpdate`).execute(this, oldState, newState);
|
2020-03-02 19:38:42 +00:00
|
|
|
});
|
|
|
|
this.on('error', (error) => {
|
2020-03-12 09:59:05 +00:00
|
|
|
console.error(error);
|
2020-03-02 19:38:42 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
this.login(this.config.token).catch(err => console.log('Failed to login: ' + err));
|
|
|
|
}
|
|
|
|
};
|