DeltaBravo92

Warn

Jul 27th, 2022 (edited)
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const { MessageEmbed } = require(`discord.js`)
  2. const { Kick_On_Warnings, Warnings_Until_Kick } = require('../../settings/configuration.js').BOT_SETTINGS
  3. const { Kick_Channel_Logs } = require("../../settings/configuration").LOGGING;
  4.  
  5. module.exports = {
  6.     config: {
  7.         name: 'warn',
  8.         description: 'Warn a member on the server.',
  9.         aliases: [],
  10.     },
  11.     execute: async(Client, message, args, base) => {
  12.         let embed = new MessageEmbed({ color: Client.color })
  13.             .setFooter(`${message.guild.name} |  `, message.guild.iconURL({ dynamic: true }))
  14.  
  15.         let channel = message.guild.channels.cache.get(Kick_Channel_Logs)
  16.         let member = message.mentions.members.first() || message.guild.member(args[0])
  17.         if (!message.member.hasPermission('MANAGE_MESSAGES')) return message.channel.send(embed.setDescription(`Sorry, you are missing permissions to execute this command!`))
  18.         if (!member) return message.channel.send(embed.setDescription(`No Mention? No WARN!`))
  19.         if (member.id === message.author.id) return message.channel.send(embed.setDescription('You can\'t warn yourself!'))
  20.         if (member.user.bot) return message.channel.send(embed.setDescription('You can\'t warn a bot'))
  21.         if (!args[1]) return message.channel.send(embed.setDescription('You need to provide a warning to give to the member!'))
  22.  
  23.         const userWarns = Client.db.ensure(`${message.guild.id}.${member.id}.warnings`, [])
  24.  
  25.         let reason = args.slice(1).join(' ')
  26.         userWarns.push({ user: member.id, mod: message.author.id, reason: reason })
  27.  
  28.         const warn = embed
  29.             .setTitle(`Moderation System | Warning Category`)
  30.             .setFooter(`${message.guild.name} |  `, message.guild.iconURL({ dynamic: true }))
  31.             .addField('User', member.toString(), true)
  32.             .addField('Moderator', message.author.toString(), true)
  33.             .addField('Reason', reason)
  34.             .addField('Warning History', userWarns.length ? userWarns.map((s, i) => `${i + 1}: ${s.reason}`) : 'None')
  35.  
  36.         message.channel.send(warn)
  37.         Client.db.push(`${message.guild.id}.${member.id}.warnings`, { user: member.id, mod: message.author.id, reason: reason })
  38.  
  39.         if (Kick_On_Warnings && userWarns.length >= Warnings_Until_Kick && member.kickable) {
  40.             Client.db.set(`${message.guild.id}.${member.id}.warnings`, [])
  41.             const embed = new MessageEmbed({ color: Client.color })
  42.                 .setTitle("Administration System | Kick Category")
  43.                 .setThumbnail(member.user.displayAvatarURL())
  44.                 .setColor(`GREEN`)
  45.                 .setFooter(`${message.guild.name} |  `, message.guild.iconURL({ dynamic: true }))
  46.                 .setDescription(`**Action:** Kick\n**User Kicked:** ${member.user.tag} - (${member.id})\n**Reason:** - Reaching this guilds strike limit!`)
  47.                 .setTimestamp();
  48.  
  49.             const embed2 = new MessageEmbed({ color: Client.color })
  50.                 .setTitle("Administration System | Kick Category")
  51.                 .setThumbnail(member.user.displayAvatarURL())
  52.                 .setColor(`GREEN`)
  53.                 .setFooter(`${message.guild.name} |  `, message.guild.iconURL({ dynamic: true }))
  54.                 .setDescription(`You have been **KICKED** from ${message.guild.name}!\n\n**Staff Member**: ${message.author}\n**Reason:** Reaching this guilds strike limit!`)
  55.                 .setTimestamp();
  56.  
  57.  
  58.             const sendEmbed = new MessageEmbed({ color: 'RED' })
  59.                 .setDescription(`Sorry, I can\'t dm ${member} their dms are locked!`)
  60.  
  61.            let send = await member.user.send(embed2).catch(() => {})
  62.  
  63.            member.kick(reason)
  64.                .then(() => {
  65.                    message.channel.send(embed);
  66.                    if (channel) channel.send(embed)
  67.                    if (!send) message.channel.send(sendEmbed)
  68.                })
  69.                .catch(() => {})
  70.        }
  71.    }
  72. }
Advertisement
Add Comment
Please, Sign In to add comment