Вот сам код:
<const Discord = require('discord.js');
const bot = new Discord.Client();
bot.commands = new Discord.Collection();
const fs = require('fs');
let config = require('./botconfig.json');
let token = config.token;
let prefix = config.prefix;
let profile = require("./profile.json");
fs.readdir('./cmds/',(err,files)=>{
if(err) console.log(err);
let jsfiles = files.filter(f => f.split(".").pop() === "js");
if(jsfiles.length <=0)console.log("Нет команд для загрузки!!");
console.log(`Загружено ${jsfiles.length} команд`);
jsfiles.forEach((f,i) =>{
let props = require(`./cmds/${f}`);
console.log(`${i+1}.${f} Загружено!`);
bot.commands.set(props.help.name,props);
})
});
bot.on('ready', () => {
console.log(`Запустился бот ${bot.user.username}`);
bot.generateInvite(["ADMINISTRATOR"]).then(link =>{
console.log(link);
})
});
bot.on('guildMemberAdd',(member)=>{
try{}catch{};
let role = member.guild.roles.find('name',"Суккуб");
member.addRole(role);
});
bot.on('message'), async message => {
if(message.author.bot) return;
if(message.channel.type == "dm") return;
let uid = message.author.id;
if(!profile[uid]){
profile[uid] ={
coins:10,
warns:0,
Xp:0,
lvl:0,
};
};
let u = profile[uid];
u.coins++;
u.xp++;
if(u.xp>= (u.lvl * 5)){
u.xp = 0;
u.lvl += 1;
}
fs.writeFile("./profile.json",JSON.stringify(profile),(err)=>{
if(err) Console.log(err);
});
let profile = require("./profile.json");
let user = message.author.username;
let userid = message.author.id;
let messageArray = message.content.split(" ");
let command = messageArray[0].toLowerCase();
let args = messageArray.slice(1);
if(!message.content.startsWith(prefix)) return;
let cmd = bot.commands.get(command.slice(prefix.length));
if(cmd) cmd.run(bot,message,args);
};
bot.login(token)
Работаю в Visual Studio и запускаю бота через ТЕРМИНАЛ, и там выдает вот это:
events.js:108
throw new ERR_INVALID_ARG_TYPE('listener', 'Function', listener);
^
TypeError [ERR_INVALID_ARG_TYPE]: The "listener" argument must be of type function. Received undefined
at checkListener (events.js:108:11)
at _addListener (events.js:343:3)
at Client.addListener (events.js:401:10)
at Object. (C:\Users\1\Desktop\TaftilkaBOT\bot.js:36:5)
at Module._compile (internal/modules/cjs/loader.js:1133:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1153:10)
at Module.load (internal/modules/cjs/loader.js:977:32)
at Function.Module._load (internal/modules/cjs/loader.js:877:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:74:12)
at internal/main/run_main_module.js:18:47 {
code: 'ERR_INVALID_ARG_TYPE'
Не понимаю в чем ошибка