Browse Source

[Interactions] Create User only when in DMs

pull/6961/head
AXVin 4 years ago
committed by Rapptz
parent
commit
2ad2cab50c
  1. 12
      discord/interactions.py

12
discord/interactions.py

@ -111,11 +111,7 @@ class Interaction:
except KeyError:
self.message = None
try:
self.user = User(state=self._state, data=data['user'])
except KeyError:
self.user = None
self.user: Optional[Union[User, Member]] = None
# TODO: there's a potential data loss here
if self.guild_id:
guild = self.guild or Object(id=self.guild_id)
@ -123,6 +119,12 @@ class Interaction:
self.user = Member(state=self._state, guild=guild, data=data['member'])
except KeyError:
pass
else:
try:
self.user = User(state=self._state, data=data['user'])
except KeyError:
pass
@property
def guild(self) -> Optional[Guild]:

Loading…
Cancel
Save