Advertisement
Guest User

Untitled

a guest
Mar 21st, 2019
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.93 KB | None | 0 0
  1. const Discord = require("discord.js");
  2. const client = new Discord.Client();
  3. const fs = require("fs");
  4. const prefix = "#"
  5.  
  6. client.on('ready', () => {
  7. console.log(`By 3zozHuler`);
  8. });
  9. const ms = require('ms'); // npm i ms
  10. const cool = [];
  11. client.on('message',async message => {
  12. if(message.author.bot) return;
  13. if(message.channel.type === 'dm') return;
  14.  
  15. const args = message.content.split(' ');
  16. const credits = require('./credits.json');
  17. const path = './credits.json';
  18. const mention = message.mentions.users.first() || client.users.get(args[1]) || message.author;
  19. const mentionn = message.mentions.users.first() || client.users.get(args[1]);
  20. const author = message.author.id;
  21. const balance = args[2];
  22. const daily = Math.floor(Math.random() * 350) + 10;
  23.  
  24. if(!credits[author]) credits[author] = {credits: 50};
  25. if(!credits[mention.id]) credits[mention.id] = {credits: 50};
  26. fs.writeFile(path, JSON.stringify(credits, null, 5), function(err) {if(err) console.log(err)});
  27.  
  28.  
  29. if(message.content.startsWith(prefix + "credit")) {
  30. if(args[0] !== `${prefix}credit` && args[0] !== `${prefix}credits`) return;
  31.  
  32. if(args[2]) {
  33. if(isNaN(args[2])) return message.channel.send('**:heavy_multiplication_x:| هذه الخانة يجب ان تتكون من ارقام وليس احرف.**');
  34. if(mention.bot) return message.channel.send(`**:heavy_multiplication_x:| ${message.content.split(' ')[1]} لم يتم العثور على**`);
  35. if(mention.id === message.author.id) return message.channel.send('**:heavy_multiplication_x:| لا يمكنك تحويل كردت لنفسك**');
  36. if(credits[author].credits < balance) return message.channel.send('**:heavy_multiplication_x:| أنت لا تملك هذا القدر من الكردت**');
  37. var one = Math.floor(Math.random() * 9) + 1;
  38. var two = Math.floor(Math.random() * 9) + 1;
  39. var three = Math.floor(Math.random() * 9) + 1;
  40. var four = Math.floor(Math.random() * 9) + 1;
  41.  
  42. var number = `${one}${two}${three}${four}`;
  43.  
  44. message.channel.send(`**:heavy_dollar_sign:| \`${number}\`, أكتب الرقم للأستمرار**`).then(m => {
  45. message.channel.awaitMessages(m => m.author.id === message.author.id, {max: 1, time: 10000}).then(c => {
  46. if(c.first().content === number) {
  47. m.delete();
  48. message.channel.send(`**:atm:| ${message.author.username}, قام بتحويل \`${balance}\` لـ ${mention}**`);
  49. credits[author].credits += (-balance);
  50. credits[mention.id].credits += (+balance);
  51. fs.writeFile(path, JSON.stringify(credits, null, 5), function(err) {if(err) console.log(err)});
  52. } else if(c.first().content !== number) {
  53. m.delete();
  54. message.channel.send(`** :money_with_wings: | تم الغاء الإرسال**`);
  55. }
  56. });
  57. });
  58. }
  59. if(!args[2]) {
  60. if(mention.bot) return message.channel.send(`**:heavy_multiplication_x:| ${message.content.split(' ')[1]} لم يتم العثور على**`);
  61. message.channel.send(`${mention.username}, your :credit_card: balance is **${credits[mention.id].credits}**`);
  62. }
  63.  
  64. }
  65. if(message.content.startsWith(prefix + "daily")) {
  66. if(cool.includes(message.author.id)) return message.channel.send(`**:heavy_dollar_sign: | \ , يجب عليك انتظار يوم لأخذ المبلغ مرة اخرى**`);
  67. if(mentionn) {
  68. var one = Math.floor(Math.random() * 9) + 1;
  69. var two = Math.floor(Math.random() * 9) + 1;
  70. var three = Math.floor(Math.random() * 9) + 1;
  71. var four = Math.floor(Math.random() * 9) + 1;
  72.  
  73. var number = `${one}${two}${three}${four}`;
  74.  
  75. message.channel.send(`**:atm: | \`${number}\`, قم بكتابة الرقم للأستمرار**`).then(async m => {
  76. message.channel.awaitMessages(msg => msg.author.id === message.author.id, {max: 1, time: 20000, errors: ['time']}).then(collected => {
  77. if(collected.first().content === number) {
  78. m.delete();
  79. collected.first().delete();
  80. credits[mentionn.id].credits += (+daily);
  81. fs.writeFile(path, JSON.stringify(credits, null, 5), function(err) {if(err) console.log(err)});
  82.  
  83. message.channel.send(`**:atm: | \`${daily}\`, تم تسليم المبلغ**`);
  84. }
  85. if(collected.first().content !== number) {
  86. return m.delete();
  87. }
  88. });
  89. });
  90. } else if(!mentionn) {
  91. credits[author].credits += (+daily);
  92. fs.writeFile(path, JSON.stringify(credits, null, 5), function(err) {if(err) console.log(err)});
  93.  
  94. message.channel.send(`**:atm: | \`${daily}\`, تم اعطائك المبلغ**`);
  95. }
  96. cool.unshift(message.author.id);
  97.  
  98. setTimeout(() => {
  99. cool.shift(message.author.id);
  100. message.author.send("**:atm: | \`Daily\`, يمكنك الحصول على الكردت المجانية الان**").catch();
  101. }, ms("1d"));
  102. }
  103. });
  104. client.login("token");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement