Skip to content

Commit 52cf072

Browse files
authored
Merge branch 'master' into feat-media-channels
2 parents 7f6b0c8 + c14c073 commit 52cf072

File tree

6 files changed

+28
-23
lines changed

6 files changed

+28
-23
lines changed

.github/workflows/docs-localization-download.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ jobs:
4040
working-directory: ./docs
4141
- name: "Crowdin"
4242
id: crowdin
43-
uses: crowdin/[email protected].0
43+
uses: crowdin/[email protected].1
4444
with:
4545
upload_sources: false
4646
upload_translations: false

.github/workflows/docs-localization-upload.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ jobs:
4444
sphinx-intl update -p ./build/locales ${{ vars.SPHINX_LANGUAGES }}
4545
working-directory: ./docs
4646
- name: "Crowdin"
47-
uses: crowdin/[email protected].0
47+
uses: crowdin/[email protected].1
4848
with:
4949
upload_sources: true
5050
upload_translations: false

.github/workflows/todo-checks.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
- name: "Checkout Repository"
2424
uses: actions/checkout@v4
2525
- name: "Track TODO Action"
26-
uses: ribtoks/[email protected].13-beta
26+
uses: ribtoks/[email protected].14-beta
2727
with:
2828
TOKEN: ${{ secrets.GITHUB_TOKEN }}
2929
REPO: ${{ github.repository }}

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@ These changes are available on the `master` branch, but have not yet been releas
7777
apps. ([#2650](https://github.com/Pycord-Development/pycord/pull/2650))
7878
- Fixed type annotations of cached properties.
7979
([#2635](https://github.com/Pycord-Development/pycord/issues/2635))
80+
- Fixed malformed properties in `Interaction.channel`.
81+
([#2658](https://github.com/Pycord-Development/pycord/pull/2658))
8082
- Fixed an error when responding non-ephemerally with a `Paginator` to an ephemerally
8183
deferred interaction.
8284
([#2661](https://github.com/Pycord-Development/pycord/pull/2661))

discord/interactions.py

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ class Interaction:
119119
The interaction type.
120120
guild_id: Optional[:class:`int`]
121121
The guild ID the interaction was sent from.
122-
channel: Optional[Union[:class:`abc.GuildChannel`, :class:`abc.PrivateChannel`, :class:`Thread`]]
122+
channel: Optional[Union[:class:`abc.GuildChannel`, :class:`abc.PrivateChannel`, :class:`Thread`, :class:`PartialMessageable`]]
123123
The channel the interaction was sent from.
124124
channel_id: Optional[:class:`int`]
125125
The ID of the channel the interaction was sent from.
@@ -261,20 +261,23 @@ def _from_data(self, data: InteractionPayload):
261261
except KeyError:
262262
pass
263263

264-
if channel := data.get("channel"):
265-
if (ch_type := channel.get("type")) is not None:
266-
factory, ch_type = _threaded_channel_factory(ch_type)
264+
channel = data.get("channel")
265+
data_ch_type: int | None = channel.get("type") if channel else None
267266

268-
if ch_type in (ChannelType.group, ChannelType.private):
269-
self.channel = factory(
270-
me=self.user, data=channel, state=self._state
271-
)
272-
elif self.guild:
273-
self.channel = factory(
274-
guild=self.guild, state=self._state, data=channel
275-
)
276-
else:
277-
self.channel = self.cached_channel
267+
if data_ch_type is not None:
268+
factory, ch_type = _threaded_channel_factory(data_ch_type)
269+
if ch_type in (ChannelType.group, ChannelType.private):
270+
self.channel = factory(me=self.user, data=channel, state=self._state)
271+
272+
if self.channel is None and self.guild:
273+
self.channel = self.guild._resolve_channel(self.channel_id)
274+
if self.channel is None and self.channel_id is not None:
275+
ch_type = (
276+
ChannelType.text if self.guild_id is not None else ChannelType.private
277+
)
278+
self.channel = PartialMessageable(
279+
state=self._state, id=self.channel_id, type=ch_type
280+
)
278281

279282
self._channel_data = channel
280283

@@ -306,12 +309,12 @@ def is_component(self) -> bool:
306309
return self.type == InteractionType.component
307310

308311
@utils.cached_slot_property("_cs_channel")
312+
@utils.deprecated("Interaction.channel", "2.7", stacklevel=4)
309313
def cached_channel(self) -> InteractionChannel | None:
310-
"""The channel the
311-
interaction was sent from.
314+
"""The cached channel from which the interaction was sent.
315+
DM channels are not resolved. These are :class:`PartialMessageable` instead.
312316
313-
Note that due to a Discord limitation, DM channels are not resolved since there is
314-
no data to complete them. These are :class:`PartialMessageable` instead.
317+
.. deprecated:: 2.7
315318
"""
316319
guild = self.guild
317320
channel = guild and guild._resolve_channel(self.channel_id)

requirements/dev.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ pytest-asyncio~=0.23.8
55
# pytest-order~=1.0.1
66
mypy~=1.14.1
77
coverage~=7.6
8-
pre-commit==4.0.1
8+
pre-commit==4.1.0
99
codespell==2.3.0
10-
bandit==1.8.0
10+
bandit==1.8.2
1111
flake8==7.1.1

0 commit comments

Comments
 (0)