aboutsummaryrefslogtreecommitdiff
path: root/discord/invite.py
diff options
context:
space:
mode:
authorNadir Chowdhury <[email protected]>2021-05-01 12:46:16 +0100
committerGitHub <[email protected]>2021-05-01 07:46:16 -0400
commite762f5584765f2862b7e00fd3a4ad4c097da8e42 (patch)
tree5c8e85c286f403782a13ce894351af229d3e8f88 /discord/invite.py
parentFix guild application command endpoints (diff)
downloaddiscord.py-e762f5584765f2862b7e00fd3a4ad4c097da8e42.tar.xz
discord.py-e762f5584765f2862b7e00fd3a4ad4c097da8e42.zip
Add fetch_invite with with_expiration
Diffstat (limited to 'discord/invite.py')
-rw-r--r--discord/invite.py45
1 files changed, 28 insertions, 17 deletions
diff --git a/discord/invite.py b/discord/invite.py
index 95fcb0b7..7a80d301 100644
--- a/discord/invite.py
+++ b/discord/invite.py
@@ -219,23 +219,25 @@ class Invite(Hashable):
The following table illustrates what methods will obtain the attributes:
- +------------------------------------+----------------------------------------------------------+
- | Attribute | Method |
- +====================================+==========================================================+
- | :attr:`max_age` | :meth:`abc.GuildChannel.invites`\, :meth:`Guild.invites` |
- +------------------------------------+----------------------------------------------------------+
- | :attr:`max_uses` | :meth:`abc.GuildChannel.invites`\, :meth:`Guild.invites` |
- +------------------------------------+----------------------------------------------------------+
- | :attr:`created_at` | :meth:`abc.GuildChannel.invites`\, :meth:`Guild.invites` |
- +------------------------------------+----------------------------------------------------------+
- | :attr:`temporary` | :meth:`abc.GuildChannel.invites`\, :meth:`Guild.invites` |
- +------------------------------------+----------------------------------------------------------+
- | :attr:`uses` | :meth:`abc.GuildChannel.invites`\, :meth:`Guild.invites` |
- +------------------------------------+----------------------------------------------------------+
- | :attr:`approximate_member_count` | :meth:`Client.fetch_invite` |
- +------------------------------------+----------------------------------------------------------+
- | :attr:`approximate_presence_count` | :meth:`Client.fetch_invite` |
- +------------------------------------+----------------------------------------------------------+
+ +------------------------------------+------------------------------------------------------------+
+ | Attribute | Method |
+ +====================================+============================================================+
+ | :attr:`max_age` | :meth:`abc.GuildChannel.invites`\, :meth:`Guild.invites` |
+ +------------------------------------+------------------------------------------------------------+
+ | :attr:`max_uses` | :meth:`abc.GuildChannel.invites`\, :meth:`Guild.invites` |
+ +------------------------------------+------------------------------------------------------------+
+ | :attr:`created_at` | :meth:`abc.GuildChannel.invites`\, :meth:`Guild.invites` |
+ +------------------------------------+------------------------------------------------------------+
+ | :attr:`temporary` | :meth:`abc.GuildChannel.invites`\, :meth:`Guild.invites` |
+ +------------------------------------+------------------------------------------------------------+
+ | :attr:`uses` | :meth:`abc.GuildChannel.invites`\, :meth:`Guild.invites` |
+ +------------------------------------+------------------------------------------------------------+
+ | :attr:`approximate_member_count` | :meth:`Client.fetch_invite` with `with_counts` enabled |
+ +------------------------------------+------------------------------------------------------------+
+ | :attr:`approximate_presence_count` | :meth:`Client.fetch_invite` with `with_counts` enabled |
+ +------------------------------------+------------------------------------------------------------+
+ | :attr:`expires_at` | :meth:`Client.fetch_invite` with `with_expiration` enabled |
+ +------------------------------------+------------------------------------------------------------+
If it's not in the table above then it is available by all methods.
@@ -267,6 +269,12 @@ class Invite(Hashable):
approximate_presence_count: Optional[:class:`int`]
The approximate number of members currently active in the guild.
This includes idle, dnd, online, and invisible members. Offline members are excluded.
+ expires_at: Optional[:class:`datetime.datetime`]
+ The expiration date of the invite. If the value is ``None`` when received through
+ `Client.fetch_invite` with `with_expiration` enabled, the invite will never expire.
+
+ .. versionadded:: 2.0
+
channel: Union[:class:`abc.GuildChannel`, :class:`Object`, :class:`PartialInviteChannel`]
The channel the invite is for.
target_user: Optional[:class:`User`]
@@ -295,6 +303,7 @@ class Invite(Hashable):
'_state',
'approximate_member_count',
'approximate_presence_count',
+ 'expires_at',
)
BASE = 'https://discord.gg'
@@ -311,6 +320,8 @@ class Invite(Hashable):
self.max_uses = data.get('max_uses')
self.approximate_presence_count = data.get('approximate_presence_count')
self.approximate_member_count = data.get('approximate_member_count')
+ expires_at = data.get('expires_at', None)
+ self.expires_at = parse_time(expires_at) if expires_at else None
inviter_data = data.get('inviter')
self.inviter = None if inviter_data is None else self._state.store_user(inviter_data)