mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-09-06 09:56:09 +00:00
Automatically infer entity_type when passing concrete channels
This affects Guild.create_scheduled_event and ScheduledEvent.edit Previously, you would always be required to pass it in. However, it makes sense to not repeat yourself if you already know it's a stage channel or a voice channel due to the type information.
This commit is contained in:
@ -46,7 +46,7 @@ import datetime
|
||||
import discord.abc
|
||||
from .scheduled_event import ScheduledEvent
|
||||
from .permissions import PermissionOverwrite, Permissions
|
||||
from .enums import ChannelType, PrivacyLevel, try_enum, VideoQualityMode
|
||||
from .enums import ChannelType, PrivacyLevel, try_enum, VideoQualityMode, EntityType
|
||||
from .mixins import Hashable
|
||||
from . import utils
|
||||
from .utils import MISSING
|
||||
@ -216,6 +216,10 @@ class TextChannel(discord.abc.Messageable, discord.abc.GuildChannel, Hashable):
|
||||
def _sorting_bucket(self) -> int:
|
||||
return ChannelType.text.value
|
||||
|
||||
@property
|
||||
def _scheduled_event_entity_type(self) -> Optional[EntityType]:
|
||||
return None
|
||||
|
||||
@utils.copy_doc(discord.abc.GuildChannel.permissions_for)
|
||||
def permissions_for(self, obj: Union[Member, Role], /) -> Permissions:
|
||||
base = super().permissions_for(obj)
|
||||
@ -1045,6 +1049,10 @@ class VoiceChannel(discord.abc.Messageable, VocalGuildChannel):
|
||||
async def _get_channel(self) -> Self:
|
||||
return self
|
||||
|
||||
@property
|
||||
def _scheduled_event_entity_type(self) -> Optional[EntityType]:
|
||||
return EntityType.voice
|
||||
|
||||
@property
|
||||
def type(self) -> Literal[ChannelType.voice]:
|
||||
""":class:`ChannelType`: The channel's Discord type."""
|
||||
@ -1480,6 +1488,10 @@ class StageChannel(VocalGuildChannel):
|
||||
super()._update(guild, data)
|
||||
self.topic: Optional[str] = data.get('topic')
|
||||
|
||||
@property
|
||||
def _scheduled_event_entity_type(self) -> Optional[EntityType]:
|
||||
return EntityType.stage_instance
|
||||
|
||||
@property
|
||||
def requesting_to_speak(self) -> List[Member]:
|
||||
"""List[:class:`Member`]: A list of members who are requesting to speak in the stage channel."""
|
||||
@ -1758,6 +1770,10 @@ class CategoryChannel(discord.abc.GuildChannel, Hashable):
|
||||
def _sorting_bucket(self) -> int:
|
||||
return ChannelType.category.value
|
||||
|
||||
@property
|
||||
def _scheduled_event_entity_type(self) -> Optional[EntityType]:
|
||||
return None
|
||||
|
||||
@property
|
||||
def type(self) -> Literal[ChannelType.category]:
|
||||
""":class:`ChannelType`: The channel's Discord type."""
|
||||
@ -2034,6 +2050,10 @@ class ForumChannel(discord.abc.GuildChannel, Hashable):
|
||||
def _sorting_bucket(self) -> int:
|
||||
return ChannelType.text.value
|
||||
|
||||
@property
|
||||
def _scheduled_event_entity_type(self) -> Optional[EntityType]:
|
||||
return None
|
||||
|
||||
@utils.copy_doc(discord.abc.GuildChannel.permissions_for)
|
||||
def permissions_for(self, obj: Union[Member, Role], /) -> Permissions:
|
||||
base = super().permissions_for(obj)
|
||||
|
Reference in New Issue
Block a user