mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-09-06 09:56:09 +00:00
Add type attribute to Invite
This commit is contained in:
@ -29,7 +29,7 @@ from .asset import Asset
|
||||
from .utils import parse_time, snowflake_time, _get_as_snowflake
|
||||
from .object import Object
|
||||
from .mixins import Hashable
|
||||
from .enums import ChannelType, NSFWLevel, VerificationLevel, InviteTarget, try_enum
|
||||
from .enums import ChannelType, NSFWLevel, VerificationLevel, InviteTarget, InviteType, try_enum
|
||||
from .appinfo import PartialAppInfo
|
||||
from .scheduled_event import ScheduledEvent
|
||||
|
||||
@ -296,6 +296,10 @@ class Invite(Hashable):
|
||||
|
||||
Attributes
|
||||
-----------
|
||||
type: :class:`InviteType`
|
||||
The type of the invite.
|
||||
|
||||
.. versionadded: 2.4
|
||||
max_age: Optional[:class:`int`]
|
||||
How long before the invite expires in seconds.
|
||||
A value of ``0`` indicates that it doesn't expire.
|
||||
@ -374,6 +378,7 @@ class Invite(Hashable):
|
||||
'expires_at',
|
||||
'scheduled_event',
|
||||
'scheduled_event_id',
|
||||
'type',
|
||||
)
|
||||
|
||||
BASE = 'https://discord.gg'
|
||||
@ -387,6 +392,7 @@ class Invite(Hashable):
|
||||
channel: Optional[Union[PartialInviteChannel, GuildChannel]] = None,
|
||||
):
|
||||
self._state: ConnectionState = state
|
||||
self.type: InviteType = try_enum(InviteType, data.get('type', 0))
|
||||
self.max_age: Optional[int] = data.get('max_age')
|
||||
self.code: str = data['code']
|
||||
self.guild: Optional[InviteGuildType] = self._resolve_guild(data.get('guild'), guild)
|
||||
@ -496,7 +502,7 @@ class Invite(Hashable):
|
||||
|
||||
def __repr__(self) -> str:
|
||||
return (
|
||||
f'<Invite code={self.code!r} guild={self.guild!r} '
|
||||
f'<Invite type={self.type} code={self.code!r} guild={self.guild!r} '
|
||||
f'online={self.approximate_presence_count} '
|
||||
f'members={self.approximate_member_count}>'
|
||||
)
|
||||
|
Reference in New Issue
Block a user