Skip to content

Commit

Permalink
Merge pull request Pycord-Development#1105 from Middledot/scheduled-e…
Browse files Browse the repository at this point in the history
…vent-stage-instance

Add scheduled_event attribute to stage instances
  • Loading branch information
Middledot authored Mar 4, 2022
2 parents 27e1aca + 2e24724 commit 826e5a6
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
7 changes: 4 additions & 3 deletions discord/scheduled_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
from .errors import ValidationError
from .iterators import ScheduledEventSubscribersIterator
from .mixins import Hashable
from .object import Object

__all__ = (
"ScheduledEvent",
Expand Down Expand Up @@ -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.
Expand All @@ -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

Expand Down
7 changes: 7 additions & 0 deletions discord/stage_instance.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__ = (
Expand All @@ -84,6 +86,7 @@ class StageInstance(Hashable):
"topic",
"privacy_level",
"discoverable_disabled",
"scheduled_event",
"_cs_channel",
)

Expand All @@ -98,6 +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)
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"<StageInstance id={self.id} guild={self.guild!r} channel_id={self.channel_id} topic={self.topic!r}>"
Expand Down
1 change: 1 addition & 0 deletions discord/types/channel.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,3 +164,4 @@ class StageInstance(TypedDict):
topic: str
privacy_level: PrivacyLevel
discoverable_disabled: bool
guild_scheduled_event_id: Snowflake

0 comments on commit 826e5a6

Please sign in to comment.