From 70876d7f51f5774b548e9419f765b821cf85a217 Mon Sep 17 00:00:00 2001 From: Nadir Chowdhury Date: Thu, 10 Mar 2022 01:42:25 +0000 Subject: [PATCH] ScheduledEvent.description can be Optional --- discord/scheduled_event.py | 15 ++++++++------- discord/types/scheduled_event.py | 2 +- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/discord/scheduled_event.py b/discord/scheduled_event.py index 78d8b58a6..1c32a4844 100644 --- a/discord/scheduled_event.py +++ b/discord/scheduled_event.py @@ -80,7 +80,7 @@ class ScheduledEvent(Hashable): The scheduled event's ID. name: :class:`str` The name of the scheduled event. - description: :class:`str` + description: Optional[:class:`str`] The description of the scheduled event. entity_type: :class:`EntityType` The type of entity this event is for. @@ -131,7 +131,7 @@ class ScheduledEvent(Hashable): self.id: int = int(data['id']) self.guild_id: int = int(data['guild_id']) self.name: str = data['name'] - self.description: str = data.get('description', '') + self.description: Optional[str] = data.get('description') self.entity_type = try_enum(EntityType, data['entity_type']) self.entity_id: Optional[int] = _get_as_snowflake(data, 'entity_id') self.start_time: datetime = parse_time(data['scheduled_start_time']) @@ -149,7 +149,7 @@ class ScheduledEvent(Hashable): metadata = data.get('entity_metadata') self._unroll_metadata(metadata) - def _unroll_metadata(self, data: EntityMetadata): + def _unroll_metadata(self, data: Optional[EntityMetadata]): self.location: Optional[str] = data.get('location') if data else None @classmethod @@ -296,7 +296,7 @@ class ScheduledEvent(Hashable): description: str = MISSING, channel: Optional[Snowflake] = MISSING, start_time: datetime = MISSING, - end_time: datetime = MISSING, + end_time: Optional[datetime] = MISSING, privacy_level: PrivacyLevel = MISSING, entity_type: EntityType = MISSING, status: EventStatus = MISSING, @@ -436,8 +436,9 @@ class ScheduledEvent(Hashable): raise ValueError( 'end_time must be an aware datetime. Consider using discord.utils.utcnow() or datetime.datetime.now().astimezone() for local time.' ) - end_time = end_time.isoformat() - payload['scheduled_end_time'] = end_time + payload['scheduled_end_time'] = end_time.isoformat() + else: + payload['scheduled_end_time'] = end_time if metadata: payload['entity_metadata'] = metadata @@ -491,7 +492,7 @@ class ScheduledEvent(Hashable): Returns -------- List[:class:`User`] - All thread members in the thread. + All subscribed users of this event. """ async def _before_strategy(retrieve, before, limit): diff --git a/discord/types/scheduled_event.py b/discord/types/scheduled_event.py index 13e8ee12c..f469165c7 100644 --- a/discord/types/scheduled_event.py +++ b/discord/types/scheduled_event.py @@ -35,7 +35,7 @@ EntityType = Literal[1, 2, 3] class _BaseGuildScheduledEventOptional(TypedDict, total=False): creator_id: Optional[Snowflake] - description: str + description: Optional[str] creator: User user_count: int image: Optional[str]