diff --git a/discord/http.py b/discord/http.py index 8242e1ce78..e62ab1cdde 100644 --- a/discord/http.py +++ b/discord/http.py @@ -1649,6 +1649,7 @@ def edit_scheduled_event(self, guild_id: Snowflake, event_id: Snowflake, reason: 'entity_type', 'status', 'entity_metadata', + 'image', ) payload = {k: v for k, v in payload.items() if k in valid_keys} diff --git a/discord/scheduled_events.py b/discord/scheduled_events.py index 3cae4ebe53..56615405da 100644 --- a/discord/scheduled_events.py +++ b/discord/scheduled_events.py @@ -132,6 +132,8 @@ class ScheduledEvent(Hashable): Attributes ---------- + guild: :class:`Guild` + The guild where the scheduled event is happening. name: :class:`str` The name of the scheduled event. description: Optional[:class:`str`] @@ -161,8 +163,8 @@ class ScheduledEvent(Hashable): so there is no need to use this attribute. created_at: :class:`datetime.datetime` The datetime object of when the event was created. - guild: :class:`Guild` - The guild where the scheduled event is happening. + cover: Optional[:class:`Asset`] + The cover image of the scheduled event. """ __slots__ = ( @@ -177,6 +179,7 @@ class ScheduledEvent(Hashable): 'location', 'guild', '_state', + '_cover', 'subscriber_count', ) @@ -246,14 +249,15 @@ def cover(self) -> Optional[Asset]: async def edit( self, *, + reason: Optional[str] = None, name: str = MISSING, description: str = MISSING, status: Union[int, ScheduledEventStatus] = MISSING, location: Union[str, int, VoiceChannel, StageChannel, ScheduledEventLocation] = MISSING, start_time: datetime.datetime = MISSING, end_time: datetime.datetime = MISSING, + cover: Optional[bytes] = MISSING, privacy_level: ScheduledEventPrivacyLevel = ScheduledEventPrivacyLevel.guild_only, - reason: Optional[str] = None ) -> Optional[ScheduledEvent]: """|coro| @@ -287,6 +291,8 @@ async def edit( so there is no need to change this parameter. reason: Optional[:class:`str`] The reason to show in the audit log. + Optional[:class:`Asset`] + The cover image of the scheduled event. Raises ------- @@ -315,6 +321,12 @@ async def edit( if privacy_level is not MISSING: payload["privacy_level"] = int(privacy_level) + if cover is not MISSING: + if cover is None: + payload["image"] + else: + payload["image"] = utils._bytes_to_base64_data(cover) + if location is not MISSING: if not isinstance(location, (ScheduledEventLocation, utils._MissingSentinel)): location = ScheduledEventLocation(state=self._state, value=location) @@ -328,7 +340,9 @@ async def edit( location = location if location is not MISSING else self.location if end_time is MISSING and location.type is ScheduledEventLocationType.external: - raise ValidationError("end_time needs to be passed if location type is external.") + end_time = self.end_time + if end_time is None: + raise ValidationError("end_time needs to be passed if location type is external.") if start_time is not MISSING: payload["scheduled_start_time"] = start_time.isoformat()