Advertisement
iiFireKingii

Rep Code (Eris)

Aug 31st, 2019
631
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.51 KB | None | 0 0
  1. const pretty = require('pretty-ms'); // By: FireKingYT , Codes
  2. const reps = JSON.parse(fs.readFileSync("./rep.json","utf8"));
  3. var timess = require("./timerep.json")
  4. client.on("messageCreate", (message) => {
  5. if(!reps[message.author.id]) reps[message.author.id] = {
  6. rep: 0
  7. }
  8. fs.writeFile("./rep.json", JSON.stringify(reps), function(e) {
  9. if (e) throw e;
  10. })
  11. let args = message.cleanContent.split(" ")
  12. if(args[0] == prefix + 'rep') {
  13. let mention = message.mentions[0] ? message.mentions[0].id : args[1]
  14. if(!mention) return client.createMessage(message.channel.id, `**:x: | Error , Please Type Command True Ex: \`${prefix}rep [MentionUser/ID]\`**`)
  15. if(mention === message.author.id) return client.createMessage(message.channel.id, `**:x: | Error , You Can\'t Give Rep For Yourself**`)
  16. if(!reps[mention]) reps[mention] = {
  17. rep: 0
  18. }
  19. let time = 8.64e+7;
  20. let lastrep = timess[message.author.id]
  21. if (lastrep !== null && time - (Date.now() - lastrep) > 0) {
  22. let times = (time - (Date.now() - lastrep));
  23. client.createMessage(message.channel.id, `**:x: | Error , Please Wait \`[${pretty(times, {verbose:true})}]\` For Give Rep Again**`)
  24. } else {
  25. timess[message.author.id] = Date.now();
  26. client.createMessage(message.channel.id, `**:white_check_mark: | Done I Have Give <@${mention}> \`1\` Rep**`)
  27. reps[mention].rep += 1
  28. fs.writeFile("./timerep.json", JSON.stringify(timess), function(e) {
  29. if (e) throw e;
  30. })
  31. fs.writeFile("./rep.json", JSON.stringify(reps), function(e) {
  32. if (e) throw e;
  33. })
  34. }
  35. }
  36. }) // By: FireKingYT , Codes
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement