Advertisement
KianV

Error niet gefixt krijgen.

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