This repository has been archived by the owner on Oct 4, 2020. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
72 lines (61 loc) · 2.08 KB
/
index.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
const Discord = require('discord.js');
require('dotenv').config()
const neuralnetwork = require('./utils/neural.network');
var request = require('request');
var socket = require('socket.io-client')('https://api.macedon.ga');
const { settings } = require('./data/variables');
const fs = require('fs');
const client = new Discord.Client();
client.commands = new Discord.Collection();
const commandFiles = fs.readdirSync('./commands').filter(file => file.endsWith('.js'));
for (const file of commandFiles) {
const command = require(`./commands/${file}`);
client.commands.set(command.name, command);
console.log(`Command loaded: ${file}`);
}
const eventFiles = fs.readdirSync('./events').filter(file => file.endsWith('.js'));
for (const file of eventFiles) {
const event = require(`./events/${file}`);
client.on(file.replace(".js", ""), event.bind(null, client));
console.log(`Event loaded: ${file}`);
}
socket.on('settings update', function(data) {
request.post('https://api.macedon.ga/mdbu/settings/get', { json: { sid: data } }, function(error, response, body) {
if (body[0].sid) {
settings[data] = [];
settings[data].push(body[0]);
}
});
});
socket.on('get channels', function(data) {
try {
var guild = client.guilds.cache.get(data);
var ch = {};
guild.channels.cache.forEach(channel => {
if (channel.type === "text")
ch[channel.id] = {
name: channel.name
};
});
socket.emit('return channels', ch);
} catch {
socket.emit('error');
}
});
socket.on('get categories', function(data) {
try {
var guild = client.guilds.cache.get(data);
var ch = {};
guild.channels.cache.forEach(channel => {
if (channel.type === "category")
ch[channel.id] = {
name: channel.name
};
});
socket.emit('return categories', ch);
} catch {
socket.emit('error');
}
});
neuralnetwork.init();
client.login(process.env.TOKEN);