From 6e48697c6c5be287a1f4d650b12d3cd6e0a2eb6e Mon Sep 17 00:00:00 2001 From: Middledot Date: Thu, 3 Mar 2022 19:56:11 -0500 Subject: [PATCH 1/4] Add scheduled_event to stage_instance discord/discord-api-docs#4583 --- discord/stage_instance.py | 1 + discord/types/channel.py | 1 + 2 files changed, 2 insertions(+) diff --git a/discord/stage_instance.py b/discord/stage_instance.py index 9f42c8c0ae..38d4f3cc04 100644 --- a/discord/stage_instance.py +++ b/discord/stage_instance.py @@ -98,6 +98,7 @@ def _update(self, data: StageInstancePayload): self.topic: str = data["topic"] self.privacy_level: StagePrivacyLevel = try_enum(StagePrivacyLevel, data["privacy_level"]) self.discoverable_disabled: bool = data.get("discoverable_disabled", False) + self.scheduled_event = self.guild.get_scheduled_event(int(data.get("guild_scheduled_event_id"))) def __repr__(self) -> str: return f"" diff --git a/discord/types/channel.py b/discord/types/channel.py index 59a7eff6e9..c9f16ce7ff 100644 --- a/discord/types/channel.py +++ b/discord/types/channel.py @@ -164,3 +164,4 @@ class StageInstance(TypedDict): topic: str privacy_level: PrivacyLevel discoverable_disabled: bool + guild_scheduled_event_id: Snowflake From 37988f814366053a10cf06d7e436b84d81f440d4 Mon Sep 17 00:00:00 2001 From: Middledot Date: Thu, 3 Mar 2022 20:19:51 -0500 Subject: [PATCH 2/4] Document scheduled_event on StageInstance --- discord/stage_instance.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/discord/stage_instance.py b/discord/stage_instance.py index 38d4f3cc04..2b767407e4 100644 --- a/discord/stage_instance.py +++ b/discord/stage_instance.py @@ -74,6 +74,8 @@ class StageInstance(Hashable): The privacy level of the stage instance. discoverable_disabled: :class:`bool` Whether discoverability for the stage instance is disabled. + scheduled_event: Optional[:class:`.ScheduledEvent`] + The scheduled event linked with the stage instance, if any. """ __slots__ = ( From bfdbfbaf8e3afb81c9b6b67932121f119c633dea Mon Sep 17 00:00:00 2001 From: Middledot Date: Thu, 3 Mar 2022 21:03:56 -0500 Subject: [PATCH 3/4] Fix scheduled_event attribute problems --- discord/stage_instance.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/discord/stage_instance.py b/discord/stage_instance.py index 2b767407e4..ea7c9ba632 100644 --- a/discord/stage_instance.py +++ b/discord/stage_instance.py @@ -86,6 +86,7 @@ class StageInstance(Hashable): "topic", "privacy_level", "discoverable_disabled", + "scheduled_event", "_cs_channel", ) @@ -100,7 +101,10 @@ def _update(self, data: StageInstancePayload): self.topic: str = data["topic"] self.privacy_level: StagePrivacyLevel = try_enum(StagePrivacyLevel, data["privacy_level"]) self.discoverable_disabled: bool = data.get("discoverable_disabled", False) - self.scheduled_event = self.guild.get_scheduled_event(int(data.get("guild_scheduled_event_id"))) + event_id = data.get("guild_scheduled_event") + if event_id is not None: + event_id = int(event_id) + self.scheduled_event = self.guild.get_scheduled_event(event_id) def __repr__(self) -> str: return f"" From 2e24724e317535fe4b99ce1553ed8884c9dffbec Mon Sep 17 00:00:00 2001 From: Middledot Date: Thu, 3 Mar 2022 21:08:25 -0500 Subject: [PATCH 4/4] Support discord.Object in event locations --- discord/scheduled_events.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/discord/scheduled_events.py b/discord/scheduled_events.py index 31263bdcb3..618eed2e4d 100644 --- a/discord/scheduled_events.py +++ b/discord/scheduled_events.py @@ -38,6 +38,7 @@ from .errors import ValidationError from .iterators import ScheduledEventSubscribersIterator from .mixins import Hashable +from .object import Object __all__ = ( "ScheduledEvent", @@ -73,7 +74,7 @@ class ScheduledEventLocation: Attributes ---------- - value: Union[:class:`str`, :class:`StageChannel`, :class:`VoiceChannel`] + value: Union[:class:`str`, :class:`StageChannel`, :class:`VoiceChannel`, :class:`Object`] The actual location of the scheduled event. type: :class:`ScheduledEventLocationType` The type of location. @@ -91,9 +92,9 @@ def __init__( value: Union[str, int, StageChannel, VoiceChannel], ): self._state = state - self.value: Union[str, StageChannel, VoiceChannel] + self.value: Union[str, StageChannel, VoiceChannel, Object] if isinstance(value, int): - self.value = self._state._get_guild_channel({"channel_id": int(value)}) + self.value = self._state.get_channel(id=int(value)) or Object(id=int(value)) else: self.value = value