Advertisement
Guest User

Untitled

a guest
Feb 23rd, 2019
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.56 KB | None | 0 0
  1. ReferenceError: cmdsFiles is not defined
  2. at fs.readdir (C:\Users\Rypton\Desktop\jbot\jfambot\index.js:28:5)
  3. at FSReqCallback.args [as oncomplete] (fs.js:145:20)
  4.  
  5.  
  6.  
  7. // require packages
  8. const Discord = require('discord.js');
  9. const settings = require('./settings.json');
  10. const fs = require('fs');
  11.  
  12. // initialise are bot
  13. const bot = new Discord.Client();
  14. bot.commands = new Discord.Collection();
  15.  
  16. // import bot settings (data)
  17. const prefix = settings.prefix;
  18. const token = settings.token;
  19. const owner = settings.owner;
  20.  
  21. //read commands
  22. fs.readdir('./cmds', (err,files) => {
  23. if (err) {
  24. console.log(err);
  25. }
  26.  
  27. let cmdfiles = files.filter(f => f.split(".").pop() === "js");
  28.  
  29. if (cmdfiles.length === 0){
  30. console.log("No files found");
  31. return;
  32. }
  33.  
  34. cmdsFiles.forEach((f,i) => {
  35. let props = require('./cmds/${f}');
  36. console.log('${i+1}: $(f) loaded');
  37. bot.commands.set(props.help.name, props);
  38. })
  39. })
  40.  
  41.  
  42.  
  43. bot.on('ready', async () => {
  44. console.log("JFam Scrim Bot is Online");
  45.  
  46. });
  47.  
  48. bot.on("message",msg => {
  49. if (msg.channel.type === "dm") return;
  50. if (msg.author.bot) return;
  51.  
  52. let msg_array = msg.content.split(" ");
  53. let command = msg_array[0];
  54. let args = msg_array.slice(1);
  55.  
  56. if (!command.startsWith(prefix)) return;
  57.  
  58. if (bot.commands.get(command.slice(prefix.length))){
  59. let cmd = bot.commands.get(command.slice(prefix.length));
  60. if (cmd){
  61. cmd.run(bot,msg,args);
  62. }
  63. }
  64. });
  65.  
  66.  
  67.  
  68.  
  69.  
  70. bot.login(token);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement