Browse Source

ScheduledEvent.description can be Optional

pull/7611/head
Nadir Chowdhury 3 years ago
committed by GitHub
parent
commit
70876d7f51
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 15
      discord/scheduled_event.py
  2. 2
      discord/types/scheduled_event.py

15
discord/scheduled_event.py

@ -80,7 +80,7 @@ class ScheduledEvent(Hashable):
The scheduled event's ID. The scheduled event's ID.
name: :class:`str` name: :class:`str`
The name of the scheduled event. The name of the scheduled event.
description: :class:`str` description: Optional[:class:`str`]
The description of the scheduled event. The description of the scheduled event.
entity_type: :class:`EntityType` entity_type: :class:`EntityType`
The type of entity this event is for. The type of entity this event is for.
@ -131,7 +131,7 @@ class ScheduledEvent(Hashable):
self.id: int = int(data['id']) self.id: int = int(data['id'])
self.guild_id: int = int(data['guild_id']) self.guild_id: int = int(data['guild_id'])
self.name: str = data['name'] 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_type = try_enum(EntityType, data['entity_type'])
self.entity_id: Optional[int] = _get_as_snowflake(data, 'entity_id') self.entity_id: Optional[int] = _get_as_snowflake(data, 'entity_id')
self.start_time: datetime = parse_time(data['scheduled_start_time']) self.start_time: datetime = parse_time(data['scheduled_start_time'])
@ -149,7 +149,7 @@ class ScheduledEvent(Hashable):
metadata = data.get('entity_metadata') metadata = data.get('entity_metadata')
self._unroll_metadata(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 self.location: Optional[str] = data.get('location') if data else None
@classmethod @classmethod
@ -296,7 +296,7 @@ class ScheduledEvent(Hashable):
description: str = MISSING, description: str = MISSING,
channel: Optional[Snowflake] = MISSING, channel: Optional[Snowflake] = MISSING,
start_time: datetime = MISSING, start_time: datetime = MISSING,
end_time: datetime = MISSING, end_time: Optional[datetime] = MISSING,
privacy_level: PrivacyLevel = MISSING, privacy_level: PrivacyLevel = MISSING,
entity_type: EntityType = MISSING, entity_type: EntityType = MISSING,
status: EventStatus = MISSING, status: EventStatus = MISSING,
@ -436,8 +436,9 @@ class ScheduledEvent(Hashable):
raise ValueError( raise ValueError(
'end_time must be an aware datetime. Consider using discord.utils.utcnow() or datetime.datetime.now().astimezone() for local time.' '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.isoformat()
payload['scheduled_end_time'] = end_time else:
payload['scheduled_end_time'] = end_time
if metadata: if metadata:
payload['entity_metadata'] = metadata payload['entity_metadata'] = metadata
@ -491,7 +492,7 @@ class ScheduledEvent(Hashable):
Returns Returns
-------- --------
List[:class:`User`] List[:class:`User`]
All thread members in the thread. All subscribed users of this event.
""" """
async def _before_strategy(retrieve, before, limit): async def _before_strategy(retrieve, before, limit):

2
discord/types/scheduled_event.py

@ -35,7 +35,7 @@ EntityType = Literal[1, 2, 3]
class _BaseGuildScheduledEventOptional(TypedDict, total=False): class _BaseGuildScheduledEventOptional(TypedDict, total=False):
creator_id: Optional[Snowflake] creator_id: Optional[Snowflake]
description: str description: Optional[str]
creator: User creator: User
user_count: int user_count: int
image: Optional[str] image: Optional[str]

Loading…
Cancel
Save