diff --git a/changelog/1035.deprecate.rst b/changelog/1035.deprecate.rst new file mode 100644 index 0000000000..210816ff91 --- /dev/null +++ b/changelog/1035.deprecate.rst @@ -0,0 +1 @@ +The :class:`PartyType` enum is deprecated, as voice activity IDs are not officially documented and the enum regularly becomes outdated. diff --git a/disnake/abc.py b/disnake/abc.py index 78abdbb623..980a0ccb06 100644 --- a/disnake/abc.py +++ b/disnake/abc.py @@ -38,6 +38,7 @@ from .flags import ChannelFlags, MessageFlags from .invite import Invite from .mentions import AllowedMentions +from .object import Object from .partial_emoji import PartialEmoji from .permissions import PermissionOverwrite, Permissions from .role import Role @@ -1274,7 +1275,7 @@ async def create_invite( unique: bool = True, target_type: Optional[InviteTarget] = None, target_user: Optional[User] = None, - target_application: Optional[PartyType] = None, + target_application: Optional[Union[Snowflake, PartyType]] = None, guild_scheduled_event: Optional[GuildScheduledEvent] = None, ) -> Invite: """|coro| @@ -1310,11 +1311,14 @@ async def create_invite( .. versionadded:: 2.0 - target_application: Optional[:class:`.PartyType`] + target_application: Optional[:class:`.Snowflake`] The ID of the embedded application for the invite, required if `target_type` is `TargetType.embedded_application`. .. versionadded:: 2.0 + .. versionchanged:: 2.9 + ``PartyType`` is deprecated, and :class:`.Snowflake` should be used instead. + guild_scheduled_event: Optional[:class:`.GuildScheduledEvent`] The guild scheduled event to include with the invite. @@ -1335,6 +1339,12 @@ async def create_invite( :class:`.Invite` The newly created invite. """ + if isinstance(target_application, PartyType): + utils.warn_deprecated( + "PartyType is deprecated and will be removed in future version", + stacklevel=2, + ) + target_application = Object(target_application.value) data = await self._state.http.create_invite( self.id, reason=reason, @@ -1344,7 +1354,7 @@ async def create_invite( unique=unique, target_type=try_enum_to_int(target_type), target_user_id=target_user.id if target_user else None, - target_application_id=try_enum_to_int(target_application), + target_application_id=target_application.id if target_application else None, ) invite = Invite.from_incomplete(data=data, state=self._state) invite.guild_scheduled_event = guild_scheduled_event