Skip to content

Commit

Permalink
Interaction: experimental support for partial objects
Browse files Browse the repository at this point in the history
  • Loading branch information
Bilal2453 committed Nov 28, 2024
1 parent 2b559fa commit 5a9180e
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion libs/containers/Interaction.lua
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,16 @@ function Interaction:_loadGuild(data)
if not data.guild_id then
return
end
self._guild = getGuild(self.parent, data.guild_id)
if data.guild then
local guild = data.guild
guild.emojis = guild.emojis or {}
guild.stickers = guild.stickers or {}
guild.roles = guild.roles or {}
guild = self.parent._guilds:_insert(data.guild)
self._guild = guild
else
self._guild = getGuild(self.parent, data.guild_id)
end
end

local function insertChannel(client, data, parent)
Expand Down Expand Up @@ -144,6 +153,14 @@ function Interaction:_loadChannel(data)
if self._channel then
return
end
-- otherwise, try to use the partial channel object
if data.channel then
data.channel.permission_overwrites = {}
self._channel = insertChannel(self.parent, data.channel, self._guild)
if self._channel then
return
end
end
-- last resort, request the channel object from the API if it isn't cached
self._channel = getChannel(self.parent, channelId, self._guild)
end
Expand Down

0 comments on commit 5a9180e

Please sign in to comment.