Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const Discord = require("discord.js");
- const fs = require("fs");
- let warns = JSON.parse(fs.readFileSync("./warnings.json", "utf8"));
- module.exports.run = async (bot, message, args) => {
- if(!message.member.hasPermission("MANAGE_MEMBERS")) return message.reply("**You do not have permission to use this command**");
- let wUser = message.guild.member(message.mentions.users.first()) || message.guild.members.get(args[0])
- if (!wUser) return message.reply("**Could not find the user**");
- if(wUser.hasPermission("MANAGE_MESSAGES")) return message.reply("**You cannot warn this user!**");
- let reason = args.join(" ").slice(22);
- if(!warns[wUser.id]) warns[wUser.id] = {
- warns: 0
- }
- warns[wUser.id].warns++;
- fs.writeFile("./warnings.json", JSON.stringify(warns), (err) => {
- if (err) console.log(err)
- });
- let warnEmbed = new Discord.RichEmbed()
- .setDescription("Warns")
- .setAuthor(message.author.username)
- .setColor(`#ffff00`)
- .addField("**Warned User**", wUser.tag)
- .addField("**Warned in**", message.channel)
- .addField("**Number of warnings**", warns [wUser.id].warns)
- .addField("**Reason**", reason);
- let warnChannel = message.guild.channels.find(`name`, "incidents");
- if(!warnChannel) return message.reply("Could not find the channel");
- warnChannel.send(warnEmbed);
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement