Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- bot.commands.set(props.help.name, props);
- ^
- TypeError: Cannot read property 'name' of undefined
- at jsfiles.forEach (D:loriB Discord botbot.js:22:37)
- at Array.forEach (<anonymous>)
- at fs.readdir (D:loriB Discord botbot.js:19:13)
- at FSReqWrap.oncomplete (fs.js:135:15)
- [nodemon] app crashed - waiting for file changes before starting...
- const Discord = require("discord.js");
- const settings = require("./settings.json");
- const prefix = settings.prefix;
- const fs = require("fs");
- const bot = new Discord.Client();
- bot.commands = new Discord.Collection();
- fs.readdir("./commands/", (err, files) => {
- if(err) console.error(err);
- let jsfiles = files.filter(f => f.split(".").pop() === "js");
- if(jsfiles.length <= 0) {
- console.log("Nincsenek betölteni való parancsok!");
- return;
- }
- console.log(`Betöltök ${jsfiles.length} parancsot!`);
- jsfiles.forEach((f, i) => {
- let props = require(`./commands/${f}`);
- console.log(`${i + 1}: ${f} betöltve!`);
- bot.commands.set(props.help.name, props);
- });
- });
- module.exports.run = async (bot, message, args) => {
- console.log("it works");
- }
- module.exports.help = {
- name: "avatar"
- }
Add Comment
Please, Sign In to add comment