Skip to content

Commit

Permalink
Merge branch 'master' into v2.x
Browse files Browse the repository at this point in the history
  • Loading branch information
BobDotCom committed May 17, 2022
2 parents ab95493 + 2b31689 commit f00bf5f
Show file tree
Hide file tree
Showing 73 changed files with 2,341 additions and 1,175 deletions.
2 changes: 0 additions & 2 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
<!-- Warning: No new features will be merged until the next stable release. -->

## Summary

<!-- What is this pull request for? Does it fix any issues? -->
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/bandit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: bandit
on: [pull_request, push]
jobs:
bandit:
if: github.event.pull_request.user.type != 'Bot' && !contains(github.event.pull_request.labels.*.name, 'skip-ci')
# if: github.event.pull_request.user.type != 'Bot' && !contains(github.event.pull_request.labels.*.name, 'skip-ci')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
Expand Down
9 changes: 3 additions & 6 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,14 @@
name: "CodeQL"

on:
push:
branches: [ master ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ master ]
push: null
pull_request: null
schedule:
- cron: '26 6 * * 6'

jobs:
analyze:
if: github.event.pull_request.user.type != 'Bot' && !contains(github.event.pull_request.labels.*.name, 'skip-ci')
# if: github.event.pull_request.user.type != 'Bot' && !contains(github.event.pull_request.labels.*.name, 'skip-ci')
name: Analyze
runs-on: ubuntu-latest
permissions:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/codespell.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: codespell
on: [pull_request, push]
jobs:
codespell:
if: github.event.pull_request.user.type != 'Bot' && !contains(github.event.pull_request.labels.*.name, 'skip-ci')
# if: github.event.pull_request.user.type != 'Bot' && !contains(github.event.pull_request.labels.*.name, 'skip-ci')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
Expand Down
9 changes: 4 additions & 5 deletions .github/workflows/mypy.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
name: mypy
on: [pull_request, push]
on: [ pull_request, push ]
jobs:
mypy:
if: github.event.pull_request.user.type != 'Bot' && !contains(github.event.pull_request.labels.*.name, 'skip-ci')
# if: github.event.pull_request.user.type != 'Bot' && !contains(github.event.pull_request.labels.*.name, 'skip-ci')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- run: pip install mypy
- run: pip install -r requirements.txt
- run: pip install -r requirements-dev.txt
- run: mkdir --parents --verbose .mypy_cache
- run: mypy --ignore-missing-imports --install-types --non-interactive .
- run: mypy --non-interactive .
27 changes: 27 additions & 0 deletions .github/workflows/pylint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#name: Pylint
#
#on: [ push, pull_request ]
#
#jobs:
# build:
# runs-on: ubuntu-latest
# strategy:
# matrix:
# python-version: [ "3.8" ]
# steps:
# - uses: actions/checkout@v2
# - name: Set up Python ${{ matrix.python-version }}
# uses: actions/setup-python@v2
# with:
# python-version: ${{ matrix.python-version }}
# - name: Install dependencies
# run: |
# python -m pip install --upgrade pip
# pip install -r requirements-dev.txt
# - name: Check if PR
# if: github.event.pull_request.number
# run: |
# echo "enable=fixme" >> .pylintrc
# - name: Analysing the code with pylint
# run: |
# pylint $(git ls-files '*.py')
48 changes: 48 additions & 0 deletions .github/workflows/python-app.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# This workflow will install Python dependencies, run tests and lint with a single version of Python
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions

name: Python application

on: [ push, pull_request ]

jobs:
test:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ ubuntu-latest, macos-latest, windows-latest ]
python-version: [ 3.8, 3.9, "3.10" ]
env:
OS: ${{ matrix.os }}
PYTHON: ${{ matrix.python-version }}
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.10
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8
pip install -r requirements-dev.txt
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings.
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=120 --statistics
- name: Run code coverage with pytest
run: |
coverage run -m pytest
coverage xml
- name: Upload code coverage to codecov.io
uses: codecov/codecov-action@v2
with:
# token: ${{ secrets.CODECOV_TOKEN }} # not required for public repos
env_vars: OS,PYTHON
files: ./coverage.xml
flags: pytest # optional
name: codecov-umbrella # optional
fail_ci_if_error: false # Enable once we have good coverage
verbose: true # optional (default = false)
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,4 @@ build/
test.py
build/
node_modules/*
.coverage
2 changes: 1 addition & 1 deletion .pylintrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[MESSAGES CONTROL]

disable=protected-access
disable=protected-access,fixme

enable=bad-indentation,line-too-long

Expand Down
12 changes: 12 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ Pycord
.. image:: https://img.shields.io/pypi/dm/py-cord?color=blueviolet&logo=pypi&logoColor=white&style=for-the-badge
:target: https://pypi.python.org/pypi/py-cord
:alt: PyPI downloads
.. image:: https://img.shields.io/github/v/release/Pycord-Development/pycord?include_prereleases&label=Latest%20Release&logo=github&sort=semver&style=for-the-badge&logoColor=white
:target: https://github.com/Pycord-Development/pycord/releases
:alt: Latest release

A fork of discord.py. Pycord is a modern, easy to use, feature-rich, and async ready API wrapper for Discord written in Python.

Expand Down Expand Up @@ -66,6 +69,15 @@ To install the development version, do the following:
$ git clone https://github.com/Pycord-Development/pycord
$ cd pycord
$ python3 -m pip install -U .[voice]
or if you do not want to clone the repository:

.. code:: sh
# Linux/macOS
python3 -m pip install git+https://github.com/Pycord-Development/pycord
# Windows
py -3 -m pip install git+https://github.com/Pycord-Development/pycord
Optional Packages
Expand Down
4 changes: 2 additions & 2 deletions discord/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
__author__ = "Pycord Development"
__license__ = "MIT"
__copyright__ = "Copyright 2015-2021 Rapptz & Copyright 2021-present Pycord Development"
__version__ = "2.0.0b7"
__version__ = "2.0.0rc1"

__path__ = __import__("pkgutil").extend_path(__path__, __name__)

Expand Down Expand Up @@ -75,6 +75,6 @@ class VersionInfo(NamedTuple):
serial: int


version_info: VersionInfo = VersionInfo(major=2, minor=0, micro=0, releaselevel="beta", serial=7)
version_info: VersionInfo = VersionInfo(major=2, minor=0, micro=0, releaselevel="candidate", serial=1)

logging.getLogger(__name__).addHandler(logging.NullHandler())
33 changes: 22 additions & 11 deletions discord/abc.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
Any,
Callable,
Dict,
Iterable,
List,
Optional,
Protocol,
Expand All @@ -42,7 +43,6 @@
Union,
overload,
runtime_checkable,
Iterable,
)

from . import utils
Expand Down Expand Up @@ -86,6 +86,7 @@
from .client import Client
from .embeds import Embed
from .enums import InviteTarget
from .flags import ChannelFlags
from .guild import Guild
from .member import Member
from .message import Message, MessageReference, PartialMessage
Expand All @@ -111,16 +112,16 @@ async def _single_delete_strategy(messages: Iterable[Message], *, reason: Option


async def _purge_messages_helper(
channel: Union[TextChannel, Thread, VoiceChannel],
*,
limit: Optional[int] = 100,
check: Callable[[Message], bool] = MISSING,
before: Optional[SnowflakeTime] = None,
after: Optional[SnowflakeTime] = None,
around: Optional[SnowflakeTime] = None,
oldest_first: Optional[bool] = False,
bulk: bool = True,
reason: Optional[str] = None,
channel: Union[TextChannel, Thread, VoiceChannel],
*,
limit: Optional[int] = 100,
check: Callable[[Message], bool] = MISSING,
before: Optional[SnowflakeTime] = None,
after: Optional[SnowflakeTime] = None,
around: Optional[SnowflakeTime] = None,
oldest_first: Optional[bool] = False,
bulk: bool = True,
reason: Optional[str] = None,
) -> List[Message]:
if check is MISSING:
check = lambda m: True
Expand Down Expand Up @@ -305,6 +306,7 @@ class GuildChannel:
- :class:`~discord.VoiceChannel`
- :class:`~discord.CategoryChannel`
- :class:`~discord.StageChannel`
- :class:`~discord.ForumChannel`
This ABC must also implement :class:`~discord.abc.Snowflake`.
Expand All @@ -327,6 +329,7 @@ class GuildChannel:
type: ChannelType
position: int
category_id: Optional[int]
flags: ChannelFlags
_state: ConnectionState
_overwrites: List[_Overwrites]

Expand Down Expand Up @@ -513,6 +516,14 @@ def mention(self) -> str:
""":class:`str`: The string that allows you to mention the channel."""
return f"<#{self.id}>"

@property
def jump_url(self) -> str:
""":class:`str`: Returns a URL that allows the client to jump to the channel.
.. versionadded:: 2.0
"""
return f"https://discord.com/channels/{self.guild.id}/{self.id}"

@property
def created_at(self) -> datetime:
""":class:`datetime.datetime`: Returns the channel's creation time in UTC."""
Expand Down
8 changes: 8 additions & 0 deletions discord/audit_logs.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,12 @@ def _transform_avatar(entry: AuditLogEntry, data: Optional[str]) -> Optional[Ass
return Asset._from_avatar(entry._state, entry._target_id, data) # type: ignore


def _transform_scheduled_event_cover(entry: AuditLogEntry, data: Optional[str]) -> Optional[Asset]:
if data is None:
return None
return Asset._from_scheduled_event_cover(entry._state, entry._target_id, data)


def _guild_hash_transformer(
path: str,
) -> Callable[[AuditLogEntry, Optional[str]], Optional[Asset]]:
Expand Down Expand Up @@ -238,6 +244,8 @@ class AuditLogChanges:
"location_type",
_enum_transformer(enums.ScheduledEventLocationType),
),
"command_id": ("command_id", _transform_snowflake),
"image_hash": ("cover", _transform_scheduled_event_cover),
}

def __init__(
Expand Down
Loading

0 comments on commit f00bf5f

Please sign in to comment.