Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ReferenceError: cmdsFiles is not defined
- at fs.readdir (C:\Users\Rypton\Desktop\jbot\jfambot\index.js:28:5)
- at FSReqCallback.args [as oncomplete] (fs.js:145:20)
- // require packages
- const Discord = require('discord.js');
- const settings = require('./settings.json');
- const fs = require('fs');
- // initialise are bot
- const bot = new Discord.Client();
- bot.commands = new Discord.Collection();
- // import bot settings (data)
- const prefix = settings.prefix;
- const token = settings.token;
- const owner = settings.owner;
- //read commands
- fs.readdir('./cmds', (err,files) => {
- if (err) {
- console.log(err);
- }
- let cmdfiles = files.filter(f => f.split(".").pop() === "js");
- if (cmdfiles.length === 0){
- console.log("No files found");
- return;
- }
- cmdsFiles.forEach((f,i) => {
- let props = require('./cmds/${f}');
- console.log('${i+1}: $(f) loaded');
- bot.commands.set(props.help.name, props);
- })
- })
- bot.on('ready', async () => {
- console.log("JFam Scrim Bot is Online");
- });
- bot.on("message",msg => {
- if (msg.channel.type === "dm") return;
- if (msg.author.bot) return;
- let msg_array = msg.content.split(" ");
- let command = msg_array[0];
- let args = msg_array.slice(1);
- if (!command.startsWith(prefix)) return;
- if (bot.commands.get(command.slice(prefix.length))){
- let cmd = bot.commands.get(command.slice(prefix.length));
- if (cmd){
- cmd.run(bot,msg,args);
- }
- }
- });
- bot.login(token);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement