From 6ec2e5329b1059a80adf408dc08b6955a49f318b Mon Sep 17 00:00:00 2001 From: Sacul Date: Tue, 12 Aug 2025 15:18:24 +0800 Subject: [PATCH] Deprecate with_expiration param in fetch_invite --- discord/client.py | 4 +++- discord/http.py | 2 -- discord/invite.py | 5 +++-- discord/types/gateway.py | 1 + discord/types/invite.py | 3 ++- 5 files changed, 9 insertions(+), 6 deletions(-) diff --git a/discord/client.py b/discord/client.py index 4f16e6ff5..56f256231 100644 --- a/discord/client.py +++ b/discord/client.py @@ -2510,6 +2510,9 @@ class Client: :attr:`.Invite.expires_at` field. .. versionadded:: 2.0 + .. deprecated:: 2.6 + This parameter is deprecated and will be removed in a future version as it is no + longer needed to fill the :attr:`.Invite.expires_at` field. scheduled_event_id: Optional[:class:`int`] The ID of the scheduled event this invite is for. @@ -2545,7 +2548,6 @@ class Client: data = await self.http.get_invite( resolved.code, with_counts=with_counts, - with_expiration=with_expiration, guild_scheduled_event_id=scheduled_event_id, ) return Invite.from_incomplete(state=self._connection, data=data) diff --git a/discord/http.py b/discord/http.py index 15de396d0..41927c683 100644 --- a/discord/http.py +++ b/discord/http.py @@ -1864,12 +1864,10 @@ class HTTPClient: invite_id: str, *, with_counts: bool = True, - with_expiration: bool = True, guild_scheduled_event_id: Optional[Snowflake] = None, ) -> Response[invite.Invite]: params: Dict[str, Any] = { 'with_counts': int(with_counts), - 'with_expiration': int(with_expiration), } if guild_scheduled_event_id: diff --git a/discord/invite.py b/discord/invite.py index 362f97693..38ee45901 100644 --- a/discord/invite.py +++ b/discord/invite.py @@ -290,8 +290,6 @@ class Invite(Hashable): +------------------------------------+--------------------------------------------------------------+ | :attr:`approximate_presence_count` | :meth:`Client.fetch_invite` with ``with_counts`` enabled | +------------------------------------+--------------------------------------------------------------+ - | :attr:`expires_at` | :meth:`Client.fetch_invite` with ``with_expiration`` enabled | - +------------------------------------+--------------------------------------------------------------+ If it's not in the table above then it is available by all methods. @@ -332,6 +330,9 @@ class Invite(Hashable): :meth:`Client.fetch_invite` with ``with_expiration`` enabled, the invite will never expire. .. versionadded:: 2.0 + .. versionchanged:: 2.6 + This will always be returned from all methods. ``None`` if the invite will + never expire. channel: Optional[Union[:class:`abc.GuildChannel`, :class:`Object`, :class:`PartialInviteChannel`]] The channel the invite is for. diff --git a/discord/types/gateway.py b/discord/types/gateway.py index 7dca5badc..61959dc72 100644 --- a/discord/types/gateway.py +++ b/discord/types/gateway.py @@ -145,6 +145,7 @@ class InviteCreateEvent(TypedDict): code: str created_at: str max_age: int + expires_at: Optional[str] max_uses: int temporary: bool uses: Literal[0] diff --git a/discord/types/invite.py b/discord/types/invite.py index 47c972994..06bd6649b 100644 --- a/discord/types/invite.py +++ b/discord/types/invite.py @@ -44,7 +44,6 @@ class _InviteMetadata(TypedDict, total=False): max_age: int temporary: bool created_at: str - expires_at: Optional[str] class VanityInvite(_InviteMetadata): @@ -66,6 +65,7 @@ class Invite(IncompleteInvite, total=False): guild_scheduled_event: GuildScheduledEvent type: InviteType flags: NotRequired[int] + expires_at: Optional[str] class InviteWithCounts(Invite, _GuildPreviewUnique): @@ -76,6 +76,7 @@ class GatewayInviteCreate(TypedDict): channel_id: Snowflake code: str created_at: str + expires_at: Optional[str] max_age: int max_uses: int temporary: bool