Javascript 命令不一致

Javascript 命令不一致,javascript,node.js,bots,discord,discord.js,Javascript,Node.js,Bots,Discord,Discord.js,我目前正在编写一个discord机器人,我想为该机器人编写一个about命令。这是我编写的代码,但它不起作用。我当前的所有命令都与命令文件夹中的index.js文件位于不同的文件中。你知道为什么这个坏了吗 const Discord = require('discord.js'); module.exports = { name: 'about', description: 'talks about the bot', execute(message) {

我目前正在编写一个discord机器人,我想为该机器人编写一个about命令。这是我编写的代码,但它不起作用。我当前的所有命令都与命令文件夹中的index.js文件位于不同的文件中。你知道为什么这个坏了吗

    const Discord = require('discord.js');
module.exports = {
    name: 'about',
    description: 'talks about the bot',
    execute(message) {
            const aboutEmbed = new Discord.MessageEmbed()
                .setColor('#0099ff')
                .setAuthor('Alien Bot: About')
                .setDescription(`Alien Bot, Created By MountainTiger144, Is A Fun Little Bot Used On ${client.guilds.cache.size}Servers With Commands Like <avatar And More! Check Them Out By Doing <help hub.`)
                .setThumbnail('https://fiverr-res.cloudinary.com/images/q_auto,f_auto/gigs/125937562/original/4efdc79b0e19dabcb3f6e7bef8318f2794250933/create-a-custom-discord-bot.png', 'https://fiverr-res.cloudinary.com/images/q_auto,f_auto/gigs/125937562/original/4efdc79b0e19dabcb3f6e7bef8318f2794250933/create-a-custom-discord-bot.png')
                .addFields(
                    { name: 'Guilds', value: `${client.guilds.cache.size}`, inline: true },
                    { name: 'Version', value: `${bot_info.version}`, inline: true },
                    { name: 'Rating', value: '7/10', inline: true },
                    { name: 'Support Server', value: 'If you need help or find a bug, please click the link [here](https://discord.gg/n293gkD) to get to our support server!', inline: true })
                
                channel.send(exampleEmbed);
            }
        }
const Discord=require('Discord.js');
module.exports={
姓名:'关于',
描述:'谈论机器人',
执行(消息){
const aboutEmbed=new Discord.MessageEmbed()
.setColor(“#0099ff”)
.setAuthor('外星人机器人:关于')

.setDescription(`Alien Bot,由MountainTiger144创建,是一个有趣的小Bot,在${client.guilds.cache.size}服务器上使用之类的命令,您需要通过主文件中的
execute()
函数传递
client
,如果已经传递了,只需将
client
添加到
execute()中即可
在命令文件中的功能如下:

module.exports={
姓名:'关于',
描述:'谈论机器人',
执行(消息,客户端){…}

您需要通过主文件中的
execute()
函数传递
client
,如果您已经传递了它,那么只需将
client
添加到命令文件中的
execute()
函数中,如下所示:

module.exports={
姓名:'关于',
描述:'谈论机器人',
执行(消息,客户端){…}
execute()
不知道客户机是什么,因为它尚未传入或以其他方式定义。通常,当我遇到此问题时,只需在“客户机”之前添加“message.”,然后您使用的是
message.client.guilds.cache.size
,这应该对您有用,因为消息已传入

或者,您可以将index.js文件中的client作为参数传入,这样做基本相同,但这可能会影响其他命令,因为它们可能不使用“client”参数。

execute()
不知道客户机是什么,因为它尚未传入或以其他方式定义。通常,当我遇到此问题时,只需在“客户机”之前添加“消息”。然后您使用的是
message.client.guilds.cache.size
这应该对您有用,因为消息已传入


或者,您可以将index.js文件中的client作为参数传入,这样做基本上是相同的,尽管这可能会影响其他命令,因为它们可能不使用“client”参数。

这没有任何区别。这没有任何区别。
ReferenceError: client is not defined
    at Object.execute (C:\Users\kiera\Desktop\Discord Bot\commands\about.js:10:104)
    at Client.<anonymous> (C:\Users\kiera\Desktop\Discord Bot\index.js:79:11)
    at Client.emit (events.js:315:20)
    at MessageCreateAction.handle (C:\Users\kiera\Desktop\Discord Bot\node_modules\discord.js\src\client\actions\MessageCreate.js:31:14)
    at Object.module.exports [as MESSAGE_CREATE] (C:\Users\kiera\Desktop\Discord Bot\node_modules\discord.js\src\client\websocket\handlers\MESSAGE_CREATE.js:4:32)
    at WebSocketManager.handlePacket (C:\Users\kiera\Desktop\Discord Bot\node_modules\discord.js\src\client\websocket\WebSocketManager.js:386:31)
    at WebSocketShard.onPacket (C:\Users\kiera\Desktop\Discord Bot\node_modules\discord.js\src\client\websocket\WebSocketShard.js:436:22)
    at WebSocketShard.onMessage (C:\Users\kiera\Desktop\Discord Bot\node_modules\discord.js\src\client\websocket\WebSocketShard.js:293:10)
    at WebSocket.onMessage (C:\Users\kiera\Desktop\Discord Bot\node_modules\ws\lib\event-target.js:125:16)
    at WebSocket.emit (events.js:315:20)