Skip to content

Commit

Permalink
Added voice state data validation
Browse files Browse the repository at this point in the history
  • Loading branch information
SinisterRectus committed Oct 19, 2017
1 parent de8876a commit a090a7e
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions libs/containers/Guild.lua
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ function Guild:__init(data, parent)
self._text_channels = Cache({}, GuildTextChannel, self)
self._voice_channels = Cache({}, GuildVoiceChannel, self)
self._categories = Cache({}, GuildCategoryChannel, self)
self._voice_states = {}
if not data.unavailable then
return self:_makeAvailable(data)
end
Expand All @@ -39,12 +40,12 @@ function Guild:_makeAvailable(data)
self._roles:_load(data.roles)
self._emojis:_load(data.emojis)

local voice_states = data.voice_states
for i, state in ipairs(voice_states) do
voice_states[state.user_id] = state
voice_states[i] = nil
if data.voice_states then
local states = self._voice_states
for _, state in ipairs(data.voice_states) do
states[state.user_id] = state
end
end
self._voice_states = voice_states

local text_channels = self._text_channels
local voice_channels = self._voice_channels
Expand Down

0 comments on commit a090a7e

Please sign in to comment.