Browse Source

Apply suggested changes

guest_invite -> guest
GuildInviteFlags -> InviteFlags
is_guest_invite -> guest

Co-Authored-By: dolfies <47677887+dolfies@users.noreply.github.com>
pull/10220/head
Soheab_ 3 weeks ago
parent
commit
73c564f4d4
  1. 16
      discord/abc.py
  2. 18
      discord/flags.py
  3. 8
      discord/invite.py
  4. 6
      docs/api.rst

16
discord/abc.py

@ -60,7 +60,7 @@ from .http import handle_message_parameters
from .voice_client import VoiceClient, VoiceProtocol from .voice_client import VoiceClient, VoiceProtocol
from .sticker import GuildSticker, StickerItem from .sticker import GuildSticker, StickerItem
from . import utils from . import utils
from .flags import GuildInviteFlags from .flags import InviteFlags
__all__ = ( __all__ = (
'Snowflake', 'Snowflake',
@ -1258,7 +1258,7 @@ class GuildChannel:
target_type: Optional[InviteTarget] = None, target_type: Optional[InviteTarget] = None,
target_user: Optional[User] = None, target_user: Optional[User] = None,
target_application_id: Optional[int] = None, target_application_id: Optional[int] = None,
guest_invite: bool = False, guest: bool = False,
) -> Invite: ) -> Invite:
"""|coro| """|coro|
@ -1297,11 +1297,9 @@ class GuildChannel:
The id of the embedded application for the invite, required if ``target_type`` is :attr:`.InviteTarget.embedded_application`. The id of the embedded application for the invite, required if ``target_type`` is :attr:`.InviteTarget.embedded_application`.
.. versionadded:: 2.0 .. versionadded:: 2.0
guest_invite: :class:`bool` guest: :class:`bool`
Whether the invite is a guest invite. Whether the invite is a guest invite.
This is only available to guilds that contain ``GUESTS_ENABLED`` in :attr:`.Guild.features`.
.. versionadded:: 2.6 .. versionadded:: 2.6
Raises Raises
@ -1320,10 +1318,10 @@ class GuildChannel:
if target_type is InviteTarget.unknown: if target_type is InviteTarget.unknown:
raise ValueError('Cannot create invite with an unknown target type') raise ValueError('Cannot create invite with an unknown target type')
flags: Optional[GuildInviteFlags] = None flags: Optional[InviteFlags] = None
if guest_invite: if guest:
flags = GuildInviteFlags._from_value(0) flags = InviteFlags._from_value(0)
flags.is_guest_invite = True flags.guest = True
data = await self._state.http.create_invite( data = await self._state.http.create_invite(
self.id, self.id,

18
discord/flags.py

@ -64,7 +64,7 @@ __all__ = (
'AppInstallationType', 'AppInstallationType',
'SKUFlags', 'SKUFlags',
'EmbedFlags', 'EmbedFlags',
'GuildInviteFlags', 'InviteFlags',
) )
BF = TypeVar('BF', bound='BaseFlags') BF = TypeVar('BF', bound='BaseFlags')
@ -2400,8 +2400,8 @@ class EmbedFlags(BaseFlags):
return 1 << 5 return 1 << 5
class GuildInviteFlags(BaseFlags): class InviteFlags(BaseFlags):
r"""Wraps up the Discord Guild Invite flags r"""Wraps up the Discord Invite flags
.. versionadded:: 2.6 .. versionadded:: 2.6
@ -2409,25 +2409,25 @@ class GuildInviteFlags(BaseFlags):
.. describe:: x == y .. describe:: x == y
Checks if two GuildInviteFlags are equal. Checks if two InviteFlags are equal.
.. describe:: x != y .. describe:: x != y
Checks if two GuildInviteFlags are not equal. Checks if two InviteFlags are not equal.
.. describe:: x | y, x |= y .. describe:: x | y, x |= y
Returns a GuildInviteFlags instance with all enabled flags from Returns a InviteFlags instance with all enabled flags from
both x and y. both x and y.
.. describe:: x ^ y, x ^= y .. describe:: x ^ y, x ^= y
Returns a GuildInviteFlags instance with only flags enabled on Returns a InviteFlags instance with only flags enabled on
only one of x or y, not on both. only one of x or y, not on both.
.. describe:: ~x .. describe:: ~x
Returns a GuildInviteFlags instance with all flags inverted from x. Returns a InviteFlags instance with all flags inverted from x.
.. describe:: hash(x) .. describe:: hash(x)
@ -2451,6 +2451,6 @@ class GuildInviteFlags(BaseFlags):
""" """
@flag_value @flag_value
def is_guest_invite(self): def guest(self):
""":class:`bool`: Returns ``True`` if this is a guest invite for a voice channel.""" """:class:`bool`: Returns ``True`` if this is a guest invite for a voice channel."""
return 1 << 0 return 1 << 0

8
discord/invite.py

@ -32,7 +32,7 @@ from .mixins import Hashable
from .enums import ChannelType, NSFWLevel, VerificationLevel, InviteTarget, InviteType, try_enum from .enums import ChannelType, NSFWLevel, VerificationLevel, InviteTarget, InviteType, try_enum
from .appinfo import PartialAppInfo from .appinfo import PartialAppInfo
from .scheduled_event import ScheduledEvent from .scheduled_event import ScheduledEvent
from .flags import GuildInviteFlags from .flags import InviteFlags
__all__ = ( __all__ = (
'PartialInviteChannel', 'PartialInviteChannel',
@ -527,12 +527,12 @@ class Invite(Hashable):
return url return url
@property @property
def flags(self) -> GuildInviteFlags: def flags(self) -> InviteFlags:
""":class:`GuildInviteFlags`: Returns the flags for this guild invite. """:class:`InviteFlags`: Returns the flags for this guild invite.
.. versionadded:: 2.6 .. versionadded:: 2.6
""" """
return GuildInviteFlags._from_value(self._flags) return InviteFlags._from_value(self._flags)
def set_scheduled_event(self, scheduled_event: Snowflake, /) -> Self: def set_scheduled_event(self, scheduled_event: Snowflake, /) -> Self:
"""Sets the scheduled event for this invite. """Sets the scheduled event for this invite.

6
docs/api.rst

@ -5734,12 +5734,12 @@ EmbedFlags
.. autoclass:: EmbedFlags() .. autoclass:: EmbedFlags()
:members: :members:
GuildInviteFlags InviteFlags
~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~
.. attributetable:: GuildInviteFlags .. attributetable:: InviteFlags
.. autoclass:: GuildInviteFlags() .. autoclass:: InviteFlags()
:members: :members:
ForumTag ForumTag

Loading…
Cancel
Save