mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-09-06 09:56:09 +00:00
Add support for guest invites
This commit is contained in:
@ -60,6 +60,7 @@ from .http import handle_message_parameters
|
||||
from .voice_client import VoiceClient, VoiceProtocol
|
||||
from .sticker import GuildSticker, StickerItem
|
||||
from . import utils
|
||||
from .flags import InviteFlags
|
||||
|
||||
__all__ = (
|
||||
'Snowflake',
|
||||
@ -1257,6 +1258,7 @@ class GuildChannel:
|
||||
target_type: Optional[InviteTarget] = None,
|
||||
target_user: Optional[User] = None,
|
||||
target_application_id: Optional[int] = None,
|
||||
guest: bool = False,
|
||||
) -> Invite:
|
||||
"""|coro|
|
||||
|
||||
@ -1295,6 +1297,10 @@ class GuildChannel:
|
||||
The id of the embedded application for the invite, required if ``target_type`` is :attr:`.InviteTarget.embedded_application`.
|
||||
|
||||
.. versionadded:: 2.0
|
||||
guest: :class:`bool`
|
||||
Whether the invite is a guest invite.
|
||||
|
||||
.. versionadded:: 2.6
|
||||
|
||||
Raises
|
||||
-------
|
||||
@ -1312,6 +1318,11 @@ class GuildChannel:
|
||||
if target_type is InviteTarget.unknown:
|
||||
raise ValueError('Cannot create invite with an unknown target type')
|
||||
|
||||
flags: Optional[InviteFlags] = None
|
||||
if guest:
|
||||
flags = InviteFlags._from_value(0)
|
||||
flags.guest = True
|
||||
|
||||
data = await self._state.http.create_invite(
|
||||
self.id,
|
||||
reason=reason,
|
||||
@ -1322,6 +1333,7 @@ class GuildChannel:
|
||||
target_type=target_type.value if target_type else None,
|
||||
target_user_id=target_user.id if target_user else None,
|
||||
target_application_id=target_application_id,
|
||||
flags=flags.value if flags else None,
|
||||
)
|
||||
return Invite.from_incomplete(data=data, state=self._state)
|
||||
|
||||
|
Reference in New Issue
Block a user