Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const botconfig = require("./botconfig.json");
- const tokenfile = require("./token.json");
- const Discord = require("discord.js");
- const fs = require("fs");
- const bot = new Discord.Client({disableEveryone: true});
- bot.commands = new Discord.Collection();
- fs.readdir("./commands/", async (err, files) => {
- if(err) console.log(err);
- let jsfile = files.filter(f => f.split(".").pop() === "js")
- if(jsfile.length <= 0){
- console.log("Couldn't find commands.");
- return;
- }
- jsfile.forEach((f, i) =>{
- let props = require(`./commands/${f}`);
- console.log(`${f} loaded`);
- bot.commands.set(props.help.name, props);
- });
- });
- bot.on("ready", async () => {
- console.log(`${bot.user.username} is online!`);
- bot.user.setActivity("you", {type: "WATCHING"});
- });
- bot.on("guildMemberAdd", async member => {
- console.log(`${member.if} joined the server`)
- let welcomechannel = member.guild.channels.find(`name`, "welcome");
- welcomechannel.send(`LOOK OUT EVERYONE ${member} has joined the **dAnk MeME** army`);
- });
- bot.on("guildMemberRemove", async member => {
- console.log(`${member.id} left the server`)
- let welcomechannel = member.guild.channels.find(`name`, "welcome");
- welcomechannel.send(`**FUCK** <@${member.id}> has left the **dAnk MeME** army`);
- });
- bot.on("channelCreate", async channel => {
- console.log(`${channel.name} has been created`);
- let sChannel = channel.guild.channels.find(`name`, "logs");
- let channelEmbed = new Discord.RichEmbed()
- .setDescription("~Channel Created~")
- .setColor("#15f153")
- .addField("Channel", `${channel}`)
- .addField("Created At", channel.createdAt);
- sChannel.send(channelEmbed);
- });
- bot.on("channelDelete", async channel => {
- console.log(`${channel.name} has been created`);
- let sChannel = channel.guild.channels.find(`name`, "logs");
- let channelEmbed = new Discord.RichEmbed()
- .setDescription("~Channel Deleted~")
- .setColor("#15f153")
- .addField("Channel", `${channel}`)
- .addField("Deleted By", channel.createdAt);
- sChannel.send(channelEmbed);
- });
- bot.on("message", async message => {
- if(message.author.bot) return;
- if(message.channel.type === "dm") return;
- let prefix = botconfig.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);
- });
- let prefixes = JSON.parse(fs.readFileSync("./prefixes.json", "utf8"));
- if(!prefixes[message.guild.id]){
- prefixes[message.guild.id] = {
- prefixes: botconfig.prefix
- };
- }
- let prefix = prefixes[message.guild.id].prefixes;
- bot.login(tokenfile.token);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement