This repository has been archived by the owner on Oct 15, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
hammygamble.js
459 lines (422 loc) · 20.8 KB
/
hammygamble.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
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
const Discord = require("discord.js");
const util = require('util'); // Loads the util module.
const bot = new Discord.Client();
const fs = require('fs');
let XP = JSON.parse(fs.readFileSync('./Currency.json', 'utf8'));
const lynx = "336331925612396547";
const DopplerID = "130515926117253122";
const LawlietID = "201848192357236736";
const DarwinID = "307472480627326987";
const Cryptic = "314496458915315713"
bot.on('ready', () => {
console.log("Hamsters gamble system is online ");
});
bot.on('disconnect', event => {
console.log(`[DISCONNECT] Shard ${bot.shard.id}.`);
});
var cooldownUsers = [];
//bot.on('error', console.error);
//bot.on('warn', console.warn);
// Cooldown Check Function
const checkCooldown = ((userId) => {
if(cooldownUsers.indexOf(userId) > -1) {
return true;
} else {
return false;
}
});
// Cooldown Removal Function
const removeCooldown = ((userId, timeInSeconds) => {
let index = cooldownUsers.indexOf(userId);
if(index > -1) {
setTimeout(() => {
cooldownUsers = cooldownUsers.splice(index, 0);
}, timeInSeconds * 1000)
}
});
var cooldownUsers2 = [];
//bot.on('error', console.error);
//bot.on('warn', console.warn);
// Cooldown Check Function
const checkCooldown2 = ((userId) => {
if(cooldownUsers2.indexOf(userId) > -1) {
return true;
} else {
return false;
}
});
// Cooldown Removal Function
const removeCooldown2 = ((userId, timeInSeconds) => {
let index = cooldownUsers2.indexOf(userId);
if(index > -1) {
setTimeout(() => {
cooldownUsers2 = cooldownUsers2.splice(index, 0);
}, timeInSeconds * 1000)
}
});
var cooldownUsers3 = [];
const checkCooldown3 = ((userId) => {
if(cooldownUsers3.indexOf(userId) > -1) {
return true;
} else {
return false;
}
});
// Cooldown Removal Function
const removeCooldown3 = ((userId, timeInSeconds) => {
let index = cooldownUsers3.indexOf(userId);
if(index > -1) {
setTimeout(() => {
cooldownUsers3 = cooldownUsers3.splice(index, 0);
}, timeInSeconds * 1000)
}
});
bot.on("message", async (msg) => {
if (msg.channel.type === 'dm') return;
if (msg.author.bot) return;
const fs = require('fs');
let PREF = JSON.parse(fs.readFileSync('./prefix.json', 'utf8'));
let prefix = "";
const defaultprefix = "h!";
if (!PREF[msg.guild.id]) PREF[msg.guild.id] = {prefix: defaultprefix}
let botcode = PREF[msg.guild.id].prefix;
if(!msg.content.startsWith(prefix)) return;
let args = msg.content.split(" ").slice(1);
//const args = msg.content.slice(prefix.length).trim().split(/ +/g);
//let command = msg.content.split(" ")[0]
//command = command.slice(prefix.length)
let userData = XP[msg.author.id];
if (!userData) userData = {XP: 0};
if (msg.content.startsWith(botcode + "bank")) {
const embed = new Discord.RichEmbed()
.setColor(0xE69A49)
.setTitle(" :hamster: Bank Info For: " + msg.author.username + " :hamster: ")
.setThumbnail(msg.author.avatarURL)
.setDescription("Currency: $" + userData.XP)
.addField("Awards: ", "None");
let user = msg.mentions.users.first();
if (msg.mentions.users.size < 1) return msg.channel.sendEmbed(embed).catch(console.error);
const embed2 = new Discord.RichEmbed()
.setColor(0xE69A49)
.setTitle(" :hamster: Bank Info For: " + user.username + " :hamster: ")
.setThumbnail(user.avatarURL)
.setDescription("Currency: $" + XP[user.id].XP)
.addField("Awards: ", "None");
msg.channel.sendEmbed(embed2)
}
if (!XP[msg.author.id]) XP[msg.author.id] = {XP: 0}
if (msg.content.startsWith("")) {
if(checkCooldown(msg.author.id)) {
return;
}
cooldownUsers.push(msg.author.id);
removeCooldown(msg.author.id, 20);
if (msg.author.bot) return;
var xpgained = Math.floor(Math.random() * 15) + 1;
console.log(msg.author.username + " has gained $" + xpgained)
userData.XP += xpgained
}
if (msg.content.startsWith(botcode + "payday")) {
if(checkCooldown2(msg.author.id)) {
msg.channel.send("Sorry! You have already claimed your daily paycheck please wait 24 hours to claim again.");
return;
}
cooldownUsers2.push(msg.author.id);
// remove cooldown after 5 seconds
removeCooldown2(msg.author.id, 1440);
msg.channel.send("You have recived your free daily $1000, wait another 24 hours to claim!");
userData.XP += 1000
}
if (msg.content.startsWith(botcode + "transfer")) {
if (msg.channel.type !== 'text') return msg.channel.send("Can not transfer someone money in dms ")
const usage = new Discord.RichEmbed()
.setColor(0xE69A49)
.setThumbnail(bot.user.avatarURL)
.addField("Usage: ", "h!transfer @Someone <amount>")
.addField("Example: ", "h!transfer @Someone for 10000");
if (msg.mentions.users.size < 1) return msg.channel.sendEmbed(usage).catch(console.error);
const user = msg.mentions.users.first();
let transferamount = parseInt(args.slice(1).join(' '));
let taxtransfer = (transferamount / 100) * 80;
let taxtransferz = (transferamount / 100) * 20;
console.log(taxtransfer)
console.log(transferamount)
if (transferamount < 0) return msg.channel.send("You can't give anything below 0");
if (transferamount > 6) return msg.channel.send("You can't transfer more then 6 digits at a time");
if (isNaN(transferamount)) return msg.channel.send("Not a valid number");
if (userData.XP < transferamount) return msg.channel.send("You dont have enough money to transfer that much, you have: $" + userData.XP);
if (user.id === msg.author.id) return msg.channel.send("Can't transfer money to yourself")
//if (!XP[user.id].XP !== 'undefined') return msg.channel.send("You need to talk more to start earning money before you can transfer any")
console.log(msg.author.username + "Has transfered: $" + transferamount + " to: " + user.username)
userData.XP -= transferamount
XP[user.id].XP += taxtransfer
msg.channel.send("I have successfully transfered $" + taxtransfer + ", to " + user.username + ". Transaction fee: $" + taxtransferz + ". New balance: $" + userData.XP + ".")
}
if (msg.content.startsWith(botcode + "givemoney")) {
if (msg.author.id !== LawlietID && msg.author.id !== DopplerID && msg.author.id !== DarwinID && msg.author.id !== Cryptic) return msg.channel.send("Not whitelisted to use this command");
//let user = msg.mentions.users.first();
var xpamount = args.join(' ');
//if (msg.mentions.users.size < 1) return msg.reply(':x: You must mention someone to give xp to them. :x:').catch(console.error);
if (xpamount.length > 8) return msg.channel.send("Can not use more then 8 numbers")
if (isNaN(xpamount)) return msg.channel.send("Not a valid number")
const xpgive = (Math.round(xpamount))
userData.XP += xpgive
msg.channel.send("I have given money to: " + msg.author.username + " $" + xpamount);
}
if (msg.content.startsWith(botcode + "slots")) {
var betamount = args.join('');
const wonamount = (Math.round(betamount * 2))
if (userData.XP < betamount) return msg.channel.send("You dont have enough money to bet that much, you have: $" + userData.XP);
if (betamount < -0) return msg.channel.send("You can't bet anything below 0: you bet $" + betamount);
if (betamount.length > 9) return msg.channel.send("Can not bet more then 9 numbers at a time")
if (isNaN(betamount)) return msg.channel.send("Not a valid number")
if (betamount.length < 1) return msg.channel.send("Did not set a bet amount")
const slots = [':grapes:', ':cherries:', ':lemon:'];
const slotOne = slots[Math.floor(Math.random() * slots.length)];
const slotTwo = slots[Math.floor(Math.random() * slots.length)];
const slotThree = slots[Math.floor(Math.random() * slots.length)];
const slotfour = slots[Math.floor(Math.random() * slots.length)];
const slotfive = slots[Math.floor(Math.random() * slots.length)];
const slotsix = slots[Math.floor(Math.random() * slots.length)];
const slotseven = slots[Math.floor(Math.random() * slots.length)];
const sloteight = slots[Math.floor(Math.random() * slots.length)];
const slotnine = slots[Math.floor(Math.random() * slots.length)];
if (slotOne === slotTwo && slotOne === slotThree || slotfour === slotfive && slotfour === slotsix || slotseven === sloteight && slotseven === slotnine) {
const embed = new Discord.RichEmbed()
.setColor(0xE69A49)
.addField("Line 1", `${slotfour}|${slotfive}|${slotsix}`)
.addField("Line 2", `${slotOne}|${slotTwo}|${slotThree}`)
.addField("Line 3", `${slotseven}|${sloteight}|${slotnine}`)
.setFooter("Wow! " + msg.author.username + " won " + wonamount + " Great job!");
msg.channel.sendEmbed(embed)
var x = betamount * 1.5;
userData.XP += wonamount
console.log("User Won slots")
} else {
const embed2 = new Discord.RichEmbed()
.setColor(0xE69A49)
.addField("Line 1", `${slotfour}|${slotfive}|${slotsix}`)
.addField("Line 2", `${slotOne}|${slotTwo}|${slotThree}`)
.addField("Line 3", `${slotseven}|${sloteight}|${slotnine}`)
.setFooter("Awww " + msg.author.username + " lost " + betamount + " that sucks!");
msg.channel.sendEmbed(embed2)
userData.XP -= betamount
console.log("User Lost slots")
}
}
if (msg.content.startsWith(botcode + "roll")) {
const usage = new Discord.RichEmbed()
.setColor(0xE69A49)
.setThumbnail(bot.user.avatarURL)
.addField("Usage: ", "h!roll <number> <amount/bet>")
.addField("Example: ", "h!roll 50 1000");
var dice = Math.floor(Math.random() * 100) + 1;
let number = args[0];
let amount = args[1];
if (amount.length < 1) return msg.channel.send({usage});
if (number.length < 1) return msg.channel.send({usage});
if (userData.XP < amount) return msg.channel.send("You dont have enough money to bet that much, you have: $" + userData.XP)
const gambleamount = (Math.round(amount))
const numberval = (Math.round(number))
If (dice <= number) {
const embed = new Discord.RichEmbed()
.setColor(0xE69A49)
.setTimestamp()
.setTitle("The dice has rolled: " + dice)
.setDescription("You have won!")
.setThumbnail("http://www.pngall.com/wp-content/uploads/2016/04/Dice-Free-Download-PNG.png")
userData.XP += gambleamount
} else {
const embed2 = new Discord.RichEmbed()
.setColor(0xE69A49)
.setTimestamp()
.setTitle("The dice has rolled: " + dice)
.setDescription("You have lost!")
.setThumbnail("http://www.pngall.com/wp-content/uploads/2016/04/Dice-Free-Download-PNG.png")
userData.XP -= gambleamount
// embeds end
if (numberval > dice) return msg.channel.send({embed})
if (numberval < dice) return msg.channel.send({embed2})
}
}
if (msg.content.startsWith(botcode + "awardsgamble")) {
const embed2 = new Discord.RichEmbed()
.setColor(0xE69A49)
.setTitle(" :hamster: Awards Info :hamster: ")
.addField(`:ring: - Earn up to $5000`, "\u200b", true)
.addField(":credit_card: - Earn up to $20,000", "\u200b", true)
.addField(`:moneybag: - Earn up to $50,000`, "\u200b", true)
.addField(`:gem: - Earn up to $100,000`, "\u200b", true)
.addField(`:money_with_wings: - Secret Award`, "\u200b", true)
.addField(`:wrench: - Secret Award`, "\u200b", true)
msg.channel.sendEmbed(embed2)
}
if (msg.content.startsWith(botcode + "25")) {
if(checkCooldown3(msg.author.id)) {
msg.channel.send("Need to wait 5 seconds before gambling again!")
return;
}
cooldownUsers3.push(msg.author.id);
removeCooldown3(msg.author.id, 5);
const usage = new Discord.RichEmbed()
.setColor(0xE69A49)
.setThumbnail(bot.user.avatarURL)
.addField("Usage: ", "h!roll <number> <amount/bet>")
.addField("Example: ", "h!roll 50 1000");
var dice = Math.floor(Math.random() * 47.99 + 1);
var number = args.join(' ');
const wonamount = (Math.round(number * 1.25))
if (number.length < 1) return msg.channel.sendEmbed(usage);
if (userData.XP < number) return msg.channel.send("You dont have enough money to bet that much, you have: $" + userData.XP);
if (number < -0) return msg.channel.send("You can't bet anything below 0: you bet $" + number)
if (number.includes("e" || "inf")) return message.channel.send("is not a valid number to bet")
if (isNaN(number)) return msg.channel.send(number + "is not a valid number to bet");
if (number.length > 6) return msg.channel.send("Can not bet more then 6 numbers at a time")
if (dice >= "25") {
const embed = new Discord.RichEmbed()
.setColor(0xE69A49)
.setTimestamp()
.setTitle("The dice has rolled: " + dice)
.setDescription("You have won $" + wonamount + "!")
.setThumbnail("http://www.pngall.com/wp-content/uploads/2016/04/Dice-Free-Download-PNG.png")
userData.XP += wonamount
msg.channel.send(embed)
} else {
const embed2 = new Discord.RichEmbed()
.setColor(0xE69A49)
.setTimestamp()
.setTitle("The dice has rolled: " + dice)
.setDescription("You have lost $" + number + "!")
.setThumbnail("http://www.pngall.com/wp-content/uploads/2016/04/Dice-Free-Download-PNG.png")
userData.XP -= number
msg.channel.send(embed2)
}
}
if (msg.content.startsWith(botcode + "50")) {
if(checkCooldown3(msg.author.id)) {
msg.channel.send("Need to wait 5 seconds before gambling again!")
return;
}
cooldownUsers3.push(msg.author.id);
removeCooldown3(msg.author.id, 5);
const usage = new Discord.RichEmbed()
.setColor(0xE69A49)
.setThumbnail(bot.user.avatarURL)
.addField("Usage: ", "h!roll <number> <amount/bet>")
.addField("Example: ", "h!roll 50 1000");
var dice = Math.floor(Math.random() * 75.99 + 1);
var number = args.join('');
const wonamount = (Math.round(number * 1.50))
if (number.length < 1) return msg.channel.sendEmbed(usage);
if (userData.XP < number) return msg.channel.send("You dont have enough money to bet that much, you have: $" + userData.XP);
if (number.includes("e" || "inf")) return message.channel.send("is not a valid number to bet")
if (number < -0) return msg.channel.send("You can't bet anything below 0: you bet $" + number)
if (isNaN(number)) return msg.channel.send(number + "is not a valid number to bet");
if (number.length > 6) return msg.channel.send("Can not bet more then 6 numbers at a time")
if (dice >= "50") {
const embed = new Discord.RichEmbed()
.setColor(0xE69A49)
.setTimestamp()
.setTitle("The dice has rolled: " + dice)
.setDescription("You have won $" + wonamount + "!")
.setThumbnail("http://www.pngall.com/wp-content/uploads/2016/04/Dice-Free-Download-PNG.png")
userData.XP += wonamount
msg.channel.send(embed)
} else {
const embed2 = new Discord.RichEmbed()
.setColor(0xE69A49)
.setTimestamp()
.setTitle("The dice has rolled: " + dice)
.setDescription("You have lost $" + number + "!")
.setThumbnail("http://www.pngall.com/wp-content/uploads/2016/04/Dice-Free-Download-PNG.png")
userData.XP -= number
msg.channel.send(embed2)
}
}
if (msg.content.startsWith(botcode + "75")) {
if(checkCooldown3(msg.author.id)) {
msg.channel.send("Need to wait 5 seconds before gambling again!")
return;
}
cooldownUsers3.push(msg.author.id);
removeCooldown3(msg.author.id, 5);
const usage = new Discord.RichEmbed()
.setColor(0xE69A49)
.setThumbnail(bot.user.avatarURL)
.addField("Usage: ", "h!roll <number> <amount/bet>")
.addField("Example: ", "h!roll 50 1000");
var dice = Math.floor(Math.random() * 85.99 + 1);
var number = args.join('');
const wonamount = (Math.round(number * 1.75))
if (number.length < 1) return msg.channel.sendEmbed(usage);
if (userData.XP < number) return msg.channel.send("You dont have enough money to bet that much, you have: $" + userData.XP)
if (number < -0) return msg.channel.send("You can't bet anything below 0: you bet $" + number)
if (number.includes("e" || "inf")) return message.channel.send("is not a valid number to bet")
if (isNaN(number)) return msg.channel.send(number + "is not a valid number to bet");
if (number.length > 6) return msg.channel.send("Can not bet more then 6 numbers at a time")
if (dice >= "75") {
const embed = new Discord.RichEmbed()
.setColor(0xE69A49)
.setTimestamp()
.setTitle("The dice has rolled: " + dice)
.setDescription("You have won $" + wonamount + "!")
.setThumbnail("http://www.pngall.com/wp-content/uploads/2016/04/Dice-Free-Download-PNG.png")
userData.XP += wonamount
msg.channel.send(embed)
} else {
const embed2 = new Discord.RichEmbed()
.setColor(0xE69A49)
.setTimestamp()
.setTitle("The dice has rolled: " + dice)
.setDescription("You have lost $" + number + "!")
.setThumbnail("http://www.pngall.com/wp-content/uploads/2016/04/Dice-Free-Download-PNG.png")
userData.XP -= number
msg.channel.send(embed2)
}
}
if (msg.content.startsWith(botcode + "99")) {
if(checkCooldown3(msg.author.id)) {
msg.channel.send("Need to wait 5 seconds before gambling again!")
return;
}
cooldownUsers3.push(msg.author.id);
removeCooldown3(msg.author.id, 5);
const usage = new Discord.RichEmbed()
.setColor(0xE69A49)
.setThumbnail(bot.user.avatarURL)
.addField("Usage: ", "h!roll <number> <amount/bet>")
.addField("Example: ", "h!roll 50 1000");
var dice = Math.floor(Math.random() * 115.99 + 1);
var number = args.join('');
const wonamount = (Math.round(number * 2))
if (number.length < 1) return msg.channel.sendEmbed(usage);
if (userData.XP < number) return msg.channel.send("You dont have enough money to bet that much, you have: $" + userData.XP);
if (number < -0) return msg.channel.send("You can't bet anything below 0: you bet $" + number)
if (number.includes("e" || "inf")) return message.channel.send("is not a valid number to bet")
if (isNaN(number)) return msg.channel.send(number + "is not a valid number to bet");
if (number.length > 6) return msg.channel.send("Can not bet more then 6 numbers at a time")
if (dice >= "99") {
const embed = new Discord.RichEmbed()
.setColor(0xE69A49)
.setTimestamp()
.setTitle("The dice has rolled: " + dice)
.setDescription("You have won $" + wonamount + "!")
.setThumbnail("http://www.pngall.com/wp-content/uploads/2016/04/Dice-Free-Download-PNG.png")
userData.XP += wonamount
msg.channel.send(embed)
} else {
const embed2 = new Discord.RichEmbed()
.setColor(0xE69A49)
.setTimestamp()
.setTitle("The dice has rolled: " + dice)
.setDescription("You have lost $" + number + "!")
.setThumbnail("http://www.pngall.com/wp-content/uploads/2016/04/Dice-Free-Download-PNG.png")
userData.XP -= number
msg.channel.send(embed2)
}
}
console.log("Data Writing")
fs.writeFileSync('./Currency.json', JSON.stringify(XP), console.error);
console.log("Data Writen")
});
bot.login('your bot token');