Browse Source

Update create invite parameters

pull/10109/head
dolfies 2 years ago
parent
commit
31c31ce030
  1. 20
      discord/abc.py
  2. 8
      discord/http.py
  3. 2
      discord/invite.py

20
discord/abc.py

@ -1260,9 +1260,10 @@ class GuildChannel:
max_uses: int = 0,
temporary: bool = False,
unique: bool = True,
validate: Optional[Union[Invite, str]],
target_type: Optional[InviteTarget] = None,
target_user: Optional[User] = None,
target_application_id: Optional[int] = None,
target_application: Optional[Snowflake] = None,
) -> Invite:
"""|coro|
@ -1286,8 +1287,11 @@ class GuildChannel:
Indicates if a unique invite URL should be created. Defaults to True.
If this is set to ``False`` then it will return a previously created
invite.
reason: Optional[:class:`str`]
The reason for creating this invite. Shows up on the audit log.
validate: Union[:class:`Invite`, :class:`str`]
The existing channel invite to validate and return for reuse.
If this invite is invalid, a new invite will be created according to the parameters and returned.
.. versionadded:: 2.0
target_type: Optional[:class:`.InviteTarget`]
The type of target for the voice channel invite, if any.
@ -1298,11 +1302,14 @@ class GuildChannel:
.. versionadded:: 2.0
target_application_id:: Optional[:class:`int`]
The id of the embedded application for the invite, required if `target_type` is `TargetType.embedded_application`.
target_application:: Optional[:class:`Application`]
The embedded application for the invite, required if `target_type` is `TargetType.embedded_application`.
.. versionadded:: 2.0
reason: Optional[:class:`str`]
The reason for creating this invite. Shows up on the audit log.
Raises
-------
~discord.HTTPException
@ -1323,9 +1330,10 @@ class GuildChannel:
max_uses=max_uses,
temporary=temporary,
unique=unique,
validate=utils.resolve_invite(validate).code if validate else None,
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,
target_application_id=target_application.id if target_application else None,
)
return Invite.from_incomplete(data=data, state=self._state)

8
discord/http.py

@ -1792,6 +1792,7 @@ class HTTPClient:
max_uses: int = 0,
temporary: bool = False,
unique: bool = True,
validate: Optional[str] = None,
target_type: Optional[invite.InviteTargetType] = None,
target_user_id: Optional[Snowflake] = None,
target_application_id: Optional[Snowflake] = None,
@ -1799,11 +1800,12 @@ class HTTPClient:
payload = {
'max_age': max_age,
'max_uses': max_uses,
'target_type': target_type,
'temporary': temporary,
'unique': unique,
'validate': validate,
}
if target_type:
payload['target_type'] = target_type
if unique:
payload['unique'] = unique
if target_user_id:
payload['target_user_id'] = target_user_id
if target_application_id:

2
discord/invite.py

@ -530,7 +530,7 @@ class Invite(Hashable):
channel_data = data.get('channel')
if channel_data and channel_data.get('type') == ChannelType.private.value:
channel_data['recipients'] = [data['inviter']] if 'inviter' in data else []
channel_data['recipients'] = [data['inviter']] if 'inviter' in data else [] # type: ignore
channel = PartialInviteChannel(channel_data, state)
channel = state.get_channel(getattr(channel, 'id', None)) or channel

Loading…
Cancel
Save