diff options
| author | Nadir Chowdhury <[email protected]> | 2021-05-11 01:24:48 +0100 |
|---|---|---|
| committer | GitHub <[email protected]> | 2021-05-10 20:24:48 -0400 |
| commit | 757cfad38f340f31f1b18bc198b3aa83e9cbe6dc (patch) | |
| tree | 9d8f4c643e21aa4310c75090d4a666863247014e /discord/channel.py | |
| parent | [tasks] Add support for explicit time parameter (diff) | |
| download | discord.py-757cfad38f340f31f1b18bc198b3aa83e9cbe6dc.tar.xz discord.py-757cfad38f340f31f1b18bc198b3aa83e9cbe6dc.zip | |
Type up **kwargs of various methods
Diffstat (limited to 'discord/channel.py')
| -rw-r--r-- | discord/channel.py | 138 |
1 files changed, 127 insertions, 11 deletions
diff --git a/discord/channel.py b/discord/channel.py index 74f274df..c9eb9c34 100644 --- a/discord/channel.py +++ b/discord/channel.py @@ -22,11 +22,14 @@ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. """ +from __future__ import annotations + import time import asyncio +from typing import Callable, Dict, List, Optional, TYPE_CHECKING, Union, overload import discord.abc -from .permissions import Permissions +from .permissions import PermissionOverwrite, Permissions from .enums import ChannelType, try_enum, VoiceRegion, VideoQualityMode from .mixins import Hashable from . import utils @@ -44,6 +47,14 @@ __all__ = ( '_channel_factory', ) +if TYPE_CHECKING: + from .role import Role + from .member import Member + from .abc import Snowflake + from .message import Message + from .webhook import Webhook + from .abc import SnowflakeTime + async def _single_delete_strategy(messages): for m in messages: await m.delete() @@ -190,6 +201,27 @@ class TextChannel(discord.abc.Messageable, discord.abc.GuildChannel, Hashable): """ return self._state._get_message(self.last_message_id) if self.last_message_id else None + @overload + async def edit( + self, + *, + reason: Optional[str] = ..., + name: str = ..., + topic: str = ..., + position: int = ..., + nsfw: bool = ..., + sync_permissions: bool = ..., + category: Optional[CategoryChannel] = ..., + slowmode_delay: int = ..., + type: ChannelType = ..., + overwrites: Dict[Union[Role, Member, Snowflake], PermissionOverwrite] = ..., + ) -> None: + ... + + @overload + async def edit(self) -> None: + ... + async def edit(self, *, reason=None, **options): """|coro| @@ -246,7 +278,7 @@ class TextChannel(discord.abc.Messageable, discord.abc.GuildChannel, Hashable): await self._edit(options, reason=reason) @utils.copy_doc(discord.abc.GuildChannel.clone) - async def clone(self, *, name=None, reason=None): + async def clone(self, *, name: str = None, reason: str = None) -> TextChannel: return await self._clone_impl({ 'topic': self.topic, 'nsfw': self.nsfw, @@ -302,7 +334,17 @@ class TextChannel(discord.abc.Messageable, discord.abc.GuildChannel, Hashable): message_ids = [m.id for m in messages] await self._state.http.delete_messages(self.id, message_ids) - async def purge(self, *, limit=100, check=None, before=None, after=None, around=None, oldest_first=False, bulk=True): + async def purge( + self, + *, + limit: int = 100, + check: Callable[[Message], bool] = None, + before: Optional[SnowflakeTime] = None, + after: Optional[SnowflakeTime] = None, + around: Optional[SnowflakeTime] = None, + oldest_first: Optional[bool] = False, + bulk: bool = True, + ) -> List[Message]: """|coro| Purges a list of messages that meet the criteria given by the predicate @@ -428,7 +470,7 @@ class TextChannel(discord.abc.Messageable, discord.abc.GuildChannel, Hashable): data = await self._state.http.channel_webhooks(self.id) return [Webhook.from_state(d, state=self._state) for d in data] - async def create_webhook(self, *, name, avatar=None, reason=None): + async def create_webhook(self, *, name: str, avatar: bytes = None, reason: str = None) -> Webhook: """|coro| Creates a webhook for this channel. @@ -468,7 +510,7 @@ class TextChannel(discord.abc.Messageable, discord.abc.GuildChannel, Hashable): data = await self._state.http.create_webhook(self.id, name=str(name), avatar=avatar, reason=reason) return Webhook.from_state(data, state=self._state) - async def follow(self, *, destination, reason=None): + async def follow(self, *, destination: TextChannel, reason: Optional[str] = None) -> Webhook: """ Follows a channel using a webhook. @@ -680,12 +722,33 @@ class VoiceChannel(VocalGuildChannel): return ChannelType.voice @utils.copy_doc(discord.abc.GuildChannel.clone) - async def clone(self, *, name=None, reason=None): + async def clone(self, *, name: str = None, reason: str = None) -> VoiceChannel: return await self._clone_impl({ 'bitrate': self.bitrate, 'user_limit': self.user_limit }, name=name, reason=reason) + @overload + async def edit( + self, + *, + reason: Optional[str] = ..., + name: str = ..., + bitrate: int = ..., + user_limit: int = ..., + position: int = ..., + sync_permissions: int = ..., + category: Optional[CategoryChannel] = ..., + overwrites: Dict[Union[Role, Member], PermissionOverwrite] = ..., + rtc_region: Optional[VoiceRegion] = ..., + video_quality_mode: VideoQualityMode = ..., + ) -> None: + ... + + @overload + async def edit(self) -> None: + ... + async def edit(self, *, reason=None, **options): """|coro| @@ -822,11 +885,31 @@ class StageChannel(VocalGuildChannel): return ChannelType.stage_voice @utils.copy_doc(discord.abc.GuildChannel.clone) - async def clone(self, *, name=None, reason=None): + async def clone(self, *, name: str = None, reason: Optional[str] = None) -> StageChannel: return await self._clone_impl({ 'topic': self.topic, }, name=name, reason=reason) + @overload + async def edit( + self, + *, + reason: Optional[str] = ..., + name: str = ..., + topic: Optional[str] = ..., + position: int = ..., + sync_permissions: int = ..., + category: Optional[CategoryChannel] = ..., + overwrites: Dict[Union[Role, Member], PermissionOverwrite] = ..., + rtc_region: Optional[VoiceRegion] = ..., + video_quality_mode: VideoQualityMode = ..., + ) -> None: + ... + + @overload + async def edit(self) -> None: + ... + async def edit(self, *, reason=None, **options): """|coro| @@ -839,7 +922,7 @@ class StageChannel(VocalGuildChannel): ---------- name: :class:`str` The new channel's name. - topic: :class:`str` + topic: Optional[:class:`str`] The new channel's topic. position: :class:`int` The new channel's position. @@ -873,7 +956,6 @@ class StageChannel(VocalGuildChannel): """ await self._edit(options, reason=reason) - class CategoryChannel(discord.abc.GuildChannel, Hashable): """Represents a Discord channel category. @@ -948,11 +1030,27 @@ class CategoryChannel(discord.abc.GuildChannel, Hashable): return self.nsfw or self.guild.nsfw @utils.copy_doc(discord.abc.GuildChannel.clone) - async def clone(self, *, name=None, reason=None): + async def clone(self, *, name: str = None, reason: Optional[str] = None) -> CategoryChannel: return await self._clone_impl({ 'nsfw': self.nsfw }, name=name, reason=reason) + @overload + async def edit( + self, + *, + reason: Optional[str] = ..., + name: str = ..., + position: int = ..., + nsfw: bool = ..., + overwrites: Dict[Union[Role, Member], PermissionOverwrite] = ..., + ) -> None: + ... + + @overload + async def edit(self) -> None: + ... + async def edit(self, *, reason=None, **options): """|coro| @@ -1159,11 +1257,29 @@ class StoreChannel(discord.abc.GuildChannel, Hashable): return self.nsfw or self.guild.nsfw @utils.copy_doc(discord.abc.GuildChannel.clone) - async def clone(self, *, name=None, reason=None): + async def clone(self, *, name: str = None, reason: Optional[str] = None) -> StoreChannel: return await self._clone_impl({ 'nsfw': self.nsfw }, name=name, reason=reason) + @overload + async def edit( + self, + *, + name: str = ..., + position: int = ..., + nsfw: bool = ..., + sync_permissions: bool = ..., + category: Optional[CategoryChannel], + reason: Optional[str], + overwrites: Dict[Union[Role, Member], PermissionOverwrite] + ) -> None: + ... + + @overload + async def edit(self) -> None: + ... + async def edit(self, *, reason=None, **options): """|coro| |