FoxCraftGaming

Untitled

Apr 13th, 2021
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.79 KB | None | 0 0
  1. Code:
  2.  
  3.  
  4. const discord = require("discord.js");
  5. const botConfig = require("./botconfig.json");
  6. const fs = require("fs");
  7. const { url } = require("inspector");
  8. const client = new discord.Client();
  9. client.commands = new discord.Collection();
  10. fs.readdir("./commands/", (err, files) => {
  11. if(err) console.log(err);
  12. var jsFiles = files.filter(f => f.split(".").pop() === "js");
  13. if (jsFiles.length <=0) {
  14. console.log("Kon geen bestanden vinden");
  15. return;
  16. }
  17. jsFiles.forEach((f,i) => {
  18. var fileGet = require(`./commands/${f}`);
  19. console.log(`Bestand ${f} succesvol geladen`);
  20. client.commands.set(fileGet.help.name, fileGet);
  21. })
  22. });
  23. client.login(botConfig.token);
  24. client.on("ready", async () => {
  25. console.log(`${client.user.username} is online`);
  26. client.user.setPresence({
  27. status: 'online',
  28. activity: {
  29. name: "voor help, type >help",
  30. type: "PLAYING"
  31. }
  32. });
  33. });
  34. client.on("message", async message =>{
  35. if(message.author.bot) return;
  36. if(message.channel.type == "dm") return;
  37. var prefix = botConfig.prefix;
  38. var messageArray = message.content.split(" ");
  39. var command = messageArray[0];
  40. var commands = client.commands.get(command.slice(prefix.length));
  41. if(commands) commands.run(client, message, arguments);
  42. });
  43.  
  44.  
  45.  
  46.  
  47.  
  48.  
  49. error:
  50. A:\Discord_Bot\edge\index.js:17
  51. client.commands.set(fileGet.help.name, fileGet);
  52. ^
  53.  
  54. TypeError: Cannot read property 'name' of undefined
  55. at A:\Discord_Bot\edge\index.js:17:42
  56. at Array.forEach (<anonymous>)
  57. at A:\Discord_Bot\edge\index.js:14:13
  58. at FSReqCallback.oncomplete (fs.js:171:23)
  59. [nodemon] app crashed - waiting for file changes before starting...
  60.  
Advertisement
Add Comment
Please, Sign In to add comment