Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const Discord = require('discord.js');
- const client = new Discord.Client({ partials: ["MESSAGE", "CHANNEL", "REACTION" ]});
- const guild = client.guilds.cache.get("790189687750918154");
- const fs = require('fs');
- const ms = require('ms');
- let warns = JSON.parse(fs.readFileSync("./warnings.json", "utf8"));
- module.exports = {
- name: 'warn',
- description: 'Warns a member',
- async execute(client, message, args,){
- if(!message.member.hasPermission("MANAGE_MEMBERS")) return message.reply("Imagine having a permission to do that!");
- let wUser = message.guild.member(message.mentions.users.first());
- if(!wUser) return message.reply("Mention a member stupid!");
- 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.MessageEmbed()
- .setDescription("Warns")
- .setAuthor(message.author.username)
- .setColor("#dbaa40")
- .addFields( {name: "Warning", value:`"Warned user", ${wUser.tag}`},
- {name: '\u200B', value:`"Number of infractons" ${warns[wUser.id].warns}`},
- {name: '\u200B', value:`"Reason", ${reason}`},
- {name: '\u200B', value:`"Warned in", ${message.channel}`},
- )
- //.addField("Warned in", message.channel)
- //.addField("Number of Warnings", warns[wUser.id].warns)
- //.addField("Reason", reason)
- //.addField("Warned user", wUser.tag)
- let warnchannel = guild.channel.cache.get("❗│warnings")
- if(!warnchannel) return message.reply("Didn't find the channel");
- warnchannel.send(warnEmbed);
- if(warns[wUser.id].warns == 5){
- let muterole = message.guild.roles.cache.find(name => name.name === 'Muted');
- let mutetime = "24h";
- await(wUser.addRole(muterole.id));
- message.channel.send(`${wUser.tag} has been temporarily muted because of continuous infractions! If you think there is a mistake, open a ticket in ✉│contact-staff!`);
- setTimeout(function(){
- wUser.removeRole(muterole.id)
- message.channel.send(`${wUser.tag} is now unmuted! Try not to be a bad boy/girl nex time!`)
- })
- }
- if(warns[wUser.id].warns == 10){
- message.guild.member(wUser).kick(reason);
- message.channel.send(`${wUser.tag} has been kicked because of continuous infractions! If you think there is a mistake, open a ticket in ✉│contact-staff!`)
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement