【问题标题】:ReferenceError: client is not defined. Discord JSReferenceError:未定义客户端。不和谐 JS
【发布时间】:2020-11-10 04:24:13
【问题描述】:
ReferenceError: clinet is not defined
at Client.<anonymous> (/Users/gavinmartin/Desktop/myshadow/main.js:34:9)
at Client.emit (events.js:315:20)
at MessageCreateAction.handle (/Users/gavinmartin/Desktop/myshadow/node_modules/discord.js/src/client/actions/MessageCreate.js:31:14)
at Object.module.exports [as MESSAGE_CREATE] (/Users/gavinmartin/Desktop/myshadow/node_modules/discord.js/src/client/websocket/handlers/MESSAGE_CREATE.js:4:32)
at WebSocketManager.handlePacket (/Users/gavinmartin/Desktop/myshadow/node_modules/discord.js/src/client/websocket/WebSocketManager.js:386:31)
at WebSocketShard.onPacket (/Users/gavinmartin/Desktop/myshadow/node_modules/discord.js/src/client/websocket/WebSocketShard.js:436:22)
at WebSocketShard.onMessage (/Users/gavinmartin/Desktop/myshadow/node_modules/discord.js/src/client/websocket/WebSocketShard.js:293:10)
at WebSocket.onMessage (/Users/gavinmartin/Desktop/myshadow/node_modules/ws/lib/event-target.js:125:16)
at WebSocket.emit (events.js:315:20)

尝试运行自定义命令时会发生此错误。

【问题讨论】:

    标签: discord


    【解决方案1】:

    请在询问时提供导致错误的代码。

    虽然看着这个clinet is not defined

    您似乎拼错了client 最有可能

    【讨论】:

    • client.on('message', message =&gt; { 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); } else if (command === 'support'){ client.commands.get('support').execute(message, args); } else if (command === 'cmds'){ client.commands.get('cmds').execute(message, args); } });
    • !ping, !support 有效,但 !cmds 无效,并且格式相同。
    • @WoahCreates 错误很明显,上面写着clinet is not defined。您在代码中写了clinet,而不是main.js 第34 行第9 行的client。似乎您在评论中修复了错字,但这只是导致您的问题出现错误的原因,因此请在您的代码中修复它会工作的
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-04-16
    • 2018-08-26
    • 2021-08-08
    • 2014-04-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多