|
|
@ -26,7 +26,7 @@ from __future__ import annotations |
|
|
|
|
|
|
|
from typing import Optional, TYPE_CHECKING |
|
|
|
|
|
|
|
from .utils import MISSING, cached_slot_property |
|
|
|
from .utils import MISSING, cached_slot_property, _get_as_snowflake |
|
|
|
from .mixins import Hashable |
|
|
|
from .enums import PrivacyLevel, try_enum |
|
|
|
|
|
|
@ -41,6 +41,7 @@ if TYPE_CHECKING: |
|
|
|
from .state import ConnectionState |
|
|
|
from .channel import StageChannel |
|
|
|
from .guild import Guild |
|
|
|
from .scheduled_event import ScheduledEvent |
|
|
|
|
|
|
|
|
|
|
|
class StageInstance(Hashable): |
|
|
@ -76,6 +77,10 @@ class StageInstance(Hashable): |
|
|
|
The privacy level of the stage instance. |
|
|
|
discoverable_disabled: :class:`bool` |
|
|
|
Whether discoverability for the stage instance is disabled. |
|
|
|
scheduled_event_id: Optional[:class:`int`] |
|
|
|
The ID of scheduled event that belongs to the stage instance if any. |
|
|
|
|
|
|
|
.. versionadded:: 2.0 |
|
|
|
""" |
|
|
|
|
|
|
|
__slots__ = ( |
|
|
@ -86,7 +91,9 @@ class StageInstance(Hashable): |
|
|
|
'topic', |
|
|
|
'privacy_level', |
|
|
|
'discoverable_disabled', |
|
|
|
'scheduled_event_id', |
|
|
|
'_cs_channel', |
|
|
|
'_cs_scheduled_event', |
|
|
|
) |
|
|
|
|
|
|
|
def __init__(self, *, state: ConnectionState, guild: Guild, data: StageInstancePayload) -> None: |
|
|
@ -100,6 +107,7 @@ class StageInstance(Hashable): |
|
|
|
self.topic: str = data['topic'] |
|
|
|
self.privacy_level: PrivacyLevel = try_enum(PrivacyLevel, data['privacy_level']) |
|
|
|
self.discoverable_disabled: bool = data.get('discoverable_disabled', False) |
|
|
|
self.scheduled_event_id: Optional[int] = _get_as_snowflake(data, 'guild_scheduled_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}>' |
|
|
@ -110,6 +118,12 @@ class StageInstance(Hashable): |
|
|
|
# the returned channel will always be a StageChannel or None |
|
|
|
return self._state.get_channel(self.channel_id) # type: ignore |
|
|
|
|
|
|
|
@cached_slot_property('_cs_scheduled_event') |
|
|
|
def scheduled_event(self) -> Optional[ScheduledEvent]: |
|
|
|
"""Optional[:class:`ScheduledEvent`]: The scheduled event that belongs to the stage instance.""" |
|
|
|
# Guild.get_scheduled_event() expects an int, we are passing Optional[int] |
|
|
|
return self.guild.get_scheduled_event(self.scheduled_event_id) # type: ignore |
|
|
|
|
|
|
|
async def edit( |
|
|
|
self, |
|
|
|
*, |
|
|
|