Advertisement
Guest User

Untitled

a guest
Apr 9th, 2020
374
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. */ index.js file */
  2.  
  3. const Discord = require('discord.js');
  4. // const {Client, Attachment} = require('discord.js');
  5. const botConfig = require("./botconfig.json");
  6.  
  7. const fs = require('fs');
  8.  
  9. const bot = new Discord.Client();   // we create the bot
  10. bot.commands = new Discord.Collection();
  11.  
  12. fs.readdir("./commands/" , (err, files) => {
  13.     if(err) console.log(err);
  14.  
  15.     var jsFiles = files.filter(f => f.split(".").pop() === "js");
  16.  
  17.     if(jsFiles.length <= 0) {
  18.         console.log("Couldn't find it");
  19.         return;
  20.     }
  21.  
  22.     jsFiles.forEach((f, i) => {
  23.  
  24.         var fileGet = require(`./commands/${f}`);
  25.         console.log(`The file ${f} is loaded`);
  26.  
  27.         bot.commands.set(fileGet.help.name, fileGet);
  28.  
  29.     })
  30.  
  31. });
  32.  
  33. bot.on("ready", async () => { //laatste is een lambda || arrow expressie
  34.    
  35.     console.log(`${bot.user.username} is online!`)
  36.  
  37.     bot.user.setActivity("La Casa De Papel", {type: "WATCHING"});
  38.  
  39. });
  40.  
  41. bot.on("message", async message => {
  42.  
  43.     // If bot sends msg, send return
  44.     if (message.author.bot) return;
  45.  
  46.     if (message.channel.type === "dm") return;
  47.    
  48.     var prefix = botConfig.prefix;
  49.  
  50.     var version = '1.0.3';
  51.     var creator = 'ScorpY';
  52.  
  53.     var messageArray = message.content.split(" "); //
  54.  
  55.     var command = messageArray[0];
  56.  
  57.     var arguments = messageArray.slice(1);
  58.  
  59.     var commands = bot.commands.get(command.slice(prefix.length));
  60.  
  61.     if(commands) commands.run(bot,message, arguments);  
  62.  
  63. })
  64.  
  65. bot.login(botConfig.token);
  66.  
  67. */ kickuser.js file */
  68.  
  69. //696692048543088691
  70. const Discord = require("discord.js");
  71.  
  72. module.exports.run = async (bot, message, args) => {
  73.  
  74.     if (message.member.hasPermission("KICK_MEMBERS")) {
  75.  
  76.         if (!message.mentions.users) return message.reply('You must tag 1 user.');
  77.  
  78.         else {
  79.  
  80.             const channel = message.guild.channels.cache.get(696692048543088691);
  81.             const member = message.mentions.members.first();
  82.             let reason = message.content.split(" ").slice(2).join(' ');
  83.  
  84.             if (member.kickable == false) return message.channel.send("That user cannot be kicked!");
  85.  
  86.             else {
  87.  
  88.                 if (!reason) reason = (`No reason provided.`);
  89.  
  90.                 await member.send(`You have been kicked from **${message.guild.name}** with the reason: **${reason}**`)
  91.                     .catch(err => message.channel.send(`⚠ Unable to contact **${member}**.`));
  92.  
  93.                 await member.kick(reason);
  94.  
  95.                 const kickEmbed = new MessageEmbed()
  96.                     .setAuthor(member.user.tag, member.user())
  97.                     .setThumbnail(member.user.avatarURL())
  98.                     .setColor("#ee0000")
  99.                     .setTimestamp()
  100.                     .addField("Kicked By", message.author.tag)
  101.                     .addField("Reason", reason);
  102.  
  103.                 await channel.send(kickEmbed);
  104.  
  105.                 console.log(`${message.author.tag} kicked ${member.user.tag} from '${message.guild.name}' with the reason: '${reason}'.`);
  106.  
  107.             }
  108.         }
  109.     } else {
  110.         message.channel.send("You do not have permission to use kick.");
  111.         return;
  112.     }
  113. }
  114.  
  115.  
  116. module.exports.help = {
  117.     name: "kickuser"
  118. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement