Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const pretty = require('pretty-ms'); // By: FireKingYT , Codes
- const reps = JSON.parse(fs.readFileSync("./rep.json","utf8"));
- var timess = require("./timerep.json")
- client.on("messageCreate", (message) => {
- if(!reps[message.author.id]) reps[message.author.id] = {
- rep: 0
- }
- fs.writeFile("./rep.json", JSON.stringify(reps), function(e) {
- if (e) throw e;
- })
- let args = message.cleanContent.split(" ")
- if(args[0] == prefix + 'rep') {
- let mention = message.mentions[0] ? message.mentions[0].id : args[1]
- if(!mention) return client.createMessage(message.channel.id, `**:x: | Error , Please Type Command True Ex: \`${prefix}rep [MentionUser/ID]\`**`)
- if(mention === message.author.id) return client.createMessage(message.channel.id, `**:x: | Error , You Can\'t Give Rep For Yourself**`)
- if(!reps[mention]) reps[mention] = {
- rep: 0
- }
- let time = 8.64e+7;
- let lastrep = timess[message.author.id]
- if (lastrep !== null && time - (Date.now() - lastrep) > 0) {
- let times = (time - (Date.now() - lastrep));
- client.createMessage(message.channel.id, `**:x: | Error , Please Wait \`[${pretty(times, {verbose:true})}]\` For Give Rep Again**`)
- } else {
- timess[message.author.id] = Date.now();
- client.createMessage(message.channel.id, `**:white_check_mark: | Done I Have Give <@${mention}> \`1\` Rep**`)
- reps[mention].rep += 1
- fs.writeFile("./timerep.json", JSON.stringify(timess), function(e) {
- if (e) throw e;
- })
- fs.writeFile("./rep.json", JSON.stringify(reps), function(e) {
- if (e) throw e;
- })
- }
- }
- }) // By: FireKingYT , Codes
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement