并且在测试机器人时出现错误,请帮助我修复它。我试图在Internet上找到一种解决方案,但是有完全不同的错误:( 我将感谢能帮助我的人!这是代码。
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;
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(ling);
})
});
bot.on('message', async message => {
if (message.author.bot) return;
if (message.author.type == "dm") return;
let user = message.author.username;
let userid = message.author.id;
let messageArray = message.content.split("");
let commands = messageArray[0].ToLowerCase()
let args = messageArray.splice (1);
if (!message.content.startstWith(prefix)) return;
let cmd = bot.commands.get(command.slice(prefix.length));
if(cmd) cmd.run(bot,message,args);
});
bot.login(token);