This repository has been archived by the owner on Jan 27, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
269 lines (254 loc) · 8.16 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
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
/*
Please read INSTALL.MD before running this software package
---
Flame Discord Bot JavaScript Rewrite
By Ryan "Edgewurth"
*/
const Discord = require('discord.js');
const ytdl = require('ytdl-core');
const client = new Discord.Client();
const flameInfoCommands = require("./cmd/info.js");
const flameFunCommands = require("./cmd/fun.js");
const flameEcoCommands = require("./cmd/eco.js");
const flameSettingCommands = require("./cmd/settings.js");
const flameErrorHandler = require("./cmd/errorhandle.js");
const queue = new Map();
var fs = require('file-system');
var levels
var userconf
fs.readFile('./configs/levels.json', 'utf8', function(err, contents) {
levels = JSON.parse(contents);
});
fs.readFile('./configs/userconf.json', 'utf8', function(err, contents) {
userconf = JSON.parse(contents);
});
var contents = null
client.on("ready", () => {
console.log(`Logged in as ${client.user.tag}!`); // Indicates you were logged in.
console.log(`Flame Discord client By Edgewurth`);
})
var clientPrefix = "&";
function sortObject(o) {
var a = [],i;
for(i in o){
if(o.hasOwnProperty(i)){
a.push([i,o[i]]);
}
}
a.sort(function(a,b){ return a[0]>b[0]?1:-1; })
return a;
}
client.on('message', msg => {
try {
var cmd = msg.content.split(" "); // Splits message so we can have arguments AND check if message starts with "X".
/* Command Currently Broken
if (cmd[0] === clientPrefix + "rng") {
msg.channel.send ("TEMP: In Nums are: " + cmd[1] + cmd[2]);
msg.channel.send (Math.floor(Math.random() * Number(parseFloat(cmd[2]))) + Number(parseFloat(cmd[1])))
} */
if (cmd[0] === clientPrefix + "sendargs1") {
msg.channel.send (cmd[1]);
}
if (cmd[0] === clientPrefix + "about") {
msg.channel.send (flameInfoCommands.about())
}
if (cmd[0] === clientPrefix + "throwerr") {
throw "Test Error Message";
}
if (cmd[0] === clientPrefix + "settings") {
/* This command section is fairly large */
msg.channel.send(":warning: - This Command does not save settings right now");
if (cmd[1] == null) {
msg.channel.send ("Command Syntax is ``&settings <server/user> [setting]``, for a full list of settings, see <link goes here>");
}
if (cmd[1] == "server") {
/*if (cmd[2] == "prefix") {
msg.channel.send("Set prefix to ``" + cmd[3] + "``");
}*/
msg.reply("To Be Done")
}
if (cmd[1] == "user") {
if (cmd[2] == "dmhelp") {
if (typeof userconf[msg.author.id + "_dmhelp"] === "undefined") {
userconf[msg.author.id + "_dmhelp"] = "true";
fs.writeFile("./configs/userconf.json",JSON.stringify(userconf));
msg.reply("Set Send DM Help to True");
}
if (typeof userconf[msg.author.id + "_dmhelp"] === "true") {
userconf[msg.author.id + "_dmhelp"] = "false";
fs.writeFile("./configs/userconf.json",JSON.stringify(userconf));
msg.reply("Set Send DM Help to False");
} else {
userconf[msg.author.id + "_dmhelp"] = "true";
fs.writeFile("./configs/userconf.json",JSON.stringify(userconf));
msg.reply("Set Send DM Help to True");
}
}
}
}
if (cmd[0] === clientPrefix + "help") {
if (typeof userconf[msg.author.id + "_dmhelp"] === "undefined") {
userconf[msg.author.id + "_dmhelp"] = "true";
};
if (userconf[msg.author.id + "_dmhelp"] === "true") {
msg.channel.send ("Please check your inbox to see the help list. If your private messages are closed, then please type ``&settings``, and press the User/Send Help to Inbox buttons.");
msg.author.send(flameInfoCommands.help(cmd[1]))
} else {
msg.reply(flameInfoCommands.help(cmd[1]))
};
}
if (cmd[0] === clientPrefix + "ban") {
const user = msg.mentions.users.first();
var reason;
var i;
for (i = 2; i < cmd.length; i++) {
reason += cmd[i] + " ";
}
if (user) {
const member = msg.guild.members.resolve(user);
if (member) {
member
.ban(reason)
.then(() => {
msg.reply("Banned ${user.tag}");
})
.catch(err => { msg.reply("Could not ban that member"); });
}
else
{
msg.reply("Member not in server");
}
}
else
{
msg.reply("Please mention a user");
}
}
if (cmd[0] === clientPrefix + "unban") {
const user = msg.mentions.users.first();
var reason;
var i;
for (i = 2; i < cmd.length; i++) {
reason += cmd[i] + " ";
}
if (user) {
const member = msg.guild.members.resolve(user);
if (member) {
member
.unban(reason)
.then(() => {
msg.reply("Unban ${user.tag}");
})
.catch(err => { msg.reply("Could not unban that member"); });
}
else
{
msg.reply("Member not in server");
}
}
else
{
msg.reply("Please mention a user");
}
}
if (cmd[0] === clientPrefix + "kick") {
const user = msg.mentions.users.first();
var reason;
var i;
for (i = 2; i < cmd.length; i++) {
reason += cmd[i] + " ";
}
if (user) {
const member = msg.guild.members.resolve(user);
if (member) {
member
.kick(reason)
.then(() => {
msg.reply("Kicked ${user.tag}");
})
.catch(err => { msg.reply("Could not kick that member"); });
}
else
{
msg.reply("Member not in server");
}
}
else
{
msg.reply("Please mention a user");
}
}
if (cmd[0] === clientPrefix + "8ball") {
msg.channel.send (flameFunCommands.eightball())
}
if (cmd[0] === clientPrefix + "dbg") {
if (msg.author.id === "354512960250576896") {
if (cmd[1] === "shutdown") {
msg.channel.send("DEBUG - Shutting Down...");
process.exit()
}
if (cmd[1] === "reload") {
msg.channel.send("DEBUG - Reloading");
process.reset()
}
} else {
msg.channel.send("DEBUG - You're not Ryan Edgewurth. Task Failed");
}
}
if (cmd[0] === clientPrefix + "ping") {
var date = new Date();
msg.channel.send ("Pong! The latency is " + (msg.createdTimestamp - Date.now()) + "ms");
}
if (cmd[0] === clientPrefix + "bal") {
if (typeof levels[msg.author.id] === "undefined") {
levels[msg.author.id] = 0;
}
msg.channel.send ("Your Current Balance Is $" + levels[msg.author.id]);
}
if (cmd[0] === clientPrefix + "leaderboard") {
if (typeof levels[msg.author.id] === "undefined") {
levels[msg.author.id] = 0;
}
var levelsort = sortObject(levels);
msg.channel.send ("__**Leaderboard**__\n10. " + levelsort[Object.keys(levelsort)[1]].name);
}
if (cmd[0] === clientPrefix + "work") {
var job = flameEcoCommands.getjob();
var pay = flameEcoCommands.getworkpay(job);
var jobname = flameEcoCommands.getworkplace(job);
if (typeof levels[msg.author.id] === "undefined") {
levels[msg.author.id] = pay;
} else {
levels[msg.author.id] = levels[msg.author.id] + pay;}
msg.reply("You worked at " + jobname + " and got $" + pay);
}
if (cmd[0] === clientPrefix + "testembed") {
const exampleEmbed = new Discord.MessageEmbed()
.setColor('#ee5615')
.setTitle('Some title')
.setURL('https://discord.js.org/')
.setAuthor('Some name', 'https://i.imgur.com/wSTFkRM.png', 'https://discord.js.org')
.setDescription('Some description here')
.setThumbnail('https://i.imgur.com/wSTFkRM.png')
.addFields(
{ name: 'Regular field title', value: 'Some value here' },
{ name: '\u200B', value: '\u200B' },
{ name: 'Inline field title', value: 'Some value here', inline: true },
{ name: 'Inline field title', value: 'Some value here', inline: true },
)
.addField('Inline field title', 'Some value here', true)
.setImage('https://i.imgur.com/wSTFkRM.png')
.setTimestamp()
.setFooter('Some footer text here', 'https://i.imgur.com/wSTFkRM.png');
msg.channel.send(exampleEmbed);
}
if (typeof levels[msg.author.id] === "undefined") {
levels[msg.author.id] = 0;
} else {
levels[msg.author.id] = levels[msg.author.id] + 1;}
fs.writeFile("./configs/levels.json",JSON.stringify(levels)); }
catch(err) {
msg.reply(flameErrorHandler.errorhandle(err.message, err.name, msg.content, msg.author.id));
}
});
client.login('<TOKEN>');