Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* index.js */
- const Discord = require('discord.js');
- // const {Client, Attachment} = require('discord.js');
- const botConfig = require("./botconfig.json");
- const fs = require('fs');
- const bot = new Discord.Client(); // we create the bot
- bot.commands = new Discord.Collection();
- fs.readdir("./commands/" , (err, files) => {
- if(err) console.log(err);
- var jsFiles = files.filter(f => f.split(".").pop() === "js");
- if(jsFiles.length <= 0) {
- console.log("Couldn't find it");
- return;
- }
- jsFiles.forEach((f, i) => {
- var fileGet = require(`./commands/${f}`);
- console.log(`The file ${f} is loaded`);
- bot.commands.set(fileGet.help.name, fileGet);
- })
- });
- bot.on("ready", async () => { //laatste is een lambda || arrow expressie
- console.log(`${bot.user.username} is online!`)
- bot.user.setActivity("La Casa De Papel", {type: "WATCHING"});
- });
- bot.on("message", async message => {
- // If bot sends msg, send return
- if (message.author.bot) return;
- if (message.channel.type === "dm") return;
- var prefix = botConfig.prefix;
- var version = '1.0.3';
- var creator = 'ScorpY';
- var messageArray = message.content.split(" "); //
- var command = messageArray[0];
- var arguments = messageArray.slice(1);
- var commands = bot.commands.get(command.slice(prefix.length));
- if(commands) commands.run(bot,message, arguments);
- })
- bot.login(botConfig.token);
- /* kickuser.js */
- const discord = require("discord.js");
- module.exports.run = async (bot, message, args) => {
- if (message.member.hasPermission("KICK_MEMBERS")) {
- if (!message.mentions.users) return message.reply('You must tag 1 user.');
- else {
- const channel = message.guild.channels.cache.get(415363512186175519);
- const member = message.mentions.members.first();
- let reason = message.content.split(" ").slice(2).join(' ');
- if (member.kickable == false) return message.channel.send("That user cannot be kicked!");
- else {
- if (!reason) reason = (`No reason provided.`);
- await member.send(`You have been kicked from **${message.guild.name}** with the reason: **${reason}**`)
- .catch(err => message.channel.send(`⚠ Unable to contact **${member}**.`));
- await member.kick(reason);
- const kickEmbed = new Discord.MessageEmbed()
- .setAuthor(member.user.tag, member.user.iconURL())
- .setColor("#ee0000")
- .setTimestamp()
- .addField("Kicked By", message.author.tag)
- .addField("Reason", reason);
- await channel.send(kickEmbed);
- console.log(`${message.author.tag} kicked ${member.user.tag} from '${message.guild.name}' with the reason: '${reason}'.`);
- }
- }
- } else {
- message.channel.send("You do not have permission to use kick.");
- return;
- }
- }
- module.exports.help = {
- name: "kickuser"
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement