SHARE
TWEET

Er gaat iets fout maar kan de fout niet vinden!

KianV Jul 19th, 2019 80 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. CODE:
  2. ------------------------
  3.  
  4. const discord = require("discord.js");
  5. const botConfig = require("./botconfig.json");
  6.  
  7. const fs = require(`fs`);
  8.  
  9.  
  10. const bot = new discord.Client();
  11. bot.command = new discord.Collection();
  12.  
  13. fs.readdir("./commands/" , (err, files) => {
  14.  
  15.     if(err) console.log(err);
  16.  
  17.     var jsFiles = files.filter(f => f.split(".").pop() === "js");
  18.  
  19.     if (jsFiles.length <= 0) {
  20.         console.log("Kon geen files vinden!");
  21.         return;
  22.     }
  23.  
  24.     jsFiles.forEach((f, i) => {
  25.  
  26.         var fileGet = require(`./commands/${f}`);
  27.         console.log(`De file ${f} is geladen`);
  28.  
  29.         bot.commands.set(fileGet.help.name, fileGet);
  30.  
  31.     })
  32.  
  33.  
  34. });
  35.  
  36.  
  37. bot.on("ready", async () => {
  38.  
  39.     console.log(`Zuidland Bot is online!`);
  40.  
  41.     bot.user.setActivity("Zuidland Roleplay", {type: "PLAYING"});
  42. });
  43.  
  44. bot.on("message", async message => {
  45.  
  46.     // Als bot bericht stuurt stuur dan terug.
  47.     if (message.author.bot) return;
  48.  
  49.     if (message.channel.type === "dm") return;
  50.  
  51.     var prefix = botConfig.prefix;
  52.  
  53.     var messageArray = message.content.split(" ");
  54.  
  55.     var command = messageArray [0];
  56.  
  57.     var arguments = messageArray.slice(1);
  58.  
  59.     if( command === `${prefix}hallo`){
  60.  
  61.         return message.channel.send("Hallo!");
  62.     }
  63.  
  64.  
  65. });
  66.  
  67. bot.login(botConfig.token);
  68.  
  69. ----------------------------------------
  70. ERROR:
  71.  
  72. [nodemon] 1.19.1
  73. [nodemon] to restart at any time, enter `rs`
  74. [nodemon] watching: *.*
  75. [nodemon] starting `node index.js`
  76. De file hallo.js is geladen
  77. C:\Users\kianv\3D Objects\ZuidlandBot\index.js:26
  78.         bot.commands.set(fileGet.help.name, fileGet);
  79.                      ^
  80.  
  81. TypeError: Cannot read property 'set' of undefined
  82.     at jsFiles.forEach (C:\Users\kianv\3D Objects\ZuidlandBot\index.js:26:22)
  83.     at Array.forEach (<anonymous>)
  84.     at fs.readdir (C:\Users\kianv\3D Objects\ZuidlandBot\index.js:21:13)
  85.     at FSReqCallback.args [as oncomplete] (fs.js:145:20)
  86. [nodemon] app crashed - waiting for file changes before starting...
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top