|
|
@ -193,6 +193,26 @@ class Interaction(Generic[ClientT]): |
|
|
|
except KeyError: |
|
|
|
self.guild_locale = None |
|
|
|
|
|
|
|
guild = None |
|
|
|
if self.guild_id: |
|
|
|
guild = self._state._get_or_create_unavailable_guild(self.guild_id) |
|
|
|
|
|
|
|
raw_channel = data.get('channel', {}) |
|
|
|
channel_id = utils._get_as_snowflake(raw_channel, 'id') |
|
|
|
if channel_id is not None and guild is not None: |
|
|
|
self.channel = guild and guild._resolve_channel(channel_id) |
|
|
|
|
|
|
|
raw_ch_type = raw_channel.get('type') |
|
|
|
if self.channel is None and raw_ch_type is not None: |
|
|
|
factory, ch_type = _threaded_channel_factory(raw_ch_type) # type is never None |
|
|
|
if factory is None: |
|
|
|
logging.info('Unknown channel type {type} for channel ID {id}.'.format_map(raw_channel)) |
|
|
|
else: |
|
|
|
if ch_type in (ChannelType.group, ChannelType.private): |
|
|
|
self.channel = factory(me=self._client.user, data=raw_channel, state=self._state) # type: ignore |
|
|
|
elif guild is not None: |
|
|
|
self.channel = factory(guild=guild, state=self._state, data=raw_channel) # type: ignore |
|
|
|
|
|
|
|
self.message: Optional[Message] |
|
|
|
try: |
|
|
|
# The channel and message payloads are mismatched yet handled properly at runtime |
|
|
@ -204,10 +224,7 @@ class Interaction(Generic[ClientT]): |
|
|
|
self._permissions: int = 0 |
|
|
|
self._app_permissions: int = int(data.get('app_permissions', 0)) |
|
|
|
|
|
|
|
guild = None |
|
|
|
if self.guild_id: |
|
|
|
guild = self._state._get_or_create_unavailable_guild(self.guild_id) |
|
|
|
|
|
|
|
if guild is not None: |
|
|
|
# Upgrade Message.guild in case it's missing with partial guild data |
|
|
|
if self.message is not None and self.message.guild is None: |
|
|
|
self.message.guild = guild |
|
|
@ -225,22 +242,6 @@ class Interaction(Generic[ClientT]): |
|
|
|
except KeyError: |
|
|
|
pass |
|
|
|
|
|
|
|
raw_channel = data.get('channel', {}) |
|
|
|
channel_id = utils._get_as_snowflake(raw_channel, 'id') |
|
|
|
if channel_id is not None and guild is not None: |
|
|
|
self.channel = guild and guild._resolve_channel(channel_id) |
|
|
|
|
|
|
|
raw_ch_type = raw_channel.get('type') |
|
|
|
if self.channel is None and raw_ch_type is not None: |
|
|
|
factory, ch_type = _threaded_channel_factory(raw_ch_type) # type is never None |
|
|
|
if factory is None: |
|
|
|
logging.info('Unknown channel type {type} for channel ID {id}.'.format_map(raw_channel)) |
|
|
|
else: |
|
|
|
if ch_type in (ChannelType.group, ChannelType.private): |
|
|
|
self.channel = factory(me=self._client.user, data=raw_channel, state=self._state) # type: ignore |
|
|
|
elif guild is not None: |
|
|
|
self.channel = factory(guild=guild, state=self._state, data=raw_channel) # type: ignore |
|
|
|
|
|
|
|
@property |
|
|
|
def client(self) -> ClientT: |
|
|
|
""":class:`Client`: The client that is handling this interaction. |
|
|
|