Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- CODE:
- const discord = require("discord.js");
- const botConfig = require("./botconfig.json");
- const fs = require(`fs`);
- 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(`Zuidland Bot is online!`);
- bot.user.setActivity("Zuidland Roleplay", {type: "PLAYING"});
- });
- bot.on("message", async message => {
- // Als bot bericht stuurt stuur dan terug.
- 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));
- if(commands) commands.run(bot,message, arguments);
- });
- bot.login(botConfig.token);
- ------------------------------
- ERROR:
- [nodemon] 1.19.1
- [nodemon] to restart at any time, enter `rs`
- [nodemon] watching: *.*
- [nodemon] starting `node index.js`
- De file close.js is geladen
- De file hallo.js is geladen
- De file play.js is geladen
- C:\Users\kianv\3D Objects\ZuidlandBot\index.js:26
- bot.commands.set(fileGet.help.name, fileGet);
- ^
- TypeError: Cannot read property 'name' of undefined
- at jsFiles.forEach (C:\Users\kianv\3D Objects\ZuidlandBot\index.js:26:39)
- at Array.forEach (<anonymous>)
- at fs.readdir (C:\Users\kianv\3D Objects\ZuidlandBot\index.js:21:13)
- at FSReqCallback.args [as oncomplete] (fs.js:145:20)
- [nodemon] app crashed - waiting for file changes before starting...
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement