From 502e1adac8fbcb00a6a989be7099dbe5fe3735ad Mon Sep 17 00:00:00 2001 From: shiftinv Date: Sat, 7 Oct 2023 23:03:59 +0200 Subject: [PATCH] feat: add `Entitlement.deleted` --- disnake/entitlement.py | 8 ++++++++ disnake/types/entitlement.py | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/disnake/entitlement.py b/disnake/entitlement.py index fb60e64731..60d83da050 100644 --- a/disnake/entitlement.py +++ b/disnake/entitlement.py @@ -66,6 +66,8 @@ class Entitlement(Hashable): See also :attr:`guild`. application_id: :class:`int` The parent application's ID. + deleted: :class:`bool` + Whether the entitlement was deleted. starts_at: Optional[:class:`datetime.datetime`] The time at which the entitlement starts being active. Set to ``None`` when this is a test entitlement. @@ -84,6 +86,7 @@ class Entitlement(Hashable): "guild_id", "application_id", "type", + "deleted", "starts_at", "ends_at", ) @@ -97,6 +100,7 @@ def __init__(self, *, data: EntitlementPayload, state: ConnectionState) -> None: self.guild_id: Optional[int] = _get_as_snowflake(data, "guild_id") self.application_id: int = int(data["application_id"]) self.type: EntitlementType = try_enum(EntitlementType, data["type"]) + self.deleted: bool = data.get("deleted", False) self.starts_at: Optional[datetime.datetime] = parse_time(data.get("starts_at")) self.ends_at: Optional[datetime.datetime] = parse_time(data.get("ends_at")) @@ -135,11 +139,15 @@ def is_active(self) -> bool: :return type: :class:`bool` """ + if self.deleted: + return False + now = utcnow() if self.starts_at is not None and now < self.starts_at: return False if self.ends_at is not None and now >= self.ends_at: return False + return True async def delete(self) -> None: diff --git a/disnake/types/entitlement.py b/disnake/types/entitlement.py index 18daeb938d..e0f178dd41 100644 --- a/disnake/types/entitlement.py +++ b/disnake/types/entitlement.py @@ -16,6 +16,6 @@ class Entitlement(TypedDict): guild_id: NotRequired[Snowflake] application_id: Snowflake type: EntitlementType - consumed: bool # always false in this case + deleted: bool starts_at: NotRequired[str] ends_at: NotRequired[str]