Skip to content

Commit

Permalink
Resolved merge conflicts and synced with latest v2.6.0
Browse files Browse the repository at this point in the history
  • Loading branch information
AMIT YADAV authored and AMIT YADAV committed Jul 22, 2024
2 parents 2a647ab + ed1f73c commit 5a528d3
Show file tree
Hide file tree
Showing 107 changed files with 5,112 additions and 643 deletions.
9 changes: 9 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,15 @@ jobs:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
# Python 3.8/3.9 are on macos-13 but not macos-latest (macos-14-arm64)
# https://github.com/actions/setup-python/issues/696#issuecomment-1637587760
exclude:
- { python-version: "3.8", os: "macos-latest" }
- { python-version: "3.9", os: "macos-latest" }
include:
- { python-version: "3.8", os: "macos-13" }
- { python-version: "3.9", os: "macos-13" }

env:
OS: ${{ matrix.os }}
PYTHON: ${{ matrix.python-version }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Run tdg-github-action
uses: ribtoks/tdg-github-action@v0.4.7-beta
uses: ribtoks/tdg-github-action@v0.4.11-beta
with:
TOKEN: ${{ secrets.GITHUB_TOKEN }}
REPO: ${{ github.repository }}
Expand Down
8 changes: 4 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ ci:

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
rev: v4.6.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- repo: https://github.com/PyCQA/autoflake
rev: v2.2.1
rev: v2.3.1
hooks:
- id: autoflake
# args:
Expand All @@ -19,7 +19,7 @@ repos:
# - --remove-duplicate-keys
# - --remove-unused-variables
- repo: https://github.com/asottile/pyupgrade
rev: v3.15.0
rev: v3.16.0
hooks:
- id: pyupgrade
args: [--py38-plus]
Expand All @@ -28,7 +28,7 @@ repos:
hooks:
- id: isort
- repo: https://github.com/psf/black
rev: 23.12.1
rev: 24.4.2
hooks:
- id: black
args: [--safe, --quiet]
Expand Down
239 changes: 193 additions & 46 deletions CHANGELOG.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Key Features
- Modern Pythonic API using ``async`` and ``await``.
- Proper rate limit handling.
- Optimised for both speed and memory usage.
- Full Application Command Support
- Full application API support.

Installing
----------
Expand Down
3 changes: 3 additions & 0 deletions discord/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,13 @@
from .member import *
from .mentions import *
from .message import *
from .monetization import *
from .object import *
from .onboarding import *
from .partial_emoji import *
from .permissions import *
from .player import *
from .poll import *
from .raw_models import *
from .reaction import *
from .role import *
Expand Down
8 changes: 4 additions & 4 deletions discord/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@
"""

import argparse
import importlib.metadata
import platform
import sys
from pathlib import Path
from typing import Tuple

import aiohttp
import pkg_resources

import discord

Expand All @@ -47,9 +47,9 @@ def show_version() -> None:
"- py-cord v{0.major}.{0.minor}.{0.micro}-{0.releaselevel}".format(version_info)
)
if version_info.releaselevel != "final":
pkg = pkg_resources.get_distribution("py-cord")
if pkg:
entries.append(f" - py-cord pkg_resources: v{pkg.version}")
version = importlib.metadata.version("py-cord")
if version:
entries.append(f" - py-cord importlib.metadata: v{version}")

entries.append(f"- aiohttp v{aiohttp.__version__}")
uname = platform.uname()
Expand Down
1 change: 1 addition & 0 deletions discord/_typed_dict.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
"""

import sys

# PEP 655 Required and NotRequired were added in python 3.11. This file is simply a
Expand Down
1 change: 1 addition & 0 deletions discord/_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
"""

from __future__ import annotations

import datetime
Expand Down
79 changes: 48 additions & 31 deletions discord/abc.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@
from .guild import Guild
from .member import Member
from .message import Message, MessageReference, PartialMessage
from .poll import Poll
from .state import ConnectionState
from .threads import Thread
from .types.channel import Channel as ChannelPayload
Expand All @@ -115,7 +116,7 @@ async def _single_delete_strategy(


async def _purge_messages_helper(
channel: TextChannel | Thread | VoiceChannel,
channel: TextChannel | StageChannel | Thread | VoiceChannel,
*,
limit: int | None = 100,
check: Callable[[Message], bool] = MISSING,
Expand Down Expand Up @@ -341,8 +342,7 @@ class GuildChannel:

def __init__(
self, *, state: ConnectionState, guild: Guild, data: dict[str, Any]
):
...
): ...

def __str__(self) -> str:
return self.name
Expand Down Expand Up @@ -526,9 +526,9 @@ async def _edit(
"default_reaction_emoji must be of type: Emoji | int | str"
)

options[
"default_reaction_emoji"
] = default_reaction_emoji._to_forum_reaction_payload()
options["default_reaction_emoji"] = (
default_reaction_emoji._to_forum_reaction_payload()
)

if options:
return await self._state.http.edit_channel(
Expand Down Expand Up @@ -853,8 +853,7 @@ async def set_permissions(
*,
overwrite: PermissionOverwrite | None = ...,
reason: str | None = ...,
) -> None:
...
) -> None: ...

@overload
async def set_permissions(
Expand All @@ -863,8 +862,7 @@ async def set_permissions(
*,
reason: str | None = ...,
**permissions: bool,
) -> None:
...
) -> None: ...

async def set_permissions(
self, target, *, overwrite=MISSING, reason=None, **permissions
Expand Down Expand Up @@ -1033,8 +1031,7 @@ async def move(
category: Snowflake | None = MISSING,
sync_permissions: bool = MISSING,
reason: str | None = MISSING,
) -> None:
...
) -> None: ...

@overload
async def move(
Expand All @@ -1045,8 +1042,7 @@ async def move(
category: Snowflake | None = MISSING,
sync_permissions: bool = MISSING,
reason: str = MISSING,
) -> None:
...
) -> None: ...

@overload
async def move(
Expand All @@ -1057,8 +1053,7 @@ async def move(
category: Snowflake | None = MISSING,
sync_permissions: bool = MISSING,
reason: str = MISSING,
) -> None:
...
) -> None: ...

@overload
async def move(
Expand All @@ -1069,8 +1064,7 @@ async def move(
category: Snowflake | None = MISSING,
sync_permissions: bool = MISSING,
reason: str = MISSING,
) -> None:
...
) -> None: ...

async def move(self, **kwargs) -> None:
"""|coro|
Expand Down Expand Up @@ -1352,15 +1346,16 @@ async def send(
file: File = ...,
stickers: Sequence[GuildSticker | StickerItem] = ...,
delete_after: float = ...,
nonce: str | int = ...,
nonce: int | str = ...,
enforce_nonce: bool = ...,
allowed_mentions: AllowedMentions = ...,
reference: Message | MessageReference | PartialMessage = ...,
mention_author: bool = ...,
view: View = ...,
poll: Poll = ...,
suppress: bool = ...,
silent: bool = ...,
) -> Message:
...
) -> Message: ...

@overload
async def send(
Expand All @@ -1372,15 +1367,16 @@ async def send(
files: list[File] = ...,
stickers: Sequence[GuildSticker | StickerItem] = ...,
delete_after: float = ...,
nonce: str | int = ...,
nonce: int | str = ...,
enforce_nonce: bool = ...,
allowed_mentions: AllowedMentions = ...,
reference: Message | MessageReference | PartialMessage = ...,
mention_author: bool = ...,
view: View = ...,
poll: Poll = ...,
suppress: bool = ...,
silent: bool = ...,
) -> Message:
...
) -> Message: ...

@overload
async def send(
Expand All @@ -1392,15 +1388,16 @@ async def send(
file: File = ...,
stickers: Sequence[GuildSticker | StickerItem] = ...,
delete_after: float = ...,
nonce: str | int = ...,
nonce: int | str = ...,
enforce_nonce: bool = ...,
allowed_mentions: AllowedMentions = ...,
reference: Message | MessageReference | PartialMessage = ...,
mention_author: bool = ...,
view: View = ...,
poll: Poll = ...,
suppress: bool = ...,
silent: bool = ...,
) -> Message:
...
) -> Message: ...

@overload
async def send(
Expand All @@ -1412,15 +1409,16 @@ async def send(
files: list[File] = ...,
stickers: Sequence[GuildSticker | StickerItem] = ...,
delete_after: float = ...,
nonce: str | int = ...,
nonce: int | str = ...,
enforce_nonce: bool = ...,
allowed_mentions: AllowedMentions = ...,
reference: Message | MessageReference | PartialMessage = ...,
mention_author: bool = ...,
view: View = ...,
poll: Poll = ...,
suppress: bool = ...,
silent: bool = ...,
) -> Message:
...
) -> Message: ...

async def send(
self,
Expand All @@ -1434,10 +1432,12 @@ async def send(
stickers=None,
delete_after=None,
nonce=None,
enforce_nonce=None,
allowed_mentions=None,
reference=None,
mention_author=None,
view=None,
poll=None,
suppress=None,
silent=None,
):
Expand Down Expand Up @@ -1471,9 +1471,13 @@ async def send(
The file to upload.
files: List[:class:`~discord.File`]
A list of files to upload. Must be a maximum of 10.
nonce: :class:`int`
nonce: Union[:class:`str`, :class:`int`]
The nonce to use for sending this message. If the message was successfully sent,
then the message will have a nonce with this value.
enforce_nonce: Optional[:class:`bool`]
Whether :attr:`nonce` is enforced to be validated.
.. versionadded:: 2.5
delete_after: :class:`float`
If provided, the number of seconds to wait in the background
before deleting the message we just sent. If the deletion fails,
Expand Down Expand Up @@ -1517,6 +1521,10 @@ async def send(
Whether to suppress push and desktop notifications for the message.
.. versionadded:: 2.4
poll: :class:`Poll`
The poll to send.
.. versionadded:: 2.6
Returns
-------
Expand Down Expand Up @@ -1596,6 +1604,9 @@ async def send(
else:
components = None

if poll:
poll = poll.to_dict()

if file is not None and files is not None:
raise InvalidArgument("cannot pass both file and files parameter to send()")

Expand All @@ -1613,10 +1624,12 @@ async def send(
embed=embed,
embeds=embeds,
nonce=nonce,
enforce_nonce=enforce_nonce,
message_reference=reference,
stickers=stickers,
components=components,
flags=flags,
poll=poll,
)
finally:
file.close()
Expand All @@ -1638,11 +1651,13 @@ async def send(
embed=embed,
embeds=embeds,
nonce=nonce,
enforce_nonce=enforce_nonce,
allowed_mentions=allowed_mentions,
message_reference=reference,
stickers=stickers,
components=components,
flags=flags,
poll=poll,
)
finally:
for f in files:
Expand All @@ -1655,11 +1670,13 @@ async def send(
embed=embed,
embeds=embeds,
nonce=nonce,
enforce_nonce=enforce_nonce,
allowed_mentions=allowed_mentions,
message_reference=reference,
stickers=stickers,
components=components,
flags=flags,
poll=poll,
)

ret = state.create_message(channel=channel, data=data)
Expand Down
Loading

0 comments on commit 5a528d3

Please sign in to comment.