Advertisement
IxRawan_

Credits ._.

Jul 12th, 2019
262
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.87 KB | None | 0 0
  1.  
  2. const ms = rquire('ms')
  3. const cool = [];
  4. client.on('message',async message => {
  5. if(message.author.bot) return;
  6. if(message.channel.type === 'dm') return;
  7.  
  8. const guildid = "595231357873946627"; // ايدي السيرفر الي موجود فيه الروم
  9. const channelid = "599221947569537045"; // ايدي الروم
  10. var prefix = ".";
  11. const args = message.content.split(' ');
  12. const credits = require('./credits.json');
  13. const path = './credits.json';
  14. const mention = message.mentions.users.first() || client.users.get(args[1]) || message.author;
  15. const mentionn = message.mentions.users.first() || client.users.get(args[1]);
  16. const author = message.author.id;
  17. const balance = args[2];
  18. const daily = Math.floor(Math.random() * 350) + 10;
  19.  
  20. if(!credits[author]) credits[author] = {credits: 50};
  21. if(!credits[mention.id]) credits[mention.id] = {credits: 50};
  22. fs.writeFile(path, JSON.stringify(credits, null, 5), function(err) {if(err) console.log(err)});
  23.  
  24.  
  25. if(message.content.startsWith(prefix + "credits")) {
  26. if(args[0] !== `${prefix}credit` && args[0] !== `${prefix}credits`) return;
  27.  
  28. if(args[2]) {
  29. if(isNaN(args[2])) return message.channel.send('**:heavy_multiplication_x:| This field should consist of numbers and not letters .**');
  30. if(mention.bot) return message.channel.send(`**:heavy_multiplication_x:| ${message.content.split(' ')[1]} Not found **`);
  31. if(mention.id === message.author.id) return message.channel.send('**:heavy_multiplication_x:| You can not convert credits for yourself **');
  32. if(credits[author].credits < balance) return message.channel.send('**:heavy_multiplication_x:| Your balance is not enough for that! **');
  33. var one = Math.floor(Math.random() * 9) + 1;
  34. var two = Math.floor(Math.random() * 9) + 1;
  35. var three = Math.floor(Math.random() * 9) + 1;
  36. var four = Math.floor(Math.random() * 9) + 1;
  37.  
  38. var number = `${one}${two}${three}${four}`;
  39.  
  40. message.channel.send(`**| :moneybag: \`${number}\`, type these numbers to confirm**`).then(m => {
  41. message.channel.awaitMessages(m => m.author.id === message.author.id, {max: 1, time: 10000}).then(c => {
  42. if(c.first().content === number) {
  43. m.delete();
  44. message.channel.send(`**:moneybag:| ${message.author.username}, has transferred \`${balance}\` to ${mention}**`)
  45. var sendembed = new Discord.RichEmbed()
  46. .setColor('RANDOM')
  47. .setTitle(`عملية تحويل جديدة`)
  48. .addField(`${message.author.username}#${message.author.discriminator}:اسم والتاق المرسل\n${message.author.id} :ايدي المرسل\n${mention.username}#${mention.discriminator}: اسم والتاق المستقبل\n ${mention.id}:ايدي المستقبل\n ${balance} : المبلغ\n${moment(message.createdAt).format('D/MM/YYYY h:mm')} : تم التحويل في`, client.user.username)
  49. client.guilds.get(guildid).channels.get(channelid).send(sendembed);
  50. credits[author].credits += (-balance);
  51. credits[mention.id].credits += (+balance);
  52. fs.writeFile(path, JSON.stringify(credits, null, 5), function(err) {if(err) console.log(err)});
  53. } else if(c.first().content !== number) {
  54. m.delete();
  55. message.channel.send(`** :moneybag: | Sending canceled **`);
  56. }
  57. });
  58. });
  59. }
  60. if(!args[2]) {
  61. if(mention.bot) return message.channel.send(`**:heavy_multiplication_x:| ${message.content.split(' ')[1]} لم يتم العثور على**`);
  62. message.channel.send(`**${mention.username}, your :credit_card: balance is \`\`$${credits[mention.id].credits}\`\`.**`); }
  63. }
  64. if(message.content.startsWith(prefix + "daily")) {
  65. if(cool.includes(message.author.id)) return message.channel.send(`**:stopwatch: | ${mention.username} \ , your daily :yen: credits refreshes in 24 hours **`);
  66. if(mentionn) {
  67. var one = Math.floor(Math.random() * 9) + 1;
  68. var two = Math.floor(Math.random() * 9) + 1;
  69. var three = Math.floor(Math.random() * 9) + 1;
  70. var four = Math.floor(Math.random() * 9) + 1;
  71.  
  72. var number = `${one}${two}${three}${four}`;
  73.  
  74. message.channel.send(`**:atm: | \`${number}\`, type these numbers to confirm **`).then(async m => {
  75. message.channel.awaitMessages(msg => msg.author.id === message.author.id, {max: 1, time: 20000, errors: ['time']}).then(collected => {
  76.  
  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}\`, you received your :yen:**`)
  84.  
  85. }
  86. if(collected.first().content !== number) {
  87. return m.delete();
  88. }
  89. });
  90. });
  91. } else if(!mentionn) {
  92. credits[author].credits += (+daily);
  93. fs.writeFile(path, JSON.stringify(credits, null, 5), function(err) {if(err) console.log(err)});
  94.  
  95. var dailyembed = new Discord.RichEmbed()
  96. .setColor('RANDOM')
  97. .setTitle(`شخص استلم ديلي جديد`)
  98. .addField(`${message.author.username}#${message.author.discriminator} :اسم والتاق المستقبل\n${message.author.id} :ايدي المستقبل\n${daily} :المبلغ المستلم`, client.user.username);
  99.  
  100. client.guilds.get(guildid).channels.get(channelid).send(dailyembed)
  101. message.channel.send(`**:atm: | , you received your :yen: \`${daily}\` daily credits! **`);
  102. }
  103. cool.unshift(message.author.id);
  104.  
  105. setTimeout(() => {
  106. cool.shift(message.author.id);
  107. message.author.send("**:atm: | \`Daily\`, يمكنك الحصول على الكردت المجانية الان**").catch();
  108. }, ms("1d"));
  109. }
  110. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement