From 5226073408c77defc1fd35f606af41b758ecf745 Mon Sep 17 00:00:00 2001 From: grey-cat-1908 Date: Wed, 30 Mar 2022 22:19:38 +0300 Subject: [PATCH] messageable base --- melisa/models/guild/channel.py | 81 ++++++++++++++++++---------------- 1 file changed, 43 insertions(+), 38 deletions(-) diff --git a/melisa/models/guild/channel.py b/melisa/models/guild/channel.py index 34ff7e4..00dd1d8 100644 --- a/melisa/models/guild/channel.py +++ b/melisa/models/guild/channel.py @@ -235,44 +235,9 @@ class Channel(APIModelBase): return message -class TextChannel(Channel): - """A subclass of ``Channel`` representing text channels with all the same attributes.""" - - @overload - async def edit( - self, - *, - name: Optional[str] = None, - type: Optional[ChannelType] = None, - position: Optional[int] = None, - topic: Optional[str] = None, - nsfw: Optional[bool] = None, - rate_limit_per_user: Optional[int] = None, - bitrate: Optional[int] = None, - user_limit: Optional[int] = None, - permission_overwrite: Optional[List[Dict[str, Any]]] = None, - parent_id: Optional[Union[str, int, Snowflake]] = None, - rtc_region: Optional[str] = None, - video_quality_mode: Optional[int] = None, - default_auto_archive_duration: Optional[int] = None, - ) -> TextChannel: - ... - - async def edit(self, **kwargs): - """|coro| - Edit a text channel with the specified keyword arguments. - - Parameters - ---------- - \\*\\*kwargs : - The keyword arguments to edit the channel with. - - Returns - ------- - :class:`~melisa.models.guild.channel.TextChannel` - The updated channel object. - """ - return await super().edit(**kwargs) +class MessageableChannel(Channel): + """A subclass of ``Channel`` with methods that are only available for channels, + where user can send messages.""" async def history( self, @@ -500,6 +465,46 @@ class TextChannel(Channel): return +class TextChannel(MessageableChannel): + """A subclass of ``Channel`` representing text channels with all the same attributes.""" + + @overload + async def edit( + self, + *, + name: Optional[str] = None, + type: Optional[ChannelType] = None, + position: Optional[int] = None, + topic: Optional[str] = None, + nsfw: Optional[bool] = None, + rate_limit_per_user: Optional[int] = None, + bitrate: Optional[int] = None, + user_limit: Optional[int] = None, + permission_overwrite: Optional[List[Dict[str, Any]]] = None, + parent_id: Optional[Union[str, int, Snowflake]] = None, + rtc_region: Optional[str] = None, + video_quality_mode: Optional[int] = None, + default_auto_archive_duration: Optional[int] = None, + ) -> TextChannel: + ... + + async def edit(self, **kwargs): + """|coro| + Edit a text channel with the specified keyword arguments. + + Parameters + ---------- + \\*\\*kwargs : + The keyword arguments to edit the channel with. + + Returns + ------- + :class:`~melisa.models.guild.channel.TextChannel` + The updated channel object. + """ + return await super().edit(**kwargs) + + # noinspection PyTypeChecker channel_types_for_converting: Dict[ChannelType, Channel] = { ChannelType.GUILD_TEXT: TextChannel