2017-02-17 204 views
0
else if (m.content.startsWith(config.prefix + 'voteskip' && (client.guildMember.voiceChannel.connection() === guild.user.voiceChannel.connection()))) 

嗨無法讀取屬性「voiceChannel」在那裏,上面這段代碼的目的是比較機器人的語音信道以及誰在使用該命令* voteskip用戶。但是,當有人使用該命令時,會給出完整的錯誤:discord.js錯誤類型錯誤:未定義

TypeError: Cannot read property 'voiceChannel' of undefined

任何想法爲什麼?

回答

0

此JavaScript錯誤意味着client.guildMemberundefined即未設置,因此無法獲取任何未定義或設置的屬性的屬性。

你可能會做出太強烈的假設,即客戶有一個公會成員(不管那是什麼)。檢查是否定義了client.guildMember(例如client.guildMember !== undefined),否則處理該情況。