├── .editorconfig ├── .flake8 ├── .github ├── dependabot.yml └── workflows │ ├── release.yml │ └── unit-tests.yml ├── .gitignore ├── .pre-commit-config.yaml ├── LICENSE ├── README.md ├── discord-stubs ├── __init__.pyi ├── __main__.pyi ├── abc.pyi ├── activity.pyi ├── appinfo.pyi ├── asset.pyi ├── audit_logs.pyi ├── backoff.pyi ├── calls.pyi ├── channel.pyi ├── client.pyi ├── colour.pyi ├── context_managers.pyi ├── embeds.pyi ├── emoji.pyi ├── enums.pyi ├── errors.pyi ├── ext │ ├── commands │ │ ├── __init__.pyi │ │ ├── _types.pyi │ │ ├── bot.pyi │ │ ├── cog.pyi │ │ ├── context.pyi │ │ ├── converter.pyi │ │ ├── cooldowns.pyi │ │ ├── core.pyi │ │ ├── errors.pyi │ │ ├── help.pyi │ │ └── view.pyi │ └── tasks │ │ └── __init__.pyi ├── file.pyi ├── flags.pyi ├── gateway.pyi ├── guild.pyi ├── http.pyi ├── integrations.pyi ├── invite.pyi ├── iterators.pyi ├── member.pyi ├── mentions.pyi ├── message.pyi ├── mixins.pyi ├── object.pyi ├── oggparse.pyi ├── opus.pyi ├── partial_emoji.pyi ├── permissions.pyi ├── player.pyi ├── raw_models.pyi ├── reaction.pyi ├── relationship.pyi ├── role.pyi ├── shard.pyi ├── state.pyi ├── sticker.pyi ├── team.pyi ├── template.pyi ├── user.pyi ├── utils.pyi ├── voice_client.pyi ├── webhook.pyi └── widget.pyi ├── fix-site-packages.sh ├── mypy.ini ├── poetry.lock ├── pyproject.toml ├── stubtest-whitelist.txt └── test-data ├── mypy.ini ├── test_bot.yml ├── test_client.yml ├── test_iterators.yml ├── test_member.yml └── test_permissions.yml /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | charset = utf-8 5 | end_of_line = lf 6 | insert_final_newline = true 7 | indent_style = tab 8 | indent_size = 4 9 | 10 | [*.py] 11 | indent_style = space 12 | max_line_length = 88 13 | 14 | [*.pyi] 15 | indent_style = space 16 | max_line_length = 88 17 | 18 | [*.yml] 19 | indent_style = space 20 | indent_size = 2 21 | 22 | [*.yaml] 23 | indent_style = space 24 | indent_size = 2 25 | 26 | [*.toml] 27 | indent_style = space 28 | indent_size = 2 29 | 30 | [*.md] 31 | indent_style = space 32 | indent_size = 2 33 | -------------------------------------------------------------------------------- /.flake8: -------------------------------------------------------------------------------- 1 | [flake8] 2 | max-line-length = 88 3 | ignore = E203, E266, E501, W503 4 | select = B,C,E,F,W,T4,B9 5 | exclude = 6 | .git, 7 | __pycache__, 8 | .venv, 9 | external 10 | per-file-ignores = 11 | *.pyi: F403, F405, F811, E127, E128, E203, E266, E301, E302, E305, E501, E701, E704, E741, B303, W503, W504 12 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: pip 4 | directory: "/" 5 | schedule: 6 | interval: daily 7 | open-pull-requests-limit: 10 8 | assignees: 9 | - bryanforbes 10 | - package-ecosystem: "github-actions" 11 | directory: "/" 12 | schedule: 13 | interval: daily 14 | open-pull-requests-limit: 10 15 | assignees: 16 | - bryanforbes 17 | -------------------------------------------------------------------------------- /.github/workflows/release.yml: -------------------------------------------------------------------------------- 1 | name: Create Release 2 | 3 | on: 4 | push: 5 | tags: 6 | - v[0-9]+.[0-9]+.[0-9]+ 7 | 8 | jobs: 9 | Release: 10 | name: Create Release 11 | runs-on: ubuntu-latest 12 | steps: 13 | - name: Checkout code 14 | uses: actions/checkout@v2.3.4 15 | - name: Get version 16 | id: version 17 | run: | 18 | echo ::set-output name=version::${GITHUB_REF#refs/tags/v} 19 | - name: Set up Python 3.8 20 | uses: actions/setup-python@v2.2.2 21 | with: 22 | python-version: 3.8 23 | - name: Install Poetry 24 | uses: snok/install-poetry@v1.1.8 25 | with: 26 | version: 1.1.4 27 | virtualenvs-create: true 28 | virtualenvs-in-project: true 29 | virtualenvs-path: .venv 30 | - name: Install dependencies 31 | run: | 32 | poetry install --no-dev -v 33 | ./fix-site-packages.sh 34 | - name: Publish to PyPI 35 | env: 36 | POETRY_PYPI_TOKEN_PYPI: ${{ secrets.PYPI_TOKEN }} 37 | run: | 38 | poetry publish --build -n 39 | - name: Create Release 40 | id: create_release 41 | uses: actions/create-release@v1.1.4 42 | env: 43 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 44 | with: 45 | tag_name: v${{ steps.version.outputs.version }} 46 | release_name: v${{ steps.version.outputs.version }} 47 | draft: false 48 | prerelease: false 49 | - name: Upload tarball 50 | uses: actions/upload-release-asset@v1.0.2 51 | env: 52 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 53 | with: 54 | upload_url: ${{ steps.create_release.outputs.upload_url }} 55 | asset_path: dist/discord.py-stubs-${{ steps.version.outputs.version }}.tar.gz 56 | asset_name: discord.py-stubs-${{ steps.version.outputs.version }}.tar.gz 57 | asset_content_type: application/gzip 58 | - name: Upload wheel 59 | uses: actions/upload-release-asset@v1.0.2 60 | env: 61 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 62 | with: 63 | upload_url: ${{ steps.create_release.outputs.upload_url }} 64 | asset_path: dist/discord.py_stubs-${{ steps.version.outputs.version }}-py3-none-any.whl 65 | asset_name: discord.py_stubs-${{ steps.version.outputs.version }}-py3-none-any.whl 66 | asset_content_type: application/zip 67 | -------------------------------------------------------------------------------- /.github/workflows/unit-tests.yml: -------------------------------------------------------------------------------- 1 | name: Unit tests 2 | 3 | on: 4 | push: 5 | branches: 6 | - master 7 | pull_request: 8 | 9 | jobs: 10 | build: 11 | uses: bryanforbes/python-workflows/.github/workflows/reusable-unit-tests.yml@master 12 | with: 13 | python_versions: '["3.6", "3.7", "3.8", "3.9"]' 14 | post_install: './fix-site-packages.sh' 15 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | __pycache__ 2 | .venv/ 3 | .mypy_cache/ 4 | .pytest_cache/ 5 | dist/ 6 | *.egg 7 | *.egg-info 8 | *.eggs 9 | /discord 10 | -------------------------------------------------------------------------------- /.pre-commit-config.yaml: -------------------------------------------------------------------------------- 1 | default_stages: [commit] 2 | repos: 3 | - repo: local 4 | hooks: 5 | - id: post-checkout-local 6 | name: poetry install 7 | always_run: true 8 | language: system 9 | entry: poetry install 10 | stages: [post-checkout] 11 | - id: isort 12 | name: isort 13 | language: system 14 | entry: poetry run isort --check-only 15 | files: \.pyi?$ 16 | - id: black 17 | name: black 18 | language: system 19 | entry: poetry run black --check 20 | files: \.pyi?$ 21 | - id: flake8 22 | name: flake8 23 | language: system 24 | entry: poetry run flake8 25 | files: \.pyi?$ 26 | - id: mypy 27 | name: mypy 28 | language: system 29 | entry: poetry run mypy discord-stubs 30 | files: \.pyi?$ 31 | pass_filenames: false 32 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | BSD 3-Clause License 2 | 3 | © 2020, Bryan Forbes 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the copyright holder nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 18 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 21 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 23 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 24 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 25 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 26 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # discord.py-stubs 2 | 3 | [![License](https://img.shields.io/badge/License-BSD%203--Clause-blue.svg)](https://github.com/bryanforbes/discord.py-stubs/blob/master/LICENSE) 4 | [![Checked with mypy](http://www.mypy-lang.org/static/mypy_badge.svg)](http://mypy-lang.org/) 5 | [![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/ambv/black) 6 | 7 | This package contains type stubs to provide more precise static types and type inference for discord.py. 8 | 9 | ## Installation 10 | 11 | ``` 12 | pip install discord.py-stubs 13 | ``` 14 | 15 | **NOTE:** Because `discord.py` uses namespace packages for its extensions, `mypy` must be configured to use namespace packages either with the `--namespace-packages` command line flag, or by setting `namespace_packages = True` in your `mypy` configuration file. See the [import discovery](https://mypy.readthedocs.io/en/stable/command_line.html#import-discovery) section of the `mypy` documentation for more details. 16 | 17 | ## Usage Notes 18 | 19 | In most cases, installing this package will enable developers to type check their discord.py bots using mypy out of the box. However, if developers wish to subclass the classes in `discord.ext.commands` they will need to follow the `mypy` documentation outlining how to use [classes that are generic in stubs but not at runtime](https://mypy.readthedocs.io/en/stable/common_issues.html#using-classes-that-are-generic-in-stubs-but-not-at-runtime): 20 | 21 | ```python 22 | from typing import TYPE_CHECKING 23 | from discord.ext import commands 24 | 25 | class MyContext(commands.Context): 26 | ... 27 | 28 | if TYPE_CHECKING: 29 | Cog = commands.Cog[MyContext] 30 | else: 31 | Cog = commands.Cog 32 | 33 | class MyCog(Cog): 34 | ... 35 | ``` 36 | 37 | In order to avoid this issue, developers can use [`discord-ext-typed-commands`](https://github.com/bryanforbes/discord-ext-typed-commands/): 38 | 39 | ```python 40 | from discord.ext import typed_commands 41 | 42 | class MyContext(typed_commands.Context): 43 | ... 44 | 45 | class MyCog(typed_commands.Cog[MyContext]): 46 | ... 47 | ``` 48 | 49 | ## Development 50 | 51 | Make sure you have [poetry](https://python-poetry.org/) installed. 52 | 53 | ``` 54 | poetry install 55 | poetry run pre-commit install --hook-type pre-commit --hook-type post-checkout 56 | ``` 57 | 58 | 59 | ## Version numbering scheme 60 | 61 | The **major** and **minor** version numbers of `discord.py-stubs` will match the **major** and **minor** version numbers of the `discord.py` release the stubs represent. For instance, if you are using `discord.py` version `1.7.4`, you would use `discord.py-stubs` version `1.7.X` where `X` is the latest **patch** version of the stubs. Using semver dependency specifications, `discord.py-stubs` version `~1.7` is designed to work with `discord.py` version `~1.7`. 62 | 63 | In addition, `discord.py-stubs` will indicate which versions of the runtime library are compatible through its dependency information (as suggested in PEP-561). 64 | -------------------------------------------------------------------------------- /discord-stubs/__init__.pyi: -------------------------------------------------------------------------------- 1 | from typing import NamedTuple 2 | from typing_extensions import Final 3 | 4 | from . import abc as abc # noqa: F401 5 | from . import opus as opus # noqa: F401 6 | from . import utils as utils # noqa: F401 7 | from .activity import * # noqa: F401 8 | from .appinfo import AppInfo as AppInfo # noqa: F401 9 | from .asset import Asset as Asset # noqa: F401 10 | from .audit_logs import AuditLogChanges as AuditLogChanges # noqa: F401 11 | from .audit_logs import AuditLogDiff as AuditLogDiff # noqa: F401 12 | from .audit_logs import AuditLogEntry as AuditLogEntry # noqa: F401 13 | from .calls import CallMessage as CallMessage # noqa: F401 14 | from .calls import GroupCall as GroupCall # noqa: F401 15 | from .channel import CategoryChannel as CategoryChannel # noqa: F401 16 | from .channel import DMChannel as DMChannel # noqa: F401 17 | from .channel import GroupChannel as GroupChannel # noqa: F401 18 | from .channel import StageChannel as StageChannel # noqa: F401 19 | from .channel import StoreChannel as StoreChannel # noqa: F401 20 | from .channel import TextChannel as TextChannel # noqa: F401 21 | from .channel import VoiceChannel as VoiceChannel # noqa: F401 22 | from .client import Client as Client # noqa: F401 23 | from .colour import Color as Color # noqa: F401 24 | from .colour import Colour as Colour # noqa: F401 25 | from .embeds import Embed as Embed # noqa: F401 26 | from .emoji import Emoji as Emoji # noqa: F401 27 | from .enums import * # noqa: F401 28 | from .errors import * # noqa: F401 29 | from .file import File as File # noqa: F401 30 | from .flags import Intents as Intents # noqa: F401 31 | from .flags import MemberCacheFlags as MemberCacheFlags # noqa: F401 32 | from .flags import MessageFlags as MessageFlags # noqa: F401 33 | from .flags import PublicUserFlags as PublicUserFlags # noqa: F401 34 | from .flags import SystemChannelFlags as SystemChannelFlags # noqa: F401 35 | from .guild import Guild as Guild # noqa: F401 36 | from .integrations import Integration as Integration # noqa: F401 37 | from .integrations import IntegrationAccount as IntegrationAccount # noqa: F401 38 | from .invite import Invite as Invite # noqa: F401 39 | from .member import Member as Member # noqa: F401 40 | from .member import VoiceState as VoiceState # noqa: F401 41 | from .mentions import AllowedMentions as AllowedMentions # noqa: F401 42 | from .message import Attachment as Attachment # noqa: F401 43 | from .message import DeletedReferencedMessage as DeletedReferencedMessage # noqa: F401 44 | from .message import Message as Message # noqa: F401 45 | from .message import MessageReference as MessageReference # noqa: F401 46 | from .message import PartialMessage as PartialMessage # noqa: F401 47 | from .object import Object as Object # noqa: F401 48 | from .partial_emoji import PartialEmoji as PartialEmoji # noqa: F401 49 | from .permissions import PermissionOverwrite as PermissionOverwrite # noqa: F401 50 | from .permissions import Permissions as Permissions # noqa: F401 51 | from .player import AudioSource as AudioSource # noqa: F401 52 | from .player import FFmpegAudio as FFmpegAudio # noqa: F401 53 | from .player import FFmpegOpusAudio as FFmpegOpusAudio # noqa: F401 54 | from .player import FFmpegPCMAudio as FFmpegPCMAudio # noqa: F401 55 | from .player import PCMAudio as PCMAudio # noqa: F401 56 | from .player import PCMVolumeTransformer as PCMVolumeTransformer # noqa: F401 57 | from .raw_models import * # noqa: F401 58 | from .reaction import Reaction as Reaction # noqa: F401 59 | from .relationship import Relationship as Relationship # noqa: F401 60 | from .role import Role as Role # noqa: F401 61 | from .role import RoleTags as RoleTags # noqa: F401 62 | from .shard import AutoShardedClient as AutoShardedClient # noqa: F401 63 | from .shard import ShardInfo as ShardInfo # noqa: F401 64 | from .sticker import Sticker as Sticker # noqa: F401 65 | from .team import * # noqa: F401 66 | from .template import Template as Template # noqa: F401 67 | from .user import ClientUser as ClientUser # noqa: F401 68 | from .user import Profile as Profile # noqa: F401 69 | from .user import User as User # noqa: F401 70 | from .voice_client import VoiceClient as VoiceClient # noqa: F401 71 | from .voice_client import VoiceProtocol as VoiceProtocol # noqa: F401 72 | from .webhook import * # noqa: F401 73 | from .widget import Widget as Widget # noqa: F401 74 | from .widget import WidgetChannel as WidgetChannel # noqa: F401 75 | from .widget import WidgetMember as WidgetMember # noqa: F401 76 | 77 | class VersionInfo(NamedTuple): 78 | major: int 79 | minor: int 80 | micro: int 81 | releaselevel: str 82 | serial: int 83 | 84 | __title__: Final[str] 85 | __author__: Final[str] 86 | __license__: Final[str] 87 | __copyright__: Final[str] 88 | __version__: Final[str] 89 | version_info: Final[VersionInfo] 90 | -------------------------------------------------------------------------------- /discord-stubs/__main__.pyi: -------------------------------------------------------------------------------- 1 | from argparse import ArgumentParser, Namespace 2 | from pathlib import Path 3 | from typing import Any, Tuple 4 | 5 | def show_version() -> None: ... 6 | def core(parser: Any, args: Any) -> None: ... 7 | 8 | bot_template: str 9 | gitignore_template: str 10 | cog_template: str 11 | cog_extras: str 12 | translation_table: Any 13 | 14 | def to_path(parser: Any, name: Any, *, replace_spaces: bool = ...) -> Path: ... 15 | def newbot(parser: Any, args: Any) -> None: ... 16 | def newcog(parser: Any, args: Any) -> None: ... 17 | def add_newbot_args(subparser: Any) -> None: ... 18 | def add_newcog_args(subparser: Any) -> None: ... 19 | def parse_args() -> Tuple[ArgumentParser, Namespace]: ... 20 | def main() -> None: ... 21 | -------------------------------------------------------------------------------- /discord-stubs/abc.pyi: -------------------------------------------------------------------------------- 1 | import abc 2 | import datetime 3 | from typing import Dict, List, Optional, Type, TypeVar, Union, overload 4 | from typing_extensions import Protocol, runtime_checkable 5 | 6 | from .channel import CategoryChannel 7 | from .context_managers import Typing 8 | from .embeds import Embed 9 | from .file import File 10 | from .guild import Guild 11 | from .invite import Invite 12 | from .iterators import HistoryIterator 13 | from .member import Member 14 | from .mentions import AllowedMentions 15 | from .message import Message, MessageReference 16 | from .permissions import PermissionOverwrite, Permissions 17 | from .role import Role 18 | from .user import ClientUser 19 | from .voice_client import VoiceClient, VoiceProtocol 20 | 21 | _GC = TypeVar('_GC', bound=GuildChannel) 22 | _VP = TypeVar('_VP', bound=VoiceProtocol) 23 | 24 | @runtime_checkable 25 | class Snowflake(Protocol): 26 | id: int 27 | @property 28 | @abc.abstractmethod 29 | def created_at(self) -> datetime.datetime: ... 30 | 31 | @runtime_checkable 32 | class User(Snowflake, Protocol): 33 | name: str 34 | discriminator: str 35 | avatar: Optional[str] 36 | bot: bool 37 | @property 38 | @abc.abstractmethod 39 | def display_name(self) -> str: ... 40 | @property 41 | @abc.abstractmethod 42 | def mention(self) -> str: ... 43 | 44 | @runtime_checkable 45 | class PrivateChannel(Snowflake, Protocol): 46 | me: ClientUser 47 | 48 | class GuildChannel: 49 | id: int 50 | name: str 51 | guild: Guild 52 | position: int 53 | category_id: Optional[int] 54 | @property 55 | def changed_roles(self) -> List[Role]: ... 56 | @property 57 | def mention(self) -> str: ... 58 | @property 59 | def created_at(self) -> datetime.datetime: ... 60 | def overwrites_for(self, obj: Union[Role, User]) -> PermissionOverwrite: ... 61 | @property 62 | def overwrites(self) -> Dict[Union[Role, Member], PermissionOverwrite]: ... 63 | @property 64 | def category(self) -> Optional[CategoryChannel]: ... 65 | @property 66 | def permissions_synced(self) -> bool: ... 67 | def permissions_for(self, member: Member) -> Permissions: ... 68 | async def delete(self, *, reason: Optional[str] = ...) -> None: ... 69 | @overload 70 | async def set_permissions( 71 | self, 72 | target: Union[Member, Role], 73 | *, 74 | overwrite: Optional[PermissionOverwrite] = ..., 75 | reason: Optional[str] = ..., 76 | ) -> None: ... 77 | @overload 78 | async def set_permissions( 79 | self, 80 | target: Union[Member, Role], 81 | *, 82 | reason: Optional[str] = ..., 83 | create_instant_invite: Optional[bool] = ..., 84 | kick_members: Optional[bool] = ..., 85 | ban_members: Optional[bool] = ..., 86 | administrator: Optional[bool] = ..., 87 | manage_channels: Optional[bool] = ..., 88 | manage_guild: Optional[bool] = ..., 89 | add_reactions: Optional[bool] = ..., 90 | view_audit_log: Optional[bool] = ..., 91 | priority_speaker: Optional[bool] = ..., 92 | stream: Optional[bool] = ..., 93 | read_messages: Optional[bool] = ..., 94 | view_channel: Optional[bool] = ..., 95 | send_messages: Optional[bool] = ..., 96 | send_tts_messages: Optional[bool] = ..., 97 | manage_messages: Optional[bool] = ..., 98 | embed_links: Optional[bool] = ..., 99 | attach_files: Optional[bool] = ..., 100 | read_message_history: Optional[bool] = ..., 101 | mention_everyone: Optional[bool] = ..., 102 | external_emojis: Optional[bool] = ..., 103 | use_external_emojis: Optional[bool] = ..., 104 | view_guild_insights: Optional[bool] = ..., 105 | connect: Optional[bool] = ..., 106 | speak: Optional[bool] = ..., 107 | mute_members: Optional[bool] = ..., 108 | deafen_members: Optional[bool] = ..., 109 | move_members: Optional[bool] = ..., 110 | use_voice_activation: Optional[bool] = ..., 111 | change_nickname: Optional[bool] = ..., 112 | manage_nicknames: Optional[bool] = ..., 113 | manage_roles: Optional[bool] = ..., 114 | manage_permissions: Optional[bool] = ..., 115 | manage_webhooks: Optional[bool] = ..., 116 | manage_emojis: Optional[bool] = ..., 117 | ) -> None: ... 118 | async def clone( 119 | self: _GC, *, name: Optional[str] = ..., reason: Optional[str] = ... 120 | ) -> _GC: ... 121 | @overload 122 | async def move( 123 | self, 124 | *, 125 | beginning: bool, 126 | offset: int = ..., 127 | category: Optional[Snowflake] = ..., 128 | sync_permissions: bool = ..., 129 | reason: Optional[str] = ..., 130 | ) -> None: ... 131 | @overload 132 | async def move( 133 | self, 134 | *, 135 | end: bool, 136 | offset: int = ..., 137 | category: Optional[Snowflake] = ..., 138 | sync_permissions: bool = ..., 139 | reason: Optional[str] = ..., 140 | ) -> None: ... 141 | @overload 142 | async def move( 143 | self, 144 | *, 145 | before: Snowflake, 146 | offset: int = ..., 147 | category: Optional[Snowflake] = ..., 148 | sync_permissions: bool = ..., 149 | reason: Optional[str] = ..., 150 | ) -> None: ... 151 | @overload 152 | async def move( 153 | self, 154 | *, 155 | after: Snowflake, 156 | offset: int = ..., 157 | category: Optional[Snowflake] = ..., 158 | sync_permissions: bool = ..., 159 | reason: Optional[str] = ..., 160 | ) -> None: ... 161 | async def create_invite( 162 | self, 163 | *, 164 | reason: Optional[str] = ..., 165 | max_age: int = ..., 166 | max_uses: int = ..., 167 | temporary: bool = ..., 168 | unique: bool = ..., 169 | ) -> Invite: ... 170 | async def invites(self) -> List[Invite]: ... 171 | 172 | class Messageable(metaclass=abc.ABCMeta): 173 | async def send( 174 | self, 175 | content: Optional[object] = ..., 176 | *, 177 | tts: bool = ..., 178 | embed: Optional[Embed] = ..., 179 | file: Optional[File] = ..., 180 | files: Optional[List[File]] = ..., 181 | delete_after: Optional[float] = ..., 182 | nonce: Optional[int] = ..., 183 | allowed_mentions: Optional[AllowedMentions] = ..., 184 | reference: Optional[Union[Message, MessageReference]] = ..., 185 | mention_author: Optional[bool] = ..., 186 | ) -> Message: ... 187 | async def trigger_typing(self) -> None: ... 188 | def typing(self) -> Typing: ... 189 | async def fetch_message(self, id: int) -> Message: ... 190 | async def pins(self) -> List[Message]: ... 191 | def history( 192 | self, 193 | *, 194 | limit: Optional[int] = ..., 195 | before: Optional[Union[Snowflake, datetime.datetime]] = ..., 196 | after: Optional[Union[Snowflake, datetime.datetime]] = ..., 197 | around: Optional[Union[Snowflake, datetime.datetime]] = ..., 198 | oldest_first: Optional[bool] = ..., 199 | ) -> HistoryIterator: ... 200 | 201 | class Connectable(metaclass=abc.ABCMeta): 202 | @overload 203 | async def connect( 204 | self, *, timeout: float = ..., reconnect: bool = ... 205 | ) -> VoiceClient: ... 206 | @overload 207 | async def connect( 208 | self, *, timeout: float = ..., reconnect: bool = ..., cls: Type[_VP] = ... 209 | ) -> _VP: ... 210 | -------------------------------------------------------------------------------- /discord-stubs/activity.pyi: -------------------------------------------------------------------------------- 1 | import datetime 2 | from typing import Any, List, Optional, Union, overload 3 | 4 | from .colour import Colour 5 | from .enums import ActivityType 6 | from .http import ( 7 | _ActivityAssetsDict, 8 | _ActivityDict, 9 | _ActivityPartyDict, 10 | _CustomActivityDict, 11 | _PartialEmojiDict, 12 | _SpotifyActivityDict, 13 | _TimestampsDict, 14 | ) 15 | from .partial_emoji import PartialEmoji 16 | 17 | class BaseActivity: 18 | @property 19 | def created_at(self) -> datetime.datetime: ... 20 | 21 | class Activity(BaseActivity): 22 | application_id: int 23 | name: str 24 | url: str 25 | type: ActivityType 26 | state: str 27 | details: str 28 | timestamps: _TimestampsDict 29 | assets: _ActivityAssetsDict 30 | party: _ActivityPartyDict 31 | emoji: Optional[PartialEmoji] 32 | flags: int 33 | sync_id: Optional[str] 34 | session_id: Optional[str] 35 | def __init__( 36 | self, 37 | *, 38 | state: Optional[str] = ..., 39 | details: Optional[str] = ..., 40 | timestamps: _TimestampsDict = ..., 41 | assets: _ActivityAssetsDict = ..., 42 | party: _ActivityPartyDict = ..., 43 | application_id: Optional[Union[str, int]] = ..., 44 | name: Optional[str] = ..., 45 | url: Optional[str] = ..., 46 | flags: int = ..., 47 | sync_id: Optional[str] = ..., 48 | session_id: Optional[str] = ..., 49 | type: ActivityType = ..., 50 | ) -> None: ... 51 | def to_dict(self) -> _ActivityDict: ... 52 | @property 53 | def start(self) -> Optional[datetime.datetime]: ... 54 | @property 55 | def end(self) -> Optional[datetime.datetime]: ... 56 | @property 57 | def large_image_url(self) -> Optional[str]: ... 58 | @property 59 | def small_image_url(self) -> Optional[str]: ... 60 | @property 61 | def large_image_text(self) -> Optional[str]: ... 62 | @property 63 | def small_image_text(self) -> Optional[str]: ... 64 | 65 | class Game(BaseActivity): 66 | name: str 67 | @overload 68 | def __init__(self, name: str, *, timestamps: _TimestampsDict) -> None: ... 69 | @overload 70 | def __init__( 71 | self, 72 | name: str, 73 | *, 74 | start: Optional[datetime.datetime] = ..., 75 | end: Optional[datetime.datetime] = ..., 76 | ) -> None: ... 77 | @property 78 | def type(self) -> ActivityType: ... 79 | @property 80 | def start(self) -> Optional[datetime.datetime]: ... 81 | @property 82 | def end(self) -> Optional[datetime.datetime]: ... 83 | def to_dict(self) -> _ActivityDict: ... 84 | def __eq__(self, other: Any) -> bool: ... 85 | def __ne__(self, other: Any) -> bool: ... 86 | def __hash__(self) -> int: ... 87 | 88 | class Streaming(BaseActivity): 89 | platform: str 90 | name: str 91 | details: str 92 | game: Optional[str] 93 | url: str 94 | assets: _ActivityAssetsDict 95 | def __init__( 96 | self, 97 | *, 98 | name: str, 99 | url: str, 100 | details: Optional[str] = ..., 101 | assets: _ActivityAssetsDict = ..., 102 | ) -> None: ... 103 | @property 104 | def type(self) -> ActivityType: ... 105 | @property 106 | def twitch_name(self) -> Optional[str]: ... 107 | def to_dict(self) -> _ActivityDict: ... 108 | def __eq__(self, other: Any) -> bool: ... 109 | def __ne__(self, other: Any) -> bool: ... 110 | def __hash__(self) -> int: ... 111 | 112 | class Spotify: 113 | @property 114 | def type(self) -> ActivityType: ... 115 | @property 116 | def created_at(self) -> datetime.datetime: ... 117 | @property 118 | def colour(self) -> Colour: ... 119 | @property 120 | def color(self) -> Colour: ... 121 | def to_dict(self) -> _SpotifyActivityDict: ... 122 | @property 123 | def name(self) -> str: ... 124 | def __eq__(self, other: Any) -> bool: ... 125 | def __ne__(self, other: Any) -> bool: ... 126 | def __hash__(self) -> int: ... 127 | @property 128 | def title(self) -> Optional[str]: ... 129 | @property 130 | def artists(self) -> List[str]: ... 131 | @property 132 | def artist(self) -> str: ... 133 | @property 134 | def album(self) -> str: ... 135 | @property 136 | def album_cover_url(self) -> str: ... 137 | @property 138 | def track_id(self) -> str: ... 139 | @property 140 | def start(self) -> datetime.datetime: ... 141 | @property 142 | def end(self) -> datetime.datetime: ... 143 | @property 144 | def duration(self) -> datetime.timedelta: ... 145 | @property 146 | def party_id(self) -> str: ... 147 | 148 | class CustomActivity(BaseActivity): 149 | name: Optional[str] 150 | emoji: Optional[PartialEmoji] 151 | def __init__( 152 | self, 153 | name: Optional[str], 154 | *, 155 | emoji: Optional[Union[PartialEmoji, str, _PartialEmojiDict]] = ..., 156 | **extra: Any, 157 | ) -> None: ... 158 | @property 159 | def type(self) -> ActivityType: ... 160 | def to_dict(self) -> _CustomActivityDict: ... 161 | def __eq__(self, other: Any) -> bool: ... 162 | def __ne__(self, other: Any) -> bool: ... 163 | def __hash__(self) -> int: ... 164 | -------------------------------------------------------------------------------- /discord-stubs/appinfo.pyi: -------------------------------------------------------------------------------- 1 | from typing import List, Optional 2 | 3 | from .asset import _VALID_STATIC_ICON_FORMATS, Asset 4 | from .guild import Guild 5 | from .team import Team 6 | from .user import User 7 | 8 | class AppInfo: 9 | id: int 10 | name: str 11 | description: Optional[str] 12 | icon: Optional[str] 13 | rpc_origins: Optional[List[str]] 14 | bot_public: bool 15 | bot_require_code_grant: bool 16 | owner: User 17 | team: Team 18 | summary: str 19 | verify_key: str 20 | guild_id: Optional[int] 21 | primary_sku_id: Optional[int] 22 | slug: Optional[str] 23 | cover_image: Optional[str] 24 | @property 25 | def icon_url(self) -> Asset: ... 26 | def icon_url_as( 27 | self, *, format: _VALID_STATIC_ICON_FORMATS = ..., size: int = ... 28 | ) -> Asset: ... 29 | @property 30 | def cover_image_url(self) -> Asset: ... 31 | def cover_image_url_as( 32 | self, *, format: _VALID_STATIC_ICON_FORMATS = ..., size: int = ... 33 | ) -> Asset: ... 34 | @property 35 | def guild(self) -> Optional[Guild]: ... 36 | -------------------------------------------------------------------------------- /discord-stubs/asset.pyi: -------------------------------------------------------------------------------- 1 | import sys 2 | from typing import Any, BinaryIO, ClassVar, FrozenSet, Union 3 | from typing_extensions import Final, Literal 4 | 5 | if sys.version_info >= (3, 6): 6 | from os import PathLike 7 | 8 | _VALID_STATIC_ICON_FORMATS = Literal['jpeg', 'jpg', 'webp', 'png'] 9 | _VALID_ANIMATED_ICON_FORMATS = Literal[_VALID_STATIC_ICON_FORMATS, 'gif'] 10 | 11 | VALID_STATIC_FORMATS: Final[FrozenSet[_VALID_STATIC_ICON_FORMATS]] 12 | VALID_AVATAR_FORMATS: Final[FrozenSet[_VALID_ANIMATED_ICON_FORMATS]] 13 | 14 | class Asset: 15 | BASE: ClassVar[str] 16 | def __len__(self) -> int: ... 17 | def __bool__(self) -> bool: ... 18 | def __eq__(self, other: Any) -> bool: ... 19 | def __ne__(self, other: Any) -> bool: ... 20 | def __hash__(self) -> int: ... 21 | async def read(self) -> bytes: ... 22 | if sys.version_info >= (3, 6): 23 | async def save( 24 | self, fp: Union[BinaryIO, PathLike[str], str], *, seek_begin: bool = ... 25 | ) -> int: ... 26 | else: 27 | async def save( 28 | self, fp: Union[BinaryIO, str], *, seek_begin: bool = ... 29 | ) -> int: ... 30 | -------------------------------------------------------------------------------- /discord-stubs/audit_logs.pyi: -------------------------------------------------------------------------------- 1 | import datetime 2 | from typing import Any, Callable, ClassVar, Dict, Iterator, Optional, Tuple 3 | 4 | from . import enums 5 | from .abc import User as _ABCUser 6 | from .guild import Guild 7 | from .mixins import Hashable 8 | from .utils import cached_property 9 | 10 | class AuditLogDiff: 11 | def __len__(self) -> int: ... 12 | def __iter__(self) -> Iterator[Tuple[str, Any]]: ... 13 | 14 | class AuditLogChanges: 15 | TRANSFORMERS: ClassVar[ 16 | Dict[str, Tuple[Optional[str], Optional[Callable[[Any, Any], AuditLogDiff]]]] 17 | ] 18 | before: AuditLogDiff 19 | after: AuditLogDiff 20 | 21 | class AuditLogEntry(Hashable): 22 | id: int 23 | guild: Guild 24 | action: enums.AuditLogAction 25 | user: _ABCUser 26 | reason: Optional[str] 27 | extra: Any 28 | @cached_property 29 | def created_at(self) -> datetime.datetime: ... 30 | @cached_property 31 | def target(self) -> Any: ... 32 | @cached_property 33 | def category(self) -> Optional[enums.AuditLogActionCategory]: ... 34 | @cached_property 35 | def changes(self) -> AuditLogChanges: ... 36 | @cached_property 37 | def before(self) -> AuditLogDiff: ... 38 | @cached_property 39 | def after(self) -> AuditLogDiff: ... 40 | -------------------------------------------------------------------------------- /discord-stubs/backoff.pyi: -------------------------------------------------------------------------------- 1 | from typing import Union 2 | 3 | class ExponentialBackoff: 4 | def __init__(self, base: int = ..., *, integral: bool = ...) -> None: ... 5 | def delay(self) -> Union[int, float]: ... 6 | -------------------------------------------------------------------------------- /discord-stubs/calls.pyi: -------------------------------------------------------------------------------- 1 | import datetime 2 | from typing import List, Optional, Union, type_check_only 3 | from typing_extensions import TypedDict 4 | 5 | from .channel import GroupChannel 6 | from .enums import VoiceRegion 7 | from .member import VoiceState 8 | from .message import Message 9 | from .user import ClientUser, User 10 | 11 | @type_check_only 12 | class _BaseVoiceStateDict(TypedDict): 13 | channel_id: Optional[int] 14 | user_id: int 15 | session_id: str 16 | deaf: bool 17 | mute: bool 18 | self_deaf: bool 19 | self_mute: bool 20 | suppress: bool 21 | 22 | @type_check_only 23 | class _VoiceStateDict(_BaseVoiceStateDict, total=False): 24 | guild_id: int 25 | 26 | class CallMessage: 27 | ended_timestamp: Optional[datetime.datetime] 28 | participants: Optional[List[User]] 29 | message: Message 30 | def __init__( 31 | self, 32 | message: Message, 33 | *, 34 | ended_timestamp: Optional[str] = ..., 35 | participants: List[User], 36 | ) -> None: ... 37 | @property 38 | def call_ended(self) -> bool: ... 39 | @property 40 | def channel(self) -> GroupChannel: ... 41 | @property 42 | def duration(self) -> datetime.timedelta: ... 43 | 44 | class GroupCall: 45 | call: CallMessage 46 | unavailable: Optional[bool] 47 | ringing: List[User] 48 | region: VoiceRegion 49 | def __init__( 50 | self, 51 | *, 52 | call: CallMessage, 53 | unavailable: bool, 54 | voice_states: List[_VoiceStateDict] = ..., 55 | region: VoiceRegion, 56 | ringing: List[int] = ..., 57 | ) -> None: ... 58 | @property 59 | def connected(self) -> List[Union[User, ClientUser]]: ... 60 | @property 61 | def channel(self) -> GroupChannel: ... 62 | def voice_state_for( 63 | self, user: Union[User, ClientUser] 64 | ) -> Optional[VoiceState]: ... 65 | -------------------------------------------------------------------------------- /discord-stubs/channel.pyi: -------------------------------------------------------------------------------- 1 | import datetime 2 | from typing import Callable, Dict, Iterable, List, Optional, Union, overload 3 | from typing_extensions import Literal 4 | 5 | import discord.abc 6 | 7 | from .asset import _VALID_STATIC_ICON_FORMATS, Asset 8 | from .enums import ChannelType, VoiceRegion 9 | from .member import Member, VoiceState 10 | from .message import Message, PartialMessage 11 | from .mixins import Hashable 12 | from .permissions import PermissionOverwrite, Permissions 13 | from .role import Role 14 | from .user import BaseUser, ClientUser, User 15 | from .webhook import _AsyncWebhook 16 | 17 | _OverwritesDict = Dict[Union[Role, Member], PermissionOverwrite] 18 | 19 | class TextChannel(discord.abc.Messageable, discord.abc.GuildChannel, Hashable): 20 | topic: Optional[str] 21 | last_message_id: Optional[int] 22 | slowmode_delay: int 23 | nsfw: bool 24 | @property 25 | def type(self) -> Literal[ChannelType.text, ChannelType.news]: ... 26 | def permissions_for(self, member: Member) -> Permissions: ... 27 | @property 28 | def members(self) -> List[Member]: ... 29 | def is_nsfw(self) -> bool: ... 30 | def is_news(self) -> bool: ... 31 | @property 32 | def last_message(self) -> Optional[Message]: ... 33 | async def edit( 34 | self, 35 | *, 36 | reason: Optional[str] = ..., 37 | name: str = ..., 38 | topic: str = ..., 39 | position: int = ..., 40 | nsfw: bool = ..., 41 | sync_permissions: bool = ..., 42 | category: Optional[CategoryChannel] = ..., 43 | slowmode_delay: int = ..., 44 | type: ChannelType = ..., 45 | overwrites: _OverwritesDict = ..., 46 | ) -> None: ... 47 | async def delete_messages(self, messages: Iterable[Message]) -> None: ... 48 | async def purge( 49 | self, 50 | *, 51 | limit: Optional[int] = ..., 52 | check: Optional[Callable[[Message], bool]] = ..., 53 | before: Optional[Union[datetime.datetime, Message]] = ..., 54 | after: Optional[Union[datetime.datetime, Message]] = ..., 55 | around: Optional[Union[datetime.datetime, Message]] = ..., 56 | oldest_first: Optional[bool] = ..., 57 | bulk: bool = ..., 58 | ) -> List[Message]: ... 59 | async def webhooks(self) -> List[_AsyncWebhook]: ... 60 | async def create_webhook( 61 | self, 62 | *, 63 | name: str, 64 | avatar: Optional[Union[bytes, bytearray]] = ..., 65 | reason: Optional[str] = ..., 66 | ) -> _AsyncWebhook: ... 67 | async def follow( 68 | self, *, destination: TextChannel, reason: Optional[str] = ... 69 | ) -> _AsyncWebhook: ... 70 | def get_partial_message(self, message_id: int) -> PartialMessage: ... 71 | 72 | class VocalGuildChannel(discord.abc.Connectable, discord.abc.GuildChannel, Hashable): 73 | bitrate: int 74 | user_limit: int 75 | rtc_region: Optional[VoiceRegion] 76 | @property 77 | def members(self) -> List[Member]: ... 78 | @property 79 | def voice_states(self) -> Dict[int, VoiceState]: ... 80 | def permissions_for(self, member: Member) -> Permissions: ... 81 | 82 | class VoiceChannel(VocalGuildChannel): 83 | @property 84 | def type(self) -> Literal[ChannelType.voice]: ... 85 | async def edit( 86 | self, 87 | *, 88 | reason: Optional[str] = ..., 89 | name: str = ..., 90 | bitrate: int = ..., 91 | user_limit: int = ..., 92 | position: int = ..., 93 | sync_permissions: bool = ..., 94 | category: Optional[CategoryChannel] = ..., 95 | overwrites: _OverwritesDict = ..., 96 | rtc_region: Optional[VoiceRegion] = ..., 97 | ) -> None: ... 98 | 99 | class StageChannel(VocalGuildChannel): 100 | topic: str 101 | @property 102 | def requesting_to_speak(self) -> List[Member]: ... 103 | @property 104 | def type(self) -> Literal[ChannelType.stage_voice]: ... 105 | async def edit( 106 | self, 107 | *, 108 | reason: Optional[str] = ..., 109 | name: str = ..., 110 | topic: str = ..., 111 | position: int = ..., 112 | sync_permissions: bool = ..., 113 | category: Optional[CategoryChannel] = ..., 114 | overwrites: _OverwritesDict = ..., 115 | rtc_region: Optional[VoiceRegion] = ..., 116 | ) -> None: ... 117 | 118 | class CategoryChannel(discord.abc.GuildChannel, Hashable): 119 | nsfw: bool 120 | @property 121 | def type(self) -> Literal[ChannelType.category]: ... 122 | def is_nsfw(self) -> bool: ... 123 | async def edit( 124 | self, 125 | *, 126 | reason: Optional[str] = ..., 127 | name: str = ..., 128 | position: int = ..., 129 | nsfw: bool = ..., 130 | overwrites: Dict[Union[Role, Member], PermissionOverwrite] = ..., 131 | ) -> None: ... 132 | @overload 133 | async def move( 134 | self, 135 | *, 136 | beginning: bool, 137 | offset: int = ..., 138 | category: Optional[discord.abc.Snowflake] = ..., 139 | sync_permissions: bool = ..., 140 | reason: Optional[str] = ..., 141 | ) -> None: ... 142 | @overload 143 | async def move( 144 | self, 145 | *, 146 | end: bool, 147 | offset: int = ..., 148 | category: Optional[discord.abc.Snowflake] = ..., 149 | sync_permissions: bool = ..., 150 | reason: Optional[str] = ..., 151 | ) -> None: ... 152 | @overload 153 | async def move( 154 | self, 155 | *, 156 | before: discord.abc.Snowflake, 157 | offset: int = ..., 158 | category: Optional[discord.abc.Snowflake] = ..., 159 | sync_permissions: bool = ..., 160 | reason: Optional[str] = ..., 161 | ) -> None: ... 162 | @overload 163 | async def move( 164 | self, 165 | *, 166 | after: discord.abc.Snowflake, 167 | offset: int = ..., 168 | category: Optional[discord.abc.Snowflake] = ..., 169 | sync_permissions: bool = ..., 170 | reason: Optional[str] = ..., 171 | ) -> None: ... 172 | @property 173 | def channels(self) -> List[Union[TextChannel, VoiceChannel, StoreChannel]]: ... 174 | @property 175 | def text_channels(self) -> List[TextChannel]: ... 176 | @property 177 | def voice_channels(self) -> List[VoiceChannel]: ... 178 | @property 179 | def stage_channels(self) -> List[StageChannel]: ... 180 | async def create_text_channel( 181 | self, 182 | name: str, 183 | *, 184 | overwrites: Optional[Dict[Union[Role, Member], PermissionOverwrite]] = ..., 185 | position: int = ..., 186 | topic: str = ..., 187 | slowmode_delay: int = ..., 188 | nsfw: bool = ..., 189 | reason: Optional[str] = ..., 190 | ) -> TextChannel: ... 191 | async def create_voice_channel( 192 | self, 193 | name: str, 194 | *, 195 | overwrites: Optional[Dict[Union[Role, Member], PermissionOverwrite]] = ..., 196 | bitrate: int = ..., 197 | position: int = ..., 198 | user_limit: int = ..., 199 | rtc_region: Optional[VoiceRegion] = ..., 200 | reason: Optional[str] = ..., 201 | ) -> VoiceChannel: ... 202 | async def create_stage_channel( 203 | self, 204 | name: str, 205 | *, 206 | overwrites: Optional[Dict[Union[Role, Member], PermissionOverwrite]] = ..., 207 | topic: str = ..., 208 | position: int = ..., 209 | rtc_region: Optional[VoiceRegion] = ..., 210 | reason: Optional[str] = ..., 211 | ) -> StageChannel: ... 212 | 213 | class StoreChannel(discord.abc.GuildChannel, Hashable): 214 | nsfw: bool 215 | @property 216 | def type(self) -> Literal[ChannelType.store]: ... 217 | def permissions_for(self, member: Member) -> Permissions: ... 218 | def is_nsfw(self) -> bool: ... 219 | async def edit( 220 | self, 221 | *, 222 | reason: Optional[str] = ..., 223 | name: str = ..., 224 | position: int = ..., 225 | nsfw: bool = ..., 226 | sync_permissions: bool = ..., 227 | category: Optional[CategoryChannel] = ..., 228 | overwrites: _OverwritesDict = ..., 229 | ) -> None: ... 230 | 231 | class DMChannel(discord.abc.Messageable, Hashable): 232 | id: int 233 | recipient: User 234 | me: ClientUser 235 | @property 236 | def type(self) -> Literal[ChannelType.private]: ... 237 | @property 238 | def created_at(self) -> datetime.datetime: ... 239 | def permissions_for(self, user: Optional[BaseUser] = ...) -> Permissions: ... 240 | def get_partial_message(self, message_id: int) -> PartialMessage: ... 241 | 242 | class GroupChannel(discord.abc.Messageable, Hashable): 243 | id: int 244 | me: ClientUser 245 | owner: User 246 | icon: Optional[str] 247 | name: Optional[str] 248 | recipients: List[User] 249 | @property 250 | def type(self) -> Literal[ChannelType.group]: ... 251 | @property 252 | def icon_url(self) -> Asset: ... 253 | def icon_url_as( 254 | self, *, format: _VALID_STATIC_ICON_FORMATS = ..., size: int = ... 255 | ) -> Asset: ... 256 | @property 257 | def created_at(self) -> datetime.datetime: ... 258 | def permissions_for(self, user: BaseUser) -> Permissions: ... 259 | async def add_recipients(self, *recipients: User) -> None: ... 260 | async def remove_recipients(self, *recipients: User) -> None: ... 261 | async def edit( 262 | self, name: Optional[str] = ..., icon: Optional[bytes] = ... 263 | ) -> None: ... 264 | async def leave(self) -> None: ... 265 | -------------------------------------------------------------------------------- /discord-stubs/colour.pyi: -------------------------------------------------------------------------------- 1 | from typing import Any, Optional, Tuple, Type, TypeVar 2 | 3 | _C = TypeVar('_C', bound=Colour) 4 | 5 | class Colour: 6 | value: int 7 | def __init__(self, value: int) -> None: ... 8 | def __eq__(self, other: Any) -> bool: ... 9 | def __ne__(self, other: Any) -> bool: ... 10 | def __hash__(self) -> int: ... 11 | @property 12 | def r(self) -> int: ... 13 | @property 14 | def g(self) -> int: ... 15 | @property 16 | def b(self) -> int: ... 17 | def to_rgb(self) -> Tuple[int, int, int]: ... 18 | @classmethod 19 | def from_rgb(cls: Type[_C], r: int, g: int, b: int) -> _C: ... 20 | @classmethod 21 | def from_hsv(cls: Type[_C], h: float, s: float, v: float) -> _C: ... 22 | @classmethod 23 | def default(cls: Type[_C]) -> _C: ... 24 | @classmethod 25 | def random(cls: Type[_C], *, seed: Optional[Any] = ...) -> _C: ... 26 | @classmethod 27 | def teal(cls: Type[_C]) -> _C: ... 28 | @classmethod 29 | def dark_teal(cls: Type[_C]) -> _C: ... 30 | @classmethod 31 | def green(cls: Type[_C]) -> _C: ... 32 | @classmethod 33 | def dark_green(cls: Type[_C]) -> _C: ... 34 | @classmethod 35 | def blue(cls: Type[_C]) -> _C: ... 36 | @classmethod 37 | def dark_blue(cls: Type[_C]) -> _C: ... 38 | @classmethod 39 | def purple(cls: Type[_C]) -> _C: ... 40 | @classmethod 41 | def dark_purple(cls: Type[_C]) -> _C: ... 42 | @classmethod 43 | def magenta(cls: Type[_C]) -> _C: ... 44 | @classmethod 45 | def dark_magenta(cls: Type[_C]) -> _C: ... 46 | @classmethod 47 | def gold(cls: Type[_C]) -> _C: ... 48 | @classmethod 49 | def dark_gold(cls: Type[_C]) -> _C: ... 50 | @classmethod 51 | def orange(cls: Type[_C]) -> _C: ... 52 | @classmethod 53 | def dark_orange(cls: Type[_C]) -> _C: ... 54 | @classmethod 55 | def red(cls: Type[_C]) -> _C: ... 56 | @classmethod 57 | def dark_red(cls: Type[_C]) -> _C: ... 58 | @classmethod 59 | def lighter_grey(cls: Type[_C]) -> _C: ... 60 | @classmethod 61 | def lighter_gray(cls: Type[_C]) -> _C: ... 62 | @classmethod 63 | def dark_grey(cls: Type[_C]) -> _C: ... 64 | @classmethod 65 | def dark_gray(cls: Type[_C]) -> _C: ... 66 | @classmethod 67 | def light_grey(cls: Type[_C]) -> _C: ... 68 | @classmethod 69 | def light_gray(cls: Type[_C]) -> _C: ... 70 | @classmethod 71 | def darker_grey(cls: Type[_C]) -> _C: ... 72 | @classmethod 73 | def darker_gray(cls: Type[_C]) -> _C: ... 74 | @classmethod 75 | def blurple(cls: Type[_C]) -> _C: ... 76 | @classmethod 77 | def greyple(cls: Type[_C]) -> _C: ... 78 | @classmethod 79 | def dark_theme(cls: Type[_C]) -> _C: ... 80 | 81 | Color = Colour 82 | -------------------------------------------------------------------------------- /discord-stubs/context_managers.pyi: -------------------------------------------------------------------------------- 1 | import asyncio 2 | from typing import Any, Optional 3 | 4 | from .abc import Messageable 5 | 6 | class Typing: 7 | loop: asyncio.AbstractEventLoop 8 | messageable: Messageable 9 | task: Optional[asyncio.Task[None]] 10 | def __init__(self, messageable: Messageable) -> None: ... 11 | async def do_typing(self) -> None: ... 12 | def __enter__(self) -> Typing: ... 13 | def __exit__(self, exc_type: Any, exc: Any, tb: Any) -> None: ... 14 | async def __aenter__(self) -> Typing: ... 15 | async def __aexit__(self, exc_type: Any, exc: Any, tb: Any) -> None: ... 16 | -------------------------------------------------------------------------------- /discord-stubs/embeds.pyi: -------------------------------------------------------------------------------- 1 | import datetime 2 | from typing import Any, ClassVar, Dict, List, Type, TypeVar, Union, type_check_only 3 | from typing_extensions import Final, Protocol 4 | 5 | from .colour import Colour 6 | from .http import _EmbedDict 7 | 8 | class _EmptyEmbed: 9 | def __bool__(self) -> bool: ... 10 | def __len__(self) -> int: ... 11 | 12 | EmptyEmbed: Final[_EmptyEmbed] 13 | 14 | class EmbedProxy: 15 | def __init__(self, layer: Dict[str, Any]) -> None: ... 16 | def __len__(self) -> int: ... 17 | def __getattr__(self, attr: str) -> _EmptyEmbed: ... 18 | 19 | _E = TypeVar('_E', bound=Embed) 20 | 21 | @type_check_only 22 | class _EmbedFooterData(Protocol): 23 | text: Union[str, _EmptyEmbed] 24 | icon_url: Union[str, _EmptyEmbed] 25 | 26 | @type_check_only 27 | class _EmbedImageData(Protocol): 28 | url: Union[str, _EmptyEmbed] 29 | proxy_url: Union[str, _EmptyEmbed] 30 | height: Union[int, _EmptyEmbed] 31 | width: Union[int, _EmptyEmbed] 32 | 33 | @type_check_only 34 | class _EmbedVideoData(Protocol): 35 | url: Union[str, _EmptyEmbed] 36 | height: Union[int, _EmptyEmbed] 37 | width: Union[int, _EmptyEmbed] 38 | 39 | @type_check_only 40 | class _EmbedProviderData(Protocol): 41 | name: Union[str, _EmptyEmbed] 42 | url: Union[str, _EmptyEmbed] 43 | 44 | @type_check_only 45 | class _EmbedAuthorData(Protocol): 46 | name: Union[str, _EmptyEmbed] 47 | url: Union[str, _EmptyEmbed] 48 | icon_url: Union[str, _EmptyEmbed] 49 | proxy_icon_url: Union[str, _EmptyEmbed] 50 | 51 | @type_check_only 52 | class _EmbedFieldData(Protocol): 53 | name: Union[str, _EmptyEmbed] 54 | value: Union[str, _EmptyEmbed] 55 | inline: Union[bool, _EmptyEmbed] 56 | 57 | class Embed: 58 | title: Union[str, _EmptyEmbed] 59 | type: str 60 | description: Union[str, _EmptyEmbed] 61 | url: Union[str, _EmptyEmbed] 62 | colour: Union[int, Colour, _EmptyEmbed] 63 | color: Union[int, Colour, _EmptyEmbed] 64 | timestamp: Union[datetime.datetime, _EmptyEmbed] 65 | 66 | Empty: ClassVar[_EmptyEmbed] 67 | def __init__( 68 | self, 69 | *, 70 | color: Union[int, Colour, _EmptyEmbed] = ..., 71 | colour: Union[int, Colour, _EmptyEmbed] = ..., 72 | title: Union[object, _EmptyEmbed] = ..., 73 | type: str = ..., 74 | url: Union[object, _EmptyEmbed] = ..., 75 | description: Union[object, _EmptyEmbed] = ..., 76 | timestamp: Union[datetime.datetime, _EmptyEmbed] = ..., 77 | ) -> None: ... 78 | @classmethod 79 | def from_dict(cls: Type[_E], data: _EmbedDict) -> _E: ... 80 | def copy(self) -> Embed: ... 81 | def __len__(self) -> int: ... 82 | @property 83 | def footer(self) -> _EmbedFooterData: ... 84 | def set_footer( 85 | self: _E, 86 | *, 87 | text: Union[str, _EmptyEmbed] = ..., 88 | icon_url: Union[str, _EmptyEmbed] = ..., 89 | ) -> _E: ... 90 | @property 91 | def image(self) -> _EmbedImageData: ... 92 | def set_image(self: _E, *, url: Union[str, _EmptyEmbed]) -> _E: ... 93 | @property 94 | def thumbnail(self) -> _EmbedImageData: ... 95 | def set_thumbnail(self: _E, *, url: Union[str, _EmptyEmbed]) -> _E: ... 96 | @property 97 | def video(self) -> _EmbedVideoData: ... 98 | @property 99 | def provider(self) -> _EmbedProviderData: ... 100 | @property 101 | def author(self) -> _EmbedAuthorData: ... 102 | def set_author( 103 | self: _E, 104 | *, 105 | name: str, 106 | url: Union[str, _EmptyEmbed] = ..., 107 | icon_url: Union[str, _EmptyEmbed] = ..., 108 | ) -> _E: ... 109 | def remove_author(self: _E) -> _E: ... 110 | @property 111 | def fields(self) -> List[_EmbedFieldData]: ... 112 | def add_field(self: _E, *, name: str, value: str, inline: bool = ...) -> _E: ... 113 | def insert_field_at( 114 | self: _E, index: int, *, name: str, value: str, inline: bool = ... 115 | ) -> _E: ... 116 | def clear_fields(self) -> None: ... 117 | def remove_field(self, index: int) -> None: ... 118 | def set_field_at( 119 | self: _E, index: int, *, name: str, value: str, inline: bool = ... 120 | ) -> _E: ... 121 | def to_dict(self) -> _EmbedDict: ... 122 | -------------------------------------------------------------------------------- /discord-stubs/emoji.pyi: -------------------------------------------------------------------------------- 1 | import datetime 2 | from typing import Any, Iterator, List, Optional, Tuple 3 | 4 | from .asset import _VALID_ANIMATED_ICON_FORMATS, _VALID_STATIC_ICON_FORMATS, Asset 5 | from .guild import Guild 6 | from .partial_emoji import _EmojiTag 7 | from .role import Role 8 | from .user import User 9 | 10 | class Emoji(_EmojiTag): 11 | name: str 12 | id: int 13 | require_colons: bool 14 | animated: bool 15 | managed: bool 16 | guild_id: int 17 | available: bool 18 | user: Optional[User] 19 | def __iter__(self) -> Iterator[Tuple[str, Any]]: ... 20 | def __eq__(self, other: Any) -> bool: ... 21 | def __ne__(self, other: Any) -> bool: ... 22 | def __hash__(self) -> int: ... 23 | @property 24 | def created_at(self) -> datetime.datetime: ... 25 | @property 26 | def url(self) -> Asset: ... 27 | @property 28 | def roles(self) -> List[Role]: ... 29 | @property 30 | def guild(self) -> Guild: ... 31 | def url_as( 32 | self, 33 | *, 34 | format: Optional[_VALID_ANIMATED_ICON_FORMATS] = ..., 35 | static_format: _VALID_STATIC_ICON_FORMATS = ..., 36 | ) -> Asset: ... 37 | def is_usable(self) -> bool: ... 38 | async def delete(self, *, reason: Optional[str] = ...) -> None: ... 39 | async def edit( 40 | self, 41 | *, 42 | name: Optional[str] = ..., 43 | roles: Optional[List[Role]] = ..., 44 | reason: Optional[str] = ..., 45 | ) -> None: ... 46 | -------------------------------------------------------------------------------- /discord-stubs/enums.pyi: -------------------------------------------------------------------------------- 1 | from enum import Enum as Enum 2 | from typing import Optional 3 | from typing_extensions import Literal 4 | 5 | # Technically, these enumerations do not inherit from enum.Enum, but because type checking 6 | # does something special for enum.Enum and discord.enums.Enum is a drop-in replacement for 7 | # enum.Enum, typings are using enum.Enum directly 8 | 9 | class ChannelType(Enum): 10 | text: int 11 | private: int 12 | voice: int 13 | group: int 14 | category: int 15 | news: int 16 | store: int 17 | stage_voice: int 18 | 19 | class MessageType(Enum): 20 | default: int 21 | recipient_add: int 22 | recipient_remove: int 23 | call: int 24 | channel_name_change: int 25 | channel_icon_change: int 26 | pins_add: int 27 | new_member: int 28 | premium_guild_subscription: int 29 | premium_guild_tier_1: int 30 | premium_guild_tier_2: int 31 | premium_guild_tier_3: int 32 | channel_follow_add: int 33 | guild_stream: int 34 | guild_discovery_disqualified: int 35 | guild_discovery_requalified: int 36 | guild_discovery_grace_period_initial_warning: int 37 | guild_discovery_grace_period_final_warning: int 38 | 39 | class VoiceRegion(Enum): 40 | us_west: str 41 | us_east: str 42 | us_south: str 43 | us_central: str 44 | eu_west: str 45 | eu_central: str 46 | singapore: str 47 | london: str 48 | sydney: str 49 | amsterdam: str 50 | frankfurt: str 51 | brazil: str 52 | hongkong: str 53 | russia: str 54 | japan: str 55 | southafrica: str 56 | south_korea: str 57 | india: str 58 | europe: str 59 | dubai: str 60 | vip_us_east: str 61 | vip_us_west: str 62 | vip_amsterdam: str 63 | 64 | class SpeakingState(Enum): 65 | none: int 66 | voice: int 67 | soundshare: int 68 | priority: int 69 | def __int__(self) -> int: ... 70 | 71 | class VerificationLevel(Enum): 72 | none: int 73 | low: int 74 | medium: int 75 | high: int 76 | table_flip: int 77 | extreme: int 78 | double_table_flip: int 79 | very_high: int 80 | 81 | class ContentFilter(Enum): 82 | disabled: int 83 | no_role: int 84 | all_members: int 85 | 86 | class UserContentFilter(Enum): 87 | disabled: int 88 | friends: int 89 | all_messages: int 90 | 91 | class FriendFlags(Enum): 92 | noone: int 93 | mutual_guilds: int 94 | mutual_friends: int 95 | guild_and_friends: int 96 | everyone: int 97 | 98 | class Theme(Enum): 99 | light: str 100 | dark: str 101 | 102 | class Status(Enum): 103 | online: str 104 | offline: str 105 | idle: str 106 | dnd: str 107 | do_not_disturb: str 108 | invisible: str 109 | 110 | class DefaultAvatar(Enum): 111 | blurple: int 112 | grey: int 113 | gray: int 114 | green: int 115 | orange: int 116 | red: int 117 | 118 | class RelationshipType(Enum): 119 | friend: int 120 | blocked: int 121 | incoming_request: int 122 | outgoing_request: int 123 | 124 | class NotificationLevel(Enum): 125 | all_messages: int 126 | only_mentions: int 127 | 128 | class AuditLogActionCategory(Enum): 129 | create: int 130 | delete: int 131 | update: int 132 | 133 | class AuditLogAction(Enum): 134 | guild_update: int 135 | channel_create: int 136 | channel_update: int 137 | channel_delete: int 138 | overwrite_create: int 139 | overwrite_update: int 140 | overwrite_delete: int 141 | kick: int 142 | member_prune: int 143 | ban: int 144 | unban: int 145 | member_update: int 146 | member_role_update: int 147 | member_move: int 148 | member_disconnect: int 149 | bot_add: int 150 | role_create: int 151 | role_update: int 152 | role_delete: int 153 | invite_create: int 154 | invite_update: int 155 | invite_delete: int 156 | webhook_create: int 157 | webhook_update: int 158 | webhook_delete: int 159 | emoji_create: int 160 | emoji_update: int 161 | emoji_delete: int 162 | message_delete: int 163 | message_bulk_delete: int 164 | message_pin: int 165 | message_unpin: int 166 | integration_create: int 167 | integration_update: int 168 | integration_delete: int 169 | @property 170 | def category(self) -> Optional[AuditLogActionCategory]: ... 171 | @property 172 | def target_type( 173 | self, 174 | ) -> Literal[ 175 | 'all', 176 | 'guild', 177 | 'channel', 178 | 'user', 179 | 'role', 180 | 'invite', 181 | 'webhook', 182 | 'emoji', 183 | 'message', 184 | 'integration', 185 | ]: ... 186 | 187 | class UserFlags(Enum): 188 | staff: int 189 | partner: int 190 | hypesquad: int 191 | bug_hunter: int 192 | mfa_sms: int 193 | premium_promo_dismissed: int 194 | hypesquad_bravery: int 195 | hypesquad_brilliance: int 196 | hypesquad_balance: int 197 | early_supporter: int 198 | team_user: int 199 | system: int 200 | has_unread_urgent_messages: int 201 | bug_hunter_level_2: int 202 | verified_bot: int 203 | verified_bot_developer: int 204 | 205 | class ActivityType(Enum): 206 | unknown: int 207 | playing: int 208 | streaming: int 209 | listening: int 210 | watching: int 211 | custom: int 212 | competing: int 213 | def __int__(self) -> int: ... 214 | 215 | class HypeSquadHouse(Enum): 216 | bravery: int 217 | brilliance: int 218 | balance: int 219 | 220 | class PremiumType(Enum): 221 | nitro_classic: int 222 | nitro: int 223 | 224 | class TeamMembershipState(Enum): 225 | invited: int 226 | accepted: int 227 | 228 | class WebhookType(Enum): 229 | incoming: int 230 | channel_follower: int 231 | 232 | class ExpireBehaviour(Enum): 233 | remove_role: int 234 | kick: int 235 | 236 | ExpireBehavior = ExpireBehaviour 237 | 238 | class StickerType(Enum): 239 | png: int 240 | apng: int 241 | lottie: int 242 | -------------------------------------------------------------------------------- /discord-stubs/errors.pyi: -------------------------------------------------------------------------------- 1 | from typing import Any, Dict, Optional, Union 2 | 3 | import aiohttp 4 | 5 | class DiscordException(Exception): ... 6 | class ClientException(DiscordException): ... 7 | class NoMoreItems(DiscordException): ... 8 | class GatewayNotFound(DiscordException): ... 9 | 10 | def flatten_error_dict(d: Dict[str, Any], key: str = ...) -> Dict[str, Any]: ... 11 | 12 | class HTTPException(DiscordException): 13 | response: aiohttp.ClientResponse 14 | text: str 15 | status: int 16 | code: int 17 | def __init__( 18 | self, response: aiohttp.ClientResponse, message: Union[str, Dict[str, Any]] 19 | ) -> None: ... 20 | 21 | class Forbidden(HTTPException): ... 22 | class NotFound(HTTPException): ... 23 | class DiscordServerError(HTTPException): ... 24 | class InvalidData(ClientException): ... 25 | class InvalidArgument(ClientException): ... 26 | class LoginFailure(ClientException): ... 27 | 28 | class ConnectionClosed(ClientException): 29 | code: Optional[int] 30 | reason: str 31 | shard_id: Optional[int] 32 | def __init__( 33 | self, 34 | socket: aiohttp.ClientWebSocketResponse, 35 | *, 36 | shard_id: Optional[int], 37 | code: Optional[int] = ..., 38 | ) -> None: ... 39 | 40 | class PrivilegedIntentsRequired(ClientException): 41 | shard_id: Optional[int] 42 | -------------------------------------------------------------------------------- /discord-stubs/ext/commands/__init__.pyi: -------------------------------------------------------------------------------- 1 | from .bot import AutoShardedBot as AutoShardedBot # noqa: F401 2 | from .bot import Bot as Bot # noqa: F401 3 | from .bot import when_mentioned as when_mentioned # noqa: F401 4 | from .bot import when_mentioned_or as when_mentioned_or # noqa: F401 5 | from .cog import * # noqa: F401 6 | from .context import Context as Context # noqa: F401 7 | from .converter import * # noqa: F401 8 | from .cooldowns import * # noqa: F401 9 | from .core import * # noqa: F401 10 | from .errors import * # noqa: F401 11 | from .help import * # noqa: F401 12 | -------------------------------------------------------------------------------- /discord-stubs/ext/commands/_types.pyi: -------------------------------------------------------------------------------- 1 | class _BaseCommand: ... 2 | -------------------------------------------------------------------------------- /discord-stubs/ext/commands/cog.pyi: -------------------------------------------------------------------------------- 1 | from typing import ( 2 | Any, 3 | Callable, 4 | Coroutine, 5 | Generic, 6 | Iterator, 7 | List, 8 | Optional, 9 | Tuple, 10 | TypeVar, 11 | Union, 12 | ) 13 | 14 | from .context import Context 15 | from .core import Command, Group 16 | 17 | _CT = TypeVar('_CT', bound=Context) 18 | _L = TypeVar('_L', bound=Callable[..., Coroutine[Any, Any, Any]]) 19 | 20 | class CogMeta(type): 21 | @classmethod 22 | def qualified_name(cls) -> str: ... 23 | 24 | class Cog(Generic[_CT], metaclass=CogMeta): 25 | __cog_commands__: Any 26 | def get_commands(self) -> List[Command[_CT]]: ... 27 | @property 28 | def qualified_name(self) -> str: ... 29 | @property 30 | def description(self) -> str: ... 31 | def walk_commands(self) -> Iterator[Union[Command[_CT], Group[_CT]]]: ... 32 | def get_listeners(self) -> List[Tuple[str, Callable[..., Any]]]: ... 33 | @classmethod 34 | def listener(cls, name: Optional[str] = ...) -> Callable[[_L], _L]: ... 35 | def has_error_handler(self) -> bool: ... 36 | def cog_unload(self) -> None: ... 37 | def bot_check_once(self, ctx: _CT) -> Union[bool, Coroutine[Any, Any, bool]]: ... 38 | def bot_check(self, ctx: _CT) -> Union[bool, Coroutine[Any, Any, bool]]: ... 39 | def cog_check(self, ctx: _CT) -> Union[bool, Coroutine[Any, Any, bool]]: ... 40 | async def cog_command_error(self, ctx: _CT, error: Any) -> None: ... 41 | async def cog_before_invoke(self, ctx: _CT) -> None: ... 42 | async def cog_after_invoke(self, ctx: _CT) -> None: ... 43 | -------------------------------------------------------------------------------- /discord-stubs/ext/commands/context.pyi: -------------------------------------------------------------------------------- 1 | from typing import Any, Dict, List, Optional, TypeVar, Union 2 | 3 | import discord 4 | 5 | from .bot import Bot 6 | from .cog import Cog 7 | from .core import Command 8 | 9 | _C = TypeVar('_C', bound=Context) 10 | 11 | class Context(discord.abc.Messageable): 12 | message: discord.Message 13 | bot: Bot[Any] 14 | args: List[Any] 15 | kwargs: Dict[str, Any] 16 | prefix: str 17 | command: Command[Any] 18 | invoked_with: Optional[str] 19 | invoked_parents: List[str] 20 | invoked_subcommand: Optional[Command[Any]] 21 | subcommand_passed: Optional[str] 22 | command_failed: bool 23 | async def invoke( 24 | self: _C, __command: Command[_C], *args: Any, **kwargs: Any 25 | ) -> Any: ... 26 | async def reinvoke( 27 | self, *, call_hooks: bool = ..., restart: bool = ... 28 | ) -> None: ... 29 | @property 30 | def valid(self) -> bool: ... 31 | @property 32 | def cog(self: _C) -> Optional[Cog[_C]]: ... 33 | @discord.utils.cached_property 34 | def guild(self) -> Optional[discord.Guild]: ... 35 | @discord.utils.cached_property 36 | def channel( 37 | self, 38 | ) -> Union[discord.TextChannel, discord.DMChannel, discord.GroupChannel]: ... 39 | @discord.utils.cached_property 40 | def author(self) -> Union[discord.User, discord.Member]: ... 41 | @discord.utils.cached_property 42 | def me(self) -> Union[discord.Member, discord.ClientUser]: ... 43 | @property 44 | def voice_client(self) -> Optional[discord.VoiceProtocol]: ... 45 | async def send_help( 46 | self: _C, __entity: Optional[Union[Command[_C], Cog[_C], str]] 47 | ) -> Any: ... 48 | async def reply( 49 | self, 50 | content: Optional[object] = ..., 51 | *, 52 | tts: bool = ..., 53 | embed: Optional[discord.Embed] = ..., 54 | file: Optional[discord.File] = ..., 55 | files: Optional[List[discord.File]] = ..., 56 | delete_after: Optional[float] = ..., 57 | nonce: Optional[int] = ..., 58 | allowed_mentions: Optional[discord.AllowedMentions] = ..., 59 | reference: Optional[Union[discord.Message, discord.MessageReference]] = ..., 60 | mention_author: Optional[bool] = ..., 61 | ) -> discord.Message: ... 62 | -------------------------------------------------------------------------------- /discord-stubs/ext/commands/converter.pyi: -------------------------------------------------------------------------------- 1 | from typing import Any, ClassVar, List, Optional, Pattern 2 | 3 | import discord 4 | 5 | from .bot import Bot 6 | from .context import Context 7 | 8 | class Converter: 9 | async def convert(self, ctx: Context, argument: str) -> Any: ... 10 | 11 | class IDConverter(Converter): ... 12 | 13 | class MemberConverter(IDConverter): 14 | async def query_member_named( 15 | self, guild: discord.Guild, argument: str 16 | ) -> Optional[discord.Member]: ... 17 | async def query_member_by_id( 18 | self, bot: Bot[Context], guild: discord.Guild, user_id: int 19 | ) -> Optional[discord.Member]: ... 20 | async def convert(self, ctx: Context, argument: str) -> discord.Member: ... 21 | 22 | class UserConverter(IDConverter): 23 | async def convert(self, ctx: Context, argument: str) -> discord.User: ... 24 | 25 | class PartialMessageConverter(Converter): 26 | async def convert(self, ctx: Context, argument: str) -> discord.PartialMessage: ... 27 | 28 | class MessageConverter(PartialMessageConverter): 29 | async def convert( # type: ignore[override] 30 | self, ctx: Context, argument: str 31 | ) -> discord.Message: ... 32 | 33 | class TextChannelConverter(IDConverter): 34 | async def convert(self, ctx: Context, argument: str) -> discord.TextChannel: ... 35 | 36 | class VoiceChannelConverter(IDConverter): 37 | async def convert(self, ctx: Context, argument: str) -> discord.VoiceChannel: ... 38 | 39 | class StageChannelConverter(IDConverter): 40 | async def convert(self, ctx: Context, argument: str) -> discord.StageChannel: ... 41 | 42 | class CategoryChannelConverter(IDConverter): 43 | async def convert(self, ctx: Context, argument: str) -> discord.CategoryChannel: ... 44 | 45 | class StoreChannelConverter(IDConverter): 46 | async def convert(self, ctx: Context, argument: str) -> discord.StoreChannel: ... 47 | 48 | class ColourConverter(Converter): 49 | RGB_REGEX: ClassVar[Pattern[str]] 50 | def parse_hex_number(self, argument: str) -> discord.Colour: ... 51 | def parse_rgb_number(self, argument: str, number: str) -> int: ... 52 | def parse_rgb( 53 | self, argument: str, *, regex: Pattern[str] = ... 54 | ) -> discord.Colour: ... 55 | async def convert(self, ctx: Context, argument: str) -> discord.Colour: ... 56 | 57 | ColorConverter = ColourConverter 58 | 59 | class RoleConverter(IDConverter): 60 | async def convert(self, ctx: Context, argument: str) -> discord.Role: ... 61 | 62 | class GameConverter(Converter): 63 | async def convert(self, ctx: Context, argument: str) -> discord.Game: ... 64 | 65 | class InviteConverter(Converter): 66 | async def convert(self, ctx: Context, argument: str) -> discord.Invite: ... 67 | 68 | class GuildConverter(IDConverter): 69 | async def convert(self, ctx: Context, argument: str) -> discord.Guild: ... 70 | 71 | class EmojiConverter(IDConverter): 72 | async def convert(self, ctx: Context, argument: str) -> discord.Emoji: ... 73 | 74 | class PartialEmojiConverter(Converter): 75 | async def convert(self, ctx: Context, argument: str) -> discord.PartialEmoji: ... 76 | 77 | class clean_content(Converter): 78 | def __init__( 79 | self, 80 | *, 81 | fix_channel_mentions: bool = ..., 82 | use_nicknames: bool = ..., 83 | escape_markdown: bool = ..., 84 | remove_markdown: bool = ..., 85 | ) -> None: ... 86 | async def convert(self, ctx: Context, argument: str) -> str: ... 87 | 88 | Greedy = List 89 | -------------------------------------------------------------------------------- /discord-stubs/ext/commands/cooldowns.pyi: -------------------------------------------------------------------------------- 1 | from typing import Optional, Tuple, Type, TypeVar, Union 2 | from typing_extensions import Protocol 3 | 4 | from discord.enums import Enum 5 | from discord.message import Message 6 | 7 | _CM = TypeVar('_CM', bound=CooldownMapping) 8 | _MC = TypeVar('_MC', bound=MaxConcurrency) 9 | 10 | _BucketKey = Union[int, Tuple[Optional[int], int]] 11 | _CooldownType = Union[BucketType, _CooldownCallable] 12 | 13 | class _CooldownCallable(Protocol): 14 | def __call__(self, __msg: Message) -> Optional[_BucketKey]: ... 15 | 16 | class BucketType(Enum): 17 | default: int 18 | user: int 19 | guild: int 20 | channel: int 21 | member: int 22 | category: int 23 | role: int 24 | def get_key(self, msg: Message) -> Optional[_BucketKey]: ... 25 | def __call__(self, msg: Message) -> Optional[_BucketKey]: ... 26 | 27 | class Cooldown: 28 | rate: int 29 | per: float 30 | type: _CooldownType 31 | def __init__(self, rate: int, per: float, type: _CooldownType) -> None: ... 32 | def get_tokens(self, current: Optional[int] = ...) -> int: ... 33 | def get_retry_after(self, current: Optional[float] = ...) -> float: ... 34 | def update_rate_limit(self, current: Optional[float] = ...) -> Optional[float]: ... 35 | def reset(self) -> None: ... 36 | def copy(self) -> Cooldown: ... 37 | 38 | class CooldownMapping: 39 | def __init__(self, original: Cooldown) -> None: ... 40 | def copy(self) -> CooldownMapping: ... 41 | @property 42 | def valid(self) -> bool: ... 43 | @classmethod 44 | def from_cooldown( 45 | cls: Type[_CM], 46 | rate: int, 47 | per: float, 48 | type: _CooldownType, 49 | ) -> _CM: ... 50 | def get_bucket( 51 | self, message: Message, current: Optional[float] = ... 52 | ) -> Cooldown: ... 53 | def update_rate_limit( 54 | self, message: Message, current: Optional[float] = ... 55 | ) -> Optional[float]: ... 56 | 57 | class MaxConcurrency: 58 | number: int 59 | per: _CooldownType 60 | wait: bool 61 | def __init__(self, number: int, *, per: _CooldownType, wait: bool) -> None: ... 62 | def copy(self: _MC) -> _MC: ... 63 | def get_key(self, message: Message) -> Union[str, int]: ... 64 | async def acquire(self, message: Message) -> None: ... 65 | async def release(self, message: Message) -> None: ... 66 | -------------------------------------------------------------------------------- /discord-stubs/ext/commands/core.pyi: -------------------------------------------------------------------------------- 1 | from inspect import Parameter 2 | from typing import ( 3 | Any, 4 | Callable, 5 | Coroutine, 6 | Dict, 7 | Generic, 8 | Iterator, 9 | List, 10 | Mapping, 11 | Optional, 12 | Set, 13 | Tuple, 14 | Type, 15 | TypeVar, 16 | Union, 17 | overload, 18 | type_check_only, 19 | ) 20 | from typing_extensions import Protocol 21 | 22 | from ._types import _BaseCommand 23 | from .cog import Cog 24 | from .context import Context 25 | from .cooldowns import Cooldown, CooldownMapping, _CooldownType 26 | 27 | _CoroType = Callable[..., Coroutine[Any, Any, Any]] 28 | 29 | _CT = TypeVar('_CT', bound=Context) 30 | _C = TypeVar('_C', bound=_CoroType) 31 | _CMD = TypeVar('_CMD', bound=Command[Any]) 32 | _F = TypeVar('_F', bound=Union[_CoroType, Command[Any]]) 33 | _T_contra = TypeVar('_T_contra', contravariant=True) 34 | 35 | @type_check_only 36 | class _CheckPredicate(Protocol[_T_contra]): 37 | def __call__(self, __ctx: _T_contra) -> Union[bool, Coroutine[Any, Any, bool]]: ... 38 | 39 | @type_check_only 40 | class _CheckDecorator(Protocol): 41 | def __call__(self, __func: _F) -> _F: ... 42 | 43 | @type_check_only 44 | class _InvokeCallback(Protocol[_T_contra]): 45 | async def __call__(self, __ctx: _T_contra) -> None: ... 46 | 47 | class Command(_BaseCommand, Generic[_CT]): 48 | name: str 49 | callback: _CoroType 50 | help: Optional[str] 51 | brief: Optional[str] 52 | usage: Optional[str] 53 | aliases: Union[List[str], Tuple[str, ...]] 54 | enabled: bool 55 | parent: Optional[Command[_CT]] 56 | checks: List[_CheckPredicate[_CT]] 57 | description: str 58 | hidden: bool 59 | rest_is_raw: bool 60 | ignore_extra: bool 61 | require_var_positional: bool 62 | cooldown_after_parsing: bool 63 | params: Mapping[str, Parameter] 64 | _buckets: CooldownMapping 65 | cog: Optional[Cog[_CT]] 66 | def __init__( 67 | self, 68 | func: _CoroType, 69 | *, 70 | name: str = ..., 71 | enabled: bool = ..., 72 | help: Optional[str] = ..., 73 | brief: Optional[str] = ..., 74 | usage: Optional[str] = ..., 75 | aliases: Union[List[str], Tuple[str, ...]] = ..., 76 | description: str = ..., 77 | hidden: bool = ..., 78 | rest_is_raw: bool = ..., 79 | ignore_extra: bool = ..., 80 | require_var_positional: bool = ..., 81 | cooldown_after_parsing: bool = ..., 82 | checks: List[_CheckPredicate[_CT]] = ..., 83 | cooldown: Cooldown = ..., 84 | parent: _BaseCommand = ..., 85 | cog: Optional[Cog[_CT]] = ..., 86 | ) -> None: ... 87 | def add_check(self, func: _CheckPredicate[_CT]) -> None: ... 88 | def remove_check(self, func: _CheckPredicate[_CT]) -> None: ... 89 | def update( 90 | self, 91 | *, 92 | name: str = ..., 93 | enabled: bool = ..., 94 | help: Optional[str] = ..., 95 | brief: Optional[str] = ..., 96 | usage: Optional[str] = ..., 97 | aliases: Union[List[str], Tuple[str, ...]] = ..., 98 | description: str = ..., 99 | hidden: bool = ..., 100 | rest_is_raw: bool = ..., 101 | ignore_extra: bool = ..., 102 | require_var_positional: bool = ..., 103 | cooldown_after_parsing: bool = ..., 104 | ) -> None: ... 105 | async def __call__(self, *args: Any, **kwargs: Any) -> Any: ... 106 | def copy(self: _CMD) -> _CMD: ... 107 | async def dispatch_error(self, ctx: _CT, error: Exception) -> None: ... 108 | async def do_conversion( 109 | self, ctx: _CT, converter: Any, argument: str, param: Parameter 110 | ) -> Any: ... 111 | async def transform(self, ctx: _CT, param: Parameter) -> Any: ... 112 | @property 113 | def clean_params(self) -> Mapping[str, Parameter]: ... 114 | @property 115 | def full_parent_name(self) -> str: ... 116 | @property 117 | def parents(self) -> List[Command[_CT]]: ... 118 | @property 119 | def root_parent(self) -> Optional[Command[_CT]]: ... 120 | @property 121 | def qualified_name(self) -> str: ... 122 | async def call_before_hooks(self, ctx: _CT) -> None: ... 123 | async def call_after_hooks(self, ctx: _CT) -> None: ... 124 | async def prepare(self, ctx: _CT) -> None: ... 125 | def is_on_cooldown(self, ctx: _CT) -> bool: ... 126 | def reset_cooldown(self, ctx: _CT) -> None: ... 127 | def get_cooldown_retry_after(self, ctx: _CT) -> float: ... 128 | async def invoke(self, ctx: _CT) -> None: ... 129 | async def reinvoke(self, ctx: _CT, *, call_hooks: bool = ...) -> None: ... 130 | def error(self, coro: _C) -> _C: ... 131 | def has_error_handler(self) -> bool: ... 132 | def before_invoke(self, coro: _C) -> _C: ... 133 | def after_invoke(self, coro: _C) -> _C: ... 134 | @property 135 | def cog_name(self) -> Optional[str]: ... 136 | @property 137 | def short_doc(self) -> str: ... 138 | @property 139 | def signature(self) -> str: ... 140 | async def can_run(self, ctx: _CT) -> bool: ... 141 | 142 | class GroupMixin(Generic[_CT]): 143 | all_commands: Dict[str, Command[_CT]] 144 | case_insensitive: bool 145 | @property 146 | def commands(self) -> Set[Command[_CT]]: ... 147 | def recursively_remove_all_commands(self) -> None: ... 148 | def add_command(self, command: Command[_CT]) -> None: ... 149 | def remove_command(self, name: str) -> Optional[Command[_CT]]: ... 150 | def walk_commands(self) -> Iterator[Union[Command[_CT], Group[_CT]]]: ... 151 | def get_command(self, name: str) -> Optional[Command[_CT]]: ... 152 | def command( 153 | self, 154 | name: Optional[str] = ..., 155 | *, 156 | enabled: bool = ..., 157 | help: Optional[str] = ..., 158 | brief: Optional[str] = ..., 159 | usage: Optional[str] = ..., 160 | aliases: Union[List[str], Tuple[str, ...]] = ..., 161 | description: str = ..., 162 | hidden: bool = ..., 163 | rest_is_raw: bool = ..., 164 | ignore_extra: bool = ..., 165 | require_var_positional: bool = ..., 166 | cooldown_after_parsing: bool = ..., 167 | ) -> Callable[[_CoroType], Command[_CT]]: ... 168 | def group( 169 | self, 170 | name: str = ..., 171 | *, 172 | enabled: bool = ..., 173 | help: Optional[str] = ..., 174 | brief: Optional[str] = ..., 175 | usage: Optional[str] = ..., 176 | aliases: Union[List[str], Tuple[str, ...]] = ..., 177 | description: str = ..., 178 | hidden: bool = ..., 179 | rest_is_raw: bool = ..., 180 | ignore_extra: bool = ..., 181 | cooldown_after_parsing: bool = ..., 182 | invoke_without_command: bool = ..., 183 | case_insensitive: bool = ..., 184 | ) -> Callable[[_CoroType], Group[_CT]]: ... 185 | 186 | _G = TypeVar('_G', bound=Group[Any]) 187 | 188 | class Group(GroupMixin[_CT], Command[_CT]): 189 | invoke_without_command: bool 190 | def __init__( 191 | self, 192 | *, 193 | name: str = ..., 194 | enabled: bool = ..., 195 | help: Optional[str] = ..., 196 | brief: Optional[str] = ..., 197 | usage: Optional[str] = ..., 198 | aliases: Union[List[str], Tuple[str, ...]] = ..., 199 | description: str = ..., 200 | hidden: bool = ..., 201 | rest_is_raw: bool = ..., 202 | ignore_extra: bool = ..., 203 | cooldown_after_parsing: bool = ..., 204 | invoke_without_command: bool = ..., 205 | case_insensitive: bool = ..., 206 | ) -> None: ... 207 | def copy(self: _G) -> _G: ... 208 | 209 | @overload 210 | def command( 211 | name: Optional[str] = ..., 212 | *, 213 | enabled: bool = ..., 214 | help: Optional[str] = ..., 215 | brief: Optional[str] = ..., 216 | usage: Optional[str] = ..., 217 | aliases: Union[List[str], Tuple[str, ...]] = ..., 218 | description: str = ..., 219 | hidden: bool = ..., 220 | rest_is_raw: bool = ..., 221 | ignore_extra: bool = ..., 222 | require_var_positional: bool = ..., 223 | cooldown_after_parsing: bool = ..., 224 | ) -> Callable[[_CoroType], Command[Any]]: ... 225 | @overload 226 | def command( 227 | name: Optional[str] = ..., 228 | cls: Optional[Type[Command[_CT]]] = ..., 229 | *, 230 | enabled: bool = ..., 231 | help: Optional[str] = ..., 232 | brief: Optional[str] = ..., 233 | usage: Optional[str] = ..., 234 | aliases: Union[List[str], Tuple[str, ...]] = ..., 235 | description: str = ..., 236 | hidden: bool = ..., 237 | rest_is_raw: bool = ..., 238 | ignore_extra: bool = ..., 239 | require_var_positional: bool = ..., 240 | cooldown_after_parsing: bool = ..., 241 | ) -> Callable[[_CoroType], Command[_CT]]: ... 242 | @overload 243 | def group( 244 | name: str = ..., 245 | *, 246 | enabled: bool = ..., 247 | help: Optional[str] = ..., 248 | brief: Optional[str] = ..., 249 | usage: Optional[str] = ..., 250 | aliases: Union[List[str], Tuple[str, ...]] = ..., 251 | description: str = ..., 252 | hidden: bool = ..., 253 | rest_is_raw: bool = ..., 254 | ignore_extra: bool = ..., 255 | cooldown_after_parsing: bool = ..., 256 | invoke_without_command: bool = ..., 257 | case_insensitive: bool = ..., 258 | ) -> Callable[[_CoroType], Group[Any]]: ... 259 | @overload 260 | def group( 261 | name: str = ..., 262 | *, 263 | cls: Optional[Type[Group[_CT]]] = ..., 264 | enabled: bool = ..., 265 | help: Optional[str] = ..., 266 | brief: Optional[str] = ..., 267 | usage: Optional[str] = ..., 268 | aliases: Union[List[str], Tuple[str, ...]] = ..., 269 | description: str = ..., 270 | hidden: bool = ..., 271 | rest_is_raw: bool = ..., 272 | ignore_extra: bool = ..., 273 | cooldown_after_parsing: bool = ..., 274 | invoke_without_command: bool = ..., 275 | case_insensitive: bool = ..., 276 | ) -> Callable[[_CoroType], Group[Any]]: ... 277 | def check(predicate: _CheckPredicate[_CT]) -> _CheckDecorator: ... 278 | def check_any(*checks: _CheckPredicate[_CT]) -> _CheckDecorator: ... 279 | def has_role(item: Union[int, str]) -> _CheckDecorator: ... 280 | def has_any_role(*items: Union[int, str]) -> _CheckDecorator: ... 281 | def bot_has_role(item: Union[int, str]) -> _CheckDecorator: ... 282 | def bot_has_any_role(*items: Union[int, str]) -> _CheckDecorator: ... 283 | def has_permissions(**perms: bool) -> _CheckDecorator: ... 284 | def bot_has_permissions(**perms: bool) -> _CheckDecorator: ... 285 | def has_guild_permissions(**perms: bool) -> _CheckDecorator: ... 286 | def bot_has_guild_permissions(**perms: bool) -> _CheckDecorator: ... 287 | def dm_only() -> _CheckDecorator: ... 288 | def guild_only() -> _CheckDecorator: ... 289 | def is_owner() -> _CheckDecorator: ... 290 | def is_nsfw() -> _CheckDecorator: ... 291 | def cooldown(rate: int, per: float, type: _CooldownType = ...) -> _CheckDecorator: ... 292 | def max_concurrency( 293 | number: int, per: _CooldownType = ..., *, wait: bool = ... 294 | ) -> _CheckDecorator: ... 295 | def before_invoke(coro: _InvokeCallback[_CT]) -> _CheckDecorator: ... 296 | def after_invoke(coro: _InvokeCallback[_CT]) -> _CheckDecorator: ... 297 | -------------------------------------------------------------------------------- /discord-stubs/ext/commands/errors.pyi: -------------------------------------------------------------------------------- 1 | from inspect import Parameter 2 | from typing import Any, List, Optional, Tuple, Union 3 | 4 | from discord import ( 5 | CategoryChannel, 6 | DMChannel, 7 | GroupChannel, 8 | Permissions, 9 | StoreChannel, 10 | TextChannel, 11 | VoiceChannel, 12 | abc, 13 | ) 14 | from discord.errors import ClientException, DiscordException 15 | 16 | from .cooldowns import BucketType, Cooldown 17 | 18 | class CommandError(DiscordException): 19 | def __init__(self, message: Optional[str] = ..., *args: Any) -> None: ... 20 | 21 | class ConversionError(DiscordException): 22 | converter: Any 23 | original: Exception 24 | def __init__(self, converter: Any, original: Exception) -> None: ... 25 | 26 | class UserInputError(CommandError): ... 27 | class CommandNotFound(CommandError): ... 28 | 29 | class MissingRequiredArgument(UserInputError): 30 | param: Parameter 31 | def __init__(self, param: Parameter) -> None: ... 32 | 33 | class TooManyArguments(UserInputError): ... 34 | class BadArgument(UserInputError): ... 35 | class CheckFailure(CommandError): ... 36 | class CheckAnyFailure(CheckFailure): ... 37 | class PrivateMessageOnly(CheckFailure): ... 38 | 39 | class NoPrivateMessage(CheckFailure): 40 | def __init__(self, message: Optional[str] = ...) -> None: ... 41 | 42 | class NotOwner(CheckFailure): ... 43 | 44 | class MemberNotFound(BadArgument): 45 | argument: str 46 | 47 | class UserNotFound(BadArgument): 48 | argument: str 49 | 50 | class GuildNotFound(BadArgument): 51 | argument: str 52 | 53 | class MessageNotFound(BadArgument): 54 | argument: str 55 | 56 | class ChannelNotReadable(BadArgument): 57 | argument: Union[ 58 | TextChannel, 59 | VoiceChannel, 60 | CategoryChannel, 61 | StoreChannel, 62 | DMChannel, 63 | GroupChannel, 64 | ] 65 | 66 | class ChannelNotFound(BadArgument): 67 | argument: str 68 | 69 | class BadColourArgument(BadArgument): 70 | argument: str 71 | 72 | BadColorArgument = BadColourArgument 73 | 74 | class RoleNotFound(BadArgument): 75 | argument: str 76 | 77 | class BadInviteArgument(BadArgument): ... 78 | 79 | class EmojiNotFound(BadArgument): 80 | argument: str 81 | 82 | class PartialEmojiConversionFailure(BadArgument): 83 | argument: str 84 | 85 | class BadBoolArgument(BadArgument): 86 | argument: str 87 | 88 | class DisabledCommand(CommandError): ... 89 | 90 | class CommandInvokeError(CommandError): 91 | original: Exception 92 | def __init__(self, e: Exception) -> None: ... 93 | 94 | class CommandOnCooldown(CommandError): 95 | cooldown: Cooldown 96 | retry_after: float 97 | def __init__(self, cooldown: Cooldown, retry_after: float) -> None: ... 98 | 99 | class MaxConcurrencyReached(CommandError): 100 | number: int 101 | per: BucketType 102 | def __init__(self, number: int, per: BucketType) -> None: ... 103 | 104 | class MissingRole(CheckFailure): 105 | missing_role: Union[str, int] 106 | def __init__(self, missing_role: Union[str, int]) -> None: ... 107 | 108 | class BotMissingRole(CheckFailure): 109 | missing_role: Union[str, int] 110 | def __init__(self, missing_role: Union[str, int]) -> None: ... 111 | 112 | class MissingAnyRole(CheckFailure): 113 | missing_roles: List[Union[str, int]] 114 | def __init__(self, missing_roles: List[Union[str, int]]) -> None: ... 115 | 116 | class BotMissingAnyRole(CheckFailure): 117 | missing_roles: List[Union[str, int]] 118 | def __init__(self, missing_roles: List[Union[str, int]]) -> None: ... 119 | 120 | class NSFWChannelRequired(CheckFailure): 121 | channel: abc.GuildChannel 122 | def __init__(self, channel: abc.GuildChannel) -> None: ... 123 | 124 | class MissingPermissions(CheckFailure): 125 | missing_perms: List[Permissions] 126 | def __init__(self, missing_perms: List[Permissions], *args: Any) -> None: ... 127 | 128 | class BotMissingPermissions(CheckFailure): 129 | missing_perms: List[Permissions] 130 | def __init__(self, missing_perms: List[Permissions], *args: Any) -> None: ... 131 | 132 | class BadUnionArgument(UserInputError): 133 | param: Parameter 134 | converters: Tuple[Any, ...] 135 | errors: List[CommandError] 136 | def __init__( 137 | self, param: Parameter, converters: Tuple[Any, ...], errors: List[CommandError] 138 | ) -> None: ... 139 | 140 | class ArgumentParsingError(UserInputError): ... 141 | 142 | class UnexpectedQuoteError(ArgumentParsingError): 143 | quote: str 144 | def __init__(self, quote: str) -> None: ... 145 | 146 | class InvalidEndOfQuotedStringError(ArgumentParsingError): 147 | char: str 148 | def __init__(self, char: str) -> None: ... 149 | 150 | class ExpectedClosingQuoteError(ArgumentParsingError): 151 | close_quote: str 152 | def __init__(self, close_quote: str) -> None: ... 153 | 154 | class ExtensionError(DiscordException): 155 | name: str 156 | 157 | class ExtensionAlreadyLoaded(ExtensionError): 158 | def __init__(self, name: str) -> None: ... 159 | 160 | class ExtensionNotLoaded(ExtensionError): 161 | def __init__(self, name: str) -> None: ... 162 | 163 | class NoEntryPointError(ExtensionError): 164 | def __init__(self, name: str) -> None: ... 165 | 166 | class ExtensionFailed(ExtensionError): 167 | original: Exception 168 | def __init__(self, name: str, original: Exception) -> None: ... 169 | 170 | class ExtensionNotFound(ExtensionError): 171 | original: ImportError 172 | def __init__(self, name: str, original: Optional[ImportError] = ...) -> None: ... 173 | 174 | class CommandRegistrationError(ClientException): 175 | alias_conflict: bool 176 | def __init__(self, name: str, *, alias_conflict: bool = ...) -> None: ... 177 | -------------------------------------------------------------------------------- /discord-stubs/ext/commands/help.pyi: -------------------------------------------------------------------------------- 1 | from inspect import Parameter 2 | from typing import ( 3 | Any, 4 | Awaitable, 5 | Callable, 6 | ClassVar, 7 | Dict, 8 | Generic, 9 | Iterable, 10 | List, 11 | Mapping, 12 | Optional, 13 | Pattern, 14 | Sequence, 15 | TypeVar, 16 | Union, 17 | type_check_only, 18 | ) 19 | from typing_extensions import Protocol, TypedDict 20 | 21 | import discord 22 | 23 | from .cog import Cog 24 | from .context import Context 25 | from .cooldowns import Cooldown 26 | from .core import Command, Group, _CheckPredicate 27 | from .errors import CommandError 28 | 29 | _T = TypeVar('_T') 30 | _MaybeAwaitable = Union[Awaitable[_T], _T] 31 | _CT = TypeVar('_CT', bound=Context) 32 | _HC = TypeVar('_HC', bound=HelpCommand[Any]) 33 | 34 | @type_check_only 35 | class _CommandAttrs(TypedDict, total=False): 36 | name: str 37 | enabled: bool 38 | help: Optional[str] 39 | brief: Optional[str] 40 | usage: Optional[str] 41 | aliases: List[str] 42 | description: str 43 | hidden: bool 44 | rest_is_raw: bool 45 | ignore_extra: bool 46 | cooldown: Cooldown 47 | parent: Command[Context] 48 | checks: List[_CheckPredicate[Any]] 49 | 50 | @type_check_only 51 | class _PaginatorProtocol(Protocol): 52 | def clear(self) -> None: ... 53 | def add_line(self, line: str = ..., *, empty: bool = ...) -> None: ... 54 | def close_page(self) -> None: ... 55 | def __len__(self) -> int: ... 56 | @property 57 | def pages(self) -> List[str]: ... 58 | 59 | class Paginator: 60 | prefix: Optional[str] 61 | suffix: Optional[str] 62 | max_size: int 63 | linesep: str 64 | def __init__( 65 | self, 66 | prefix: Optional[str] = ..., 67 | suffix: Optional[str] = ..., 68 | max_size: int = ..., 69 | linesep: str = ..., 70 | ) -> None: ... 71 | def clear(self) -> None: ... 72 | def add_line(self, line: str = ..., *, empty: bool = ...) -> None: ... 73 | def close_page(self) -> None: ... 74 | def __len__(self) -> int: ... 75 | @property 76 | def pages(self) -> List[str]: ... 77 | 78 | class _HelpCommandImpl(Command[_CT]): 79 | async def prepare(self, ctx: _CT) -> None: ... 80 | @property 81 | def clean_params(self) -> Mapping[str, Parameter]: ... 82 | 83 | class HelpCommand(Generic[_CT]): 84 | context: Optional[_CT] 85 | show_hidden: bool 86 | verify_checks: Optional[bool] 87 | command_attrs: _CommandAttrs 88 | cog: Optional[Cog[_CT]] 89 | 90 | MENTION_TRANSFORMS: ClassVar[Dict[str, str]] 91 | MENTION_PATTERN: ClassVar[Pattern[str]] 92 | def __init__( 93 | self, 94 | *, 95 | show_hidden: bool = ..., 96 | verify_checks: Optional[bool] = ..., 97 | command_attrs: _CommandAttrs = ..., 98 | ) -> None: ... 99 | def copy(self: _HC) -> _HC: ... 100 | def add_check(self, func: _CheckPredicate[_CT]) -> None: ... 101 | def remove_check(self, func: _CheckPredicate[_CT]) -> None: ... 102 | def get_bot_mapping(self) -> Dict[Optional[Cog[_CT]], List[Command[_CT]]]: ... 103 | @property 104 | def clean_prefix(self) -> str: ... 105 | @property 106 | def invoked_with(self) -> str: ... 107 | def get_command_signature(self, command: Command[_CT]) -> str: ... 108 | def remove_mentions(self, string: str) -> str: ... 109 | def command_not_found(self, string: str) -> _MaybeAwaitable[str]: ... 110 | def subcommand_not_found( 111 | self, command: Command[_CT], string: str 112 | ) -> _MaybeAwaitable[str]: ... 113 | async def filter_commands( 114 | self, 115 | commands: Iterable[Command[_CT]], 116 | *, 117 | sort: bool = ..., 118 | key: Optional[Callable[[Command[_CT]], Any]] = ..., 119 | ) -> List[Command[_CT]]: ... 120 | def get_max_size(self, commands: Sequence[Command[_CT]]) -> int: ... 121 | def get_destination( 122 | self, 123 | ) -> Union[discord.TextChannel, discord.DMChannel, discord.GroupChannel]: ... 124 | async def send_error_message(self, error: str) -> None: ... 125 | async def on_help_command_error(self, ctx: _CT, error: CommandError) -> None: ... 126 | async def send_bot_help( 127 | self, mapping: Mapping[Optional[Cog[_CT]], List[Command[_CT]]] 128 | ) -> Any: ... 129 | async def send_cog_help(self, cog: Cog[_CT]) -> Any: ... 130 | async def send_group_help(self, group: Group[_CT]) -> Any: ... 131 | async def send_command_help(self, command: Command[_CT]) -> Any: ... 132 | async def prepare_help_command( 133 | self, ctx: _CT, command: Optional[str] = ... 134 | ) -> None: ... 135 | async def command_callback( 136 | self, ctx: _CT, *, command: Optional[str] = ... 137 | ) -> Any: ... 138 | 139 | class DefaultHelpCommand(HelpCommand[_CT]): 140 | width: int 141 | sort_commands: bool 142 | indent: int 143 | commands_heading: str 144 | no_category: str 145 | paginator: _PaginatorProtocol 146 | def __init__( 147 | self, 148 | *, 149 | show_hidden: bool = ..., 150 | verify_checks: bool = ..., 151 | command_attrs: _CommandAttrs = ..., 152 | width: int = ..., 153 | indent: int = ..., 154 | sort_commands: bool = ..., 155 | dm_help: Optional[bool] = ..., 156 | dm_help_threshold: Optional[int] = ..., 157 | commands_heading: str = ..., 158 | no_category: str = ..., 159 | paginator: Optional[_PaginatorProtocol] = ..., 160 | ) -> None: ... 161 | def shorten_text(self, text: str) -> str: ... 162 | def get_ending_note(self) -> str: ... 163 | def add_indented_commands( 164 | self, 165 | commands: Sequence[Command[_CT]], 166 | *, 167 | heading: str, 168 | max_size: Optional[int] = ..., 169 | ) -> None: ... 170 | async def send_pages(self) -> None: ... 171 | def add_command_formatting(self, command: Command[_CT]) -> None: ... 172 | async def prepare_help_command(self, ctx: _CT, command: Optional[str]) -> None: ... # type: ignore[override] 173 | async def send_bot_help( 174 | self, mapping: Mapping[Optional[Cog[_CT]], List[Command[_CT]]] 175 | ) -> None: ... 176 | async def send_command_help(self, command: Command[_CT]) -> None: ... 177 | async def send_group_help(self, group: Group[_CT]) -> None: ... 178 | async def send_cog_help(self, cog: Cog[_CT]) -> None: ... 179 | 180 | class MinimalHelpCommand(HelpCommand[_CT]): 181 | sort_commands: bool 182 | commands_heading: str 183 | aliases_heading: str 184 | no_category: str 185 | paginator: _PaginatorProtocol 186 | def __init__( 187 | self, 188 | *, 189 | show_hidden: bool = ..., 190 | verify_checks: bool = ..., 191 | command_attrs: _CommandAttrs = ..., 192 | sort_commands: bool = ..., 193 | commands_heading: str = ..., 194 | dm_help: Optional[bool] = ..., 195 | dm_help_threshold: Optional[int] = ..., 196 | aliases_heading: str = ..., 197 | no_category: str = ..., 198 | paginator: Optional[_PaginatorProtocol] = ..., 199 | ) -> None: ... 200 | async def send_pages(self) -> None: ... 201 | def get_opening_note(self) -> str: ... 202 | def get_command_signature(self, command: Command[_CT]) -> str: ... 203 | def get_ending_note(self) -> Optional[str]: ... 204 | def add_bot_commands_formatting( 205 | self, commands: Sequence[Command[_CT]], heading: str 206 | ) -> None: ... 207 | def add_subcommand_formatting(self, command: Command[_CT]) -> None: ... 208 | def add_aliases_formatting(self, aliases: Sequence[str]) -> None: ... 209 | def add_command_formatting(self, command: Command[_CT]) -> None: ... 210 | async def prepare_help_command(self, ctx: _CT, command: Optional[str]) -> None: ... # type: ignore[override] 211 | async def send_bot_help( 212 | self, mapping: Mapping[Optional[Cog[_CT]], List[Command[_CT]]] 213 | ) -> None: ... 214 | async def send_cog_help(self, cog: Cog[_CT]) -> None: ... 215 | async def send_group_help(self, group: Group[_CT]) -> None: ... 216 | async def send_command_help(self, command: Command[_CT]) -> None: ... 217 | -------------------------------------------------------------------------------- /discord-stubs/ext/commands/view.pyi: -------------------------------------------------------------------------------- 1 | from typing import Optional 2 | 3 | class StringView: 4 | def __init__(self, buffer: str) -> None: ... 5 | @property 6 | def current(self) -> Optional[str]: ... 7 | @property 8 | def eof(self) -> bool: ... 9 | def undo(self) -> None: ... 10 | def skip_ws(self) -> bool: ... 11 | def skip_string(self, string: str) -> bool: ... 12 | def read_rest(self) -> str: ... 13 | def read(self, n: int) -> str: ... 14 | def get(self) -> str: ... 15 | def get_word(self) -> str: ... 16 | def get_quoted_word(self) -> Optional[str]: ... 17 | -------------------------------------------------------------------------------- /discord-stubs/ext/tasks/__init__.pyi: -------------------------------------------------------------------------------- 1 | import asyncio 2 | import datetime 3 | from typing import ( 4 | Any, 5 | Awaitable, 6 | Callable, 7 | Generator, 8 | Generic, 9 | Optional, 10 | Type, 11 | TypeVar, 12 | Union, 13 | overload, 14 | type_check_only, 15 | ) 16 | from typing_extensions import Protocol 17 | 18 | _T = TypeVar('_T') 19 | _L = TypeVar('_L', bound=Loop[Any]) 20 | _CoroType = Callable[..., Union[Awaitable[_T], Generator[Any, None, _T]]] 21 | _C = TypeVar('_C', bound=Callable[..., Awaitable[Any]]) 22 | 23 | @type_check_only 24 | class _LoopCallback(Protocol): 25 | async def __call__(self) -> Any: ... 26 | 27 | @type_check_only 28 | class _ErrorCallback(Protocol): 29 | async def __call__(self, __exc: BaseException) -> Any: ... 30 | 31 | class Loop(Generic[_T]): 32 | coro: _CoroType[_T] 33 | seconds: float 34 | hours: float 35 | minutes: float 36 | reconnect: bool 37 | loop: asyncio.AbstractEventLoop 38 | count: Optional[int] 39 | def __init__( 40 | self, 41 | coro: _CoroType[_T], 42 | seconds: float, 43 | hours: float, 44 | minutes: float, 45 | count: Optional[int], 46 | reconnect: bool, 47 | loop: Optional[asyncio.AbstractEventLoop], 48 | ) -> None: ... 49 | @overload 50 | def __get__(self: _L, obj: None, objtype: Any) -> _L: ... 51 | @overload 52 | def __get__(self, obj: Any, objtype: Any) -> Loop[_T]: ... 53 | @property 54 | def current_loop(self) -> int: ... 55 | @property 56 | def next_iteration(self) -> Optional[datetime.datetime]: ... 57 | async def __call__(self, *args: Any, **kwargs: Any) -> _T: ... 58 | def start(self, *args: Any, **kwargs: Any) -> asyncio.Task[_T]: ... 59 | def stop(self) -> None: ... 60 | def cancel(self) -> None: ... 61 | def restart(self, *args: Any, **kwargs: Any) -> None: ... 62 | def add_exception_type(self, *exceptions: Type[BaseException]) -> None: ... 63 | def clear_exception_types(self) -> None: ... 64 | def remove_exception_type(self, *exceptions: Type[BaseException]) -> bool: ... 65 | def get_task(self) -> asyncio.Task[_T]: ... 66 | def is_being_cancelled(self) -> bool: ... 67 | def failed(self) -> bool: ... 68 | def is_running(self) -> bool: ... 69 | def before_loop(self, coro: _LoopCallback) -> _LoopCallback: ... 70 | def after_loop(self, coro: _LoopCallback) -> _LoopCallback: ... 71 | def error(self, coro: _ErrorCallback) -> _ErrorCallback: ... 72 | def change_interval( 73 | self, *, seconds: float = ..., minutes: float = ..., hours: float = ... 74 | ) -> None: ... 75 | 76 | def loop( 77 | *, 78 | seconds: float = ..., 79 | minutes: float = ..., 80 | hours: float = ..., 81 | count: Optional[int] = ..., 82 | reconnect: bool = ..., 83 | loop: Optional[asyncio.AbstractEventLoop] = ..., 84 | ) -> Callable[[_CoroType[_T]], Loop[_T]]: ... 85 | -------------------------------------------------------------------------------- /discord-stubs/file.pyi: -------------------------------------------------------------------------------- 1 | from typing import BinaryIO, Optional, Union 2 | 3 | class File: 4 | fp: Union[str, BinaryIO] 5 | filename: Optional[str] 6 | spoiler: bool 7 | def __init__( 8 | self, 9 | fp: Union[str, BinaryIO], 10 | filename: Optional[str] = ..., 11 | *, 12 | spoiler: bool = ..., 13 | ) -> None: ... 14 | def reset(self, *, seek: bool = ...) -> None: ... 15 | def close(self) -> None: ... 16 | -------------------------------------------------------------------------------- /discord-stubs/flags.pyi: -------------------------------------------------------------------------------- 1 | from typing import ( 2 | Any, 3 | Callable, 4 | ClassVar, 5 | Dict, 6 | Iterator, 7 | List, 8 | Tuple, 9 | Type, 10 | TypeVar, 11 | overload, 12 | ) 13 | 14 | from .enums import UserFlags 15 | 16 | _F = TypeVar('_F', bound=flag_value) 17 | _I = TypeVar('_I', bound=Intents) 18 | _MCF = TypeVar('_MCF', bound=MemberCacheFlags) 19 | 20 | class flag_value: 21 | flag: int 22 | def __init__(self, func: Callable[[Any], int]) -> None: ... 23 | @overload 24 | def __get__(self: _F, instance: None, owner: Any) -> _F: ... 25 | @overload 26 | def __get__(self, instance: Any, owner: Any) -> bool: ... 27 | def __set__(self, instance: Any, value: bool) -> None: ... 28 | 29 | class alias_flag_value(flag_value): ... 30 | 31 | class BaseFlags: 32 | value: int 33 | def __init__(self, **kwargs: bool) -> None: ... 34 | def __eq__(self, other: Any) -> bool: ... 35 | def __ne__(self, other: Any) -> bool: ... 36 | def __hash__(self) -> int: ... 37 | def __iter__(self) -> Iterator[Tuple[str, bool]]: ... 38 | 39 | class SystemChannelFlags(BaseFlags): 40 | VALID_FLAGS: ClassVar[Dict[str, int]] 41 | 42 | join_notifications: flag_value 43 | premium_subscriptions: flag_value 44 | 45 | class MessageFlags(BaseFlags): 46 | VALID_FLAGS: ClassVar[Dict[str, int]] 47 | 48 | crossposted: flag_value 49 | is_crossposted: flag_value 50 | suppress_embeds: flag_value 51 | source_message_deleted: flag_value 52 | urgent: flag_value 53 | 54 | class PublicUserFlags(BaseFlags): 55 | VALID_FLAGS: ClassVar[Dict[str, int]] 56 | 57 | staff: flag_value 58 | partner: flag_value 59 | hypesquad: flag_value 60 | bug_hunter: flag_value 61 | hypesquad_bravery: flag_value 62 | hypesquad_brilliance: flag_value 63 | hypesquad_balance: flag_value 64 | early_supporter: flag_value 65 | team_user: flag_value 66 | system: flag_value 67 | bug_hunter_level_2: flag_value 68 | verified_bot: flag_value 69 | verified_bot_developer: flag_value 70 | early_verified_bot_developer: alias_flag_value 71 | def all(self) -> List[UserFlags]: ... 72 | 73 | class Intents(BaseFlags): 74 | VALID_FLAGS: ClassVar[Dict[str, int]] 75 | def __init__( 76 | self, 77 | *, 78 | guilds: bool = ..., 79 | members: bool = ..., 80 | bans: bool = ..., 81 | emojis: bool = ..., 82 | integrations: bool = ..., 83 | webhooks: bool = ..., 84 | invites: bool = ..., 85 | voice_states: bool = ..., 86 | presences: bool = ..., 87 | messages: bool = ..., 88 | guild_messages: bool = ..., 89 | dm_messages: bool = ..., 90 | reactions: bool = ..., 91 | guild_reactions: bool = ..., 92 | dm_reactions: bool = ..., 93 | typing: bool = ..., 94 | guild_typing: bool = ..., 95 | dm_typing: bool = ..., 96 | ) -> None: ... 97 | @classmethod 98 | def all(cls: Type[_I]) -> _I: ... 99 | @classmethod 100 | def none(cls: Type[_I]) -> _I: ... 101 | @classmethod 102 | def default(cls: Type[_I]) -> _I: ... 103 | guilds: flag_value 104 | members: flag_value 105 | bans: flag_value 106 | emojis: flag_value 107 | integrations: flag_value 108 | webhooks: flag_value 109 | invites: flag_value 110 | voice_states: flag_value 111 | presences: flag_value 112 | messages: alias_flag_value 113 | guild_messages: flag_value 114 | dm_messages: flag_value 115 | reactions: alias_flag_value 116 | guild_reactions: flag_value 117 | dm_reactions: flag_value 118 | typing: alias_flag_value 119 | guild_typing: flag_value 120 | dm_typing: flag_value 121 | 122 | class MemberCacheFlags(BaseFlags): 123 | VALID_FLAGS: ClassVar[Dict[str, int]] 124 | def __init__( 125 | self, *, online: bool = ..., voice: bool = ..., joined: bool = ... 126 | ) -> None: ... 127 | @classmethod 128 | def all(cls: Type[_MCF]) -> _MCF: ... 129 | @classmethod 130 | def none(cls: Type[_MCF]) -> _MCF: ... 131 | online: flag_value 132 | voice: flag_value 133 | joined: flag_value 134 | @classmethod 135 | def from_intents(cls: Type[_MCF], intents: Intents) -> _MCF: ... 136 | -------------------------------------------------------------------------------- /discord-stubs/gateway.pyi: -------------------------------------------------------------------------------- 1 | import asyncio 2 | import threading 3 | from typing import ( 4 | Any, 5 | Callable, 6 | ClassVar, 7 | Dict, 8 | Iterable, 9 | List, 10 | NamedTuple, 11 | Optional, 12 | Type, 13 | TypeVar, 14 | Union, 15 | type_check_only, 16 | ) 17 | from typing_extensions import Literal, TypedDict 18 | 19 | import aiohttp 20 | 21 | from .activity import BaseActivity 22 | from .client import Client 23 | from .enums import SpeakingState 24 | from .voice_client import VoiceClient 25 | 26 | @type_check_only 27 | class _KeepAlivePayloadDict(TypedDict): 28 | op: int 29 | d: int 30 | 31 | class ReconnectWebSocket(Exception): 32 | shard_id: int 33 | resume: bool 34 | op: Literal['RESUME', 'IDENTIFY'] 35 | def __init__(self, shard_id: int, *, resume: bool = ...) -> None: ... 36 | 37 | class WebSocketClosure(Exception): ... 38 | 39 | class EventListener(NamedTuple): 40 | predicate: Callable[[Any], bool] 41 | event: str 42 | result: Optional[Callable[[Any], Any]] 43 | future: asyncio.Future[Any] 44 | 45 | class GatewayRatelimiter: 46 | def __init__(self, count: int = ..., per: float = ...) -> None: ... 47 | def get_delay(self) -> float: ... 48 | def is_ratelimited(self) -> bool: ... 49 | async def block(self) -> None: ... 50 | 51 | class KeepAliveHandler(threading.Thread): 52 | def __init__(self, *args: Any, **kwargs: Any) -> None: ... 53 | def run(self) -> None: ... 54 | def get_payload(self) -> _KeepAlivePayloadDict: ... 55 | def stop(self) -> None: ... 56 | def tick(self) -> None: ... 57 | def ack(self) -> None: ... 58 | 59 | class VoiceKeepAliveHandler(KeepAliveHandler): ... 60 | 61 | _DWS = TypeVar('_DWS', bound=DiscordWebSocket) 62 | 63 | class DiscordClientWebSocketResponse(aiohttp.ClientWebSocketResponse): 64 | async def close(self, *, code: int = ..., message: bytes = ...) -> bool: ... 65 | 66 | class DiscordWebSocket: 67 | DISPATCH: ClassVar[int] 68 | HEARTBEAT: ClassVar[int] 69 | IDENTIFY: ClassVar[int] 70 | PRESENCE: ClassVar[int] 71 | VOICE_STATE: ClassVar[int] 72 | VOICE_PING: ClassVar[int] 73 | RESUME: ClassVar[int] 74 | RECONNECT: ClassVar[int] 75 | REQUEST_MEMBERS: ClassVar[int] 76 | INVALIDATE_SESSION: ClassVar[int] 77 | HELLO: ClassVar[int] 78 | HEARTBEAT_ACK: ClassVar[int] 79 | GUILD_SYNC: ClassVar[int] 80 | 81 | thread_id: int 82 | session_id: Optional[int] 83 | sequence: Optional[int] 84 | @property 85 | def open(self) -> bool: ... 86 | def is_ratelimited(self) -> bool: ... 87 | @classmethod 88 | async def from_client( 89 | cls: Type[_DWS], 90 | client: Client, 91 | *, 92 | initial: bool = ..., 93 | gateway: Optional[str] = ..., 94 | shard_id: Optional[int] = ..., 95 | session: Optional[int] = ..., 96 | sequence: Optional[int] = ..., 97 | resume: bool = ..., 98 | ) -> _DWS: ... 99 | def wait_for( 100 | self, 101 | event: str, 102 | predicate: Callable[[Any], bool], 103 | result: Optional[Callable[[Any], Any]] = ..., 104 | ) -> asyncio.Future[Any]: ... 105 | async def identify(self) -> None: ... 106 | async def resume(self) -> None: ... 107 | async def received_message(self, msg: Union[str, bytes]) -> None: ... 108 | @property 109 | def latency(self) -> float: ... 110 | async def poll_event(self) -> None: ... 111 | async def send(self, data: str) -> None: ... 112 | async def send_as_json(self, data: Any) -> None: ... 113 | async def send_heartbeat(self, data: Any) -> None: ... 114 | async def change_presence( 115 | self, 116 | *, 117 | activity: Optional[BaseActivity] = ..., 118 | status: Optional[str] = ..., 119 | afk: bool = ..., 120 | since: float = ..., 121 | ) -> None: ... 122 | async def request_sync(self, guild_ids: Iterable[int]) -> None: ... 123 | async def request_chunks( 124 | self, 125 | guild_id: int, 126 | query: Optional[str] = ..., 127 | *, 128 | limit: int, 129 | user_ids: Optional[List[int]] = ..., 130 | presences: bool = ..., 131 | nonce: Optional[str] = ..., 132 | ) -> None: ... 133 | async def voice_state( 134 | self, 135 | guild_id: int, 136 | channel_id: Optional[int], 137 | self_mute: bool = ..., 138 | self_deaf: bool = ..., 139 | ) -> None: ... 140 | async def close(self, code: int = ...) -> None: ... 141 | 142 | _DVWS = TypeVar('_DVWS', bound=DiscordVoiceWebSocket) 143 | 144 | class DiscordVoiceWebSocket: 145 | IDENTIFY: ClassVar[int] 146 | SELECT_PROTOCOL: ClassVar[int] 147 | READY: ClassVar[int] 148 | HEARTBEAT: ClassVar[int] 149 | SESSION_DESCRIPTION: ClassVar[int] 150 | SPEAKING: ClassVar[int] 151 | HEARTBEAT_ACK: ClassVar[int] 152 | RESUME: ClassVar[int] 153 | HELLO: ClassVar[int] 154 | RESUMED: ClassVar[int] 155 | CLIENT_CONNECT: ClassVar[int] 156 | CLIENT_DISCONNECT: ClassVar[int] 157 | 158 | thread_id: int 159 | async def send_as_json(self, data: Any) -> None: ... 160 | async def send_heartbeat(self, data: Any) -> None: ... 161 | async def resume(self) -> None: ... 162 | async def identify(self) -> None: ... 163 | @classmethod 164 | async def from_client( 165 | cls: Type[_DVWS], client: VoiceClient, *, resume: bool = ... 166 | ) -> _DVWS: ... 167 | async def select_protocol(self, ip: str, port: str, mode: str) -> None: ... 168 | async def client_connect(self) -> None: ... 169 | async def speak(self, state: SpeakingState = ...) -> None: ... 170 | async def received_message(self, msg: Dict[str, Any]) -> None: ... 171 | async def initial_connection(self, data: Dict[str, Any]) -> None: ... 172 | @property 173 | def latency(self) -> float: ... 174 | @property 175 | def average_latency(self) -> float: ... 176 | async def load_secret_key(self, data: Dict[str, Any]) -> None: ... 177 | async def poll_event(self) -> None: ... 178 | async def close(self, code: int = ...) -> None: ... 179 | -------------------------------------------------------------------------------- /discord-stubs/integrations.pyi: -------------------------------------------------------------------------------- 1 | import datetime 2 | from typing import Optional 3 | 4 | from .enums import ExpireBehaviour 5 | from .guild import Guild 6 | from .role import Role 7 | from .user import User 8 | 9 | class IntegrationAccount: 10 | id: int 11 | name: str 12 | 13 | class Integration: 14 | id: int 15 | name: str 16 | guild: Guild 17 | type: str 18 | enabled: bool 19 | syncing: bool 20 | role: Role 21 | enable_emoticons: Optional[bool] 22 | expire_behaviour: ExpireBehaviour 23 | expire_behavior: ExpireBehaviour 24 | expire_grace_period: int 25 | user: User 26 | account: IntegrationAccount 27 | synced_at: datetime.datetime 28 | async def edit( 29 | self, 30 | *, 31 | expire_behaviour: ExpireBehaviour = ..., 32 | expire_behavior: ExpireBehaviour = ..., 33 | expire_grace_period: int = ..., 34 | enable_emoticons: bool = ..., 35 | ) -> None: ... 36 | async def sync(self) -> None: ... 37 | async def delete(self) -> None: ... 38 | -------------------------------------------------------------------------------- /discord-stubs/invite.pyi: -------------------------------------------------------------------------------- 1 | import datetime 2 | from typing import ClassVar, List, Optional, Union 3 | 4 | from .asset import _VALID_ANIMATED_ICON_FORMATS, _VALID_STATIC_ICON_FORMATS, Asset 5 | from .channel import StoreChannel, TextChannel, VoiceChannel 6 | from .enums import ChannelType, VerificationLevel 7 | from .guild import Guild 8 | from .mixins import Hashable 9 | from .object import Object 10 | from .user import User 11 | 12 | class PartialInviteChannel: 13 | id: int 14 | name: str 15 | type: ChannelType 16 | @property 17 | def mention(self) -> str: ... 18 | @property 19 | def created_at(self) -> datetime.datetime: ... 20 | 21 | class PartialInviteGuild: 22 | features: List[str] 23 | icon: Optional[str] 24 | banner: Optional[str] 25 | id: int 26 | name: str 27 | splash: Optional[str] 28 | verification_level: VerificationLevel 29 | description: Optional[str] 30 | @property 31 | def created_at(self) -> datetime.datetime: ... 32 | @property 33 | def icon_url(self) -> Asset: ... 34 | def is_icon_animated(self) -> bool: ... 35 | def icon_url_as( 36 | self, 37 | *, 38 | format: Optional[_VALID_ANIMATED_ICON_FORMATS] = ..., 39 | static_format: _VALID_STATIC_ICON_FORMATS = ..., 40 | size: int = ..., 41 | ) -> Asset: ... 42 | @property 43 | def banner_url(self) -> Asset: ... 44 | def banner_url_as( 45 | self, *, format: _VALID_STATIC_ICON_FORMATS = ..., size: int = ... 46 | ) -> Asset: ... 47 | @property 48 | def splash_url(self) -> Asset: ... 49 | def splash_url_as( 50 | self, *, format: _VALID_STATIC_ICON_FORMATS = ..., size: int = ... 51 | ) -> Asset: ... 52 | 53 | class Invite(Hashable): 54 | BASE: ClassVar[str] 55 | 56 | max_age: int 57 | code: str 58 | guild: Optional[Union[Guild, Object, PartialInviteGuild]] 59 | revoked: bool 60 | created_at: datetime.datetime 61 | temporary: bool 62 | uses: int 63 | max_uses: int 64 | inviter: User 65 | approximate_member_count: Optional[int] 66 | approximate_presence_count: Optional[int] 67 | channel: Union[ 68 | TextChannel, VoiceChannel, StoreChannel, Object, PartialInviteChannel 69 | ] 70 | def __hash__(self) -> int: ... 71 | @property 72 | def id(self) -> str: ... 73 | @property 74 | def url(self) -> str: ... 75 | async def delete(self, *, reason: Optional[str] = ...) -> None: ... 76 | -------------------------------------------------------------------------------- /discord-stubs/iterators.pyi: -------------------------------------------------------------------------------- 1 | from typing import Any, Callable, Coroutine, Generic, List, Optional, TypeVar, Union 2 | from typing_extensions import Final 3 | 4 | from .audit_logs import AuditLogEntry 5 | from .guild import Guild 6 | from .http import _GuildDict, _GuildMemberDict 7 | from .member import Member 8 | from .message import Message 9 | from .object import Object 10 | from .user import User 11 | 12 | OLDEST_OBJECT: Final[Object] 13 | 14 | _IT = TypeVar('_IT') 15 | _AIT = TypeVar('_AIT', bound=_AsyncIterator[Any]) 16 | _OIT = TypeVar('_OIT') 17 | _VT = TypeVar('_VT') 18 | 19 | class _AsyncIterator(Generic[_IT]): 20 | def get(self, **attrs: Any) -> Coroutine[Any, Any, Optional[_IT]]: ... 21 | async def find( 22 | self, predicate: Callable[[_IT], Union[bool, Coroutine[Any, Any, bool]]] 23 | ) -> Optional[_IT]: ... 24 | def chunk(self, max_size: int) -> _ChunkedAsyncIterator[_IT]: ... 25 | def map( 26 | self, func: Callable[[_IT], Union[_OIT, Coroutine[Any, Any, _OIT]]] 27 | ) -> _MappedAsyncIterator[_OIT]: ... 28 | def filter( 29 | self, predicate: Callable[[_IT], Union[bool, Coroutine[Any, Any, bool]]] 30 | ) -> _FilteredAsyncIterator[_IT]: ... 31 | async def flatten(self) -> List[_IT]: ... 32 | def __aiter__(self: _AIT) -> _AIT: ... 33 | async def __anext__(self) -> _IT: ... 34 | 35 | def _identity(x: _VT) -> _VT: ... 36 | 37 | class _ChunkedAsyncIterator(_AsyncIterator[List[_IT]]): 38 | async def next(self) -> List[_IT]: ... 39 | 40 | class _MappedAsyncIterator(_AsyncIterator[_IT]): 41 | async def next(self) -> _IT: ... 42 | 43 | class _FilteredAsyncIterator(_AsyncIterator[_IT]): 44 | async def next(self) -> _IT: ... 45 | 46 | class ReactionIterator(_AsyncIterator[Union[User, Member]]): 47 | async def next(self) -> Union[User, Member]: ... 48 | async def fill_users(self) -> None: ... 49 | 50 | class HistoryIterator(_AsyncIterator[Message]): 51 | async def next(self) -> Message: ... 52 | async def flatten(self) -> List[Message]: ... 53 | async def fill_messages(self) -> None: ... 54 | 55 | class AuditLogIterator(_AsyncIterator[AuditLogEntry]): 56 | async def next(self) -> AuditLogEntry: ... 57 | 58 | class GuildIterator(_AsyncIterator[Guild]): 59 | async def next(self) -> Guild: ... 60 | def create_guild(self, data: _GuildDict) -> Guild: ... 61 | async def flatten(self) -> List[Guild]: ... 62 | async def fill_guilds(self) -> None: ... 63 | 64 | class MemberIterator(_AsyncIterator[Member]): 65 | async def next(self) -> Member: ... 66 | async def fill_members(self) -> None: ... 67 | async def create_member(self, data: _GuildMemberDict) -> Member: ... 68 | -------------------------------------------------------------------------------- /discord-stubs/member.pyi: -------------------------------------------------------------------------------- 1 | import datetime 2 | from typing import Any, List, Optional, Tuple, Union 3 | 4 | import discord.abc 5 | 6 | from .activity import BaseActivity, Spotify 7 | from .channel import GroupChannel, StageChannel, VoiceChannel 8 | from .colour import Colour 9 | from .enums import Status 10 | from .guild import Guild 11 | from .message import Message 12 | from .permissions import Permissions 13 | from .role import Role 14 | from .user import _CommonUser, _User 15 | 16 | class VoiceState: 17 | deaf: bool 18 | mute: bool 19 | self_mute: bool 20 | self_deaf: bool 21 | self_stream: bool 22 | self_video: bool 23 | suppress: bool 24 | requested_to_speak_at: Optional[datetime.datetime] 25 | afk: bool 26 | channel: Optional[Union[GroupChannel, VoiceChannel, StageChannel]] 27 | session_id: str 28 | 29 | class Member(_CommonUser, _User, discord.abc.Messageable, discord.abc.User): 30 | joined_at: Optional[datetime.datetime] 31 | activities: Tuple[Union[BaseActivity, Spotify], ...] 32 | nick: Optional[str] 33 | pending: bool 34 | premium_since: Optional[datetime.datetime] 35 | guild: Guild 36 | def __eq__(self, other: Any) -> bool: ... 37 | def __ne__(self, other: Any) -> bool: ... 38 | def __hash__(self) -> int: ... 39 | @property 40 | def status(self) -> Union[Status, str]: ... 41 | @property 42 | def raw_status(self) -> str: ... 43 | @property 44 | def mobile_status(self) -> Status: ... 45 | @property 46 | def desktop_status(self) -> Status: ... 47 | @property 48 | def web_status(self) -> Status: ... 49 | def is_on_mobile(self) -> bool: ... 50 | @property 51 | def colour(self) -> Colour: ... 52 | @property 53 | def color(self) -> Colour: ... 54 | @property 55 | def roles(self) -> List[Role]: ... 56 | @property 57 | def mention(self) -> str: ... 58 | @property 59 | def display_name(self) -> str: ... 60 | @property 61 | def activity(self) -> Union[BaseActivity, Spotify]: ... 62 | def mentioned_in(self, message: Message) -> bool: ... 63 | def permissions_in(self, channel: discord.abc.GuildChannel) -> Permissions: ... 64 | @property 65 | def top_role(self) -> Role: ... 66 | @property 67 | def guild_permissions(self) -> Permissions: ... 68 | @property 69 | def voice(self) -> Optional[VoiceState]: ... 70 | async def ban( 71 | self, *, reason: Optional[str] = ..., delete_message_days: int = ... 72 | ) -> None: ... 73 | async def unban(self, *, reason: Optional[str] = ...) -> None: ... 74 | async def kick(self, *, reason: Optional[str] = ...) -> None: ... 75 | async def edit( 76 | self, 77 | *, 78 | reason: Optional[str] = ..., 79 | nick: Optional[str] = ..., 80 | mute: bool = ..., 81 | deafen: bool = ..., 82 | suppress: bool = ..., 83 | roles: List[Role] = ..., 84 | voice_channel: Optional[VoiceChannel] = ..., 85 | ) -> None: ... 86 | async def request_to_speak(self) -> None: ... 87 | async def move_to( 88 | self, channel: Optional[VoiceChannel], *, reason: Optional[str] = ... 89 | ) -> None: ... 90 | async def add_roles( 91 | self, 92 | *roles: discord.abc.Snowflake, 93 | reason: Optional[str] = ..., 94 | atomic: bool = ..., 95 | ) -> None: ... 96 | async def remove_roles( 97 | self, 98 | *roles: discord.abc.Snowflake, 99 | reason: Optional[str] = ..., 100 | atomic: bool = ..., 101 | ) -> None: ... 102 | -------------------------------------------------------------------------------- /discord-stubs/mentions.pyi: -------------------------------------------------------------------------------- 1 | from typing import Any, Iterable, List, Type, TypeVar, Union, type_check_only 2 | from typing_extensions import TypedDict 3 | 4 | from .abc import Snowflake 5 | 6 | _AM = TypeVar('_AM', bound=AllowedMentions) 7 | 8 | class _FakeBool: 9 | def __eq__(self, other: Any) -> bool: ... 10 | def __bool__(self) -> bool: ... 11 | 12 | default: _FakeBool 13 | 14 | @type_check_only 15 | class _AllowedMentionsDictBase(TypedDict): 16 | parse: List[str] 17 | 18 | @type_check_only 19 | class _AllowedMentionsDict(_AllowedMentionsDictBase, total=False): 20 | users: List[int] 21 | roles: List[int] 22 | replied_user: bool 23 | 24 | class AllowedMentions: 25 | everyone: bool 26 | users: Union[bool, Iterable[Snowflake]] 27 | roles: Union[bool, Iterable[Snowflake]] 28 | replied_user: bool 29 | def __init__( 30 | self, 31 | *, 32 | everyone: Union[bool, _FakeBool] = ..., 33 | users: Union[bool, _FakeBool, Iterable[Snowflake]] = ..., 34 | roles: Union[bool, _FakeBool, Iterable[Snowflake]] = ..., 35 | replied_user: Union[bool, _FakeBool] = ..., 36 | ) -> None: ... 37 | @classmethod 38 | def all(cls: Type[_AM]) -> _AM: ... 39 | @classmethod 40 | def none(cls: Type[_AM]) -> _AM: ... 41 | def to_dict(self) -> _AllowedMentionsDict: ... 42 | def merge(self, other: AllowedMentions) -> AllowedMentions: ... 43 | -------------------------------------------------------------------------------- /discord-stubs/message.pyi: -------------------------------------------------------------------------------- 1 | import datetime 2 | from os import PathLike 3 | from typing import BinaryIO, List, Optional, Type, TypeVar, Union, type_check_only 4 | from typing_extensions import TypedDict 5 | 6 | from .abc import User as _BaseUser 7 | from .calls import CallMessage 8 | from .channel import DMChannel, GroupChannel, TextChannel 9 | from .embeds import Embed 10 | from .emoji import Emoji 11 | from .enums import MessageType 12 | from .file import File 13 | from .flags import MessageFlags 14 | from .guild import Guild 15 | from .member import Member 16 | from .mentions import AllowedMentions 17 | from .mixins import Hashable 18 | from .partial_emoji import PartialEmoji 19 | from .reaction import Reaction 20 | from .role import Role 21 | from .sticker import Sticker 22 | from .user import ClientUser, User 23 | from .utils import cached_slot_property 24 | 25 | _MR = TypeVar('_MR', bound=MessageReference) 26 | 27 | class Attachment(Hashable): 28 | id: int 29 | size: int 30 | height: Optional[int] 31 | width: Optional[int] 32 | filename: str 33 | url: str 34 | proxy_url: str 35 | content_type: Optional[str] 36 | def is_spoiler(self) -> bool: ... 37 | async def save( 38 | self, 39 | fp: Union[BinaryIO, PathLike[str], str], 40 | *, 41 | seek_begin: bool = ..., 42 | use_cached: bool = ..., 43 | ) -> int: ... 44 | async def read(self, *, use_cached: bool = ...) -> bytes: ... 45 | async def to_file(self, *, use_cached: bool = ..., spoiler: bool = ...) -> File: ... 46 | 47 | class DeletedReferencedMessage: 48 | @property 49 | def id(self) -> Optional[int]: ... 50 | @property 51 | def channel_id(self) -> int: ... 52 | @property 53 | def guild_id(self) -> Optional[int]: ... 54 | 55 | @type_check_only 56 | class _BaseMessageReferenceDict(TypedDict): 57 | channel_id: int 58 | 59 | @type_check_only 60 | class _MessageReferenceDict(_BaseMessageReferenceDict, total=False): 61 | message_id: int 62 | guild_id: int 63 | fail_if_not_exists: bool 64 | 65 | class MessageReference: 66 | message_id: Optional[int] 67 | channel_id: int 68 | guild_id: Optional[int] 69 | fail_if_not_exists: bool 70 | resolved: Optional[Union[Message, DeletedReferencedMessage]] 71 | def __init__( 72 | self, 73 | *, 74 | message_id: int, 75 | channel_id: int, 76 | guild_id: Optional[int] = ..., 77 | fail_if_not_exists: bool = ..., 78 | ) -> None: ... 79 | @classmethod 80 | def from_message( 81 | cls: Type[_MR], message: Message, *, fail_if_not_exists: bool = ... 82 | ) -> _MR: ... 83 | @property 84 | def cached_message(self) -> Optional[Message]: ... 85 | @property 86 | def jump_url(self) -> str: ... 87 | def to_dict(self) -> _MessageReferenceDict: ... 88 | to_message_reference_dict = to_dict 89 | 90 | @type_check_only 91 | class _MessageActivity(TypedDict, total=False): 92 | type: int 93 | party_id: str 94 | 95 | @type_check_only 96 | class _MessageApplication(TypedDict): 97 | id: str 98 | name: str 99 | description: str 100 | icon: str 101 | cover_image: str 102 | 103 | @type_check_only 104 | class _MessageShared: 105 | @property 106 | def jump_url(self) -> str: ... 107 | async def delete(self, *, delay: Optional[float] = ...) -> None: ... 108 | async def publish(self) -> None: ... 109 | async def pin(self, *, reason: Optional[str] = ...) -> None: ... 110 | async def unpin(self, *, reason: Optional[str] = ...) -> None: ... 111 | async def add_reaction( 112 | self, emoji: Union[Emoji, Reaction, PartialEmoji, str] 113 | ) -> None: ... 114 | async def remove_reaction( 115 | self, emoji: Union[Emoji, Reaction, PartialEmoji, str], member: _BaseUser 116 | ) -> None: ... 117 | async def clear_reaction( 118 | self, emoji: Union[Emoji, Reaction, PartialEmoji, str] 119 | ) -> None: ... 120 | async def clear_reactions(self) -> None: ... 121 | async def reply( 122 | self, 123 | content: Optional[object] = ..., 124 | *, 125 | tts: bool = ..., 126 | embed: Optional[Embed] = ..., 127 | file: Optional[File] = ..., 128 | files: Optional[List[File]] = ..., 129 | delete_after: Optional[float] = ..., 130 | nonce: Optional[int] = ..., 131 | allowed_mentions: Optional[AllowedMentions] = ..., 132 | mention_author: Optional[bool] = ..., 133 | ) -> Message: ... 134 | def to_reference(self, *, fail_if_not_exists: bool = ...) -> MessageReference: ... 135 | def to_message_reference_dict(self) -> _MessageReferenceDict: ... 136 | 137 | class Message(Hashable, _MessageShared): 138 | id: int 139 | tts: bool 140 | type: MessageType 141 | author: Union[User, Member] 142 | content: str 143 | nonce: Union[int, str] 144 | embeds: List[Embed] 145 | channel: Union[TextChannel, DMChannel, GroupChannel] 146 | call: Optional[CallMessage] 147 | reference: Optional[MessageReference] 148 | mention_everyone: bool 149 | mentions: List[Union[User, Member, ClientUser]] 150 | role_mentions: List[Role] 151 | webhook_id: Optional[int] 152 | attachments: List[Attachment] 153 | pinned: bool 154 | flags: MessageFlags 155 | reactions: List[Reaction] 156 | activity: Optional[_MessageActivity] 157 | application: Optional[_MessageApplication] 158 | stickers: List[Sticker] 159 | @cached_slot_property('_cs_guild') 160 | def guild(self) -> Optional[Guild]: ... 161 | @cached_slot_property('_cs_raw_mentions') 162 | def raw_mentions(self) -> List[int]: ... 163 | @cached_slot_property('_cs_raw_channel_mentions') 164 | def raw_channel_mentions(self) -> List[int]: ... 165 | @cached_slot_property('_cs_raw_role_mentions') 166 | def raw_role_mentions(self) -> List[int]: ... 167 | @cached_slot_property('_cs_channel_mentions') 168 | def channel_mentions(self) -> List[TextChannel]: ... 169 | @cached_slot_property('_cs_clean_content') 170 | def clean_content(self) -> str: ... 171 | @property 172 | def created_at(self) -> datetime.datetime: ... 173 | @property 174 | def edited_at(self) -> Optional[datetime.datetime]: ... 175 | @property 176 | def jump_url(self) -> str: ... 177 | def is_system(self) -> bool: ... 178 | @cached_slot_property('_cs_system_content') 179 | def system_content(self) -> str: ... 180 | async def edit( 181 | self, 182 | *, 183 | content: Optional[str] = ..., 184 | embed: Optional[Embed] = ..., 185 | suppress: bool = ..., 186 | delete_after: Optional[float] = ..., 187 | allowed_mentions: Optional[AllowedMentions] = ..., 188 | ) -> None: ... 189 | async def ack(self) -> None: ... 190 | 191 | class PartialMessage(Hashable, _MessageShared): 192 | id: int 193 | channel: Union[TextChannel, DMChannel] 194 | @property 195 | def created_at(self) -> datetime.datetime: ... 196 | @cached_slot_property('_cs_guild') 197 | def guild(self) -> Optional[Guild]: ... 198 | async def fetch(self) -> Message: ... 199 | async def edit( 200 | self, 201 | *, 202 | content: Optional[str] = ..., 203 | embed: Optional[Embed] = ..., 204 | suppress: bool = ..., 205 | delete_after: Optional[float] = ..., 206 | allowed_mentions: Optional[AllowedMentions] = ..., 207 | ) -> Optional[Message]: ... 208 | -------------------------------------------------------------------------------- /discord-stubs/mixins.pyi: -------------------------------------------------------------------------------- 1 | from typing import Any 2 | 3 | class EqualityComparable: 4 | def __eq__(self, other: Any) -> bool: ... 5 | def __ne__(self, other: Any) -> bool: ... 6 | 7 | class Hashable(EqualityComparable): 8 | def __hash__(self) -> int: ... 9 | -------------------------------------------------------------------------------- /discord-stubs/object.pyi: -------------------------------------------------------------------------------- 1 | import datetime 2 | from typing import SupportsInt, Text, Union 3 | from typing_extensions import SupportsIndex 4 | 5 | from .mixins import Hashable 6 | 7 | class Object(Hashable): 8 | id: int 9 | def __init__(self, id: Union[Text, bytes, SupportsInt, SupportsIndex]) -> None: ... 10 | @property 11 | def created_at(self) -> datetime.datetime: ... 12 | -------------------------------------------------------------------------------- /discord-stubs/oggparse.pyi: -------------------------------------------------------------------------------- 1 | from typing import BinaryIO, Iterator, Tuple 2 | 3 | from .errors import DiscordException 4 | 5 | class OggError(DiscordException): ... 6 | 7 | class OggPage: 8 | segtable: bytes 9 | data: bytes 10 | def __init__(self, stream: BinaryIO) -> None: ... 11 | def iter_packets(self) -> Iterator[Tuple[bytes, bool]]: ... 12 | 13 | class OggStream: 14 | stream: BinaryIO 15 | def __init__(self, stream: BinaryIO) -> None: ... 16 | def iter_packets(self) -> Iterator[bytes]: ... 17 | -------------------------------------------------------------------------------- /discord-stubs/opus.pyi: -------------------------------------------------------------------------------- 1 | from ctypes import Structure, c_float, c_int, c_int16, pointer 2 | from typing import Any, ClassVar, Optional, Type, Union, type_check_only 3 | from typing_extensions import Final, TypedDict 4 | 5 | from .errors import DiscordException 6 | 7 | c_int_ptr: Final[Type[pointer[c_int]]] 8 | c_int16_ptr: Final[Type[pointer[c_int16]]] 9 | c_float_ptr: Final[Type[pointer[c_float]]] 10 | 11 | class EncoderStruct(Structure): ... 12 | class DecoderStruct(Structure): ... 13 | 14 | EncoderStructPtr: Final[Type[pointer[EncoderStruct]]] 15 | DecoderStructPtr: Final[Type[pointer[DecoderStruct]]] 16 | 17 | OK: Final[int] 18 | BAD_ARG: Final[int] 19 | APPLICATION_AUDIO: Final[int] 20 | APPLICATION_VOIP: Final[int] 21 | APPLICATION_LOWDELAY: Final[int] 22 | CTL_SET_BITRATE: Final[int] 23 | CTL_SET_BANDWIDTH: Final[int] 24 | CTL_SET_FEC: Final[int] 25 | CTL_SET_PLP: Final[int] 26 | CTL_SET_SIGNAL: Final[int] 27 | CTL_SET_GAIN: Final[int] 28 | CTL_LAST_PACKET_DURATION: Final[int] 29 | 30 | @type_check_only 31 | class _BandCtl(TypedDict): 32 | narrow: int 33 | medium: int 34 | wide: int 35 | superwide: int 36 | full: int 37 | 38 | @type_check_only 39 | class _SignalCtl(TypedDict): 40 | auto: int 41 | voice: int 42 | music: int 43 | 44 | band_ctl: Final[_BandCtl] 45 | signal_ctl: Final[_SignalCtl] 46 | 47 | def libopus_loader(name: str) -> Any: ... 48 | def load_opus(name: str) -> None: ... 49 | def is_loaded() -> bool: ... 50 | 51 | class OpusError(DiscordException): 52 | code: int 53 | 54 | class OpusNotLoaded(DiscordException): ... 55 | 56 | class _OpusStruct: 57 | SAMPLING_RATE: ClassVar[int] 58 | CHANNELS: ClassVar[int] 59 | FRAME_LENGTH: ClassVar[int] 60 | SAMPLE_SIZE: ClassVar[int] 61 | SAMPLES_PER_FRAME: ClassVar[int] 62 | FRAME_SIZE: ClassVar[int] 63 | @staticmethod 64 | def get_opus_version() -> str: ... 65 | 66 | class Encoder(_OpusStruct): 67 | application: int 68 | def __init__(self, application: int = ...) -> None: ... 69 | def __del__(self) -> None: ... 70 | def set_bitrate(self, kbps: int) -> int: ... 71 | def set_bandwidth(self, req: str) -> None: ... 72 | def set_signal_type(self, req: str) -> None: ... 73 | def set_fec(self, enabled: bool = ...) -> None: ... 74 | def set_expected_packet_loss_percent( 75 | self, percentage: Union[int, float] 76 | ) -> None: ... 77 | def encode(self, pcm: bytes, frame_size: int) -> bytes: ... 78 | 79 | class Decoder(_OpusStruct): 80 | def __init__(self) -> None: ... 81 | def __del__(self) -> None: ... 82 | @staticmethod 83 | def packet_get_nb_frames(data: bytes) -> int: ... 84 | @staticmethod 85 | def packet_get_nb_channels(data: bytes) -> int: ... 86 | @classmethod 87 | def packet_get_samples_per_frame(cls, data: bytes) -> int: ... 88 | def set_gain(self, dB: int) -> int: ... 89 | def set_volume(self, mult: int) -> int: ... 90 | def decode(self, data: Optional[bytes], *, fec: bool = ...) -> bytes: ... 91 | -------------------------------------------------------------------------------- /discord-stubs/partial_emoji.pyi: -------------------------------------------------------------------------------- 1 | from datetime import datetime 2 | from typing import Any, Optional, Type, TypeVar 3 | 4 | from .asset import _VALID_ANIMATED_ICON_FORMATS, _VALID_STATIC_ICON_FORMATS, Asset 5 | from .http import _PartialEmojiDict 6 | 7 | class _EmojiTag: ... 8 | 9 | _PE = TypeVar('_PE', bound=PartialEmoji) 10 | 11 | class PartialEmoji(_EmojiTag): 12 | animated: bool 13 | name: Optional[str] 14 | id: Optional[int] 15 | @classmethod 16 | def from_dict(cls: Type[_PE], data: _PartialEmojiDict) -> _PE: ... 17 | def to_dict(self) -> _PartialEmojiDict: ... 18 | @classmethod 19 | def with_state( 20 | cls: Type[_PE], 21 | state: Any, 22 | *, 23 | name: Optional[str], 24 | animated: bool = ..., 25 | id: Optional[int] = ..., 26 | ) -> _PE: ... 27 | def __eq__(self, other: Any) -> bool: ... 28 | def __ne__(self, other: Any) -> bool: ... 29 | def __hash__(self) -> int: ... 30 | def is_custom_emoji(self) -> bool: ... 31 | def is_unicode_emoji(self) -> bool: ... 32 | @property 33 | def created_at(self) -> Optional[datetime]: ... 34 | @property 35 | def url(self) -> Asset: ... 36 | def url_as( 37 | self, 38 | *, 39 | format: Optional[_VALID_ANIMATED_ICON_FORMATS] = ..., 40 | static_format: _VALID_STATIC_ICON_FORMATS = ..., 41 | ) -> Asset: ... 42 | -------------------------------------------------------------------------------- /discord-stubs/permissions.pyi: -------------------------------------------------------------------------------- 1 | from typing import Any, ClassVar, Dict, Iterator, Optional, Set, Tuple, Type, TypeVar 2 | 3 | from .flags import BaseFlags, alias_flag_value, flag_value 4 | 5 | _P = TypeVar('_P', bound=Permissions) 6 | 7 | class permission_alias(alias_flag_value): 8 | alias: str 9 | 10 | class Permissions(BaseFlags): 11 | VALID_FLAGS: ClassVar[Dict[str, int]] 12 | 13 | create_instant_invite: flag_value 14 | kick_members: flag_value 15 | ban_members: flag_value 16 | administrator: flag_value 17 | manage_channels: flag_value 18 | manage_guild: flag_value 19 | add_reactions: flag_value 20 | view_audit_log: flag_value 21 | priority_speaker: flag_value 22 | stream: flag_value 23 | read_messages: flag_value 24 | view_channel: permission_alias 25 | send_messages: flag_value 26 | send_tts_messages: flag_value 27 | manage_messages: flag_value 28 | embed_links: flag_value 29 | attach_files: flag_value 30 | read_message_history: flag_value 31 | mention_everyone: flag_value 32 | external_emojis: flag_value 33 | use_external_emojis: permission_alias 34 | view_guild_insights: flag_value 35 | connect: flag_value 36 | speak: flag_value 37 | mute_members: flag_value 38 | deafen_members: flag_value 39 | move_members: flag_value 40 | use_voice_activation: flag_value 41 | change_nickname: flag_value 42 | manage_nicknames: flag_value 43 | manage_roles: flag_value 44 | manage_permissions: permission_alias 45 | manage_webhooks: flag_value 46 | manage_emojis: flag_value 47 | use_slash_commands: flag_value 48 | request_to_speak: flag_value 49 | def __init__( 50 | self, 51 | permissions: int = ..., 52 | *, 53 | create_instant_invite: bool = ..., 54 | kick_members: bool = ..., 55 | ban_members: bool = ..., 56 | administrator: bool = ..., 57 | manage_channels: bool = ..., 58 | manage_guild: bool = ..., 59 | add_reactions: bool = ..., 60 | view_audit_log: bool = ..., 61 | priority_speaker: bool = ..., 62 | stream: bool = ..., 63 | read_messages: bool = ..., 64 | view_channel: bool = ..., 65 | send_messages: bool = ..., 66 | send_tts_messages: bool = ..., 67 | manage_messages: bool = ..., 68 | embed_links: bool = ..., 69 | attach_files: bool = ..., 70 | read_message_history: bool = ..., 71 | mention_everyone: bool = ..., 72 | external_emojis: bool = ..., 73 | use_external_emojis: bool = ..., 74 | view_guild_insights: bool = ..., 75 | connect: bool = ..., 76 | speak: bool = ..., 77 | mute_members: bool = ..., 78 | deafen_members: bool = ..., 79 | move_members: bool = ..., 80 | use_voice_activation: bool = ..., 81 | change_nickname: bool = ..., 82 | manage_nicknames: bool = ..., 83 | manage_roles: bool = ..., 84 | manage_permissions: bool = ..., 85 | manage_webhooks: bool = ..., 86 | manage_emojis: bool = ..., 87 | use_slash_commands: bool = ..., 88 | request_to_speak: bool = ..., 89 | ) -> None: ... 90 | def is_subset(self, other: Any) -> bool: ... 91 | def is_superset(self, other: Any) -> bool: ... 92 | def is_strict_subset(self, other: Any) -> bool: ... 93 | def is_strict_superset(self, other: Any) -> bool: ... 94 | def __le__(self, other: Any) -> bool: ... 95 | def __ge__(self, other: Any) -> bool: ... 96 | def __lt__(self, other: Any) -> bool: ... 97 | def __gt__(self, other: Any) -> bool: ... 98 | @classmethod 99 | def none(cls: Type[_P]) -> _P: ... 100 | @classmethod 101 | def all(cls: Type[_P]) -> _P: ... 102 | @classmethod 103 | def all_channel(cls: Type[_P]) -> _P: ... 104 | @classmethod 105 | def general(cls: Type[_P]) -> _P: ... 106 | @classmethod 107 | def membership(cls: Type[_P]) -> _P: ... 108 | @classmethod 109 | def text(cls: Type[_P]) -> _P: ... 110 | @classmethod 111 | def voice(cls: Type[_P]) -> _P: ... 112 | @classmethod 113 | def stage(cls: Type[_P]) -> _P: ... 114 | @classmethod 115 | def advanced(cls: Type[_P]) -> _P: ... 116 | @classmethod 117 | def stage_moderator(cls: Type[_P]) -> _P: ... 118 | def update( 119 | self, 120 | *, 121 | create_instant_invite: bool = ..., 122 | kick_members: bool = ..., 123 | ban_members: bool = ..., 124 | administrator: bool = ..., 125 | manage_channels: bool = ..., 126 | manage_guild: bool = ..., 127 | add_reactions: bool = ..., 128 | view_audit_log: bool = ..., 129 | priority_speaker: bool = ..., 130 | stream: bool = ..., 131 | read_messages: bool = ..., 132 | view_channel: bool = ..., 133 | send_messages: bool = ..., 134 | send_tts_messages: bool = ..., 135 | manage_messages: bool = ..., 136 | embed_links: bool = ..., 137 | attach_files: bool = ..., 138 | read_message_history: bool = ..., 139 | mention_everyone: bool = ..., 140 | external_emojis: bool = ..., 141 | use_external_emojis: bool = ..., 142 | view_guild_insights: bool = ..., 143 | connect: bool = ..., 144 | speak: bool = ..., 145 | mute_members: bool = ..., 146 | deafen_members: bool = ..., 147 | move_members: bool = ..., 148 | use_voice_activation: bool = ..., 149 | change_nickname: bool = ..., 150 | manage_nicknames: bool = ..., 151 | manage_roles: bool = ..., 152 | manage_permissions: bool = ..., 153 | manage_webhooks: bool = ..., 154 | manage_emojis: bool = ..., 155 | use_slash_commands: bool = ..., 156 | request_to_speak: bool = ..., 157 | ) -> None: ... 158 | def handle_overwrite(self, allow: int, deny: int) -> None: ... 159 | 160 | _PO = TypeVar('_PO', bound=PermissionOverwrite) 161 | 162 | class PermissionOverwrite: 163 | VALID_NAMES: ClassVar[Set[str]] 164 | PURE_FLAGS: ClassVar[Set[str]] 165 | 166 | create_instant_invite: Optional[bool] 167 | kick_members: Optional[bool] 168 | ban_members: Optional[bool] 169 | administrator: Optional[bool] 170 | manage_channels: Optional[bool] 171 | manage_guild: Optional[bool] 172 | add_reactions: Optional[bool] 173 | view_audit_log: Optional[bool] 174 | priority_speaker: Optional[bool] 175 | stream: Optional[bool] 176 | read_messages: Optional[bool] 177 | view_channel: Optional[bool] 178 | send_messages: Optional[bool] 179 | send_tts_messages: Optional[bool] 180 | manage_messages: Optional[bool] 181 | embed_links: Optional[bool] 182 | attach_files: Optional[bool] 183 | read_message_history: Optional[bool] 184 | mention_everyone: Optional[bool] 185 | external_emojis: Optional[bool] 186 | use_external_emojis: Optional[bool] 187 | view_guild_insights: Optional[bool] 188 | connect: Optional[bool] 189 | speak: Optional[bool] 190 | mute_members: Optional[bool] 191 | deafen_members: Optional[bool] 192 | move_members: Optional[bool] 193 | use_voice_activation: Optional[bool] 194 | change_nickname: Optional[bool] 195 | manage_nicknames: Optional[bool] 196 | manage_roles: Optional[bool] 197 | manage_permissions: Optional[bool] 198 | manage_webhooks: Optional[bool] 199 | manage_emojis: Optional[bool] 200 | use_slash_commands: Optional[bool] 201 | request_to_speak: Optional[bool] 202 | def __init__( 203 | self, 204 | *, 205 | create_instant_invite: Optional[bool] = ..., 206 | kick_members: Optional[bool] = ..., 207 | ban_members: Optional[bool] = ..., 208 | administrator: Optional[bool] = ..., 209 | manage_channels: Optional[bool] = ..., 210 | manage_guild: Optional[bool] = ..., 211 | add_reactions: Optional[bool] = ..., 212 | view_audit_log: Optional[bool] = ..., 213 | priority_speaker: Optional[bool] = ..., 214 | stream: Optional[bool] = ..., 215 | read_messages: Optional[bool] = ..., 216 | view_channel: Optional[bool] = ..., 217 | send_messages: Optional[bool] = ..., 218 | send_tts_messages: Optional[bool] = ..., 219 | manage_messages: Optional[bool] = ..., 220 | embed_links: Optional[bool] = ..., 221 | attach_files: Optional[bool] = ..., 222 | read_message_history: Optional[bool] = ..., 223 | mention_everyone: Optional[bool] = ..., 224 | external_emojis: Optional[bool] = ..., 225 | use_external_emojis: Optional[bool] = ..., 226 | view_guild_insights: Optional[bool] = ..., 227 | connect: Optional[bool] = ..., 228 | speak: Optional[bool] = ..., 229 | mute_members: Optional[bool] = ..., 230 | deafen_members: Optional[bool] = ..., 231 | move_members: Optional[bool] = ..., 232 | use_voice_activation: Optional[bool] = ..., 233 | change_nickname: Optional[bool] = ..., 234 | manage_nicknames: Optional[bool] = ..., 235 | manage_roles: Optional[bool] = ..., 236 | manage_permissions: Optional[bool] = ..., 237 | manage_webhooks: Optional[bool] = ..., 238 | manage_emojis: Optional[bool] = ..., 239 | use_slash_commands: Optional[bool] = ..., 240 | request_to_speak: Optional[bool] = ..., 241 | ) -> None: ... 242 | def __eq__(self, other: Any) -> bool: ... 243 | def pair(self) -> Tuple[Permissions, Permissions]: ... 244 | @classmethod 245 | def from_pair(cls: Type[_PO], allow: Permissions, deny: Permissions) -> _PO: ... 246 | def is_empty(self) -> bool: ... 247 | def update( 248 | self, 249 | *, 250 | create_instant_invite: Optional[bool] = ..., 251 | kick_members: Optional[bool] = ..., 252 | ban_members: Optional[bool] = ..., 253 | administrator: Optional[bool] = ..., 254 | manage_channels: Optional[bool] = ..., 255 | manage_guild: Optional[bool] = ..., 256 | add_reactions: Optional[bool] = ..., 257 | view_audit_log: Optional[bool] = ..., 258 | priority_speaker: Optional[bool] = ..., 259 | stream: Optional[bool] = ..., 260 | read_messages: Optional[bool] = ..., 261 | view_channel: Optional[bool] = ..., 262 | send_messages: Optional[bool] = ..., 263 | send_tts_messages: Optional[bool] = ..., 264 | manage_messages: Optional[bool] = ..., 265 | embed_links: Optional[bool] = ..., 266 | attach_files: Optional[bool] = ..., 267 | read_message_history: Optional[bool] = ..., 268 | mention_everyone: Optional[bool] = ..., 269 | external_emojis: Optional[bool] = ..., 270 | use_external_emojis: Optional[bool] = ..., 271 | view_guild_insights: Optional[bool] = ..., 272 | connect: Optional[bool] = ..., 273 | speak: Optional[bool] = ..., 274 | mute_members: Optional[bool] = ..., 275 | deafen_members: Optional[bool] = ..., 276 | move_members: Optional[bool] = ..., 277 | use_voice_activation: Optional[bool] = ..., 278 | change_nickname: Optional[bool] = ..., 279 | manage_nicknames: Optional[bool] = ..., 280 | manage_roles: Optional[bool] = ..., 281 | manage_permissions: Optional[bool] = ..., 282 | manage_webhooks: Optional[bool] = ..., 283 | manage_emojis: Optional[bool] = ..., 284 | use_slash_commands: Optional[bool] = ..., 285 | request_to_speak: Optional[bool] = ..., 286 | ) -> None: ... 287 | def __iter__(self) -> Iterator[Tuple[str, Optional[bool]]]: ... 288 | -------------------------------------------------------------------------------- /discord-stubs/player.pyi: -------------------------------------------------------------------------------- 1 | import io 2 | import threading 3 | from typing import ( 4 | Any, 5 | BinaryIO, 6 | Callable, 7 | ClassVar, 8 | Optional, 9 | Tuple, 10 | Type, 11 | TypeVar, 12 | Union, 13 | overload, 14 | ) 15 | from typing_extensions import Literal 16 | 17 | from .voice_client import VoiceClient 18 | 19 | _FOA = TypeVar('_FOA', bound=FFmpegOpusAudio) 20 | _MethodCallback = Callable[ 21 | [Union[str, io.BufferedIOBase], str], Tuple[Optional[str], Optional[int]] 22 | ] 23 | _OpusMethods = Literal['native', 'fallback'] 24 | 25 | class AudioSource: 26 | def read(self) -> bytes: ... 27 | def is_opus(self) -> bool: ... 28 | def cleanup(self) -> None: ... 29 | def __del__(self) -> None: ... 30 | 31 | class PCMAudio(AudioSource): 32 | stream: BinaryIO 33 | def __init__(self, stream: BinaryIO) -> None: ... 34 | def read(self) -> bytes: ... 35 | 36 | class FFmpegAudio(AudioSource): 37 | def __init__( 38 | self, source: Any, *, executable: str = ..., args: Any, **subprocess_kwargs: Any 39 | ) -> None: ... 40 | def cleanup(self) -> None: ... 41 | 42 | class FFmpegPCMAudio(FFmpegAudio): 43 | @overload 44 | def __init__( 45 | self, 46 | source: io.BufferedIOBase, 47 | *, 48 | executable: str = ..., 49 | pipe: bool, 50 | stderr: Optional[BinaryIO] = ..., 51 | before_options: Optional[str] = ..., 52 | options: Optional[str] = ..., 53 | ) -> None: ... 54 | @overload 55 | def __init__( 56 | self, 57 | source: str, 58 | *, 59 | executable: str = ..., 60 | stderr: Optional[BinaryIO] = ..., 61 | before_options: Optional[str] = ..., 62 | options: Optional[str] = ..., 63 | ) -> None: ... 64 | def read(self) -> bytes: ... 65 | def is_opus(self) -> bool: ... 66 | 67 | class FFmpegOpusAudio(FFmpegAudio): 68 | @overload 69 | def __init__( 70 | self, 71 | source: io.BufferedIOBase, 72 | *, 73 | bitrate: int = ..., 74 | codec: Optional[str] = ..., 75 | executable: str = ..., 76 | pipe: bool = ..., 77 | stderr: Optional[BinaryIO] = ..., 78 | before_options: Optional[str] = ..., 79 | options: Optional[str] = ..., 80 | ) -> None: ... 81 | @overload 82 | def __init__( 83 | self, 84 | source: str, 85 | *, 86 | bitrate: int = ..., 87 | codec: Optional[str] = ..., 88 | executable: str = ..., 89 | stderr: Optional[BinaryIO] = ..., 90 | before_options: Optional[str] = ..., 91 | options: Optional[str] = ..., 92 | ) -> None: ... 93 | @overload 94 | @classmethod 95 | async def from_probe( 96 | cls: Type[_FOA], 97 | source: io.BufferedIOBase, 98 | *, 99 | method: Optional[Union[_OpusMethods, _MethodCallback]] = ..., 100 | executable: str = ..., 101 | pipe: bool = ..., 102 | stderr: Optional[BinaryIO] = ..., 103 | before_options: Optional[str] = ..., 104 | options: Optional[str] = ..., 105 | ) -> _FOA: ... 106 | @overload 107 | @classmethod 108 | async def from_probe( 109 | cls: Type[_FOA], 110 | source: str, 111 | *, 112 | method: Optional[Union[_OpusMethods, _MethodCallback]] = ..., 113 | executable: str = ..., 114 | pipe: bool = ..., 115 | stderr: Optional[BinaryIO] = ..., 116 | before_options: Optional[str] = ..., 117 | options: Optional[str] = ..., 118 | ) -> _FOA: ... 119 | @overload 120 | @classmethod 121 | async def probe( 122 | cls, 123 | source: io.BufferedIOBase, 124 | *, 125 | method: Optional[Union[_OpusMethods, _MethodCallback]] = ..., 126 | executable: Optional[str] = ..., 127 | ) -> Tuple[Optional[str], Optional[int]]: ... 128 | @overload 129 | @classmethod 130 | async def probe( 131 | cls, 132 | source: str, 133 | *, 134 | method: Optional[Union[_OpusMethods, _MethodCallback]] = ..., 135 | executable: Optional[str] = ..., 136 | ) -> Tuple[Optional[str], Optional[int]]: ... 137 | def read(self) -> bytes: ... 138 | def is_opus(self) -> bool: ... 139 | 140 | class PCMVolumeTransformer(AudioSource): 141 | original: AudioSource 142 | volume: float 143 | def __init__(self, original: AudioSource, volume: float = ...) -> None: ... 144 | def cleanup(self) -> None: ... 145 | def read(self) -> bytes: ... 146 | 147 | class AudioPlayer(threading.Thread): 148 | DELAY: ClassVar[float] 149 | 150 | daemon: bool 151 | source: AudioSource 152 | client: VoiceClient 153 | loops: int 154 | def run(self) -> None: ... 155 | def stop(self) -> None: ... 156 | def pause(self, *, update_speaking: bool = ...) -> None: ... 157 | def resume(self, *, update_speaking: bool = ...) -> None: ... 158 | def is_playing(self) -> bool: ... 159 | def is_paused(self) -> bool: ... 160 | -------------------------------------------------------------------------------- /discord-stubs/raw_models.pyi: -------------------------------------------------------------------------------- 1 | from typing import List, Optional, Set, type_check_only 2 | from typing_extensions import Literal, TypedDict 3 | 4 | from .http import _MessageDict, _PartialEmojiDict 5 | from .member import Member 6 | from .message import Message 7 | from .partial_emoji import PartialEmoji 8 | 9 | @type_check_only 10 | class _BaseBulkMessageDeleteDict(TypedDict, total=False): 11 | guild_id: str 12 | 13 | @type_check_only 14 | class _BulkMessageDeleteDict(_BaseBulkMessageDeleteDict): 15 | ids: List[str] 16 | channel_id: str 17 | 18 | @type_check_only 19 | class _BaseReactionActionDict(TypedDict): 20 | message_id: str 21 | channel_id: str 22 | user_id: str 23 | emoji: _PartialEmojiDict 24 | 25 | @type_check_only 26 | class _ReactionActionDict(_BaseReactionActionDict, total=False): 27 | guild_id: str 28 | 29 | @type_check_only 30 | class _BaseReactionClearDict(TypedDict): 31 | channel_id: int 32 | message_id: int 33 | 34 | @type_check_only 35 | class _ReactionClearDict(_BaseReactionClearDict, total=False): 36 | guild_id: int 37 | 38 | class _RawReprMixin: ... 39 | 40 | class RawMessageDeleteEvent(_RawReprMixin): 41 | message_id: int 42 | channel_id: int 43 | guild_id: Optional[int] 44 | cached_message: Optional[Message] 45 | def __init__(self, data: _MessageDict) -> None: ... 46 | 47 | class RawBulkMessageDeleteEvent(_RawReprMixin): 48 | message_ids: Set[int] 49 | channel_id: int 50 | guild_id: Optional[int] 51 | cached_messages: List[Message] 52 | def __init__(self, data: _BulkMessageDeleteDict) -> None: ... 53 | 54 | class RawMessageUpdateEvent(_RawReprMixin): 55 | message_id: int 56 | channel_id: int 57 | guild_id: Optional[int] 58 | data: _MessageDict 59 | cached_message: Optional[Message] 60 | def __init__(self, data: _MessageDict) -> None: ... 61 | 62 | class RawReactionActionEvent(_RawReprMixin): 63 | message_id: int 64 | channel_id: int 65 | user_id: int 66 | emoji: PartialEmoji 67 | member: Optional[Member] 68 | event_type: Literal['REACTION_ADD', 'REACTION_REMOVE'] 69 | guild_id: Optional[int] 70 | def __init__( 71 | self, 72 | data: _ReactionActionDict, 73 | emoji: PartialEmoji, 74 | event_type: Literal['REACTION_ADD', 'REACTION_REMOVE'], 75 | ) -> None: ... 76 | 77 | class RawReactionClearEvent(_RawReprMixin): 78 | message_id: int 79 | channel_id: int 80 | guild_id: Optional[int] 81 | def __init__(self, data: _ReactionClearDict) -> None: ... 82 | 83 | class RawReactionClearEmojiEvent(_RawReprMixin): 84 | message_id: int 85 | channel_id: int 86 | guild_id: Optional[int] 87 | emoji: PartialEmoji 88 | def __init__(self, data: _ReactionClearDict, emoji: PartialEmoji) -> None: ... 89 | -------------------------------------------------------------------------------- /discord-stubs/reaction.pyi: -------------------------------------------------------------------------------- 1 | from typing import Any, Optional, Union, type_check_only 2 | from typing_extensions import Protocol, TypedDict 3 | 4 | from .abc import Snowflake 5 | from .emoji import Emoji 6 | from .iterators import ReactionIterator 7 | from .message import Message 8 | from .partial_emoji import PartialEmoji 9 | 10 | @type_check_only 11 | class _RequiredReactionData(TypedDict): 12 | me: bool 13 | 14 | @type_check_only 15 | class _ReactionData(_RequiredReactionData, total=False): 16 | count: int 17 | 18 | @type_check_only 19 | class _UserProtocol(Protocol): 20 | id: int 21 | 22 | class Reaction: 23 | emoji: Union[Emoji, PartialEmoji, str] 24 | count: int 25 | me: bool 26 | message: Message 27 | @property 28 | def custom_emoji(self) -> bool: ... 29 | def __eq__(self, other: Any) -> bool: ... 30 | def __ne__(self, other: Any) -> bool: ... 31 | def __hash__(self) -> int: ... 32 | async def remove(self, user: _UserProtocol) -> None: ... 33 | async def clear(self) -> None: ... 34 | def users( 35 | self, limit: Optional[int] = ..., after: Optional[Snowflake] = ... 36 | ) -> ReactionIterator: ... 37 | -------------------------------------------------------------------------------- /discord-stubs/relationship.pyi: -------------------------------------------------------------------------------- 1 | from .enums import RelationshipType 2 | from .user import User 3 | 4 | class Relationship: 5 | user: User 6 | type: RelationshipType 7 | async def delete(self) -> None: ... 8 | async def accept(self) -> None: ... 9 | -------------------------------------------------------------------------------- /discord-stubs/role.pyi: -------------------------------------------------------------------------------- 1 | import datetime 2 | from typing import Any, List, Optional, Union, overload 3 | 4 | from .colour import Colour 5 | from .guild import Guild 6 | from .member import Member 7 | from .mixins import Hashable 8 | from .permissions import Permissions 9 | 10 | class RoleTags: 11 | bot_id: Optional[int] 12 | integration_id: Optional[int] 13 | def is_bot_managed(self) -> bool: ... 14 | def is_premium_subscriber(self) -> bool: ... 15 | def is_integration(self) -> bool: ... 16 | 17 | class Role(Hashable): 18 | id: int 19 | name: str 20 | guild: Guild 21 | hoist: bool 22 | position: int 23 | managed: bool 24 | mentionable: bool 25 | tags: Optional[RoleTags] 26 | def __lt__(self, other: Any) -> bool: ... 27 | def __le__(self, other: Any) -> bool: ... 28 | def __gt__(self, other: Any) -> bool: ... 29 | def __ge__(self, other: Any) -> bool: ... 30 | def is_default(self) -> bool: ... 31 | def is_bot_managed(self) -> bool: ... 32 | def is_premium_subscriber(self) -> bool: ... 33 | def is_integration(self) -> bool: ... 34 | @property 35 | def permissions(self) -> Permissions: ... 36 | @property 37 | def colour(self) -> Colour: ... 38 | @property 39 | def color(self) -> Colour: ... 40 | @property 41 | def created_at(self) -> datetime.datetime: ... 42 | @property 43 | def mention(self) -> str: ... 44 | @property 45 | def members(self) -> List[Member]: ... 46 | @overload 47 | async def edit( 48 | self, 49 | *, 50 | name: str = ..., 51 | permissions: Permissions = ..., 52 | colour: Union[Colour, int] = ..., 53 | hoist: bool = ..., 54 | mentionable: bool = ..., 55 | position: int = ..., 56 | reason: Optional[str] = ..., 57 | ) -> None: ... 58 | @overload 59 | async def edit( 60 | self, 61 | *, 62 | name: str = ..., 63 | permissions: Permissions = ..., 64 | color: Union[Colour, int] = ..., 65 | hoist: bool = ..., 66 | mentionable: bool = ..., 67 | position: int = ..., 68 | reason: Optional[str] = ..., 69 | ) -> None: ... 70 | async def delete(self, *, reason: Optional[str] = ...) -> None: ... 71 | -------------------------------------------------------------------------------- /discord-stubs/shard.pyi: -------------------------------------------------------------------------------- 1 | import asyncio 2 | from typing import Any, ClassVar, List, Mapping, Optional, Tuple, Union, overload 3 | 4 | import aiohttp 5 | 6 | from .activity import BaseActivity 7 | from .client import Client 8 | from .enums import Status 9 | from .flags import Intents, MemberCacheFlags 10 | from .guild import Guild 11 | from .mentions import AllowedMentions 12 | 13 | class EventType: 14 | close: ClassVar[int] 15 | reconnect: ClassVar[int] 16 | resume: ClassVar[int] 17 | identify: ClassVar[int] 18 | terminate: ClassVar[int] 19 | clean_close: ClassVar[int] 20 | 21 | class Shard: 22 | @property 23 | def id(self) -> int: ... 24 | def launch(self) -> None: ... 25 | async def close(self) -> None: ... 26 | async def disconnect(self) -> None: ... 27 | async def worker(self) -> None: ... 28 | async def reidentify(self, exc: BaseException) -> None: ... 29 | async def reconnect(self) -> None: ... 30 | 31 | class ShardInfo: 32 | id: int 33 | shard_count: Optional[int] 34 | def is_closed(self) -> bool: ... 35 | async def disconnect(self) -> None: ... 36 | async def reconnect(self) -> None: ... 37 | async def connect(self) -> None: ... 38 | @property 39 | def latency(self) -> float: ... 40 | def is_ws_ratelimited(self) -> bool: ... 41 | 42 | class AutoShardedClient(Client): 43 | shard_ids: Optional[Union[List[int], Tuple[int]]] 44 | @overload 45 | def __init__( 46 | self, 47 | *args: Any, 48 | shard_ids: Union[List[int], Tuple[int]], 49 | shard_count: int, 50 | max_messages: Optional[int] = ..., 51 | loop: Optional[asyncio.AbstractEventLoop] = ..., 52 | connector: aiohttp.BaseConnector = ..., 53 | proxy: Optional[str] = ..., 54 | proxy_auth: Optional[aiohttp.BasicAuth] = ..., 55 | intents: Optional[Intents] = ..., 56 | member_cache_flags: Optional[MemberCacheFlags] = ..., 57 | fetch_offline_members: bool = ..., 58 | chunk_guilds_at_startup: bool = ..., 59 | status: Optional[Status] = ..., 60 | activity: Optional[BaseActivity] = ..., 61 | allowed_mentions: Optional[AllowedMentions] = ..., 62 | heartbeat_timeout: float = ..., 63 | guild_ready_timeout: float = ..., 64 | guild_subscriptions: bool = ..., 65 | assume_unsync_clock: bool = ..., 66 | ) -> None: ... 67 | @overload 68 | def __init__( 69 | self, 70 | *args: Any, 71 | shard_ids: None = ..., 72 | shard_count: Optional[int] = ..., 73 | max_messages: Optional[int] = ..., 74 | loop: Optional[asyncio.AbstractEventLoop] = ..., 75 | connector: aiohttp.BaseConnector = ..., 76 | proxy: Optional[str] = ..., 77 | proxy_auth: Optional[aiohttp.BasicAuth] = ..., 78 | intents: Optional[Intents] = ..., 79 | member_cache_flags: Optional[MemberCacheFlags] = ..., 80 | fetch_offline_members: bool = ..., 81 | chunk_guilds_at_startup: bool = ..., 82 | status: Optional[Status] = ..., 83 | activity: Optional[BaseActivity] = ..., 84 | allowed_mentions: Optional[AllowedMentions] = ..., 85 | heartbeat_timeout: float = ..., 86 | guild_ready_timeout: float = ..., 87 | guild_subscriptions: bool = ..., 88 | assume_unsync_clock: bool = ..., 89 | ) -> None: ... 90 | @property 91 | def latency(self) -> float: ... 92 | @property 93 | def latencies(self) -> List[Tuple[int, float]]: ... 94 | def get_shard(self, shard_id: int) -> Optional[ShardInfo]: ... 95 | @property 96 | def shards(self) -> Mapping[int, ShardInfo]: ... 97 | async def request_offline_members(self, *guilds: Guild) -> None: ... 98 | async def launch_shard( 99 | self, gateway: str, shard_id: int, *, initial: bool = ... 100 | ) -> None: ... 101 | async def launch_shards(self) -> None: ... 102 | async def connect(self, *, reconnect: bool = ...) -> None: ... 103 | async def close(self) -> None: ... 104 | async def change_presence( 105 | self, 106 | *, 107 | activity: Optional[BaseActivity] = ..., 108 | status: Optional[Status] = ..., 109 | afk: bool = ..., 110 | shard_id: Optional[int] = ..., 111 | ) -> None: ... 112 | def is_ws_ratelimited(self) -> bool: ... 113 | -------------------------------------------------------------------------------- /discord-stubs/state.pyi: -------------------------------------------------------------------------------- 1 | # NOTE: ConnectionState should never be accessed by the user and is only included 2 | # here in order to be used in Webhook.from_state(). For these reasons, it is declared 3 | # as an opaque structure 4 | 5 | class ConnectionState: ... 6 | class AutoShardedConnectionState(ConnectionState): ... 7 | -------------------------------------------------------------------------------- /discord-stubs/sticker.pyi: -------------------------------------------------------------------------------- 1 | from datetime import datetime 2 | from typing import List, Optional 3 | 4 | from .asset import Asset 5 | from .enums import StickerType 6 | from .mixins import Hashable 7 | 8 | class Sticker(Hashable): 9 | id: int 10 | name: str 11 | description: str 12 | pack_id: int 13 | format: StickerType 14 | image: str 15 | tags: List[str] 16 | preview_image: Optional[str] 17 | @property 18 | def created_at(self) -> datetime: ... 19 | @property 20 | def image_url(self) -> Asset: ... 21 | def image_url_as(self, *, size: int = ...) -> Optional[Asset]: ... 22 | -------------------------------------------------------------------------------- /discord-stubs/team.pyi: -------------------------------------------------------------------------------- 1 | from typing import List, Optional 2 | 3 | from .asset import _VALID_STATIC_ICON_FORMATS, Asset 4 | from .enums import TeamMembershipState 5 | from .user import BaseUser 6 | 7 | class Team: 8 | id: int 9 | name: str 10 | icon: Optional[str] 11 | owner_id: int 12 | members: List[TeamMember] 13 | @property 14 | def icon_url(self) -> Asset: ... 15 | def icon_url_as( 16 | self, *, format: _VALID_STATIC_ICON_FORMATS = ..., size: int = ... 17 | ) -> Asset: ... 18 | @property 19 | def owner(self) -> Optional[TeamMember]: ... 20 | 21 | class TeamMember(BaseUser): 22 | team: Team 23 | membership_state: TeamMembershipState 24 | permissions: List[str] 25 | -------------------------------------------------------------------------------- /discord-stubs/template.pyi: -------------------------------------------------------------------------------- 1 | import datetime 2 | from typing import Any, Optional 3 | 4 | from .enums import VoiceRegion 5 | from .guild import Guild 6 | from .user import User 7 | 8 | class Template: 9 | code: str 10 | uses: int 11 | name: str 12 | description: Optional[str] 13 | creator: User 14 | created_at: Optional[datetime.datetime] 15 | updated_at: Optional[datetime.datetime] 16 | source_guild: Guild 17 | async def create_guild( 18 | self, name: str, region: Optional[VoiceRegion] = ..., icon: Optional[Any] = ... 19 | ) -> Guild: ... 20 | async def sync(self) -> None: ... 21 | async def edit( 22 | self, *, name: str = ..., description: Optional[str] = ... 23 | ) -> None: ... 24 | async def delete(self) -> None: ... 25 | -------------------------------------------------------------------------------- /discord-stubs/user.pyi: -------------------------------------------------------------------------------- 1 | import datetime 2 | from typing import Any, List, NamedTuple, Optional, type_check_only 3 | 4 | import discord.abc 5 | 6 | from .asset import _VALID_ANIMATED_ICON_FORMATS, _VALID_STATIC_ICON_FORMATS, Asset 7 | from .channel import DMChannel, GroupChannel 8 | from .colour import Colour 9 | from .enums import ( 10 | DefaultAvatar, 11 | FriendFlags, 12 | HypeSquadHouse, 13 | PremiumType, 14 | Status, 15 | Theme, 16 | UserContentFilter, 17 | ) 18 | from .flags import PublicUserFlags 19 | from .guild import Guild 20 | from .http import _ClientUserDict 21 | from .message import Message 22 | from .permissions import Permissions 23 | from .relationship import Relationship 24 | 25 | class Profile(NamedTuple): 26 | flags: int 27 | user: User 28 | mutual_guilds: List[Guild] 29 | connected_accounts: List[Any] 30 | premium_since: Optional[datetime.datetime] 31 | @property 32 | def nitro(self) -> bool: ... 33 | @property 34 | def premium(self) -> bool: ... 35 | @property 36 | def staff(self) -> bool: ... 37 | @property 38 | def partner(self) -> bool: ... 39 | @property 40 | def bug_hunter(self) -> bool: ... 41 | @property 42 | def early_supporter(self) -> bool: ... 43 | @property 44 | def hypesquad(self) -> bool: ... 45 | @property 46 | def hypesquad_houses(self) -> List[HypeSquadHouse]: ... 47 | @property 48 | def team_user(self) -> bool: ... 49 | @property 50 | def system(self) -> bool: ... 51 | 52 | # The following is only used in the stubs in order to allow Member to use the 53 | # properties of BaseUser without inheriting from it and creating a false 54 | # positive between BaseUser and Member 55 | @type_check_only 56 | class _CommonUser: 57 | name: str 58 | id: int 59 | discriminator: str 60 | avatar: Optional[str] 61 | bot: bool 62 | system: bool 63 | def __eq__(self, other: Any) -> bool: ... 64 | def __ne__(self, other: Any) -> bool: ... 65 | def __hash__(self) -> int: ... 66 | @property 67 | def public_flags(self) -> PublicUserFlags: ... 68 | @property 69 | def avatar_url(self) -> Asset: ... 70 | def is_avatar_animated(self) -> bool: ... 71 | def avatar_url_as( 72 | self, 73 | *, 74 | format: Optional[_VALID_ANIMATED_ICON_FORMATS] = ..., 75 | static_format: _VALID_STATIC_ICON_FORMATS = ..., 76 | size: int = ..., 77 | ) -> Asset: ... 78 | @property 79 | def default_avatar(self) -> DefaultAvatar: ... 80 | @property 81 | def default_avatar_url(self) -> Asset: ... 82 | @property 83 | def colour(self) -> Colour: ... 84 | @property 85 | def color(self) -> Colour: ... 86 | @property 87 | def mention(self) -> str: ... 88 | def permissions_in(self, channel: discord.abc.GuildChannel) -> Permissions: ... 89 | @property 90 | def created_at(self) -> datetime.datetime: ... 91 | @property 92 | def display_name(self) -> str: ... 93 | def mentioned_in(self, message: Message) -> bool: ... 94 | 95 | class BaseUser(_CommonUser, discord.abc.User): ... 96 | 97 | class ClientUser(BaseUser): 98 | verified: bool 99 | email: Optional[str] 100 | locale: Optional[str] 101 | mfa_enabled: bool 102 | premium: bool 103 | premium_type: Optional[PremiumType] 104 | def get_relationship(self, user_id: int) -> Optional[Relationship]: ... 105 | @property 106 | def relationships(self) -> List[Relationship]: ... 107 | @property 108 | def friends(self) -> List[User]: ... 109 | @property 110 | def blocked(self) -> List[User]: ... 111 | async def edit( 112 | self, 113 | *, 114 | password: str = ..., 115 | new_password: str = ..., 116 | email: str = ..., 117 | username: str = ..., 118 | avatar: bytes = ..., 119 | ) -> None: ... 120 | async def create_group(self, *recipients: User) -> GroupChannel: ... 121 | async def edit_settings( 122 | self, 123 | *, 124 | afk_timeout: int = ..., 125 | animate_emojis: bool = ..., 126 | convert_emoticons: bool = ..., 127 | default_guilds_restricted: bool = ..., 128 | detect_platform_accounts: bool = ..., 129 | developer_mode: bool = ..., 130 | disable_games_tab: bool = ..., 131 | enable_tts_command: bool = ..., 132 | explicit_content_filter: UserContentFilter = ..., 133 | friend_source_flags: FriendFlags = ..., 134 | gif_auto_play: bool = ..., 135 | guild_positions: List[discord.abc.Snowflake] = ..., 136 | inline_attachment_media: bool = ..., 137 | inline_embed_media: bool = ..., 138 | locale: str = ..., 139 | message_display_compact: bool = ..., 140 | render_embeds: bool = ..., 141 | render_reactions: bool = ..., 142 | restricted_guilds: List[discord.abc.Snowflake] = ..., 143 | show_current_game: bool = ..., 144 | status: Status = ..., 145 | theme: Theme = ..., 146 | timezone_offset: int = ..., 147 | ) -> _ClientUserDict: ... 148 | 149 | # The following is only used in the stubs in order to allow Member to use the 150 | # properties of User without inheriting from it and creating a false 151 | # positive between User and Member 152 | @type_check_only 153 | class _User: 154 | @property 155 | def dm_channel(self) -> Optional[DMChannel]: ... 156 | @property 157 | def mutual_guilds(self) -> List[Guild]: ... 158 | async def create_dm(self) -> DMChannel: ... 159 | @property 160 | def relationship(self) -> Optional[Relationship]: ... 161 | async def mutual_friends(self) -> List[User]: ... 162 | def is_friend(self) -> bool: ... 163 | def is_blocked(self) -> bool: ... 164 | async def block(self) -> None: ... 165 | async def unblock(self) -> None: ... 166 | async def remove_friend(self) -> None: ... 167 | async def send_friend_request(self) -> None: ... 168 | async def profile(self) -> Profile: ... 169 | 170 | class User(_User, BaseUser, discord.abc.Messageable): ... 171 | -------------------------------------------------------------------------------- /discord-stubs/utils.pyi: -------------------------------------------------------------------------------- 1 | import asyncio 2 | import datetime 3 | from typing import ( 4 | Any, 5 | Callable, 6 | Coroutine, 7 | Generic, 8 | Iterable, 9 | List, 10 | Optional, 11 | Pattern, 12 | Sequence, 13 | Set, 14 | Type, 15 | TypeVar, 16 | Union, 17 | overload, 18 | ) 19 | from typing_extensions import Final 20 | 21 | from aiohttp.web import Request 22 | 23 | from .guild import Guild 24 | from .invite import Invite 25 | from .permissions import Permissions 26 | from .template import Template 27 | 28 | _T = TypeVar('_T') 29 | _U_co = TypeVar('_U_co', covariant=True) 30 | 31 | _FuncType = Callable[..., Any] 32 | _F = TypeVar('_F', bound=_FuncType) 33 | 34 | DISCORD_EPOCH: Final[int] 35 | 36 | class cached_property(Generic[_T, _U_co]): 37 | def __init__(self, function: Callable[[_T], _U_co]) -> None: ... 38 | @overload 39 | def __get__(self, instance: _T, owner: Type[_T]) -> _U_co: ... 40 | @overload 41 | def __get__( 42 | self, instance: None, owner: Type[_T] 43 | ) -> cached_property[_T, _U_co]: ... 44 | 45 | class CachedSlotProperty(Generic[_T, _U_co]): 46 | def __init__(self, name: str, function: Callable[[_T], _U_co]) -> None: ... 47 | @overload 48 | def __get__(self, instance: _T, owner: Type[_T]) -> _U_co: ... 49 | @overload 50 | def __get__( 51 | self, instance: None, owner: Type[_T] 52 | ) -> CachedSlotProperty[_T, _U_co]: ... 53 | 54 | def cached_slot_property( 55 | name: str, 56 | ) -> Callable[[Callable[[_T], _U_co]], CachedSlotProperty[_T, _U_co]]: ... 57 | 58 | class SequenceProxy(Sequence[_T]): 59 | def __init__(self, proxied: Sequence[_T]) -> None: ... 60 | @overload 61 | def __getitem__(self, i: int) -> _T: ... 62 | @overload 63 | def __getitem__(self, s: slice) -> Sequence[_T]: ... 64 | def __len__(self) -> int: ... 65 | def index(self, value: _T, start: int = ..., end: int = ...) -> int: ... 66 | def count(self, value: _T) -> int: ... 67 | 68 | def parse_time(timestamp: Optional[str]) -> Optional[datetime.datetime]: ... 69 | def copy_doc(original: _F) -> Callable[[Callable[..., Any]], _F]: ... 70 | def deprecated(instead: Optional[str] = ...) -> Callable[[_F], _F]: ... 71 | def oauth_url( 72 | client_id: str, 73 | permissions: Optional[Permissions] = ..., 74 | guild: Optional[Guild] = ..., 75 | redirect_uri: Optional[str] = ..., 76 | scopes: Optional[Iterable[str]] = ..., 77 | ) -> str: ... 78 | def snowflake_time(id: int) -> datetime.datetime: ... 79 | def time_snowflake(datetime_obj: datetime.datetime, high: bool = ...) -> int: ... 80 | def find(predicate: Callable[[_T], bool], seq: Iterable[_T]) -> Optional[_T]: ... 81 | def get(iterable: Iterable[_T], **attrs: Any) -> Optional[_T]: ... 82 | def _unique(iterable: Iterable[_T]) -> List[_T]: ... 83 | def _get_as_snowflake(data: Any, key: str) -> Optional[int]: ... 84 | def _get_mime_type_for_image(data: Union[bytes, bytearray]) -> str: ... 85 | def _bytes_to_base64_data(data: Union[bytes, bytearray]) -> str: ... 86 | def to_json(obj: Any) -> str: ... 87 | def _parse_ratelimit_header(request: Request, *, use_clock: bool = ...) -> float: ... 88 | async def maybe_coroutine( 89 | f: Callable[..., Union[_T, Coroutine[Any, Any, _T]]], *args: Any, **kwargs: Any 90 | ) -> _T: ... 91 | async def async_all( 92 | gen: Iterable[Union[Any, Coroutine[Any, Any, Any]]], 93 | *, 94 | check: Callable[[Any], bool] = ..., 95 | ) -> bool: ... 96 | async def sane_wait_for( 97 | futures: List[asyncio.Future[_T]], *, timeout: float 98 | ) -> Set[asyncio.Future[_T]]: ... 99 | @overload 100 | async def sleep_until(when: datetime.datetime) -> None: ... 101 | @overload 102 | async def sleep_until(when: datetime.datetime, result: _T) -> _T: ... 103 | def valid_icon_size(size: int) -> bool: ... 104 | def _string_width(string: str, *, _IS_ASCII: Pattern[str] = ...) -> int: ... 105 | def resolve_invite(invite: Union[Invite, str]) -> str: ... 106 | def resolve_template(code: Union[Template, str]) -> str: ... 107 | def remove_markdown(text: str, *, ignore_links: bool = ...) -> str: ... 108 | def escape_markdown( 109 | text: str, *, as_needed: bool = ..., ignore_links: bool = ... 110 | ) -> str: ... 111 | def escape_mentions(text: str) -> str: ... 112 | -------------------------------------------------------------------------------- /discord-stubs/voice_client.pyi: -------------------------------------------------------------------------------- 1 | import asyncio 2 | from typing import Any, Callable, ClassVar, Dict, Optional, Tuple 3 | 4 | from .abc import Connectable 5 | from .channel import VoiceChannel 6 | from .client import Client 7 | from .gateway import DiscordVoiceWebSocket 8 | from .guild import Guild 9 | from .player import AudioSource 10 | from .user import ClientUser 11 | 12 | class VoiceProtocol: 13 | client: Client 14 | channel: Connectable 15 | def __init__(self, client: Client, channel: Connectable) -> None: ... 16 | async def on_voice_state_update(self, data: Dict[str, Any]) -> None: ... 17 | async def on_voice_server_update(self, data: Dict[str, Any]) -> None: ... 18 | async def connect(self, *, timeout: float, reconnect: bool) -> None: ... 19 | async def disconnect(self, *, force: bool) -> None: ... 20 | def cleanup(self) -> None: ... 21 | 22 | class VoiceClient(VoiceProtocol): 23 | warn_nacl: ClassVar[bool] 24 | supported_modes: ClassVar[Tuple[str, ...]] 25 | 26 | session_id: str 27 | token: str 28 | endpoint: str 29 | channel: Connectable 30 | loop: asyncio.AbstractEventLoop 31 | source: Optional[AudioSource] 32 | @property 33 | def guild(self) -> Optional[Guild]: ... 34 | @property 35 | def user(self) -> ClientUser: ... 36 | def checked_add(self, attr: str, value: int, limit: int) -> None: ... 37 | async def on_voice_state_update(self, data: Dict[str, Any]) -> None: ... 38 | async def on_voice_server_update(self, data: Dict[str, Any]) -> None: ... 39 | async def voice_connect(self) -> None: ... 40 | async def voice_disconnect(self) -> None: ... 41 | def prepare_handshake(self) -> None: ... 42 | def finish_handshake(self) -> None: ... 43 | async def connect_websocket(self) -> DiscordVoiceWebSocket: ... 44 | async def connect(self, *, timeout: float, reconnect: bool) -> None: ... 45 | async def potential_reconnect(self) -> bool: ... 46 | @property 47 | def latency(self) -> float: ... 48 | @property 49 | def average_latency(self) -> float: ... 50 | async def poll_voice_ws(self, reconnect: bool) -> None: ... 51 | async def disconnect(self, *, force: bool = ...) -> None: ... 52 | async def move_to(self, channel: VoiceChannel) -> None: ... 53 | def is_connected(self) -> bool: ... 54 | def play( 55 | self, 56 | source: AudioSource, 57 | *, 58 | after: Optional[Callable[[Optional[Exception]], None]] = ..., 59 | ) -> None: ... 60 | def is_playing(self) -> bool: ... 61 | def is_paused(self) -> bool: ... 62 | def stop(self) -> None: ... 63 | def pause(self) -> None: ... 64 | def resume(self) -> None: ... 65 | def send_audio_packet(self, data: bytes, *, encode: bool = ...) -> None: ... 66 | -------------------------------------------------------------------------------- /discord-stubs/webhook.pyi: -------------------------------------------------------------------------------- 1 | import asyncio 2 | import datetime 3 | from typing import ( 4 | Any, 5 | ClassVar, 6 | Coroutine, 7 | Dict, 8 | Generic, 9 | Iterable, 10 | Optional, 11 | Type, 12 | TypeVar, 13 | Union, 14 | overload, 15 | ) 16 | from typing_extensions import Literal 17 | 18 | import aiohttp 19 | 20 | from .abc import User as _ABCUser 21 | from .asset import Asset 22 | from .channel import TextChannel 23 | from .embeds import Embed 24 | from .enums import WebhookType 25 | from .file import File 26 | from .guild import Guild 27 | from .http import _WebhookDict 28 | from .mentions import AllowedMentions 29 | from .message import Message 30 | from .mixins import Hashable 31 | from .state import ConnectionState 32 | 33 | _T = TypeVar('_T') 34 | 35 | _AsyncNone = Coroutine[Any, Any, None] 36 | _AsyncOptionalMessage = Coroutine[Any, Any, Optional[WebhookMessage[_AsyncNone]]] 37 | 38 | _N = TypeVar('_N', bound=Union[_AsyncNone, None]) 39 | _M = TypeVar('_M', bound=Union[_AsyncOptionalMessage, Optional[WebhookMessage[None]]]) 40 | 41 | class WebhookAdapter(Generic[_N, _M]): 42 | BASE: ClassVar[str] 43 | 44 | webhook: Webhook[_N, _M] 45 | def is_async(self) -> bool: ... 46 | def request( 47 | self, 48 | verb: str, 49 | url: str, 50 | payload: Optional[Dict[str, Any]] = ..., 51 | multipart: Optional[Dict[str, Any]] = ..., 52 | ) -> Any: ... 53 | def delete_webhook(self, *, reason: Optional[str] = ...) -> _N: ... 54 | def edit_webhook( 55 | self, 56 | *, 57 | reason: Optional[str] = ..., 58 | **payload: Any, 59 | ) -> _N: ... 60 | def edit_webhook_message(self, message_id: int, payload: Any) -> _N: ... 61 | def delete_webhook_message(self, message_id: int) -> _N: ... 62 | def handle_execution_response( 63 | self, 64 | response: Any, 65 | *, 66 | wait: bool, 67 | ) -> _M: ... 68 | def execute_webhook( 69 | self, 70 | *, 71 | payload: Dict[str, Any], 72 | wait: bool = ..., 73 | file: Optional[File] = ..., 74 | files: Optional[Iterable[File]] = ..., 75 | ) -> _M: ... 76 | 77 | class AsyncWebhookAdapter(WebhookAdapter[_AsyncNone, _AsyncOptionalMessage]): 78 | session: aiohttp.ClientSession 79 | loop: asyncio.AbstractEventLoop 80 | def __init__(self, session: aiohttp.ClientSession) -> None: ... 81 | def is_async(self) -> bool: ... 82 | async def request( 83 | self, 84 | verb: str, 85 | url: str, 86 | payload: Optional[Dict[str, Any]] = ..., 87 | multipart: Optional[Dict[str, Any]] = ..., 88 | *, 89 | files: Optional[Iterable[File]] = ..., 90 | reason: Optional[str] = ..., 91 | ) -> Optional[WebhookMessage[_AsyncNone]]: ... 92 | 93 | class RequestsWebhookAdapter(WebhookAdapter[None, WebhookMessage[None]]): 94 | session: Any 95 | def __init__(self, session: Optional[Any] = ..., *, sleep: bool = ...) -> None: ... 96 | def request( 97 | self, 98 | verb: str, 99 | url: str, 100 | payload: Optional[Dict[str, Any]] = ..., 101 | multipart: Optional[Dict[str, Any]] = ..., 102 | *, 103 | files: Optional[Iterable[File]] = ..., 104 | reason: Optional[str] = ..., 105 | ) -> WebhookMessage[None]: ... 106 | 107 | class WebhookMessage(Message, Generic[_N]): 108 | @overload # type: ignore[override] 109 | def edit( 110 | self, 111 | *, 112 | content: Optional[str] = ..., 113 | embed: Optional[Embed] = ..., 114 | allowed_mentions: Optional[AllowedMentions] = ..., 115 | ) -> _N: ... 116 | @overload 117 | def edit( 118 | self, 119 | *, 120 | content: Optional[str] = ..., 121 | embeds: Optional[Embed] = ..., 122 | allowed_mentions: Optional[AllowedMentions] = ..., 123 | ) -> _N: ... 124 | 125 | class Webhook(Hashable, Generic[_N, _M]): 126 | _TWebhook = TypeVar('_TWebhook', bound='Webhook[_N, _M]') 127 | _TAsyncWebhook = TypeVar( 128 | '_TAsyncWebhook', bound='Webhook[_AsyncNone, _AsyncOptionalMessage]' 129 | ) 130 | 131 | id: int 132 | type: WebhookType 133 | token: Optional[str] 134 | channel_id: Optional[int] 135 | guild_id: Optional[int] 136 | name: Optional[str] 137 | avatar: Optional[str] 138 | user: Optional[_ABCUser] 139 | @property 140 | def url(self) -> str: ... 141 | @classmethod 142 | def partial( 143 | cls: Type[_TWebhook], id: int, token: str, *, adapter: WebhookAdapter[_N, _M] 144 | ) -> _TWebhook: ... 145 | @classmethod 146 | def from_url( 147 | cls: Type[_TWebhook], url: str, *, adapter: WebhookAdapter[_N, _M] 148 | ) -> _TWebhook: ... 149 | # NOTE: While this method is public, it should never be invoked by users. 150 | @classmethod 151 | def from_state( 152 | cls: Type[_TAsyncWebhook], data: _WebhookDict, state: ConnectionState 153 | ) -> _TAsyncWebhook: ... 154 | @property 155 | def guild(self) -> Optional[Guild]: ... 156 | @property 157 | def channel(self) -> Optional[TextChannel]: ... 158 | @property 159 | def created_at(self) -> datetime.datetime: ... 160 | @property 161 | def avatar_url(self) -> Asset: ... 162 | def avatar_url_as( 163 | self, *, format: Optional[Literal['png', 'jpg', 'jpeg']] = ..., size: int = ... 164 | ) -> Asset: ... 165 | def delete(self, *, reason: Optional[str] = ...) -> _N: ... 166 | def edit( 167 | self, 168 | *, 169 | reason: Optional[str] = ..., 170 | name: Optional[str] = ..., 171 | avatar: Optional[bytes] = ..., 172 | ) -> _N: ... 173 | @overload 174 | def send( 175 | self, 176 | content: str, 177 | *, 178 | wait: bool = ..., 179 | username: Optional[str] = ..., 180 | avatar_url: Optional[Union[str, Asset]] = ..., 181 | tts: bool = ..., 182 | file: Optional[File] = ..., 183 | embed: Optional[Embed] = ..., 184 | allowed_mentions: Optional[AllowedMentions] = ..., 185 | ) -> _M: ... 186 | @overload 187 | def send( 188 | self, 189 | content: str, 190 | *, 191 | wait: bool = ..., 192 | username: Optional[str] = ..., 193 | avatar_url: Optional[Union[str, Asset]] = ..., 194 | tts: bool = ..., 195 | file: Optional[File] = ..., 196 | embeds: Optional[Iterable[Embed]] = ..., 197 | allowed_mentions: Optional[AllowedMentions] = ..., 198 | ) -> _M: ... 199 | @overload 200 | def send( 201 | self, 202 | content: str, 203 | *, 204 | wait: bool = ..., 205 | username: Optional[str] = ..., 206 | avatar_url: Optional[Union[str, Asset]] = ..., 207 | tts: bool = ..., 208 | files: Optional[Iterable[File]] = ..., 209 | embed: Optional[Embed] = ..., 210 | allowed_mentions: Optional[AllowedMentions] = ..., 211 | ) -> _M: ... 212 | @overload 213 | def send( 214 | self, 215 | content: str, 216 | *, 217 | wait: bool = ..., 218 | username: Optional[str] = ..., 219 | avatar_url: Optional[Union[str, Asset]] = ..., 220 | tts: bool = ..., 221 | files: Optional[Iterable[File]] = ..., 222 | embeds: Optional[Iterable[Embed]] = ..., 223 | allowed_mentions: Optional[AllowedMentions] = ..., 224 | ) -> _M: ... 225 | @overload 226 | def send( 227 | self, 228 | content: Optional[str] = ..., 229 | *, 230 | wait: bool = ..., 231 | username: Optional[str] = ..., 232 | avatar_url: Optional[Union[str, Asset]] = ..., 233 | tts: bool = ..., 234 | file: File, 235 | embed: Optional[Embed] = ..., 236 | allowed_mentions: Optional[AllowedMentions] = ..., 237 | ) -> _M: ... 238 | @overload 239 | def send( 240 | self, 241 | content: Optional[str] = ..., 242 | *, 243 | wait: bool = ..., 244 | username: Optional[str] = ..., 245 | avatar_url: Optional[Union[str, Asset]] = ..., 246 | tts: bool = ..., 247 | file: File, 248 | embeds: Optional[Iterable[Embed]] = ..., 249 | allowed_mentions: Optional[AllowedMentions] = ..., 250 | ) -> _M: ... 251 | @overload 252 | def send( 253 | self, 254 | content: Optional[str] = ..., 255 | *, 256 | wait: bool = ..., 257 | username: Optional[str] = ..., 258 | avatar_url: Optional[Union[str, Asset]] = ..., 259 | tts: bool = ..., 260 | files: Iterable[File], 261 | embed: Optional[Embed] = ..., 262 | allowed_mentions: Optional[AllowedMentions] = ..., 263 | ) -> _M: ... 264 | @overload 265 | def send( 266 | self, 267 | content: Optional[str] = ..., 268 | *, 269 | wait: bool = ..., 270 | username: Optional[str] = ..., 271 | avatar_url: Optional[Union[str, Asset]] = ..., 272 | tts: bool = ..., 273 | files: Iterable[File], 274 | embeds: Optional[Iterable[Embed]] = ..., 275 | allowed_mentions: Optional[AllowedMentions] = ..., 276 | ) -> _M: ... 277 | @overload 278 | def send( 279 | self, 280 | content: Optional[str] = ..., 281 | *, 282 | wait: bool = ..., 283 | username: Optional[str] = ..., 284 | avatar_url: Optional[Union[str, Asset]] = ..., 285 | tts: bool = ..., 286 | file: Optional[File] = ..., 287 | embed: Embed, 288 | allowed_mentions: Optional[AllowedMentions] = ..., 289 | ) -> _M: ... 290 | @overload 291 | def send( 292 | self, 293 | content: Optional[str] = ..., 294 | *, 295 | wait: bool = ..., 296 | username: Optional[str] = ..., 297 | avatar_url: Optional[Union[str, Asset]] = ..., 298 | tts: bool = ..., 299 | files: Optional[Iterable[File]] = ..., 300 | embed: Embed, 301 | allowed_mentions: Optional[AllowedMentions] = ..., 302 | ) -> _M: ... 303 | @overload 304 | def send( 305 | self, 306 | content: Optional[str] = ..., 307 | *, 308 | wait: bool = ..., 309 | username: Optional[str] = ..., 310 | avatar_url: Optional[Union[str, Asset]] = ..., 311 | tts: bool = ..., 312 | file: Optional[File] = ..., 313 | embeds: Iterable[Embed], 314 | allowed_mentions: Optional[AllowedMentions] = ..., 315 | ) -> _M: ... 316 | @overload 317 | def send( 318 | self, 319 | content: Optional[str] = ..., 320 | *, 321 | wait: bool = ..., 322 | username: Optional[str] = ..., 323 | avatar_url: Optional[Union[str, Asset]] = ..., 324 | tts: bool = ..., 325 | files: Optional[Iterable[File]] = ..., 326 | embeds: Iterable[Embed], 327 | allowed_mentions: Optional[AllowedMentions] = ..., 328 | ) -> _M: ... 329 | execute = send 330 | @overload 331 | def edit_message( 332 | self, 333 | message_id: int, 334 | *, 335 | content: Optional[str] = ..., 336 | embed: Optional[Embed] = ..., 337 | allowed_mentions: Optional[AllowedMentions] = ..., 338 | ) -> _N: ... 339 | @overload 340 | def edit_message( 341 | self, 342 | message_id: int, 343 | *, 344 | content: Optional[str] = ..., 345 | embeds: Optional[Embed] = ..., 346 | allowed_mentions: Optional[AllowedMentions] = ..., 347 | ) -> _N: ... 348 | def delete_message(self, message_id: int) -> _N: ... 349 | 350 | _AsyncWebhook = Webhook[_AsyncNone, _AsyncOptionalMessage] 351 | -------------------------------------------------------------------------------- /discord-stubs/widget.pyi: -------------------------------------------------------------------------------- 1 | from datetime import datetime 2 | from typing import Any, List, Optional, Union 3 | 4 | from .activity import BaseActivity, Spotify 5 | from .channel import VoiceChannel 6 | from .enums import Status 7 | from .invite import Invite 8 | from .user import BaseUser 9 | 10 | class WidgetChannel: 11 | id: int 12 | name: str 13 | position: int 14 | @property 15 | def mention(self) -> str: ... 16 | @property 17 | def created_at(self) -> datetime: ... 18 | 19 | class WidgetMember(BaseUser): 20 | id: int 21 | status: Status 22 | nick: Optional[str] 23 | activity: Optional[Union[BaseActivity, Spotify]] 24 | deafened: Optional[bool] 25 | muted: Optional[bool] 26 | suppress: Optional[bool] 27 | connected_channel: Optional[VoiceChannel] 28 | @property 29 | def display_name(self) -> str: ... 30 | 31 | class Widget: 32 | id: int 33 | name: str 34 | channels: Optional[List[WidgetChannel]] 35 | members: Optional[List[WidgetMember]] 36 | def __eq__(self, other: Any) -> bool: ... 37 | @property 38 | def created_at(self) -> datetime: ... 39 | @property 40 | def json_url(self) -> str: ... 41 | @property 42 | def invite_url(self) -> Optional[str]: ... 43 | async def fetch_invite(self, *, with_counts: bool = ...) -> Optional[Invite]: ... 44 | -------------------------------------------------------------------------------- /fix-site-packages.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | PWD="$(pwd)" 4 | PYTHON_VERSION="$1" 5 | POETRY_ENV="$(poetry env info -p)" 6 | SITE_PACKAGES="$(find ${POETRY_ENV}/lib -maxdepth 1 -mindepth 1 -type d -name python* -print0 -quit)/site-packages" 7 | SRC_DIR="${POETRY_ENV}/src" 8 | 9 | OUTPUT="${PWD}" 10 | 11 | if [ -d "${SRC_DIR}" ]; then 12 | OUTPUT="$(find ${SRC_DIR} -maxdepth 1 -mindepth 1 -type d -print)\n${OUTPUT}" 13 | OUTPUT="${OUTPUT//botus-receptus/botus-receptus/src}" 14 | fi 15 | 16 | echo -e "$OUTPUT" >| "$SITE_PACKAGES/easy-install.pth" 17 | -------------------------------------------------------------------------------- /mypy.ini: -------------------------------------------------------------------------------- 1 | [mypy] 2 | incremental = True 3 | strict = True 4 | namespace_packages = True 5 | -------------------------------------------------------------------------------- /pyproject.toml: -------------------------------------------------------------------------------- 1 | [tool.poetry] 2 | name = "discord.py-stubs" 3 | version = "1.7.4dev0" 4 | description = "discord.py stubs" 5 | homepage = "https://github.com/bryanforbes/discord.py-stubs" 6 | authors = ["Bryan Forbes "] 7 | license = "BSD-3-Clause" 8 | readme = "README.md" 9 | packages = [ 10 | { include = "discord-stubs" } 11 | ] 12 | classifiers = [ 13 | "Development Status :: 4 - Beta", 14 | "Intended Audience :: Developers", 15 | "Typing :: Typed" 16 | ] 17 | 18 | [tool.poetry.dependencies] 19 | python = "^3.6.2" 20 | "discord.py" = "~1.7.0" 21 | mypy = ">=0.800" 22 | typing-extensions = "^3.7.4" 23 | 24 | [tool.poetry.dev-dependencies] 25 | black = "^21.7b0" 26 | flake8 = "^3.9.2" 27 | flake8-pyi = "^20.10.0" 28 | isort = "^5.9.3" 29 | pre-commit = "^2.14.0" 30 | pytest = "^6.2.4" 31 | pytest-mypy-plugins = "^1.9.3" 32 | 33 | [tool.black] 34 | line-length = 88 35 | target-version = ["py36", "py37", "py38"] 36 | skip-string-normalization = true 37 | include = '\.pyi?$' 38 | exclude = ''' 39 | /( 40 | \.git 41 | | \.hg 42 | | \.mypy_cache 43 | | \.pytest_cache 44 | | \.venv 45 | | external 46 | )/ 47 | ''' 48 | 49 | [tool.isort] 50 | known_first_party = ["discord"] 51 | extra_standard_library = ["typing_extensions"] 52 | virtual_env = ".venv" 53 | profile = "black" 54 | 55 | [tool.pytest.ini_options] 56 | minversion = "6.0" 57 | addopts = "--mypy-ini-file=test-data/mypy.ini" 58 | testpaths = ["test-data"] 59 | 60 | [build-system] 61 | requires = ["poetry_core>=1.0.0"] 62 | build-backend = "poetry.core.masonry.api" 63 | -------------------------------------------------------------------------------- /test-data/mypy.ini: -------------------------------------------------------------------------------- 1 | [mypy] 2 | incremental = True 3 | strict = True 4 | namespace_packages = True 5 | 6 | [mypy-aiohttp.*] 7 | ignore_errors = True 8 | 9 | [mypy-async_timeout.*] 10 | ignore_errors = True 11 | 12 | [mypy-attr.*] 13 | ignore_errors = True 14 | -------------------------------------------------------------------------------- /test-data/test_bot.yml: -------------------------------------------------------------------------------- 1 | - case: bot_custom_context 2 | main: | 3 | import random 4 | from typing import TYPE_CHECKING, Any, Type, TypeVar, Union, cast, overload 5 | 6 | import discord 7 | from discord.ext import commands 8 | 9 | if TYPE_CHECKING: 10 | Bot = commands.Bot['MyContext'] 11 | else: 12 | Bot = commands.Bot 13 | 14 | 15 | CT = TypeVar('CT', bound='MyContext') 16 | OT = TypeVar('OT', bound=commands.Context) 17 | 18 | 19 | class MyContext(commands.Context): 20 | async def tick(self, value: int) -> None: 21 | emoji = '\N{WHITE HEAVY CHECK MARK}' if value else '\N{CROSS MARK}' 22 | try: 23 | await self.message.add_reaction(emoji) 24 | except discord.HTTPException: 25 | pass 26 | 27 | 28 | class MyBot(Bot): 29 | @overload 30 | async def get_context(self, message: discord.Message) -> MyContext: 31 | ... 32 | 33 | @overload 34 | async def get_context(self, message: discord.Message, *, cls: Type[OT]) -> OT: 35 | ... 36 | 37 | async def get_context( 38 | self, message: discord.Message, *, cls: Type[OT] = cast(Any, MyContext) 39 | ) -> Union[MyContext, OT]: 40 | return await super().get_context(message, cls=cls) 41 | 42 | 43 | bot = MyBot(command_prefix='!') 44 | 45 | 46 | @bot.command() 47 | async def guess(ctx: MyContext, number: int) -> None: 48 | """ Guess a random number from 1 to 6. """ 49 | value = random.randint(1, 6) 50 | await ctx.tick(number == value) 51 | 52 | 53 | bot.run('your token here') 54 | 55 | - case: bot_basic 56 | main: | 57 | import random 58 | 59 | import discord 60 | from discord.ext import commands 61 | 62 | description = '''An example bot to showcase the discord.ext.commands extension 63 | module. 64 | There are a number of utility commands being showcased here.''' 65 | bot = commands.Bot(command_prefix='?', description=description) 66 | 67 | reveal_type(bot) # N: Revealed type is "discord.ext.commands.bot.Bot[discord.ext.commands.context.Context]" 68 | 69 | 70 | @bot.event 71 | async def on_ready() -> None: 72 | print('Logged in as') 73 | print(bot.user.name) 74 | print(bot.user.id) 75 | print('------') 76 | 77 | 78 | @bot.command() 79 | async def add(ctx: commands.Context, left: int, right: int) -> None: 80 | """Adds two numbers together.""" 81 | await ctx.send(left + right) 82 | 83 | 84 | @bot.command() 85 | async def roll(ctx: commands.Context, dice: str) -> None: 86 | """Rolls a dice in NdN format.""" 87 | try: 88 | rolls, limit = map(int, dice.split('d')) 89 | except Exception: 90 | await ctx.send('Format has to be in NdN!') 91 | return 92 | 93 | result = ', '.join(str(random.randint(1, limit)) for r in range(rolls)) 94 | await ctx.send(result) 95 | 96 | 97 | @bot.command(description='For when you wanna settle the score some other way') 98 | async def choose(ctx: commands.Context, *choices: str) -> None: 99 | """Chooses between multiple choices.""" 100 | await ctx.send(random.choice(choices)) 101 | 102 | 103 | @bot.command() 104 | async def repeat( 105 | ctx: commands.Context, times: int, content: str = 'repeating...' 106 | ) -> None: 107 | """Repeats a message multiple times.""" 108 | for i in range(times): 109 | await ctx.send(content) 110 | 111 | 112 | @bot.command() 113 | async def joined(ctx: commands.Context, member: discord.Member) -> None: 114 | """Says when a member joined.""" 115 | await ctx.send(f'{member.name} joined in {member.joined_at}') 116 | 117 | 118 | @bot.group() 119 | async def cool(ctx: commands.Context) -> None: 120 | """Says if a user is cool. 121 | In reality this just checks if a subcommand is being invoked. 122 | """ 123 | if ctx.invoked_subcommand is None: 124 | await ctx.send('No, {ctx.subcommand_passed} is not cool') 125 | 126 | 127 | @cool.command(name='bot') 128 | async def _bot(ctx: commands.Context) -> None: 129 | """Is the bot cool?""" 130 | await ctx.send('Yes, the bot is cool.') 131 | 132 | 133 | bot.run('token') 134 | - case: bot_intents 135 | main: | 136 | import random 137 | from typing import TYPE_CHECKING, Any, Type, TypeVar, Union, cast, overload 138 | 139 | import discord 140 | from discord.ext import commands 141 | 142 | if TYPE_CHECKING: 143 | Bot = commands.Bot['MyContext'] 144 | else: 145 | Bot = commands.Bot 146 | 147 | 148 | CT = TypeVar('CT', bound='MyContext') 149 | OT = TypeVar('OT', bound=commands.Context) 150 | 151 | 152 | class MyContext(commands.Context): 153 | async def tick(self, value: int) -> None: 154 | emoji = '\N{WHITE HEAVY CHECK MARK}' if value else '\N{CROSS MARK}' 155 | try: 156 | await self.message.add_reaction(emoji) 157 | except discord.HTTPException: 158 | pass 159 | 160 | 161 | class MyBot(Bot): 162 | @overload 163 | async def get_context(self, message: discord.Message) -> MyContext: 164 | ... 165 | 166 | @overload 167 | async def get_context(self, message: discord.Message, *, cls: Type[OT]) -> OT: 168 | ... 169 | 170 | async def get_context( 171 | self, message: discord.Message, *, cls: Type[OT] = cast(Any, MyContext) 172 | ) -> Union[MyContext, OT]: 173 | return await super().get_context(message, cls=cls) 174 | 175 | 176 | bot = MyBot(command_prefix='!', intents=discord.Intents.all()) 177 | 178 | 179 | @bot.command() 180 | async def guess(ctx: MyContext, number: int) -> None: 181 | """ Guess a random number from 1 to 6. """ 182 | value = random.randint(1, 6) 183 | await ctx.tick(number == value) 184 | 185 | 186 | bot.run('your token here') 187 | -------------------------------------------------------------------------------- /test-data/test_client.yml: -------------------------------------------------------------------------------- 1 | - case: client_deleted 2 | main: | 3 | import discord 4 | 5 | class MyClient(discord.Client): 6 | async def on_ready(self) -> None: 7 | print('Connected!') 8 | print(f'Username: {self.user.name}\nID: {self.user.id}') 9 | 10 | async def on_message(self, message: discord.Message) -> None: 11 | if message.content.startswith('!deleteme'): 12 | msg = await message.channel.send('I will delete myself now...') 13 | await msg.delete() 14 | 15 | # this also works 16 | await message.channel.send('Goodbye in 3 seconds...', delete_after=3.0) 17 | 18 | async def on_message_delete(self, message: discord.Message) -> None: 19 | await message.channel.send(f'{message.author} has deleted the message: {message.content}') 20 | 21 | client = MyClient() 22 | client.run('token') 23 | 24 | - case: client_edits 25 | main: | 26 | import discord 27 | import asyncio 28 | 29 | class MyClient(discord.Client): 30 | async def on_ready(self) -> None: 31 | print('Connected!') 32 | print(f'Username: {self.user.name}\nID: {self.user.id}') 33 | 34 | async def on_message(self, message: discord.Message) -> None: 35 | if message.content.startswith('!editme'): 36 | msg = await message.channel.send('10') 37 | await asyncio.sleep(3.0) 38 | await msg.edit(content='40') 39 | 40 | async def on_message_edit(self, before: discord.Message, after: discord.Message) -> None: 41 | fmt = f'**{before.author}** edited their message:\n{before.content} -> {after.content}' 42 | await before.channel.send(fmt) 43 | 44 | client = MyClient() 45 | client.run('token') 46 | 47 | - case: client_guessing_game 48 | main: | 49 | import discord 50 | import random 51 | import asyncio 52 | 53 | class MyClient(discord.Client): 54 | async def on_ready(self) -> None: 55 | print('Logged in as') 56 | print(self.user.name) 57 | print(self.user.id) 58 | print('------') 59 | 60 | async def on_message(self, message: discord.Message) -> None: 61 | # we do not want the bot to reply to itself 62 | if message.author.id == self.user.id: 63 | return 64 | 65 | if message.content.startswith('$guess'): 66 | await message.channel.send('Guess a number between 1 and 10.') 67 | 68 | def is_correct(m: discord.Message) -> bool: 69 | return m.author == message.author and m.content.isdigit() 70 | 71 | answer = random.randint(1, 10) 72 | 73 | try: 74 | guess = await self.wait_for('message', check=is_correct, timeout=5.0) 75 | except asyncio.TimeoutError: 76 | await message.channel.send(f'Sorry, you took too long it was {answer}.') 77 | return 78 | 79 | if int(guess.content) == answer: 80 | await message.channel.send('You are right!') 81 | else: 82 | await message.channel.send(f'Oops. It is actually {answer}.') 83 | 84 | client = MyClient() 85 | client.run('token') 86 | 87 | - case: client_new_member 88 | main: | 89 | import discord 90 | 91 | class MyClient(discord.Client): 92 | async def on_ready(self) -> None: 93 | print('Logged in as') 94 | print(self.user.name) 95 | print(self.user.id) 96 | print('------') 97 | 98 | async def on_member_join(self, member: discord.Member) -> None: 99 | guild = member.guild 100 | if guild.system_channel is not None: 101 | to_send = f'Welcome {member.mention} to {guild.name}!' 102 | await guild.system_channel.send(to_send) 103 | 104 | 105 | client = MyClient() 106 | client.run('token') 107 | 108 | - case: client_reply 109 | main: | 110 | import discord 111 | 112 | class MyClient(discord.Client): 113 | async def on_ready(self) -> None: 114 | print('Logged in as') 115 | print(self.user.name) 116 | print(self.user.id) 117 | print('------') 118 | 119 | async def on_message(self, message: discord.Message) -> None: 120 | # we do not want the bot to reply to itself 121 | if message.author.id == self.user.id: 122 | return 123 | 124 | if message.content.startswith('!hello'): 125 | await message.channel.send(f'Hello {message.author.mention}') 126 | 127 | client = MyClient() 128 | client.run('token') 129 | 130 | - case: client_background_task 131 | main: | 132 | import asyncio 133 | import discord 134 | import typing 135 | 136 | class MyClient(discord.Client): 137 | def __init__(self, *args: typing.Any, **kwargs: typing.Any) -> None: 138 | super().__init__(*args, **kwargs) 139 | 140 | # create the background task and run it in the background 141 | self.bg_task = self.loop.create_task(self.my_background_task()) 142 | 143 | async def on_ready(self) -> None: 144 | print('Logged in as') 145 | print(self.user.name) 146 | print(self.user.id) 147 | print('------') 148 | 149 | async def my_background_task(self) -> None: 150 | await self.wait_until_ready() 151 | counter = 0 152 | channel = self.get_channel(1234567) 153 | assert isinstance(channel, discord.TextChannel) 154 | while not self.is_closed(): 155 | counter += 1 156 | await channel.send(counter) 157 | await asyncio.sleep(60) 158 | 159 | 160 | client = MyClient() 161 | reveal_type(client.bg_task) # N: Revealed type is "asyncio.tasks.Task[None]" 162 | client.run('token') 163 | -------------------------------------------------------------------------------- /test-data/test_iterators.yml: -------------------------------------------------------------------------------- 1 | - case: iterator_find 2 | main: | 3 | import discord 4 | 5 | async def main() -> None: 6 | client = discord.Client() 7 | 8 | def finder(guild: discord.Guild) -> bool: 9 | return True 10 | 11 | guild = await client.fetch_guilds().find(finder) 12 | 13 | reveal_type(guild) # N: Revealed type is "Union[discord.guild.Guild*, None]" 14 | 15 | - case: iterator_filter 16 | main: | 17 | import discord 18 | 19 | async def main() -> None: 20 | client = discord.Client() 21 | 22 | def filterer(guild: discord.Guild) -> bool: 23 | return True 24 | 25 | async for guild in client.fetch_guilds().filter(filterer): 26 | reveal_type(guild) # N: Revealed type is "discord.guild.Guild*" 27 | 28 | - case: iterator_map 29 | main: | 30 | import discord 31 | import typing 32 | 33 | async def main() -> None: 34 | client = discord.Client() 35 | 36 | def mapper(guild: discord.Guild) -> typing.List[discord.Member]: 37 | return guild.members 38 | 39 | async for members in client.fetch_guilds().map(mapper): 40 | reveal_type(members) # N: Revealed type is "builtins.list*[discord.member.Member]" 41 | 42 | - case: iterator_flatten 43 | main: | 44 | import discord 45 | 46 | async def main() -> None: 47 | client = discord.Client() 48 | 49 | guilds = await client.fetch_guilds().flatten() 50 | reveal_type(guilds) # N: Revealed type is "builtins.list*[discord.guild.Guild]" 51 | 52 | - case: iterator_chunk 53 | main: | 54 | import discord 55 | 56 | async def main() -> None: 57 | client = discord.Client() 58 | 59 | async for guild in client.fetch_guilds().chunk(10): 60 | reveal_type(guild) # N: Revealed type is "builtins.list*[discord.guild.Guild*]" 61 | 62 | - case: iterator_chunk_map 63 | main: | 64 | import discord 65 | import typing 66 | 67 | async def main() -> None: 68 | client = discord.Client() 69 | 70 | def member_mapper(guild: discord.Guild) -> typing.List[discord.Member]: 71 | return guild.members 72 | 73 | def mapper(guild: typing.List[discord.Guild]) -> typing.List[typing.List[discord.Member]]: 74 | return list(map(member_mapper, guild)) 75 | 76 | async for members_chunks in client.fetch_guilds().chunk(10).map(mapper): 77 | reveal_type(members_chunks) # N: Revealed type is "builtins.list*[builtins.list[discord.member.Member]]" 78 | -------------------------------------------------------------------------------- /test-data/test_member.yml: -------------------------------------------------------------------------------- 1 | - case: member_properties 2 | main: | 3 | import discord 4 | 5 | def main(member: discord.Member) -> None: 6 | reveal_type(member.name) # N: Revealed type is "builtins.str" 7 | reveal_type(member.id) # N: Revealed type is "builtins.int" 8 | reveal_type(member.discriminator) # N: Revealed type is "builtins.str" 9 | reveal_type(member.avatar) # N: Revealed type is "Union[builtins.str, None]" 10 | reveal_type(member.bot) # N: Revealed type is "builtins.bool" 11 | reveal_type(member.system) # N: Revealed type is "builtins.bool" 12 | reveal_type(member.mentioned_in) # N: Revealed type is "def (message: discord.message.Message) -> builtins.bool" 13 | reveal_type(member.dm_channel) # N: Revealed type is "Union[discord.channel.DMChannel, None]" 14 | reveal_type(member.create_dm) # N: Revealed type is "def () -> typing.Coroutine[Any, Any, discord.channel.DMChannel]" 15 | 16 | user: discord.User = member # E: Incompatible types in assignment (expression has type "Member", variable has type "User") 17 | base_user: discord.user.BaseUser = member # E: Incompatible types in assignment (expression has type "Member", variable has type "BaseUser") 18 | -------------------------------------------------------------------------------- /test-data/test_permissions.yml: -------------------------------------------------------------------------------- 1 | - case: permissions_init 2 | main: | 3 | import discord 4 | 5 | reveal_type(discord.Permissions.manage_permissions.alias) # N: Revealed type is "builtins.str" 6 | 7 | p = discord.Permissions( 8 | create_instant_invite=True, 9 | kick_members=True, 10 | ban_members=True, 11 | administrator=True, 12 | manage_channels=True, 13 | manage_guild=True, 14 | add_reactions=True, 15 | view_audit_log=True, 16 | priority_speaker=True, 17 | stream=True, 18 | read_messages=True, 19 | view_channel=True, 20 | send_messages=True, 21 | send_tts_messages=True, 22 | manage_messages=True, 23 | embed_links=True, 24 | attach_files=True, 25 | read_message_history=True, 26 | mention_everyone=True, 27 | external_emojis=True, 28 | use_external_emojis=True, 29 | view_guild_insights=True, 30 | connect=True, 31 | speak=True, 32 | mute_members=True, 33 | deafen_members=True, 34 | move_members=True, 35 | use_voice_activation=True, 36 | change_nickname=True, 37 | manage_nicknames=True, 38 | manage_roles=True, 39 | manage_permissions=True, 40 | manage_webhooks=True, 41 | manage_emojis=True, 42 | ) 43 | 44 | reveal_type(p.create_instant_invite) # N: Revealed type is "builtins.bool" 45 | reveal_type(p.view_channel) # N: Revealed type is "builtins.bool" 46 | reveal_type(p.use_external_emojis) # N: Revealed type is "builtins.bool" 47 | reveal_type(p.manage_permissions) # N: Revealed type is "builtins.bool" 48 | 49 | - case: permissions_update 50 | main: | 51 | import discord 52 | 53 | p = discord.Permissions() 54 | p.update( 55 | create_instant_invite=True, 56 | kick_members=True, 57 | ban_members=True, 58 | administrator=True, 59 | manage_channels=True, 60 | manage_guild=True, 61 | add_reactions=True, 62 | view_audit_log=True, 63 | priority_speaker=True, 64 | stream=True, 65 | read_messages=True, 66 | view_channel=True, 67 | send_messages=True, 68 | send_tts_messages=True, 69 | manage_messages=True, 70 | embed_links=True, 71 | attach_files=True, 72 | read_message_history=True, 73 | mention_everyone=True, 74 | external_emojis=True, 75 | use_external_emojis=True, 76 | view_guild_insights=True, 77 | connect=True, 78 | speak=True, 79 | mute_members=True, 80 | deafen_members=True, 81 | move_members=True, 82 | use_voice_activation=True, 83 | change_nickname=True, 84 | manage_nicknames=True, 85 | manage_roles=True, 86 | manage_permissions=True, 87 | manage_webhooks=True, 88 | manage_emojis=True, 89 | ) 90 | 91 | - case: permission_overwrite_init 92 | main: | 93 | import discord 94 | 95 | p = discord.PermissionOverwrite( 96 | create_instant_invite=None, 97 | kick_members=None, 98 | ban_members=None, 99 | administrator=None, 100 | manage_channels=None, 101 | manage_guild=None, 102 | add_reactions=None, 103 | view_audit_log=None, 104 | priority_speaker=None, 105 | stream=None, 106 | read_messages=None, 107 | view_channel=None, 108 | send_messages=None, 109 | send_tts_messages=None, 110 | manage_messages=None, 111 | embed_links=None, 112 | attach_files=None, 113 | read_message_history=None, 114 | mention_everyone=None, 115 | external_emojis=None, 116 | use_external_emojis=None, 117 | view_guild_insights=None, 118 | connect=None, 119 | speak=None, 120 | mute_members=None, 121 | deafen_members=None, 122 | move_members=None, 123 | use_voice_activation=None, 124 | change_nickname=None, 125 | manage_nicknames=None, 126 | manage_roles=None, 127 | manage_permissions=None, 128 | manage_webhooks=None, 129 | manage_emojis=None, 130 | ) 131 | 132 | reveal_type(p.create_instant_invite) # N: Revealed type is "Union[builtins.bool, None]" 133 | reveal_type(p.view_channel) # N: Revealed type is "Union[builtins.bool, None]" 134 | reveal_type(p.use_external_emojis) # N: Revealed type is "Union[builtins.bool, None]" 135 | reveal_type(p.manage_permissions) # N: Revealed type is "Union[builtins.bool, None]" 136 | 137 | - case: permission_overwrite_update 138 | main: | 139 | import discord 140 | 141 | p = discord.PermissionOverwrite() 142 | p.update( 143 | create_instant_invite=None, 144 | kick_members=None, 145 | ban_members=None, 146 | administrator=None, 147 | manage_channels=None, 148 | manage_guild=None, 149 | add_reactions=None, 150 | view_audit_log=None, 151 | priority_speaker=None, 152 | stream=None, 153 | read_messages=None, 154 | view_channel=None, 155 | send_messages=None, 156 | send_tts_messages=None, 157 | manage_messages=None, 158 | embed_links=None, 159 | attach_files=None, 160 | read_message_history=None, 161 | mention_everyone=None, 162 | external_emojis=None, 163 | use_external_emojis=None, 164 | view_guild_insights=None, 165 | connect=None, 166 | speak=None, 167 | mute_members=None, 168 | deafen_members=None, 169 | move_members=None, 170 | use_voice_activation=None, 171 | change_nickname=None, 172 | manage_nicknames=None, 173 | manage_roles=None, 174 | manage_permissions=None, 175 | manage_webhooks=None, 176 | manage_emojis=None, 177 | ) 178 | 179 | - case: guild_channel_set_permissions 180 | main: | 181 | import discord 182 | 183 | async def main(channel: discord.TextChannel, role: discord.Role) -> None: 184 | p = discord.PermissionOverwrite() 185 | 186 | await channel.set_permissions(role, overwrite=p, reason='Reason') 187 | await channel.set_permissions( 188 | role, 189 | reason='Reason', 190 | create_instant_invite=None, 191 | kick_members=True, 192 | ban_members=False, 193 | administrator=None, 194 | manage_channels=True, 195 | manage_guild=False, 196 | add_reactions=None, 197 | view_audit_log=True, 198 | priority_speaker=False, 199 | stream=None, 200 | read_messages=True, 201 | view_channel=False, 202 | send_messages=None, 203 | send_tts_messages=True, 204 | manage_messages=False, 205 | embed_links=None, 206 | attach_files=True, 207 | read_message_history=False, 208 | mention_everyone=None, 209 | external_emojis=True, 210 | use_external_emojis=False, 211 | view_guild_insights=None, 212 | connect=True, 213 | speak=False, 214 | mute_members=None, 215 | deafen_members=True, 216 | move_members=False, 217 | use_voice_activation=None, 218 | change_nickname=True, 219 | manage_nicknames=False, 220 | manage_roles=None, 221 | manage_permissions=True, 222 | manage_webhooks=False, 223 | manage_emojis=None, 224 | ) 225 | --------------------------------------------------------------------------------