Advertisement
Guest User

index.js

a guest
Apr 8th, 2020
276
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /* index.js */
  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 */
  68.  
  69. const discord = require("discord.js");
  70.  
  71. module.exports.run = async (bot, message, args) => {
  72.  
  73.     if (message.member.hasPermission("KICK_MEMBERS")) {
  74.  
  75.         if (!message.mentions.users) return message.reply('You must tag 1 user.');
  76.  
  77.         else {
  78.  
  79.             const channel = message.guild.channels.cache.get(415363512186175519);
  80.             const member = message.mentions.members.first();
  81.             let reason = message.content.split(" ").slice(2).join(' ');
  82.  
  83.             if (member.kickable == false) return message.channel.send("That user cannot be kicked!");
  84.  
  85.             else {
  86.  
  87.                 if (!reason) reason = (`No reason provided.`);
  88.  
  89.                 await member.send(`You have been kicked from **${message.guild.name}** with the reason: **${reason}**`)
  90.                     .catch(err => message.channel.send(`⚠ Unable to contact **${member}**.`));
  91.  
  92.                 await member.kick(reason);
  93.  
  94.                 const kickEmbed = new Discord.MessageEmbed()
  95.                     .setAuthor(member.user.tag, member.user.iconURL())
  96.                     .setColor("#ee0000")
  97.                     .setTimestamp()
  98.                     .addField("Kicked By", message.author.tag)
  99.                     .addField("Reason", reason);
  100.  
  101.                 await channel.send(kickEmbed);
  102.  
  103.                 console.log(`${message.author.tag} kicked ${member.user.tag} from '${message.guild.name}' with the reason: '${reason}'.`);
  104.  
  105.             }
  106.         }
  107.     } else {
  108.         message.channel.send("You do not have permission to use kick.");
  109.         return;
  110.     }
  111. }
  112.  
  113.  
  114. module.exports.help = {
  115.     name: "kickuser"
  116. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement