Skip to content

Commit 826e5a6

Browse files
authored
Merge pull request #1105 from Middledot/scheduled-event-stage-instance
Add scheduled_event attribute to stage instances
2 parents 27e1aca + 2e24724 commit 826e5a6

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

discord/scheduled_events.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
from .errors import ValidationError
3939
from .iterators import ScheduledEventSubscribersIterator
4040
from .mixins import Hashable
41+
from .object import Object
4142

4243
__all__ = (
4344
"ScheduledEvent",
@@ -73,7 +74,7 @@ class ScheduledEventLocation:
7374
7475
Attributes
7576
----------
76-
value: Union[:class:`str`, :class:`StageChannel`, :class:`VoiceChannel`]
77+
value: Union[:class:`str`, :class:`StageChannel`, :class:`VoiceChannel`, :class:`Object`]
7778
The actual location of the scheduled event.
7879
type: :class:`ScheduledEventLocationType`
7980
The type of location.
@@ -91,9 +92,9 @@ def __init__(
9192
value: Union[str, int, StageChannel, VoiceChannel],
9293
):
9394
self._state = state
94-
self.value: Union[str, StageChannel, VoiceChannel]
95+
self.value: Union[str, StageChannel, VoiceChannel, Object]
9596
if isinstance(value, int):
96-
self.value = self._state._get_guild_channel({"channel_id": int(value)})
97+
self.value = self._state.get_channel(id=int(value)) or Object(id=int(value))
9798
else:
9899
self.value = value
99100

discord/stage_instance.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@ class StageInstance(Hashable):
7474
The privacy level of the stage instance.
7575
discoverable_disabled: :class:`bool`
7676
Whether discoverability for the stage instance is disabled.
77+
scheduled_event: Optional[:class:`.ScheduledEvent`]
78+
The scheduled event linked with the stage instance, if any.
7779
"""
7880

7981
__slots__ = (
@@ -84,6 +86,7 @@ class StageInstance(Hashable):
8486
"topic",
8587
"privacy_level",
8688
"discoverable_disabled",
89+
"scheduled_event",
8790
"_cs_channel",
8891
)
8992

@@ -98,6 +101,10 @@ def _update(self, data: StageInstancePayload):
98101
self.topic: str = data["topic"]
99102
self.privacy_level: StagePrivacyLevel = try_enum(StagePrivacyLevel, data["privacy_level"])
100103
self.discoverable_disabled: bool = data.get("discoverable_disabled", False)
104+
event_id = data.get("guild_scheduled_event")
105+
if event_id is not None:
106+
event_id = int(event_id)
107+
self.scheduled_event = self.guild.get_scheduled_event(event_id)
101108

102109
def __repr__(self) -> str:
103110
return f"<StageInstance id={self.id} guild={self.guild!r} channel_id={self.channel_id} topic={self.topic!r}>"

discord/types/channel.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,3 +164,4 @@ class StageInstance(TypedDict):
164164
topic: str
165165
privacy_level: PrivacyLevel
166166
discoverable_disabled: bool
167+
guild_scheduled_event_id: Snowflake

0 commit comments

Comments
 (0)