This repository has been archived by the owner on May 19, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
51 lines (42 loc) · 1.43 KB
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import discord from 'discord.js';
import { RootCommand } from './commands/root';
import { Handlers } from './handlers/handlers';
import fs from 'fs';
import { VoiceManager, YoutubeStreamer } from './voice_manager';
class App
{
constructor(client, settings)
{
this.settings = settings;
this.client = client;
this.guild = getByID(this.client.guilds, settings.guild); // Popcorn.moe :)
this.botsChannel = getByID(this.guild.channels, settings.channel.bots); // #bots
this.featuresChannel = getByID(this.guild.channels, settings.channel.features); // #features
this.commandChannels = settings.commandChannels.map(channel => getByID(this.guild.channels, channel));
this.rootCommand = new RootCommand(this);
this.handlers = new Handlers(this);
this.voiceManager = new VoiceManager(this);
}
init()
{
this.handlers.init();
}
}
function getByID(smth, id)
{
return smth.array()
.find(o => o.id == id); // #bots
}
const client = new discord.Client();
client.on('ready', () =>
{
fs.readFile(__dirname + '/settings.json',
(err, data) =>
{
if (err) throw err;
console.log('Settings loaded');
new App(client, JSON.parse(data)).init();
});
console.log(`Logged in as ${client.user.tag}!`);
});
client.login(process.env.POPCORN_MOE_DISCORD_TOKEN);