Ledger Nano X - The secure hardware wallet
SHARE
TWEET

warn.js

UndercoverNL May 21st, 2020 1,051 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. const ms = require("ms");
  4. const warns = JSON.parse(fs.readFileSync("./warnings.json", "utf8"));
  5.  
  6. exports.run = async (client, message, args) => {
  7.    
  8.     if(!message.member.hasPermission("MANAGE_MESSAGES")) return message.channel.send("You do not have permission for this command!");
  9.    
  10.     let wUser = message.guild.member(message.mentions.users.first()) || message.guild.members.get(args[0])
  11.     if(!wUser) return message.channel.send("Please enter a valid user!");
  12.     if(wUser.hasPermission("MANAGE_MESSAGES")) return message.channel.send("This person cannot be warned!");
  13.     let reason = args.join(" ").slice(22);
  14.     if(!reason) return message.channel.send("Give a reason!");
  15.  
  16.     if(!warns[wUser.id]) warns[wUser.id] = {
  17.         warns: 0
  18.     };
  19.  
  20. warns[wUser.id].warns++;
  21.  
  22. fs.writeFile("./warnings.json", JSON.stringify(warns), (err) => {
  23.     if (err) console.log(err);
  24. });
  25.  
  26. let warnEmbed = new discord.RichEmbed()
  27. .setTitle(`You have received a warning in the **${message.guild}** discord server!`)
  28. .setColor("#ff0000")
  29. .setThumbnail(client.user.displayAvatarURL)
  30. .addField("Warned by:", message.author)
  31. .addField("Total warnings:", warns[wUser.id].warns)
  32. .addField("Reason:", reason);
  33.  
  34. wUser.send(warnEmbed).catch(e => {message.channel.send(`Could not send a DM message to the person!`)});
  35.  
  36.  
  37. return message.channel.send(`${wUser} has been successfully warned!`)
  38.  
  39. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top