Advertisement
Guest User

Untitled

a guest
Dec 11th, 2019
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.96 KB | None | 0 0
  1. const fs = require("fs")
  2. const Discord = require('discord.js')
  3. let coins = require('../coins.json')
  4.  
  5. const cooldownMembers = new Set();
  6. module.exports = (client, msg) => {
  7.  
  8.  
  9. msg.msgs = JSON.parse(fs.readFileSync("./counter.json", "utf8"));
  10. require("../functions/counter.js")(msg)
  11.  
  12. if(msg.channel.type == 'dm') return;
  13. if(msg.author.bot) return
  14.  
  15.  
  16. if(!coins[msg.author.id]){
  17. coins[msg.author.id] = {
  18. coins: 0
  19. }
  20. }
  21.  
  22. let coinAmt = Math.floor(Math.random() * 15) + 1;
  23. let baseAmt = Math.floor(Math.random() * 15) + 4;
  24. if(msg.member.roles.has('654527317451735042')){
  25. coinAmt = Math.floor(Math.random() * 10) + 1;
  26. baseAmt = Math.floor(Math.random() * 10) + 2;
  27. }
  28. if(msg.member.roles.has('654560912589586432')){
  29. coinAmt = Math.floor(Math.random() * 50) + 1;
  30. baseAmt = Math.floor(Math.random() * 50) + 5;
  31. }
  32.  
  33. if(msg.content.startsWith('!') && msg.content.startsWith('-') && msg.content.startsWith('+')) {
  34. coinAmt = 'x'
  35. baseAmt = 'y'
  36. }
  37.  
  38. console.log(` ${msg.author} teve ${coinAmt} e ${baseAmt} %`)
  39.  
  40. if(coinAmt === baseAmt){
  41. coins[msg.author.id] = {
  42. coins: coins[msg.author.id].coins + coinAmt
  43. }
  44. fs.writeFile("./coins.json", JSON.stringify(coins), (err) => {
  45. if (err) console.log(err)
  46. })
  47. let uCoins = coins[msg.author.id].coins
  48. let coinembed = new Discord.RichEmbed()
  49. .setTitle(`${msg.author.tag} ganhou moedas!`)
  50. .setDescription('Parabéns ' + `${msg.author} você ganhou moedas!`)
  51. .addField('Moedas Ganhas <a:coin:654123490034581504>', `\`${coinAmt}\``)
  52. .setColor('#90ff6e')
  53. .setFooter(`Você possui agora ${uCoins} moedas`)
  54. .setThumbnail('https://cdn.discordapp.com/attachments/652330287836954655/654059303057227780/cartoon-earth-transparent-1.png')
  55. msg.channel.send(coinembed).then(x => { x.delete(7000)})
  56. }
  57.  
  58. if(msg.content.indexOf(client.config.prefix) !== 0) return;
  59.  
  60. const args = msg.content.slice(client.config.prefix.length).trim().split(/ +/g)
  61. const command = args.shift().toLowerCase()
  62.  
  63. client.warns = JSON.parse(fs.readFileSync("./warnings.json", "utf8"));
  64.  
  65. const cmd = client.commands.get(command) || client.commands.get(client.aliases.get(command))
  66.  
  67. if(!msg.member.hasPermission('ADMINISTRATOR') && msg.channel.id !== '651617500957507592' && msg.channel.id !== '654162577479303181') return msg.reply('Você não tem permissão para mandar comandos aqui.')
  68. if(!cmd) return;
  69. if (cooldownMembers.has(msg.author.id)) return msg.reply('Você esta usando meus comandos de mais! Aguarde alguns segundos e tente novamente.');
  70.  
  71. cmd.run(client, msg, args)
  72.  
  73. if(!msg.member.hasPermission('ADMINISTRATOR') && !msg.member.roles.has('654527317451735042')) cooldownMembers.add(msg.author.id)
  74. setTimeout(() => {
  75. cooldownMembers.delete(msg.author.id)
  76. }, 6 * 1000);
  77.  
  78.  
  79. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement