【问题标题】:discord.js Error TypeError: Cannot read property 'voiceChannel' of undefineddiscord.js 错误类型错误:无法读取未定义的属性“voiceChannel”
【发布时间】:2017-07-06 23:51:30
【问题描述】:
else if (m.content.startsWith(config.prefix + 'voteskip' && (client.guildMember.voiceChannel.connection() === guild.user.voiceChannel.connection())))

您好,上面的代码旨在比较机器人和使用命令 *voteskip 的用户的语音通道。但是,当有人使用该命令时,它会给出完整的错误:

TypeError: 无法读取未定义的属性“voiceChannel”

有什么想法吗?

【问题讨论】:

    标签: javascript typeerror discord


    【解决方案1】:

    此 JavaScript 错误意味着 client.guildMemberundefined 即未设置,因此您无法获取未定义或未设置的任何属性。

    您可能过于强烈地假设客户有公会成员(无论是什么)。检查client.guildMember是否已定义(例如client.guildMember !== undefined),否则处理未定义的情况。

    【讨论】:

      猜你喜欢
      • 2021-07-27
      • 2021-02-16
      • 2018-04-29
      • 1970-01-01
      • 2023-02-23
      • 1970-01-01
      • 2021-07-10
      • 1970-01-01
      • 2021-12-03
      相关资源
      最近更新 更多