OceanicJS / Oceanic

A NodeJS library for interfacing with Discord.
https://oceanic.ws
MIT License
269 stars 25 forks source link

fix UncachedError on VOICE_STATE_UPDATE #130

Closed urbainn closed 9 months ago

urbainn commented 9 months ago

Hello, I noticed that when disabling cache, on dispatch of a VOICE_STATE_UPDATE event, oceanic will systematically throw a UncachedError (UncachedError: Member#guild is not present.)

I looked through the source code and found that in order to get the oldState, member.voiceState() is called, and this method itself calls member.guild (and it throws the error)

So I proposed to instead directly call guild?.voiceStates.get(member.id)? so that if guild is not cached, oldState will simply default to null and avoid throwing error