Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const discord = require("discord.js");
- const botConfig = require("./botconfig.json");
- const fs = require("fs")
- const active = new Map();
- const bot = new discord.Client();
- 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("Kon geen files vinden");
- return;
- }
- jsFiles.forEach((f, i) => {
- var fileGet = require(`./commands/${f}`);
- console.log(`De file ${f} is geladen`);
- bot.commands.set(fileGet.help.name, fileGet);
- })
- });
- bot.on("ready", async () => {
- console.log(`${bot.user.username} is online!`);
- bot.user.setActivity("?help", { type: "LISTENING" });
- });
- bot.on("message", async message => {
- // Als bot bericht stuurt stuur dan return
- if (message.author.bot) return;
- if (message.channel.type === "dm") return;
- var prefix = botConfig.prefix;
- var messageArray = message.content.split(" ");
- var command = messageArray[0];
- var arguments = messageArray.slice(1);
- var commands = bot.commands.get(command.slice(prefix.length));
- var options = {
- active: active
- }
- if (commands) commands.run(bot, message, arguments, options);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement