Skip to content

Commit

Permalink
chore(commands): don't put partial guild in cache
Browse files Browse the repository at this point in the history
  • Loading branch information
Middledot committed Oct 29, 2023
1 parent 612c9a6 commit 639a43a
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions discord/interactions.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,9 @@ def _from_data(self, data: InteractionPayload):
self.user: User | Member | None = None
self._permissions: int = 0

if (_guild_data := data.get("guild")):
self._state._get_create_guild(_guild_data)
self._guild: Guild | None = None
if self.guild is None and (_guild_data := data.get("guild")):
self._guild = Guild(data=data, state=self)

self._guild_data = _guild_data

Expand Down Expand Up @@ -253,6 +254,8 @@ def client(self) -> Client:
@property
def guild(self) -> Guild | None:
"""The guild the interaction was sent from."""
if self._guild:
return self._guild
return self._state and self._state._get_guild(self.guild_id)

def is_command(self) -> bool:
Expand Down

0 comments on commit 639a43a

Please sign in to comment.