├── .github ├── checkers │ ├── pylint.json │ └── pyright.json └── workflows │ ├── lint.yaml │ ├── release.yaml │ └── tests.yaml ├── .gitignore ├── .pre-commit-config.yaml ├── .readthedocs.yaml ├── LICENSE ├── README.md ├── docs ├── Makefile ├── _static │ ├── .gitkeep │ ├── logo.ico │ ├── logo.svg │ └── speed-showcase.mp4 ├── common.rst ├── conf.py ├── contributing │ └── getting_started.rst ├── events.rst ├── gateway.rst ├── http.rst ├── index.rst ├── make.bat ├── optimizing.rst ├── releasenotes.rst └── requirements.txt ├── examples ├── README.md ├── gateway │ ├── ping_pong │ │ └── ping_pong.py │ └── ping_pong_slash_command │ │ ├── README.md │ │ ├── ping_pong_slash_command.py │ │ └── register_commands.py └── http │ ├── get_channel │ └── get_channel.py │ └── get_gateway │ └── get_gateway.py ├── newsfragments └── .gitkeep ├── nextcore ├── __init__.py ├── common │ ├── __init__.py │ ├── dispatcher.py │ ├── errors.py │ ├── json.py │ ├── maybe_coro.py │ ├── times_per │ │ ├── __init__.py │ │ ├── priority_queue_container.py │ │ └── times_per.py │ └── undefined.py ├── gateway │ ├── __init__.py │ ├── close_code.py │ ├── decompressor.py │ ├── errors.py │ ├── exponential_backoff.py │ ├── op_code.py │ ├── shard.py │ └── shard_manager.py ├── http │ ├── __init__.py │ ├── authentication │ │ ├── __init__.py │ │ ├── base.py │ │ ├── bearer.py │ │ └── bot.py │ ├── bucket.py │ ├── bucket_metadata.py │ ├── client │ │ ├── __init__.py │ │ ├── base_client.py │ │ └── client.py │ ├── errors.py │ ├── global_rate_limiter │ │ ├── __init__.py │ │ ├── base.py │ │ ├── limited.py │ │ └── unlimited.py │ ├── rate_limit_storage.py │ ├── request_session.py │ └── route.py └── py.typed ├── pypi-README.md ├── pyproject.toml └── tests ├── .gitkeep ├── common ├── test_dispatcher.py ├── test_json.py ├── test_maybe_coro.py └── test_times_per.py ├── gateway └── test_exponential_backoff.py ├── http ├── global_rate_limiter │ ├── test_limited.py │ └── test_unlimited.py ├── test_bucket.py ├── test_ratelimit_storage.py └── test_route.py └── utils.py /.github/checkers/pylint.json: -------------------------------------------------------------------------------- 1 | { 2 | "problemMatcher": [ 3 | { 4 | "owner": "pylint", 5 | "serverity": "warning", 6 | "pattern": [ 7 | { 8 | "regexp": "(.+):(\\d+):(\\d+): (?:I|R|C|W|E|F)(?:\\d+): (.+) \\((.+)\\)", 9 | "file": 1, 10 | "line": 2, 11 | "column": 3, 12 | "message": 4, 13 | "code": 5 14 | } 15 | ] 16 | } 17 | ] 18 | } 19 | -------------------------------------------------------------------------------- /.github/checkers/pyright.json: -------------------------------------------------------------------------------- 1 | { 2 | "problemMatcher": [ 3 | { 4 | "owner": "pyright", 5 | "pattern": [ 6 | { 7 | "regexp": "/home/runner/work/nextcore/nextcore/(.+):(\\d+):(\\d+) - (information|warning|error): (.+) \\((.+)\\)", 8 | "file": 1, 9 | "line": 2, 10 | "column": 3, 11 | "severity": 4, 12 | "message": 5, 13 | "code": 6 14 | } 15 | ] 16 | } 17 | ] 18 | } 19 | -------------------------------------------------------------------------------- /.github/workflows/lint.yaml: -------------------------------------------------------------------------------- 1 | name: Lint 2 | permissions: 3 | contents: read 4 | on: 5 | pull_request: {} 6 | push: 7 | branches: ["master"] 8 | merge_group: {} 9 | 10 | jobs: 11 | black: 12 | runs-on: ubuntu-latest 13 | steps: 14 | - uses: actions/checkout@v1 15 | - name: Set up Python 3.10 16 | uses: actions/setup-python@v3 17 | with: 18 | python-version: "3.10" 19 | - name: Install poetry 20 | run: pip install poetry 21 | - name: Install dependencies 22 | run: poetry install 23 | - name: Run tests 24 | run: poetry run task black_check 25 | isort: 26 | runs-on: ubuntu-latest 27 | steps: 28 | - uses: actions/checkout@v1 29 | - name: Set up Python 3.10 30 | uses: actions/setup-python@v3 31 | with: 32 | python-version: "3.10" 33 | - name: Install poetry 34 | run: pip install poetry 35 | - name: Install dependencies 36 | run: poetry install 37 | - name: Run tests 38 | run: poetry run task isort_check 39 | pyright: 40 | runs-on: ubuntu-latest 41 | steps: 42 | - uses: actions/checkout@v1 43 | - name: Set up Python 3.10 44 | uses: actions/setup-python@v3 45 | with: 46 | python-version: "3.10" 47 | - name: Install poetry 48 | run: pip install poetry 49 | - name: Install dependencies 50 | run: poetry install -E speed 51 | - uses: actions/setup-node@v2 52 | name: Install node 53 | with: 54 | node-version: "14" 55 | - name: Install pyright 56 | run: npm install -g pyright 57 | - name: Enable the problem checker 58 | run: echo "::add-matcher::.github/checkers/pyright.json" 59 | - name: Run pyright 60 | run: poetry run pyright nextcore/ 61 | style-guide: 62 | runs-on: ubuntu-latest 63 | steps: 64 | - uses: actions/checkout@v1 65 | - name: Set up Python 3.10 66 | uses: actions/setup-python@v3 67 | with: 68 | python-version: "3.10" 69 | - name: Install poetry 70 | run: pip install poetry 71 | - name: Install dependencies 72 | run: poetry install 73 | - name: Enable the problem checker 74 | run: echo "::add-matcher::.github/checkers/pylint.json" 75 | - name: Run pylint 76 | run: poetry run pylint -d all -e asyncio-best-practices,license,outdated-typing --load-plugins=nextstyle nextcore/ 77 | slots-check: 78 | runs-on: ubuntu-latest 79 | steps: 80 | - uses: actions/checkout@v1 81 | - name: Set up Python 3.10 82 | uses: actions/setup-python@v3 83 | with: 84 | python-version: "3.10" 85 | - name: Install poetry 86 | run: pip install poetry 87 | - name: Install dependencies 88 | run: poetry install 89 | - name: Run slotscheck 90 | run: poetry run slotscheck nextcore/ 91 | 92 | -------------------------------------------------------------------------------- /.github/workflows/release.yaml: -------------------------------------------------------------------------------- 1 | name: Release 2 | on: 3 | release: 4 | types: ["created"] 5 | workflow_dispatch: {} 6 | 7 | permissions: 8 | id-token: write 9 | 10 | jobs: 11 | release: 12 | runs-on: ubuntu-latest 13 | steps: 14 | - uses: actions/checkout@v3 15 | - uses: actions/setup-python@v4 16 | with: 17 | python-version: 3.11 18 | - name: Install poetry 19 | run: | 20 | pip install poetry 21 | - name: Install dependencies 22 | run: | 23 | poetry install --no-root 24 | - name: Build 25 | run: | 26 | poetry build 27 | - name: Publish release 28 | uses: pypa/gh-action-pypi-publish@release/v1 29 | 30 | 31 | -------------------------------------------------------------------------------- /.github/workflows/tests.yaml: -------------------------------------------------------------------------------- 1 | name: Tests 2 | permissions: 3 | contents: read 4 | on: 5 | pull_request: {} 6 | push: 7 | branches: ["master"] 8 | merge_group: {} 9 | jobs: 10 | pytest: 11 | runs-on: ubuntu-latest 12 | strategy: 13 | matrix: 14 | python-version: ["3.8", "3.9", "3.10"] 15 | name: Pytest (${{ matrix.python-version }}) 16 | steps: 17 | - uses: actions/checkout@v1 18 | - name: Set up Python 19 | uses: actions/setup-python@v3 20 | with: 21 | python-version: ${{ matrix.python-version }} 22 | - name: Install poetry 23 | run: pip install poetry 24 | - name: Install dependencies 25 | run: poetry install 26 | - name: Run tests 27 | run: poetry run task tests 28 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | build/ 12 | develop-eggs/ 13 | dist/ 14 | downloads/ 15 | eggs/ 16 | .eggs/ 17 | lib/ 18 | lib64/ 19 | parts/ 20 | sdist/ 21 | var/ 22 | wheels/ 23 | share/python-wheels/ 24 | *.egg-info/ 25 | .installed.cfg 26 | *.egg 27 | MANIFEST 28 | poetry.lock 29 | 30 | # PyInstaller 31 | # Usually these files are written by a python script from a template 32 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 33 | *.manifest 34 | *.spec 35 | 36 | # Installer logs 37 | pip-log.txt 38 | pip-delete-this-directory.txt 39 | 40 | # Unit test / coverage reports 41 | htmlcov/ 42 | .tox/ 43 | .nox/ 44 | .coverage 45 | .coverage.* 46 | .cache 47 | nosetests.xml 48 | coverage.xml 49 | *.cover 50 | *.py,cover 51 | .hypothesis/ 52 | .pytest_cache/ 53 | cover/ 54 | 55 | # Translations 56 | *.mo 57 | *.pot 58 | 59 | # Django stuff: 60 | *.log 61 | local_settings.py 62 | db.sqlite3 63 | db.sqlite3-journal 64 | 65 | # Flask stuff: 66 | instance/ 67 | .webassets-cache 68 | 69 | # Scrapy stuff: 70 | .scrapy 71 | 72 | # Sphinx documentation 73 | docs/_build/ 74 | 75 | # PyBuilder 76 | .pybuilder/ 77 | target/ 78 | 79 | # Jupyter Notebook 80 | .ipynb_checkpoints 81 | 82 | # IPython 83 | profile_default/ 84 | ipython_config.py 85 | 86 | # pyenv 87 | # For a library or package, you might want to ignore these files since the code is 88 | # intended to run in multiple environments; otherwise, check them in: 89 | # .python-version 90 | 91 | # pipenv 92 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. 93 | # However, in case of collaboration, if having platform-specific dependencies or dependencies 94 | # having no cross-platform support, pipenv may install dependencies that don't work, or not 95 | # install all needed dependencies. 96 | #Pipfile.lock 97 | 98 | # PEP 582; used by e.g. github.com/David-OConnor/pyflow 99 | __pypackages__/ 100 | 101 | # Celery stuff 102 | celerybeat-schedule 103 | celerybeat.pid 104 | 105 | # SageMath parsed files 106 | *.sage.py 107 | 108 | # Environments 109 | .env 110 | .venv 111 | env/ 112 | venv/ 113 | ENV/ 114 | env.bak/ 115 | venv.bak/ 116 | 117 | # Spyder project settings 118 | .spyderproject 119 | .spyproject 120 | 121 | # Rope project settings 122 | .ropeproject 123 | 124 | # mkdocs documentation 125 | /site 126 | 127 | # mypy 128 | .mypy_cache/ 129 | .dmypy.json 130 | dmypy.json 131 | 132 | # Pyre type checker 133 | .pyre/ 134 | 135 | # pytype static type analyzer 136 | .pytype/ 137 | 138 | # Cython debug symbols 139 | cython_debug/ 140 | 141 | # Editors 142 | .vscode/ 143 | .idea/ 144 | -------------------------------------------------------------------------------- /.pre-commit-config.yaml: -------------------------------------------------------------------------------- 1 | # See https://pre-commit.com for more information 2 | # See https://pre-commit.com/hooks.html for more hooks 3 | repos: 4 | - repo: https://github.com/psf/black 5 | rev: 22.3.0 6 | hooks: 7 | - id: black 8 | args: ["--check"] 9 | - repo: https://github.com/pycqa/isort 10 | rev: 5.10.1 11 | hooks: 12 | - id: isort 13 | args: ["--check"] 14 | - repo: local 15 | hooks: 16 | - id: pytest 17 | name: pytest 18 | entry: pytest 19 | language: system 20 | pass_filenames: false 21 | always_run: true 22 | - repo: local 23 | hooks: 24 | - id: pyright 25 | name: pyright 26 | entry: pyright 27 | language: system 28 | pass_filenames: false 29 | always_run: true 30 | - repo: local 31 | hooks: 32 | - id: slotscheck 33 | name: slotscheck 34 | entry: slotscheck nextcore/ 35 | language: system 36 | pass_filenames: false 37 | always_run: true 38 | -------------------------------------------------------------------------------- /.readthedocs.yaml: -------------------------------------------------------------------------------- 1 | version: 2 2 | 3 | build: 4 | os: ubuntu-22.04 5 | tools: 6 | python: "3.11" 7 | jobs: 8 | post_create_environment: 9 | - pip install poetry 10 | - poetry config virtualenvs.create false 11 | post_install: 12 | - poetry install 13 | 14 | sphinx: 15 | configuration: docs/conf.py 16 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 tag-epic 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |
2 | 3 | 4 | 5 | # Nextcore 6 | A low level Discord API wrapper. 7 | 8 |
9 | 10 | ### ✨ Features 11 | 12 | - #### Speed 13 | 14 | We try to make the library as fast as possible, without compromising on readability of the code or features. 15 | 16 |