Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const { prefix, token } = require("./config.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/", (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("message", async message => {
- if(message.author.bot) return;
- 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);
- });
- bot.on('error', async (err) => {
- console.log(err.stack)
- })
- bot.login(token);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement