Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2020
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const Discord = require("discord.js");
  2. const fs = require("fs");
  3. let warns = JSON.parse(fs.readFileSync("./warnings.json", "utf8"));
  4.  
  5. module.exports.run = async (bot, message, args) => {
  6.  
  7.     if(!message.member.hasPermission("MANAGE_MEMBERS")) return message.reply("**You do not have permission to use this command**");
  8.     let wUser = message.guild.member(message.mentions.users.first()) || message.guild.members.get(args[0])
  9.     if (!wUser) return message.reply("**Could not find the user**");
  10.     if(wUser.hasPermission("MANAGE_MESSAGES")) return message.reply("**You cannot warn this user!**");
  11.     let reason = args.join(" ").slice(22);
  12.    
  13.     if(!warns[wUser.id]) warns[wUser.id] = {
  14.         warns: 0
  15.     }
  16.  
  17.     warns[wUser.id].warns++;
  18.  
  19.     fs.writeFile("./warnings.json", JSON.stringify(warns), (err) => {
  20.         if (err) console.log(err)
  21.     });
  22.     let warnEmbed = new Discord.RichEmbed()
  23.     .setDescription("Warns")
  24.     .setAuthor(message.author.username)
  25.     .setColor(`#ffff00`)
  26.     .addField("**Warned User**", wUser.tag)
  27.     .addField("**Warned in**", message.channel)
  28.     .addField("**Number of warnings**", warns [wUser.id].warns)
  29.     .addField("**Reason**", reason);
  30.  
  31.     let warnChannel = message.guild.channels.find(`name`, "incidents");
  32.     if(!warnChannel) return message.reply("Could not find the channel");
  33.  
  34.     warnChannel.send(warnEmbed);
  35.  
  36.  
  37. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement