-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
145 lines (109 loc) · 3.87 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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
const http = require('http');
const express = require('express');
const app = express();
app.get("/", (request, response) => {
response.sendStatus(200);
});
app.listen(process.env.PORT);
setInterval(() => {
http.get(`http://${process.env.PROJECT_DOMAIN}.glitch.me/`);
}, 280000);
const Discord = require("discord.js");
const {MessageEmbed, Client, Collection } = Discord;
const client = new Discord.Client({disableEveryone : true});//();
const Set = new Collection();
const fs = require("fs");
const chalk = require("chalk");
const moment = require("moment");
console.log(process.memoryUsage);
const config = require ("/app/config.json");
client.on('ready',()=>{
console.log(client.guilds.size);
client.user.setActivity(` ${config.prefix}help for help` , {url: "http://twitch.tv/pikacord", type: "STREAMING"});
console.log("ReaDY");
});
client.patrons = ['258961364939309056'];
client.on("guildMemberRemove", (member) => {
if(member.guild.id === "278135637293531136"&& client.points.has(member.id)) {
client.points.delete(member.id)}});
const settings = require("./config.json");
client.emotes = require ("./util/emojis.json");
client.animate = (id, name) => `<a:${name}:${id}>`;
client.getImage = (img) => `https://raw.githubusercontent.com/ArunKapil01/Pikachuimages/master/images/${img}`;
client.danceEmote = client.animate (client.emotes.Pika_Dance, "Pika_Dance")
client.dance = (m) => m.react(client.emojis.get(client.emotes.Pika_Dance));
client.capFL = (string) => string.charAt(0).toUpperCase() + string.slice(1);
if(process.version.slice(1).split('.')[0]<8) throw new Error('Node 8.0.0 or higher is required. Update Node on your system.');
require("./util/eventLoader.js")(client);
client.login(process.env.TOKEN);
const log = message => {
console.log(`[${moment().format('YYYY-MM-DD HH:mm:ss')}] ${message}`);
};
// Collections
client.commands = new Collection();
client.aliases = new Collection();
client.modules = new Collection();
fs.readdir('./commands/', (err, files) => {
if (err) console.error(err);
log(`Loading a total of ${files.length} commands.`);
files.forEach(f => {
let props = require(`./commands/${f}`);
// log(`Loading Command: ${props.help.name}`);
client.commands.set(props.help.name, props);
props.conf.aliases.forEach(alias => {
client.aliases.set(alias, props.help.name);
});
});
});
fs.readdir('./modules/', (err, modules) => {
if (err) console.error(err);
log(`Loading a total of ${modules.length} modules.`);
modules.forEach(m => {
let loadData = require(`./modules/${m}`);
// log(`Loading Module: ${loadData.moduledata.name}`);
client.modules.set(loadData.moduledata.name, loadData);
});
});
fs.readdir('./events/', (err, events) => {
if (err) console.error(err);
log(`Loading a total of ${events.length} events.`);
events.forEach(e => {
let loadData = require(`./events/${e}`);
// log(`Loading Event: ${e}`);
});
});
client.reload = command => {
return new Promise((resolve, reject) => {
try {
delete require.cache[require.resolve(`./commands/${command}`)];
let cmd = require(`./commands/${command}`);
client.commands.delete(command);
client.aliases.forEach((cmd, alias) => {
if (cmd === command) client.aliases.delete(alias);
});
client.commands.set(command, cmd);
cmd.conf.aliases.forEach(alias => {
client.aliases.set(alias, cmd.help.name);
});
resolve();
} catch (e){
reject(e);
}
});
};
client.elevation = message => {
let permlvl = 0;
if (message.author.id === config.botOwner) permlvl = 4;
return permlvl;
};
/**//*
process.on("unhandledRejection", err => {
console.log(err.stack);
});/**/
process.on('unhandledRejection', function(reason, p){
console.log("Possibly Unhandled Rejection at: Promise ", p, " reason: ", reason);
//
//
//
// application specific logging here
});