This repository has been archived by the owner on Aug 2, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
228 lines (214 loc) · 8.38 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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
//coded by firec, tttie, a jew (jeuxjeux20) and cth103 'use strict';
//var mongo = require('mongodb').MongoClient;
//var R6Stats = require('r6stats');
var fs = require("fs")
const uri = process.env.mongouri
const Eris = require("eris");
var token = process.env.token; //dont fricking leak
// mongo.connect(uri, function(err, db) {
global.prefixes = JSON.parse(fs.readFileSync("./prefixes.json", "utf8")) // get prefixesssss
var bot = new Eris(process.env.token);
var json = JSON.parse(fs.readFileSync('package.json', 'utf8')) //find version of bot
global.version = json.version
var prefix = "~";
const spy = false;
function dbots() {
var https = require("https");
var authToken = process.env.dbl;
var options = {
hostname: "bots.discord.pw",
path: "/api/bots/255397678492418048/stats",
method: "POST",
headers: {
"Content-Type": "application/json",
"Authorization": authToken
}
};
var req = https.request(options, function(res) {
res.setEncoding("utf8");
res.on("data", function(body) {});
});
req.on("error", function(e) {
console.log("problem with request: " + e.message);
});
// write data to request body
req.write(`{"server_count" : ${bot.guilds.length}}`);
req.end();
}
//anyone can set the custom prefix, isnt that right.
var customprefix = "meg!";
var ah = "";
exports.customprefix = customprefix;
//jew shit
var AllGames = ["With Aqua \u2764", "With Darkness \u2764", "With Kazuma \u2764", "With Wiz \u2764", "With Yunyun \u2764", "With Komekko \u2764", "With code!", "With Fire \uD83D\uDD25"];
try {
var cmds = new Array();
//load
let loadAll = function() {
let fa = fs.readdirSync("./");
for (let i = 0; i < fa.length; i++) {
let cmF = fa[i];
if (cmF.endsWith(".js")) {
var name = cmF.split(".js")[0];
if (name != "index") {
cmds[name.replace("cmd_", "")] = require("./" + name + ".js")
console.log(cmF.split(".js")[0] + ".js")
}
}
}
}
var cmdso = new Array();
let loadOWNRcmds = function() {
let fa = fs.readdirSync("./owner/");
for (let i = 0; i < fa.length; i++) {
let cmFo = fa[i];
if (cmFo.endsWith(".js")) {
var name = cmFo.split(".js")[0];
if (name != "index") {
cmdso[name.replace("cmd_", "")] = require("./owner/" + name + ".js")
console.log(cmFo.split(".js")[0] + ".js (OWNER COMMAND)")
}
}
}
}
function setGame(ok) {
var game = {
name: ok
};
bot.editStatus("online", game);
}
Object.defineProperty(Eris.Message.prototype, "guild", {
get: function() {
return this.channel.guild;
}
})
bot.on("ready", () => {
setGame(AllGames[Math.floor(AllGames.length * Math.random())] + " | ~help (" + bot.guilds.size + " Guilds)")
console.log("Megumin, The discord bot Copyright (C) 2018 Jiktim (Jimmy Team)");
console.log("This program comes with ABSOLUTELY NO WARRANTY");
console.log("This is free software, and you are welcome to redistribute it under certain conditions.");
if (spy == true) {
console.log("Message logging is on! all messages will be logged to ./logs/msglog");
} else {
console.log("Message logging is off!");
}
console.log("loading...");
loadAll();
loadOWNRcmds();
console.log("I am ready, BEEP BOOP."); // log when the bot is ready
//483695377950834688
setInterval(function() {
setGame(AllGames[Math.floor(AllGames.length * Math.random())] + " | ~help (" + bot.guilds.size + " Guilds)")
}, 180000); //set the game
/*bot.guilds.find(fn => fn.id == "476892731554136074").roles.find(fn => fn.name == "placeholder").edit({
name: ""
})*/
dbots();
});
bot.on("guildCreate", svr => {
//db.guildconfig.insertOne(svr.id)
dbots()
setGame(AllGames[Math.floor(AllGames.length * Math.random())] + " | ~help (" + bot.guilds.size + " Guilds)");
console.log("New Server : " + svr.name || " vietnam war "); //log when the bot gets added to a new guild
});
bot.on("guildDelete", (svr, unavailable) => {
dbots()
//db.deleteOne(svr.id) //u need some filter or smth idk
console.log("I was deleted in " + svr.name); //log when the bot gets kicked/banned or the guild gets deleted
});
bot.on("channelDelete", (ch, svr) => {
//console.log("Channel " + ch.name + " was deleted in the server" + svr.name);
});
bot.on("guildMemberRemove", (svr, member) => {
//console.log(member.name + " was kicked in " + svr.name);
});
bot.on("guildBanAdd", (svr, usr) => {
//console.log("On the chaos named " + svr.name + " an person named " + usr.name + " was banned.");
});
bot.on("guildBanRemove", (svr, usr) => {
//console.log("Oh well guess what in " + svr.name + " they unbanned " + usr.name );
});
bot.on("messageDelete", msg => {
/* if (msg.content != undefined) {
console.log("Message deleted by " + msg.member.username || "anon");
console.log("contents: " + msg.content || "Cannot get the contents, sorry boi");
}*/
});
bot.on("messageCreate", msg => {
if (msg.channel.type == 1) { return; }
if (msg.author.bot) { return; }
function commandrun(asd) {
var command = msg.content.slice(asd)
var commandName = command.split(" ")[0].toLowerCase();
var args = command.slice((commandName.length + 1))
if (cmds[commandName]) {
try {
cmds[commandName](msg, bot, args, cmds)
} catch (e) {
fs.appendFile('errors', e + "\n", function(err) {
if (err) throw err;
});
console.log(e)
}
}
global.owners = ["478512959598100501", "244509121838186497", "457250790751600652", "284432595905675264", "150628341316059136", "134348241700388864"]
if (global.owners.indexOf(msg.author.id) != -1) {
if (cmdso[commandName]) {
try {
cmdso[commandName](msg, bot, args, cmdso, global.owners)
} catch (e) {
fs.appendFile('errors', e + "\n", function(err) {
if (err) throw err;
});
console.log(e)
}
}
} else if (global.owners.indexOf(msg.author.id) == -1) {
/* var notownrmsg = msg.channel.createMessage("This command is for owners only!").then(lul => setTimeout(function() {
lul.delete()
}, 3000))*/
}
}
if (msg.mentions[0] != undefined) {
if (msg.mentions[0].id == 255397678492418048) {
try {
commandrun(22)
} catch (e) {
fs.appendFile('errors', e + "\n", function(err) {
if (err) throw err;
});
console.log(e)
}
}
}
if (msg.content.startsWith(prefix)) {
try {
commandrun(prefix.length)
} catch (e) {
fs.appendFile('errors', e + "\n", function(err) {
if (err) throw err;
});
console.log(e)
}
}
try {
if (global.prefixes[msg.channel.guild.id] != undefined) {
var cprefix = global.prefixes[msg.channel.guild.id].prefixes
}
if(msg.content.startsWith(cprefix)) {
commandrun(cprefix.length)
}
} catch(e) {
console.log(e)
}
if (spy == true) {
fs.appendFile('./logs/msglog', "[" + msg.author.username + ":" + msg.author.id + "] [" + msg.guild.name + ":" + msg.guild.id + "] (" + msg.content + ")\n", function(err) {
if (err) throw err;
});
}
});
} catch (err) {
console.log("ERROR: " + err);
}
bot.connect();
// });