Error handling Discord机器人将不响应,关闭

Error handling Discord机器人将不响应,关闭,error-handling,crash,discord,discord.js,Error Handling,Crash,Discord,Discord.js,我是编程Discord机器人的新手(我喜欢它),它在响应方面有问题。当我用节点main.js启动它时,它会正常工作,直到我执行类似于-ping的操作时,它才会停止工作 以下是我收到的错误: ReferenceError: clicent is not defined at Client.<anonymous> (C:\Users\Eric Müller\Desktop\Discord bot\Main.js:27:9) at Client.emit (e

我是编程Discord机器人的新手(我喜欢它),它在响应方面有问题。当我用
节点main.js
启动它时,它会正常工作,直到我执行类似于
-ping
的操作时,它才会停止工作

以下是我收到的错误:

ReferenceError: clicent is not defined
    at Client.<anonymous> (C:\Users\Eric Müller\Desktop\Discord bot\Main.js:27:9)       
    at Client.emit (events.js:315:20)
    at MessageCreateAction.handle (C:\Users\Eric Müller\Desktop\Discord bot\node_modules\discord.js\src\client\actions\MessageCreate.js:31:14)
    at Object.module.exports [as MESSAGE_CREATE] (C:\Users\Eric Müller\Desktop\Discord bot\node_modules\discord.js\src\client\websocket\handlers\MESSAGE_CREATE.js:4:32)        
    at WebSocketManager.handlePacket (C:\Users\Eric Müller\Desktop\Discord bot\node_modules\discord.js\src\client\websocket\WebSocketManager.js:384:31)
    at WebSocketShard.onPacket (C:\Users\Eric Müller\Desktop\Discord bot\node_modules\discord.js\src\client\websocket\WebSocketShard.js:444:22)
    at WebSocketShard.onMessage (C:\Users\Eric Müller\Desktop\Discord bot\node_modules\discord.js\src\client\websocket\WebSocketShard.js:301:10)
    at WebSocket.onMessage (C:\Users\Eric Müller\Desktop\Discord bot\node_modules\ws\lib\event-target.js:132:16)
    at WebSocket.emit (events.js:315:20)
    at Receiver.receiverOnMessage (C:\Users\Eric Müller\Desktop\Discord bot\node_modules\ws\lib\websocket.js:825:20)
const Discord = require('discord.js');
const client = new Discord.Client();
const prefix = '-';
const fs = require('fs');
client.commands = new Discord.Collection();
const commandFiles = fs.readdirSync('./commands/').filter(file => file.endsWith('.js'));

for(const file of commandFiles){
const command = require(`./commands/${file}`);

    client.commands.set(command.name, command);

}

client.once('ready', () => {

    console.log('Codelyon is online!');

});

client.on('message', message =>{

if(!message.content.startsWith(prefix) || message.author.bot) return;

const args = message.content.slice(prefix.length).split(/ +/);
const command = args.shift().toLowerCase();

if(command === 'ping'){

        client.commands.get('ping').execute(message, args);

}
});

client.login('   '); (DISCLAMER! THE TOKEN IS FILLED IN AND CORRECT)
module.exports = {
name: 'ping',
description: "this is a ping command!",
execute(message, args){
message.channel.send('pong!');
    }
}
ping.js:

ReferenceError: clicent is not defined
    at Client.<anonymous> (C:\Users\Eric Müller\Desktop\Discord bot\Main.js:27:9)       
    at Client.emit (events.js:315:20)
    at MessageCreateAction.handle (C:\Users\Eric Müller\Desktop\Discord bot\node_modules\discord.js\src\client\actions\MessageCreate.js:31:14)
    at Object.module.exports [as MESSAGE_CREATE] (C:\Users\Eric Müller\Desktop\Discord bot\node_modules\discord.js\src\client\websocket\handlers\MESSAGE_CREATE.js:4:32)        
    at WebSocketManager.handlePacket (C:\Users\Eric Müller\Desktop\Discord bot\node_modules\discord.js\src\client\websocket\WebSocketManager.js:384:31)
    at WebSocketShard.onPacket (C:\Users\Eric Müller\Desktop\Discord bot\node_modules\discord.js\src\client\websocket\WebSocketShard.js:444:22)
    at WebSocketShard.onMessage (C:\Users\Eric Müller\Desktop\Discord bot\node_modules\discord.js\src\client\websocket\WebSocketShard.js:301:10)
    at WebSocket.onMessage (C:\Users\Eric Müller\Desktop\Discord bot\node_modules\ws\lib\event-target.js:132:16)
    at WebSocket.emit (events.js:315:20)
    at Receiver.receiverOnMessage (C:\Users\Eric Müller\Desktop\Discord bot\node_modules\ws\lib\websocket.js:825:20)
const Discord = require('discord.js');
const client = new Discord.Client();
const prefix = '-';
const fs = require('fs');
client.commands = new Discord.Collection();
const commandFiles = fs.readdirSync('./commands/').filter(file => file.endsWith('.js'));

for(const file of commandFiles){
const command = require(`./commands/${file}`);

    client.commands.set(command.name, command);

}

client.once('ready', () => {

    console.log('Codelyon is online!');

});

client.on('message', message =>{

if(!message.content.startsWith(prefix) || message.author.bot) return;

const args = message.content.slice(prefix.length).split(/ +/);
const command = args.shift().toLowerCase();

if(command === 'ping'){

        client.commands.get('ping').execute(message, args);

}
});

client.login('   '); (DISCLAMER! THE TOKEN IS FILLED IN AND CORRECT)
module.exports = {
name: 'ping',
description: "this is a ping command!",
execute(message, args){
message.channel.send('pong!');
    }
}

正如错误所暗示的,您的代码中很可能有输入错误:

ReferenceError:客户端未定义Client。(C:\Users\Eric Müller\Desktop\Discord bot\Main.js:27:9)


该错误告诉您,在Main.js文件的第27行开头,您有clicent,但它可能应该是client。

@cat_craft简言之,clicent拼写错误。是客户。你有一个额外的c。在i和e之间。