Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Include the Discord library
- const Discord = require('discord.js');
- const bot = new Discord.Client();
- const fs = require("fs");
- bot.commands = new Discord.Collection();
- fs.readdir("./commands/",(err,files) => {
- if(err) console.log(err);
- let jsfile = files.filter(f=> f.split(".").pop()==="js")
- if (jsfile.length <= 0){
- console.log("Could not find commands.");
- return;
- }
- jsfile.forEach((f, i)=>{
- let props = require(`./commands/${f}`);
- console.log(`${f} loaded`);
- bot.commands.set(props.help.name, props);
- });
- })
- // When the bot is ready, log on the console all code must go after ready state
- bot.on('ready', async () => {
- console.log(`${bot.user.username} is online!`);
- bot.user.setActivity(":help",{type: "Playing"})
- });
- bot.on('message', async message => {
- if (message.author.bot) return;
- if (message.channel.type === "dm") return;
- let prefix = ':';
- let messageArray = message.content.split(" ");
- let cmd = messageArray[0];
- let args = messageArray.slice(1);
- let commandfile = bot.commands.get(cmd.slice(prefix.length));
- if(commandfile) commandfile.run(bot,message,args);
- if(cmd === `${prefix}report`){
- let rUser = message.guild.member(message.mentions.users.first() ||message.guild.members.get(args[0]));
- if (!rUser) return message.channel.send("Couldn't find user.");
- let reason = args.join(" ").slice(22);
- let reportembed = new Discord.RichEmbed()
- .setDescription("Reports")
- .setColor('#1da598')
- .addField("Reported User", `${rUser} with ID: ${rUser.id}`)
- .addField("Reported By", `${message.author} with ID: ${message.author.id}`)
- .addField("Channel", message.channel)
- .addField("Time", message.createdAt)
- .addField("Reason", reason);
- let reportschannel = message.guild.channels.find(`name`, "reports");
- if(!reportschannel) return message.channel.send("Couldn't find reports channels.");
- message.delete().catch(O_o=>{});
- reportschannel.send(reportembed);
- return;
- }
- if(cmd === `${prefix}ban`){
- if (!message.guild) return;
- let bUser = message.guild.member(message.mentions.users.first() ||message.guild.members.get(args[0]));
- if(!bUser) return message.channel.send("Can't find user!");
- let bReason = args.join(" ").slice(22);
- if(!message.member.hasPermission("MANAGE_MESSAGES"))return message.channel.send("You can't use this command lol")
- if(bUser.hasPermission("MANAGE_MEMBERS")) return message.channel.send("That person can't be banned")
- let banembed = new Discord.RichEmbed()
- .setDescription("~Ban~")
- .setColor('#1da598')
- .addField("Banned user:",`${bUser} with ID ${bUser.id}`)
- .addField("Banned by:", `<@${message.author.id}> with id ${message.author.id}`)
- .addField("Banned in: ",message.channel)
- .addField("Time :",message.createdAt)
- .addField("Reason", bReason);
- let banchannel = message.guild.channels.find(`name`, "incidents");
- if(!banchannel) return message.channel.send("Couldn't find incidents channels.");
- message.delete().catch(O_o=>{});
- message.guild.member(bUser).ban(bReason)
- banchannel.send(banembed);
- }
- if(cmd === `${prefix}kick`){
- if (!message.guild) return;
- let kUser = message.guild.member(message.mentions.users.first() ||message.guild.members.get(args[0]));
- if(!kUser) return message.channel.send("Can't find user!");
- let kReason = args.join(" ").slice(22);
- if(!message.member.hasPermission("MANAGE_MESSAGES"))return message.channel.send("You can't use this command lol")
- if(kUser.hasPermission("MANAGE_MESSAGES")) return message.channel.send("That person can't be kicked")
- let kickembed = new Discord.RichEmbed()
- .setDescription("~Kick~")
- .setColor('#1da598')
- .addField("Kicked Out:",`${kUser} with ID ${kUser.id}`)
- .addField("Kicked by:", `<@${message.author.id}> with id ${message.author.id}`)
- .addField("Kicked in: ",message.channel)
- .addField("Time :",message.createdAt)
- .addField("Reason", kReason);
- let kickchannel = message.guild.channels.find(`name`, "incidents");
- if(!kickchannel) return message.channel.send("Couldn't find incidents channels.");
- message.delete().catch(O_o=>{});
- message.guild.member(kUser).kick(kReason)
- kickchannel.send(kickembed);
- }
- });
- //A message listener the start of the message to start with &&play in server
- bot.login('');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement