Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add scheduled_event attribute to stage instances #1105

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 4 additions & 3 deletions discord/scheduled_events.py
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
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
Expand Up @@ -164,3 +164,4 @@ class StageInstance(TypedDict):
topic: str
privacy_level: PrivacyLevel
discoverable_disabled: bool
guild_scheduled_event_id: Snowflake