[英]discord.js Error TypeError: Cannot read property 'voiceChannel' of undefined
else if (m.content.startsWith(config.prefix + 'voteskip' && (client.guildMember.voiceChannel.connection() === guild.user.voiceChannel.connection())))
Hi there, this code above is designed to compare the voice channels of the bot and the user who uses the command *voteskip. 嗨,上面的这段代码旨在比较机器人和使用* voteskip命令的用户的语音通道。 However when someone uses the command, it gives the full error:
但是,当有人使用该命令时,它将给出完整的错误:
TypeError: Cannot read property 'voiceChannel' of undefined
TypeError:无法读取未定义的属性“ voiceChannel”
Any ideas why? 有什么想法吗?
This JavaScript error means that client.guildMember
is undefined
ie not set, thus you can't get any properties for something that isn't defined or set. 此JavaScript错误意味着
client.guildMember
是undefined
即未设置,因此您无法获得未定义或设置的任何属性。
You're probably making too strong an assumption that client has a guild member (whatever that is). 您可能会以为客户拥有公会成员(无论是哪种成员)的假设太过强烈。 Check that the
client.guildMember
is defined (eg client.guildMember !== undefined
), otherwise handle the case when it is not. 检查是否已定义
client.guildMember
(例如, client.guildMember !== undefined
),否则请处理client.guildMember !== undefined
的情况。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.