-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
85 lines (69 loc) · 2.85 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
73
74
75
76
77
78
79
80
81
82
83
84
85
/*
RakBot - Zaracza kanał
https://discordapp.com/oauth2/authorize?access_type=online&client_id=368126162024529920&redirect_uri=https%3A%2F%2Frakbot.glitch.me&scope=bot&permissions=3148800
*/
require("dotenv").config();
const Discord = require('discord.js');
const fs = require("fs");
const client = new Discord.Client();
const utils = require("./utils.js");
const commandPrefix = /^&/;
var modules = [];
modules.push(require("./modules/commands/help.js"));
modules.push(require("./modules/commands/clean.js"));
modules.push(require("./modules/commands/emoji.js"));
modules.push(require("./modules/commands/say.js"));
modules.push(require("./modules/commands/e621.js"));
modules.push(require("./modules/commands/4chan.js"));
modules.push(require("./modules/commands/reddit.js"));
modules.push(require("./modules/commands/petittube.js"));
modules.push(require("./modules/commands/kurwa.js"));
modules.push(require("./modules/commands/sonda.js"));
modules.push(require("./modules/commands/bash.js"));
modules.push(require("./modules/commands/calc.js"));
modules.push(require("./modules/commands/translate.js"));
modules.push(require("./modules/commands/rand.js"));
modules.push(require("./modules/commands/roll.js"));
modules.push(require("./modules/commands/krypto.js"));
modules.push(require("./modules/anti-rak.js"));
modules.push(require("./modules/macro.js"));
modules.push(require("./modules/ddg.js"));
modules.push(require("./modules/nano.js"));
const context = {
client: client,
modules: modules,
utils: utils,
commandPrefix: commandPrefix
};
client.on('error', console.error);
client.on('message', message => {
if(!message.author.bot){
console.log("<" + message.author.tag + "> " + message.content);
if(message.content.match(commandPrefix) != null) message.isRakbotCmd = true;
let commandFound = false;
for(var i = 0; i < modules.length; i++){
if(message.isRakbotCmd && modules[i].command && !commandFound){
if(message.content.match(new RegExp(commandPrefix.source + modules[i].regex.source)) != null){
modules[i].onInvoke(context, message);
commandFound = true;
}
}
if(modules[i].onMessage){
modules[i].onMessage(context, message);
}
}
}
});
client.on('ready', () => {
console.log('ready to rak!');
client.user.setActivity('&help • www.rak.bot.nu', { type: 'PLAYING' });
});
if(!fs.existsSync("./assets/")) fs.mkdirSync("assets"); // Make sure the assets dir exists, for module compatibility reasons.
for(var i = 0; i < modules.length; i++){
if(modules[i].onStart) modules[i].onStart(context);
}
client.login(process.env.DISCORD_API_KEY);
// utility bullshit whatever lol
Math.randomRange = function(min, max) {
return Math.floor(Math.random() * (max - min) + min);
};