daily pastebin goal
66%
SHARE
TWEET

Untitled

ala89 Dec 13th, 2018 70 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 client = new Discord.Client()
  4.  
  5. let prefix = "!"
  6.  
  7. const warns = JSON.parse(fs.readFileSync('./warns.json'))
  8.  
  9. client.login(require("./token.json"))
  10.  
  11. client.on("message", message => {
  12.     if (!message.guild) return
  13.     let args = message.content.trim().split(/ +/g)
  14.  
  15.     if (args[0].toLowerCase() === prefix + "warn") {
  16.         if (!message.member.hasPermission('MANAGE_MESSAGES')) return message.channel.send("Vous n'avez pas la permission d'utiliser cette commande")
  17.         let member = message.mentions.members.first()
  18.         if (!member) return message.channel.send("Veuillez mentionner un membre")
  19.         if (member.highestRole.comparePositionTo(message.member.highestRole) < 1 && message.author.id !== message.guild.ownerID) return message.channel.send("Vous ne pouvez pas warn ce membre")
  20.         let reason = args.slice(2).join(' ')
  21.         if (!reason) return message.channel.send("Veuillez indiquer une raison")
  22.         if (!warns[member.id]) {
  23.             warns[member.id] = []
  24.         }
  25.         warns[member.id].unshift({
  26.             reason: reason,
  27.             date: Date.now(),
  28.             mod: message.author.id
  29.         })
  30.         fs.writeFileSync('./warns.json', JSON.stringify(warns))
  31.         message.channel.send(member + " a été warn pour " + reason + " :white_check_mark:")
  32.     }
  33.  
  34.     if (args[0].toLowerCase() === prefix + "infractions") {
  35.         if (!message.member.hasPermission('MANAGE_MESSAGES')) return message.channel.send("Vous n'avez pas la permission d'utiliser cette commande")
  36.         let member = message.mentions.members.first()
  37.         if (!member) return message.channel.send("Veuillez mentionner un membre")
  38.         let embed = new Discord.RichEmbed()
  39.             .setAuthor(member.user.username, member.user.displayAvatarURL)
  40.             .addField('10 derniers warns', ((warns[member.id]) ? warns[member.id].slice(0, 10).map(e => e.reason) : "Ce membre n'a aucun warns"))
  41.             .setTimestamp()
  42.         message.channel.send(embed)
  43.     }
  44. })
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