.setDescription("Warn misbehaving members that what they are doing is wrong, and have it stored in a database in order to see a list of all their past warnings")
.addField("Notice","You must be a server administrator in order to use this command."),
meta:{
category:'Moderation',
description:"Warn misbehaving members that what they are doing is wrong, and have it stored in a database in order to see a list of all their past warnings",
if(!message.member.permissions.has("MANAGE_MESSAGES")&&!message.member.permissions.has("MANAGE_GUILD")){returnmessage.reply("You must be a server moderator (manage messages or manage server permissions) to use this command.");}
if(args.length<2&&!['check','c','list','l','clear','e','empty'].includes(args[0].toLowerCase())){returnmessage.channel.send("You must provide a reason for warning the user, or `check` or `clear`.");}
if(!mh||!Object.keys(mh.warnings).length){returnmessage.reply("There are no warnings available in this server.");}
if(!mh.warnings[user.id]||!mh.warnings[user.id].length){returnmessage.reply(`${user.id===message.author.id?'You have':'That user has'} never been warned in this server.`);}
//console.log(mh.cases, mh.warnings);
letws='';
letcwc=0;
letwarning;for(warningofmh.warnings[user.id]){
lettcase=mh.cases[warning-1];
if(tcase.status!=="Cleared"){
ws+=`\`Case #${warning}\` - Issued by <@${tcase.moderators[0]}>\n${tcase.reason}\n\n`;
}else{cwc++;}
}
if(cwc>0){ws+='*Plus '+cwc+' other warnings that have been cleared.*';}
if(cwc===mh.warnings[user.id].length){returnmessage.reply("That user has no uncleared warnings.");}
if(!mh||!Object.keys(mh.warnings).length){returnmessage.reply("There are no warnings available in this server.");}
if(!Object.keys(mh.warnings).includes(user.id)||!mh.warnings[user.id].length){returnmessage.reply(`${user.id===message.author.id?'You have':'That user has'} never been warned in this server.`);}
letmhcases=mh.cases;
letmoddedcases=[];
letcwc=0;varwc=0;
letwarning;for(warningofmh.warnings[user.id]){
if(mhcases[`${warning-1}`].status!=="Cleared"){
lettcase=mhcases[`${warning-1}`];
tcase.status="Cleared";
tcase.history.push(`${newDate().toISOString()} - ${message.author.username} - Cleared the warning.`);
if(Object.keys(options).length&&(!options.reason||!options.reason.length)){returnmessage.channel.send("You *must* use -r or -reason to specify your reason if you include any other tags. Please try again!");}
if(!options.silent){message.channel.send(`Case ${mh.cases.length} - Member has been warned. Reason: \`${reason}\``);}
if(!options.silent&&!options.nodm){client.users.cache.get(user.id).send(`\`${message.author.username}\` has warned you in \`${message.guild.name}\`. Reason: **${reason}**`);}