Discord机器人没有启动,在准备好之前一直在加载!信息显示在终端上



直到大约一个小时前,我的机器人还工作得很好,现在当我尝试启动它时,它一直在准备好之前加载!消息出现了。在这个错误之前,我根本没有更改代码,也不确定出了什么问题。

这是我的代码:

const fs = require('fs');
const Discord = require('discord.js');
const { prefix, token } = require('./myconfig10.json');
const client = new Discord.Client();
const cheerio = require('cheerio');
const request = require('request');
client.commands = new Discord.Collection();
const commandFiles = fs.readdirSync('./commands').filter(file => file.endsWith('.js'));
const embedAuthor = ('This bot was made by <my discord name>')
const servers = client.guilds.cache.size

//Telling the bot where to look for the commands
for (const file of commandFiles) {
const command = require(`./commands/${file}`);
client.commands.set(command.name, command);
}
//Once the bot is up and running, display 'Ready' in the console
client.on('ready', () => {
console.log('Ready!');



//Seeing if the message starts with the prefix
client.on('message', message => {
if (!message.content.startsWith(prefix) || message.author.bot) return;
//Telling the bot what arguments are
const args = message.content.slice(prefix.length).trim().split(/ +/)
const commandName = args.shift().toLowerCase();
//Checking to see if the command you sent is one of the commands in the commands folder 
if (!client.commands.has(commandName)) return;
console.log(`Collected 1 Item, ${message}`)
const command = client.commands.get(commandName);
//Try to execute the command.
try {
command.execute(message, args);

//If there's an error, don't crash the bot. 
} catch (error) {
console.error(error);

//Sends a message on discord telling you there was an error
message.reply('there was an error trying to execute that command!');

编辑:我修复了它,我不小心在client.login命令后面放了一个}。

您似乎忘记了用}结束它,这是问题所在吗?

最新更新