· 6 years ago · Dec 14, 2019, 11:36 PM
1const Discord = require("discord.js");
2const logging = require('./logging');
3var request = require("request");
4const jimp = require('jimp');
5var FormulaParser = require('hot-formula-parser').Parser;
6var parser = new FormulaParser();
7const Giveaway = require("discord.js-giveaway")
8const eco = require('discord-economy');
9const fs = require('fs');
10const leveling = require('discord-leveling')
11const moment = require('moment')
12const CONFIG = require('./configuration.js');
13if (CONFIG.roles.length !== CONFIG.reactions.length)
14 throw "Roles list and reactions list are not the same length! Please double check this in the config.js file";
15const client = new Discord.Client();
16const config = require("./config.json");
17const gamingNagrody = JSON.parse(fs.readFileSync("./Nagrody/NagrodyGaming.json", 'utf8'));
18const json = require('big-json');
19const StreamArray = require('stream-json/streamers/StreamArray');
20const path = require('path');
21const jsonStream = StreamArray.withParser();
22function generateMessages() {
23 return CONFIG.roles.map((r, e) => {
24 return {
25 role: r,
26 message: `React below to get the **"${r}"** role!`, //DONT CHANGE THIS,
27 emoji: CONFIG.reactions[e]
28 };
29 });
30}
31function generateEmbedFields() {
32 return CONFIG.roles.map((r, e) => {
33 return {
34 emoji: CONFIG.reactions[e],
35 role: r
36 };
37 });
38}
39jsonStream.on('data', ({key, value}) => {
40 console.log(key, value);
41});
42
43jsonStream.on('end', () => {
44 console.log('All done');
45});
46
47//fs.createReadStream('MEEBASE.json').pipe(jsonStream.input);
48client.on("ready", () => {
49 // This event will run if the bot starts, and logs in, successfully.
50 console.log(`Bot has started, with ${client.users.size} users, in ${client.channels.size} channels of ${client.guilds.size} guilds.`);
51 // Example of changing the bot's playing game to something useful. `client.user` is what the
52 // docs refer to as the "ClientUser".
53 client.user.setActivity(`discordworld.com`);
54 setInterval(myCallback, 3000);
55
56 function myCallback() {
57 let onlinevc = client.channels.get("643488650763436042");
58 let world = client.guilds.get('394809096613658626');
59 var onlineCount = world.members.filter(m => m.presence.status !== 'offline').size
60 onlinevc.setName("?| "+onlineCount + " ludzi jest online!");
61}
62});
63
64client.on("guildCreate", guild => {
65 // This event triggers when the bot joins a guild.
66 console.log(`New guild joined: ${guild.name} (id: ${guild.id}). This guild has ${guild.memberCount} members!`);
67});
68
69client.on("guildDelete", guild => {
70
71 console.log(`I have been removed from: ${guild.name} (id: ${guild.id})`);
72});
73
74
75client.on("message", async message => {
76 if(message.author.bot) return;
77 var profile = await leveling.Fetch(message.author.id)
78 lvl = profile.level
79 var end = parser.parse('5 / 6 * '+lvl+' * (2 * '+lvl+' * '+lvl+' + 27 * '+lvl+' + 91)').result
80 leveling.AddXp(message.author.id, Math.floor(Math.random() * (9 - 5 + 1) + 5))
81 if (profile.xp > end) {
82 await leveling.AddLevel(message.author.id, 1)
83 //message.reply(`Gratuluję, zdobyłeś ${profile.level + 1} poziom.`)
84}
85
86
87 if(message.channel.type === "dm"){
88 if(message.author.bot) return;
89 let wiado = client.channels.get("642841492599341090");
90 let cos = (message.author.username + " napisał do autorskiego bota na pw: " + message.content);
91 wiado.send(cos);}
92
93
94
95 if(message.content.indexOf(config.prefix) !== 0) return;
96 const duser = message.mentions.users.first()
97 const args = message.content.slice(config.prefix.length).trim().split(/ +/g);
98 const command = args.shift().toLowerCase();
99
100
101 if(command === 'addp') {
102 if(!message.member.roles.some(r=>[">Bot"].includes(r.name)) )
103 return message.reply("ERROR: No Perms");
104 if (args.length == 4) {
105 try {
106 var s = gamingNagrody[args[1]][args[2]][args[3]]["cash"]
107 } catch (e) {
108 message.channel.send("ERROR: No results")
109 return
110 } finally {
111
112 }
113 message.channel.send(gamingNagrody[args[1]][args[2]][args[3]]["wiad"])
114 await eco.AddToBalance(duser.id, gamingNagrody[args[1]][args[2]][args[3]]["cash"])
115
116 } else if(args.length < 4) {
117
118 message.channel.send("ERROR: Too few arguments")
119 } else {
120 message.channel.send("ERROR: Too many arguments")
121 }
122 }
123
124 if(command === 'rank') {
125 let user = message.mentions.users.first() || message.author;
126
127 var leaders = await leveling.Leaderboard()
128 var output = await leveling.Leaderboard({search: user.id})
129 lvl = leaders[output-1].level
130 var end = parser.parse('5 / 6 * '+lvl+' * (2 * '+lvl+' * '+lvl+' + 27 * '+lvl+' + 91)').result
131 console.log(leaders[output]);
132 console.log(leaders);
133 console.log(output);
134 console.log(lvl);
135 console.log(end);
136 const embed = new Discord.RichEmbed()
137 .setTitle("Ranking")
138 .setAuthor(user.username, user.avatarURL)
139 .setColor(0x42e9ff)
140 .setFooter("PRFL"," https://images-ext-2.discordapp.net/external/00Nasdw99GZEW3Axs2Ab_pIgo6l7hsSCdFUNxGOkZeg/%3Fsize%3D2048/https/cdn.discordapp.com/avatars/640556943685189654/2d3e39bfbee034b2f863637956454726.png?width=676&height=676 ")
141 .setTimestamp()
142 .setDescription((output+1)+':'+client.users.get(leaders[output].userid).username+' : '+leaders[output].xp+" xp\n"+output+':'+client.users.get(leaders[output-1].userid).username+' : '+leaders[output-1].xp+" xp\n"+(output-1)+':'+client.users.get(leaders[output-2].userid).username+' : '+leaders[output-2].xp+" xp\n")
143 .addField('Poziom',lvl)
144 .addField('do następnego levelu potrzebujesz ',String(Math.round(end-leaders[output].xp))+'xp - '+(lvl+1)+' poziom')
145
146
147 message.channel.send({embed})
148 }
149
150 if(command === "ping") {
151 // Calculates ping between sending a message and editing it, giving a nice round-trip latency.
152 // The second ping is an average latency between the bot and the websocket server (one-way, not round-trip)
153 const m = await message.channel.send("Ping?");
154 m.edit(`Pong! Latency is ${m.createdTimestamp - message.createdTimestamp}ms. API Latency is ${Math.round(client.ping)}ms`);};
155
156 if(command === "say") {
157 if(!message.member.roles.some(r=>[">Bot"].includes(r.name)) )
158 return message.reply("Sorry, you don't have permissions to use this!");
159 // makes the bot say something and delete the message. As an example, it's open to anyone to use.
160 // To get the "message" itself we join the `args` back into a string with spaces:
161 const sayMessage = args.join(" ");
162 // Then we delete the command message (sneaky, right?). The catch just ignores the error with a cute smiley thing.
163 message.delete().catch(O_o=>{});
164 // And we get the bot to say the thing:
165 message.channel.send(sayMessage);
166 }; //
167
168 if(command === "kick") {
169 // This command must be limited to mods and admins. In this example we just hardcode the role names.
170 // Please read on Array.some() to understand this bit:
171 // https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Array/some?
172 if(!message.member.roles.some(r=>[">Bot"].includes(r.name)) )
173 return message.reply("Sorry, you don't have permissions to use this!");
174
175 // Let's first check if we have a member and if we can kick them!
176 // message.mentions.members is a collection of people that have been mentioned, as GuildMembers.
177 // We can also support getting the member by ID, which would be args[0]
178 let member = message.mentions.members.first() || message.guild.members.get(args[0]);
179 if(!member)
180 return message.reply("Please mention a valid member of this server");
181 if(!member.kickable)
182 return message.reply("I cannot kick this user! Do they have a higher role? Do I have kick permissions?");
183
184 // slice(1) removes the first part, which here should be the user mention or ID
185 // join(' ') takes all the various parts to make it a single string.
186 let reason = args.slice(1).join(' ');
187 if(!reason) reason = "No reason provided";
188
189 // Now, time for a swift kick in the nuts!
190 await member.kick(reason)
191 .catch(error => message.reply(`Sorry ${message.author} I couldn't kick because of : ${error}`));
192 message.reply(`${member.user.tag} has been kicked by ${message.author.tag} because: ${reason}`);
193
194 };
195
196 if(command === "ban") {
197 // Most of this command is identical to kick, except that here we'll only let admins do it.
198 // In the real world mods could ban too, but this is just an example, right? ;)
199 if(!message.member.roles.some(r=>[">Bot"].includes(r.name)) )
200 return message.reply("Sorry, you don't have permissions to use this!");
201
202 let member = message.mentions.members.first();
203 if(!member)
204 return message.reply("Please mention a valid member of this server");
205 if(!member.bannable)
206 return message.reply("I cannot ban this user! Do they have a higher role? Do I have ban permissions?");
207
208 let reason = args.slice(1).join(' ');
209 if(!reason) reason = "No reason provided";
210
211 await member.ban(reason)
212 .catch(error => message.reply(`Sorry ${message.author} I couldn't ban because of : ${error}`));
213 message.reply(`${member.user.tag} has been banned by ${message.author.tag} because: ${reason}`);
214 };
215
216 if(command === "purge") {
217 if(!message.member.roles.some(r=>[">Bot"].includes(r.name)) )
218 return message.reply("Sorry, you don't have permissions to use this!");
219
220 // get the delete count, as an actual number.
221 const deleteCount = parseInt(args[0], 10);
222
223 // Ooooh nice, combined conditions. <3
224 if(!deleteCount || deleteCount < 2 || deleteCount > 100)
225 return message.reply("Please provide a number between 2 and 100 for the number of messages to delete");
226
227 // So we get our messages, and delete them. Simple enough, right?
228 const fetched = await message.channel.fetchMessages({limit: deleteCount});
229 message.channel.bulkDelete(fetched)
230 .catch(error => message.reply(`Couldn't delete messages because of: ${error}`));
231 };
232
233 if(command === "profil") {
234 const status = {
235 online: "<:Dostepny:589178591716311040> Dostępny",
236 idle: "<:Zaraz_wracam:589178609235918878> Zaraz wracam",
237 dnd: "<:Nie_przeszadzac:589178624452591620> Nie przeszkadzać",
238 offline: "<:Niedostepny_niewidoczny:589178578407784466> Niedostępny"
239 }
240 let user = message.mentions.users.first() || message.author;
241 let channel = message.mentions.users.first() || message.author;
242 let gra = "w grze " + user.presence.game;
243 if(gra === "w grze Spotify") gra = "słucha muzyki na Spotify";
244 if(gra === "w grze " + null) gra = "aktualnie nie jest w grze";
245 let nazwa = `${user.username}#${user.discriminator} (ID: ${user.id})`
246 let embed = new Discord.RichEmbed()
247 .setTitle("Profil")
248 .setTimestamp(new Date())
249 .setColor("#4286f4")
250 .setThumbnail(`${user.avatarURL}`)
251 .addField("Nazwa Użytkownika", `${nazwa}` , inline = true)
252 .addField("Utworzono dnia", `${moment.utc(user.createdAt).format('dddd, MMMM Do YYYY, HH:mm:ss')}`)
253 .addField("Status", `${status[user.presence.status]}, ${gra}`)
254 .addField("Najnowsza wiadomość", `${user.lastMessage} (ID: ${channel.lastMessageID})`)
255 .setFooter(`${user.username}#${user.discriminator}`);
256
257 return message.channel.send(embed);
258
259 };
260
261 if(command === "gay") {
262 let gay = Math.round(Math.random() * 100);
263 let gej = message.mentions.users.first() || message.author;
264 let gayembed = new Discord.RichEmbed()
265 .setColor("#f442d4")
266 .setTitle(`:gay_pride_flag: **${gej.username} jest w ${gay}% gejem!** :gay_pride_flag:`);
267 return message.channel.send(gayembed);
268 };
269
270 if(command === "zapal") {
271 message.channel.send('**ja PAAAAAAAAALE GUUUUUUUUME**').then(async msg => {
272 setTimeout(() => {
273 msg.edit('?');
274 }, 500);
275 setTimeout(() => {
276 msg.edit('? ☁ ');
277 }, 1000);
278 setTimeout(() => {
279 msg.edit('? ☁☁ ');
280 }, 1500);
281 setTimeout(() => {
282 msg.edit('? ☁☁☁ ');
283 }, 2000);
284 setTimeout(() => {
285 msg.edit('? ☁☁');
286 }, 2500);
287 setTimeout(() => {
288 msg.edit('? ☁');
289 }, 3000);
290 setTimeout(() => {
291 msg.edit('? ');
292 }, 3500);
293 setTimeout(() => {
294 msg.edit(`Palenie gumy skończoned`);
295 }, 4000);
296 });
297 };
298
299 if(command === `dzień-dobry`){
300 message.channel.send('D').then(async msg => {
301 setTimeout(() => {
302 msg.edit('Dz');
303 }, 750);
304 setTimeout(() => {
305 msg.edit('Dzi ');
306 }, 1500);
307 setTimeout(() => {
308 msg.edit('Dzie ');
309 }, 2250);
310 setTimeout(() => {
311 msg.edit('Dzień ');
312 }, 3000);
313 setTimeout(() => {
314 msg.edit('Dzień D');
315 }, 3750);
316 setTimeout(() => {
317 msg.edit('Dzień Do');
318 }, 4500);
319 setTimeout(() => {
320 msg.edit('Dzień Dob ');
321 }, 5250);
322 setTimeout(() => {
323 msg.edit(`Dzień Dobr`);
324 }, 6000);
325 setTimeout(() => {
326 msg.edit(`Dzień Dobry`);
327 }, 6750);
328 });
329 };
330
331 if(command === `dobranoc`) {
332 message.channel.send('D').then(async msg => {
333 setTimeout(() => {
334 msg.edit('Do');
335 }, 750);
336 setTimeout(() => {
337 msg.edit('Dob ');
338 }, 1500);
339 setTimeout(() => {
340 msg.edit('Dobr');
341 }, 2250);
342 setTimeout(() => {
343 msg.edit('Dobra ');
344 }, 3000);
345 setTimeout(() => {
346 msg.edit('Dobran');
347 }, 3750);
348 setTimeout(() => {
349 msg.edit('Dobrano');
350 }, 4500);
351 setTimeout(() => {
352 msg.edit('Dobranoc ');
353 }, 5250);
354 setTimeout(() => {
355 msg.edit(`Dobranoc :`);
356 }, 6000);
357 setTimeout(() => {
358 msg.edit(`Dobranoc :3`);
359 }, 6750);
360 });
361 };
362
363 if(command === `setrolemsg`) {
364 if (!message.guild) return;
365 if (message.author.bot) return;
366 if (message.guild && !message.channel.permissionsFor(message.guild.me).missing('SEND_MESSAGES')) return;
367 if (CONFIG.deleteSetupCMD) {
368 const missing = message.channel.permissionsFor(message.guild.me).missing('MANAGE_MESSAGES');
369 // Here we check if the bot can actually delete messages in the channel the command is being ran in
370 if (missing.includes('MANAGE_MESSAGES'))
371 throw new Error("I need permission to delete your command message! Please assign the 'Manage Messages' permission to me in this channel!");
372 message.delete().catch(O_o=>{});
373 }
374 const missing = message.channel.permissionsFor(message.guild.me).missing('MANAGE_MESSAGES');
375 // Here we check if the bot can actually add recations in the channel the command is being ran in
376 if (missing.includes('ADD_REACTIONS'))
377 throw new Error("I need permission to add reactions to these messages! Please assign the 'Add Reactions' permission to me in this channel!");
378
379 if (!CONFIG.embed) {
380 if (!CONFIG.initialMessage || (CONFIG.initialMessage === ''))
381 throw "The 'initialMessage' property is not set in the config.js file. Please do this!";
382
383 message.channel.send(CONFIG.initialMessage);
384
385 const messages = generateMessages();
386 for (const { role, message: msg, emoji } of messages) {
387 if (!message.guild.roles.find(r => r.name === role))
388 throw `The role '${role}' does not exist!`;
389
390 message.channel.send(msg).then(async m => {
391 const customCheck = message.guild.emojis.find(e => e.name === emoji);
392 if (!customCheck) await m.react(emoji);
393 else await m.react(customCheck.id);
394 }).catch(console.error);
395 }
396 } else {
397 if (!CONFIG.embedMessage || (CONFIG.embedMessage === ''))
398 throw "The 'embedMessage' property is not set in the config.js file. Please do this!";
399 if (!CONFIG.embedFooter || (CONFIG.embedMessage === ''))
400 throw "The 'embedFooter' property is not set in the config.js file. Please do this!";
401
402 const roleEmbed = new Discord.RichEmbed()
403 .setDescription(CONFIG.embedMessage)
404 .setFooter(CONFIG.embedFooter);
405
406 if (CONFIG.embedColor) roleEmbed.setColor(CONFIG.embedColor);
407
408 if (CONFIG.embedThumbnail && (CONFIG.embedThumbnailLink !== ''))
409 roleEmbed.setThumbnail(CONFIG.embedThumbnailLink);
410 else if (CONFIG.embedThumbnail && message.guild.icon)
411 roleEmbed.setThumbnail(message.guild.iconURL);
412
413 const fields = generateEmbedFields();
414 if (fields.length > 25) throw "That maximum roles that can be set for an embed is 25!";
415
416 for (const { emoji, role } of fields) {
417 if (!message.guild.roles.find(r => r.name === role))
418 throw `The role '${role}' does not exist!`;
419
420 const customEmote = client.emojis.find(e => e.name === emoji);
421
422 if (!customEmote) roleEmbed.addField(emoji, role, true);
423 else roleEmbed.addField(customEmote, role, true);
424 }
425
426 message.channel.send(roleEmbed).then(async m => {
427 for (const r of CONFIG.reactions) {
428 const emoji = r;
429 const customCheck = client.emojis.find(e => e.name === emoji);
430
431 if (!customCheck) await m.react(emoji);
432 else await m.react(customCheck.id);
433 }
434 });
435 }
436
437 };
438
439 if(command === `s`) {
440 let gej = message.mentions.users.first() || message.author;
441 message.channel.send('S').then(async msg => {
442 setTimeout(() => {
443 msg.edit('SP');
444 }, 500);
445 setTimeout(() => {
446 msg.edit('SPI');
447 }, 1000);
448 setTimeout(() => {
449 msg.edit('SPIE');
450 }, 1500);
451 setTimeout(() => {
452 msg.edit('SPIER');
453 }, 2000);
454 setTimeout(() => {
455 msg.edit('SPIERD');
456 }, 2500);
457 setTimeout(() => {
458 msg.edit('SPIERDA');
459 }, 3000);
460 setTimeout(() => {
461 msg.edit('SPIERDAL');
462 }, 3500);
463 setTimeout(() => {
464 msg.edit(`SPIERDALA`);
465 }, 4000);
466 setTimeout(() => {
467 msg.edit(`SPIERDALAJ`);
468 }, 4500);
469 setTimeout(() => {
470 msg.edit(`SPIERDALAJ `+gej.username);
471 }, 5000);
472 });
473
474 };
475
476 if(command === `debil`) {
477
478 let gay = Math.round(Math.random() * 100);
479 let gej = message.mentions.users.first() || message.author;
480 let gayembed = new Discord.RichEmbed()
481 .setColor("#ff0000")
482 .setTitle(` **${gej.username} jest w ${gay}% debilem!** `);
483 return message.channel.send(gayembed);
484 };
485
486 if(command === `addcash`) {
487 if(!message.member.roles.some(r=>[">Bot"].includes(r.name)) )
488 return message.reply("Sorry, you don't have permissions to use this!");
489 if(message.mentions.users.first() == null){
490 let usr = message.author;
491 eco.AddToBalance(usr.id , args[0])
492 message.channel.send("Dodano "+args[0]+" Worldsów do portfela użytkownika "+usr)
493 }else{
494 let usr = message.mentions.users.first();
495 eco.AddToBalance(usr.id , args[0])
496 message.channel.send("Dodano "+args[0]+" Worldsów do portfela użytkownika "+usr)
497 }
498
499 };
500
501 if(command === 'balance') {
502 var user = message.mentions.users.first() || message.author
503 var output = await eco.FetchBalance(user.id)
504 var xp = await leveling.Fetch(user.id)
505 const embed = new Discord.RichEmbed()
506 .setTitle("Twoje konto")
507 .setAuthor(user.username, user.avatarURL)
508 .setColor(0x00AE86)
509 .setFooter("PRFL"," https://images-ext-2.discordapp.net/external/00Nasdw99GZEW3Axs2Ab_pIgo6l7hsSCdFUNxGOkZeg/%3Fsize%3D2048/https/cdn.discordapp.com/avatars/640556943685189654/2d3e39bfbee034b2f863637956454726.png?width=676&height=676 ")
510 .setTimestamp()
511 .addField("?", `Posiadasz ${output.balance} Worldsów`)
512 .addField("?", `Posiadasz ${xp.level} level czyli ${xp.xp}xp`)
513 message.channel.send({embed})
514 }
515
516 if(command === 'daily') {
517
518 var output = await eco.Daily(message.author.id)
519 //output.updated will tell you if the user already claimed his/her daily yes or no.
520
521 if (output.updated) {
522
523 var profile = await eco.AddToBalance(message.author.id, 100)
524 message.reply(`You claimed your daily coins successfully! You now own ${profile.newbalance} coins.`);
525
526 } else {
527 message.channel.send(`Sorry, you already claimed your daily coins!\nBut no worries, over ${output.timetowait} you can daily again!`)
528 }
529
530 }
531
532 if(command === 'resetdaily') {
533
534 var output = await eco.ResetDaily(message.author.id)
535
536 message.reply(output) //It will send 'Daily Reset.'
537
538 }
539
540 if(command === 'leaderboard') {
541
542 //If you use discord-economy guild based you can use the filter() function to only allow the database within your guild
543 //(message.author.id + message.guild.id) can be your way to store guild based id's
544 //filter: x => x.userid.endsWith(message.guild.id)
545
546 //If you put a mention behind the command it searches for the mentioned user in database and tells the position.
547 if (message.mentions.users.first()) {
548
549 var output = await eco.Leaderboard({
550 filter: x => x.balance > 50,
551 search: message.mentions.users.first().id
552 })
553 message.channel.send(`The user ${message.mentions.users.first().tag} is number ${output} on my leaderboard!`);
554
555 } else {
556
557 eco.Leaderboard({
558 limit: 3, //Only takes top 3 ( Totally Optional )
559 filter: x => x.balance > 50 //Only allows people with more than 100 balance ( Totally Optional )
560 }).then(async users => { //make sure it is async
561
562 if (users[0]) var firstplace = await client.fetchUser(users[0].userid) //Searches for the user object in discord for first place
563 if (users[1]) var secondplace = await client.fetchUser(users[1].userid) //Searches for the user object in discord for second place
564 if (users[2]) var thirdplace = await client.fetchUser(users[2].userid) //Searches for the user object in discord for third place
565
566 message.channel.send(`My leaderboard:
567
568 1 - ${firstplace && firstplace.tag || 'Nobody Yet'} : ${users[0] && users[0].balance || 'None'}
569 2 - ${secondplace && secondplace.tag || 'Nobody Yet'} : ${users[1] && users[1].balance || 'None'}
570 3 - ${thirdplace && thirdplace.tag || 'Nobody Yet'} : ${users[2] && users[2].balance || 'None'}`)
571
572 })
573
574 }
575 }
576
577 if(command === 'transfer') {
578
579 var user = message.mentions.users.first()
580 var amount = args[1]
581
582 if (!user) return message.reply('Reply the user you want to send money to!')
583 if (!amount) return message.reply('Specify the amount you want to pay!')
584
585 var output = await eco.FetchBalance(message.author.id)
586 if (output.balance < amount) return message.reply('You have fewer coins than the amount you want to transfer!')
587
588 var transfer = await eco.Transfer(message.author.id, user.id, amount)
589 message.reply(`Transfering coins successfully done!\nBalance from ${message.author.tag}: ${transfer.FromUser}\nBalance from ${user.tag}: ${transfer.ToUser}`);
590 }
591
592 if(command === 'coinflip') {
593
594 var flip = args[0] //Heads or Tails
595 var amount = args[1] //Coins to gamble
596
597 if (!flip || !['heads', 'tails'].includes(flip)) return message.reply('Please specify the flip, either heads or tails!')
598 if (!amount) return message.reply('Specify the amount you want to gamble!')
599
600 var output = await eco.FetchBalance(message.author.id)
601 if (output.balance < amount) return message.reply('You have fewer coins than the amount you want to gamble!')
602
603 var gamble = await eco.Coinflip(message.author.id, flip, amount).catch(console.error)
604 message.reply(`You ${gamble.output}! New balance: ${gamble.newbalance}`)
605
606 }
607
608 if(command === 'dice') {
609
610 var roll = args[0] //Should be a number between 1 and 6
611 var amount = args[1] //Coins to gamble
612
613 if (!roll || ![1, 2, 3, 4, 5, 6].includes(parseInt(roll))) return message.reply('Specify the roll, it should be a number between 1-6')
614 if (!amount) return message.reply('Specify the amount you want to gamble!')
615
616 var output = eco.FetchBalance(message.author.id)
617 if (output.balance < amount) return message.reply('You have fewer coins than the amount you want to gamble!')
618
619 var gamble = await eco.Dice(message.author.id, roll, amount).catch(console.error)
620 message.reply(`The dice rolled ${gamble.dice}. So you ${gamble.output}! New balance: ${gamble.newbalance}`)
621
622 }
623
624 if(command === 'delete') {
625
626 var user = message.mentions.users.first()
627 if (!user) return message.reply('Please specify a user I have to delete in my database!')
628
629 if(!message.member.roles.some(r=>[">Bot"].includes(r.name)) )
630 return message.reply("Sorry, you don't have permissions to use this!");
631
632 var output = await eco.Delete(user.id)
633 if (output.deleted == true) return message.reply('Successfully deleted the user out of the database!')
634
635 message.reply('Error: Could not find the user in database.')
636
637 }
638
639 if(command === 'work') {
640
641 var output = await eco.Work(message.author.id)
642 //50% chance to fail and earn nothing. You earn between 1-100 coins. And you get one out of 20 random jobs.
643 if (output.earned == 0) return message.reply('Awh, you did not do your job well so you earned nothing!')
644 message.channel.send(`${message.author.username}
645 You worked as a \` ${output.job} \` and earned :money_with_wings: ${output.earned}
646 You now own :money_with_wings: ${output.balance}`)
647
648
649 var output = await eco.Work(message.author.id, {
650 failurerate: 10,
651 money: Math.floor(Math.random() * 500),
652 jobs: ['cashier', 'shopkeeper']
653 })
654 //10% chance to fail and earn nothing. You earn between 1-500 coins. And you get one of those 3 random jobs.
655 if (output.earned == 0) return message.reply('Awh, you did not do your job well so you earned nothing!')
656
657 message.channel.send(`${message.author.username}
658 You worked as a \` ${output.job} \` and earned :money_with_wings: ${output.earned}
659 You now own :money_with_wings: ${output.balance}`)
660
661 }
662
663 if(command === 'slots') {
664
665 var amount = args[0] //Coins to gamble
666
667 if (!amount) return message.reply('Specify the amount you want to gamble!')
668
669 var output = await eco.FetchBalance(message.author.id)
670 if (output.balance < amount) return message.reply('You have fewer coins than the amount you want to gamble!')
671
672 var gamble = await eco.Slots(message.author.id, amount, {
673 width: 3,
674 height: 1
675 }).catch(console.error)
676 message.channel.send(gamble.grid)//Grid checks for a 100% match vertical or horizontal.
677 message.reply(`You ${gamble.output}! New balance: ${gamble.newbalance}`)
678
679 }
680
681 if(command === `sendtoallonserverdmxdmd`){
682 const list = client.guilds.get("394809096613658626");
683 list.members.forEach(member => {client.users.get(member.user.id).send("to jest bot z servera WORLD, (komenda testowa)")
684 console.log("message sent to: "+member.user.id);
685 });
686
687 }
688
689 if(command === `giveallxp`){
690 if(!message.member.roles.some(r=>[">Bot"].includes(r.name)) )
691 return message.reply("Sorry, you don't have permissions to use this!");
692 const list = client.guilds.get("394809096613658626");
693 await list.members.forEach(member => {leveling.SetXp(member.user.id, 1)
694 console.log("xp set: "+member.user.id);
695 });
696
697 }
698
699 if(command === 'xpset') {
700
701 var amount = args[0]
702 var user = message.mentions.users.first() || message.author
703
704 var output = await leveling.SetXp(user.id, amount)
705 message.channel.send(`Hey ${user.tag}! You now have ${amount} xp!`);
706 }
707
708 if(command === 'xpsetlevel') {
709
710 var amount = args[0]
711 var user = message.mentions.users.first() || message.author
712
713 var output = await leveling.SetLevel(user.id, amount)
714 message.channel.send(`Hey ${user.tag}! You now have ${amount} levels!`);
715 }
716
717 if(command === 'xpleaderboard') {
718
719 //If you put a mention behind the command it searches for the mentioned user in database and tells the position.
720 if (message.mentions.users.first()) {
721
722 var output = await leveling.Leaderboard({
723 search: message.mentions.users.first().id
724 })
725 await message.channel.send(`The user ${message.mentions.users.first().tag} is number ${output} on my leaderboard!`);
726
727 //Searches for the top 3 and outputs it to the user.
728 } else {
729
730 leveling.Leaderboard().then(async users => { //make sure it is async
731
732 if (users[0]) var firstplace = await client.fetchUser(users[0].userid) //Searches for the user object in discord for first place
733 if (users[1]) var secondplace = await client.fetchUser(users[1].userid) //Searches for the user object in discord for second place
734 if (users[2]) var thirdplace = await client.fetchUser(users[2].userid) //Searches for the user object in discord for third place
735
736 message.channel.send(`My leaderboard:
737
738 1 - ${firstplace && firstplace.tag || 'Nobody Yet'} : ${users[0] && users[0].level || 'None'} : ${users[0] && users[0].xp || 'None'}
739 2 - ${secondplace && secondplace.tag || 'Nobody Yet'} : ${users[1] && users[1].level || 'None'} : ${users[1] && users[1].xp || 'None'}
740 3 - ${thirdplace && thirdplace.tag || 'Nobody Yet'} : ${users[2] && users[2].level || 'None'} : ${users[2] && users[2].xp || 'None'}`)
741
742 })
743
744 }
745 }
746
747 if(command == 'xpdelete') {
748
749 var user = message.mentions.users.first()
750 if (!user) return message.reply('Please specify a user I have to delete in my database!')
751
752 if(!message.member.roles.some(r=>[">Bot"].includes(r.name)) )
753 return message.reply("Sorry, you don't have permissions to use this!");
754
755 var output = await leveling.Delete(user.id)
756 if (output.deleted == true) return message.reply('Succesfully deleted the user out of the database!')
757
758 message.reply('Error: Could not find the user in database.')
759
760 }
761
762 if(command == 'copydata') {
763 if(!message.member.roles.some(r=>[">Bot"].includes(r.name)) )
764 return message.reply("Sorry, you don't have permissions to use this!");
765 let rawdata = fs.readFileSync('MEEBASE.json');
766 let mee = JSON.parse(rawdata);
767 console.log(mee.players.length);
768 for (var i = 0; i < mee.players.length; i++) {
769 await leveling.SetLevel(mee.players[i].id, mee.players[i].level)
770 console.log(mee.players[i].level);
771 console.log(mee.players[i].username);
772 }console.log("done");
773 console.log(mee.players.length);
774 for (var i = 0; i < mee.players.length; i++) {
775 await leveling.SetXp(mee.players[i].id, mee.players[i].xp)
776 console.log(mee.players[i].xp);
777 console.log(mee.players[i].username);
778 }console.log("done");
779 }
780
781 if(command === 'losuj') {
782 message.reply('wyslosowałem liczbę '+Math.round(Math.random() * 100))
783 }
784
785 if(command === `dicksize`) {
786 let gay = Math.round(Math.random() * 30);
787 let gej = message.mentions.users.first() || message.author;
788 let gayembed = new Discord.RichEmbed()
789 .setColor("#f442d4")
790 .setTitle(`${gej.username} ma ${gay}cm`);
791 return message.channel.send(gayembed);
792 }
793
794 if(command === `help`) {
795 message.channel.send()
796 const embed = new Discord.RichEmbed()
797 .setTitle("Help")
798 .setColor(0x00AE86)
799 .setFooter("PRFL"," https://images-ext-2.discordapp.net/external/00Nasdw99GZEW3Axs2Ab_pIgo6l7hsSCdFUNxGOkZeg/%3Fsize%3D2048/https/cdn.discordapp.com/avatars/640556943685189654/2d3e39bfbee034b2f863637956454726.png?width=676&height=676 ")
800 .setTimestamp()
801 .addField("ping","Wyświetla ping bota i API")
802 .addField("say","Pisze wiadomość jako bot.")
803 .addField("profil","Pokazuje Twój profil")
804 .addField("gay","Pokazuje w ilu procentach jesteś gejem.")
805 .addField("zapal","Pali gumę.")
806 .addField("dzień-dobry","Animowane Dzień Dobry")
807 .addField("dobranoc","Animowane Dobranoc")
808 .addField("s","Bot pisze do Ciebie lub Innych miłą wiadomość. (Tyralnia)")
809 .addField("debil","Wyświetla w ilu procentach jesteś deb*em. (Tyralnia)")
810 .addField("balance","Wyświetla ile posiadasz Worldsów oraz Twój level.")
811 .addField("daily","Dzienne dodatkowe Worldsy.")
812 .addField("slots","Ruletka. Postaw Worldsy, zakręć ruletką i zobacz czy wygrasz postawione Worldsy.")
813 .addField("losuj","Wyświetla losową liczbę.")
814 .addField("dicksize","Pokazuje ile masz cm.")
815 .addField("help","Wyświetla dostępne komendy bota.")
816 .addField("rank","Pokazuje ranking oraz Twój level.")
817
818 message.channel.send({embed})
819 }
820});
821const events = {
822 MESSAGE_REACTION_ADD: 'messageReactionAdd',
823 MESSAGE_REACTION_REMOVE: 'messageReactionRemove',
824};
825/*client.on('raw', async event => {
826 if (!events.hasOwnProperty(event.t)) return;
827
828 const { d: data } = event;
829 const user = client.users.get(data.user_id);
830 const channel = client.channels.get(data.channel_id);
831
832 const message = await channel.fetchMessage(data.message_id);
833 const member = message.guild.members.get(user.id);
834
835 const emojiKey = (data.emoji.id) ? `${data.emoji.name}:${data.emoji.id}` : data.emoji.name;
836 let reaction = message.reactions.get(emojiKey);
837
838 if (!reaction) {
839 // Create an object that can be passed through the event like normal
840 const emoji = new Emoji(client.guilds.get(data.guild_id), data.emoji);
841 reaction = new MessageReaction(message, emoji, 1, data.user_id === client.user.id);
842 }
843
844 let embedFooterText;
845 if (message.embeds[0]) embedFooterText = message.embeds[0].footer.text;
846
847 if (
848 (message.author.id === client.user.id) && (message.content !== CONFIG.initialMessage ||
849 (message.embeds[0] && (embedFooterText !== CONFIG.embedFooter)))
850 ) {
851
852 if (!CONFIG.embed && (message.embeds.length < 1)) {
853 const re = `\\*\\*"(.+)?(?="\\*\\*)`;
854 const role = message.content.match(re)[1];
855
856 if (member.id !== client.user.id) {
857 const guildRole = message.guild.roles.find(r => r.name === role);
858 if (event.t === "MESSAGE_REACTION_ADD") member.addRole(guildRole.id);
859 else if (event.t === "MESSAGE_REACTION_REMOVE") member.removeRole(guildRole.id);
860 }
861 } else if (CONFIG.embed && (message.embeds.length >= 1)) {
862 const fields = message.embeds[0].fields;
863
864 for (const { name, value } of fields) {
865 if (member.id !== client.user.id) {
866 const guildRole = message.guild.roles.find(r => r.name === value);
867 if ((name === reaction.emoji.name) || (name === reaction.emoji.toString())) {
868 if (event.t === "MESSAGE_REACTION_ADD") member.addRole(guildRole.id);
869 else if (event.t === "MESSAGE_REACTION_REMOVE") member.removeRole(guildRole.id);
870 }
871 }
872 }
873 }
874 }
875});*/
876process.on('unhandledRejection', err => {
877 const msg = err.stack.replace(new RegExp(`${__dirname}/`, 'g'), './');
878 console.error("Unhandled Rejection", msg);
879});
880client.login(config.token);
881const giveaway = Giveaway(client, {'prefix': '!bot!','giveawayRole': "642716331090640907"})