Skip to content

Commit ad70e1c

Browse files
authored
Merge pull request #1591 from Pycord-Development/merge-conflicts
merge 2.1 changes
2 parents 4e52569 + d022361 commit ad70e1c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

98 files changed

+2186
-1225
lines changed

.github/ISSUE_TEMPLATE/vulnerability_report.yml

Lines changed: 0 additions & 57 deletions
This file was deleted.

.github/SECURITY.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@
1010
## Reporting a Vulnerability
1111

1212
If you find a vulnerability you have two ways to report it:
13-
- Write us on https://pycord.dev/discord
14-
- Open an [issue](https://github.com/Pycord-Development/pycord/issues/new/choose)
13+
- Write a dm to one of our core developers on https://pycord.dev/discord
14+
- Write an email to admin@pycord.dev

.github/workflows/codespell.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@ jobs:
77
steps:
88
- uses: actions/checkout@v2
99
- uses: actions/setup-python@v2
10-
- run: pip install codespell
11-
- run: codespell --ignore-words-list="groupt,nd,ot"
10+
- run: pip install codespell==2.1.0
11+
- run: codespell --ignore-words-list="groupt,nd,ot,ro,falsy,BU" --exclude-file=".github/workflows/codespell.yml"

discord/__init__.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
__author__ = "Pycord Development"
1414
__license__ = "MIT"
1515
__copyright__ = "Copyright 2015-2021 Rapptz & Copyright 2021-present Pycord Development"
16-
__version__ = "2.0.1"
16+
__version__ = "2.1.0"
17+
1718

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

@@ -25,6 +26,7 @@
2526
from .appinfo import *
2627
from .asset import *
2728
from .audit_logs import *
29+
from .automod import *
2830
from .bot import *
2931
from .channel import *
3032
from .client import *
@@ -75,6 +77,7 @@ class VersionInfo(NamedTuple):
7577
serial: int
7678

7779

78-
version_info: VersionInfo = VersionInfo(major=2, minor=0, micro=1, releaselevel="final", serial=0)
80+
version_info: VersionInfo = VersionInfo(major=2, minor=1, micro=0, releaselevel="final", serial=0)
81+
7982

8083
logging.getLogger(__name__).addHandler(logging.NullHandler())

discord/abc.py

Lines changed: 22 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -175,14 +175,6 @@ async def _purge_messages_helper(
175175
return ret
176176

177177

178-
class _Undefined:
179-
def __repr__(self) -> str:
180-
return "see-below"
181-
182-
183-
_undefined: Any = _Undefined()
184-
185-
186178
@runtime_checkable
187179
class Snowflake(Protocol):
188180
"""An ABC that details the common operations on a Discord model.
@@ -382,7 +374,7 @@ async def _move(
382374
payload = []
383375
for index, c in enumerate(channels):
384376
d: Dict[str, Any] = {"id": c.id, "position": index}
385-
if parent_id is not _undefined and c.id == self.id:
377+
if parent_id is not MISSING and c.id == self.id:
386378
d.update(parent_id=parent_id, lock_permissions=lock_permissions)
387379
payload.append(d)
388380

@@ -392,7 +384,7 @@ async def _edit(self, options: Dict[str, Any], reason: Optional[str]) -> Optiona
392384
try:
393385
parent = options.pop("category")
394386
except KeyError:
395-
parent_id = _undefined
387+
parent_id = MISSING
396388
else:
397389
parent_id = parent and parent.id
398390

@@ -420,7 +412,7 @@ async def _edit(self, options: Dict[str, Any], reason: Optional[str]) -> Optiona
420412
try:
421413
position = options.pop("position")
422414
except KeyError:
423-
if parent_id is not _undefined:
415+
if parent_id is not MISSING:
424416
if lock_permissions:
425417
category = self.guild.get_channel(parent_id)
426418
if category:
@@ -603,7 +595,7 @@ def category(self) -> Optional[CategoryChannel]:
603595

604596
@property
605597
def permissions_synced(self) -> bool:
606-
""":class:`bool`: Whether or not the permissions for this channel are synced with the
598+
""":class:`bool`: Whether the permissions for this channel are synced with the
607599
category it belongs to.
608600
609601
If there is no category then this is ``False``.
@@ -658,7 +650,7 @@ def permissions_for(self, obj: Union[Member, Role], /) -> Permissions:
658650
# (or otherwise) are then OR'd together.
659651
# After the role permissions are resolved, the member permissions
660652
# have to take into effect.
661-
# After all that is done.. you have to do the following:
653+
# After all that is done, you have to do the following:
662654

663655
# If manage permissions is True, then all permissions are set to True.
664656

@@ -781,7 +773,7 @@ async def set_permissions(
781773
self,
782774
target: Union[Member, Role],
783775
*,
784-
overwrite: Optional[Union[PermissionOverwrite, _Undefined]] = ...,
776+
overwrite: Optional[PermissionOverwrite] = ...,
785777
reason: Optional[str] = ...,
786778
) -> None:
787779
...
@@ -796,7 +788,7 @@ async def set_permissions(
796788
) -> None:
797789
...
798790

799-
async def set_permissions(self, target, *, overwrite=_undefined, reason=None, **permissions):
791+
async def set_permissions(self, target, *, overwrite=MISSING, reason=None, **permissions):
800792
r"""|coro|
801793
802794
Sets the channel specific permission overwrites for a target in the
@@ -874,7 +866,7 @@ async def set_permissions(self, target, *, overwrite=_undefined, reason=None, **
874866
else:
875867
raise InvalidArgument("target parameter must be either Member or Role")
876868

877-
if overwrite is _undefined:
869+
if overwrite is MISSING:
878870
if len(permissions) == 0:
879871
raise InvalidArgument("No overwrite provided.")
880872
try:
@@ -1046,7 +1038,7 @@ async def move(self, **kwargs) -> None:
10461038
Raises
10471039
-------
10481040
InvalidArgument
1049-
An invalid position was given or a bad mix of arguments were passed.
1041+
An invalid position was given or a bad mix of arguments was passed.
10501042
Forbidden
10511043
You do not have permissions to move the channel.
10521044
HTTPException
@@ -1152,20 +1144,22 @@ async def create_invite(
11521144
.. versionadded:: 2.0
11531145
11541146
target_user: Optional[:class:`User`]
1155-
The user whose stream to display for this invite, required if `target_type` is `TargetType.stream`. The user must be streaming in the channel.
1147+
The user whose stream to display for this invite, required if `target_type` is `TargetType.stream`.
1148+
The user must be streaming in the channel.
11561149
11571150
.. versionadded:: 2.0
11581151
11591152
target_application_id: Optional[:class:`int`]
1160-
The id of the embedded application for the invite, required if `target_type` is `TargetType.embedded_application`.
1153+
The id of the embedded application for the invite, required if `target_type` is
1154+
`TargetType.embedded_application`.
11611155
11621156
.. versionadded:: 2.0
11631157
1164-
target_event: Optional[:class:`ScheduledEvent`]
1158+
target_event: Optional[:class:`.ScheduledEvent`]
11651159
The scheduled event object to link to the event.
1166-
Shortcut to :meth:`Invite.set_scheduled_event`
1160+
Shortcut to :meth:`.Invite.set_scheduled_event`
11671161
1168-
See :meth:`Invite.set_scheduled_event` for more
1162+
See :meth:`.Invite.set_scheduled_event` for more
11691163
info on event invite linking.
11701164
11711165
.. versionadded:: 2.0
@@ -1383,11 +1377,13 @@ async def send(
13831377
13841378
.. versionadded:: 1.4
13851379
1386-
reference: Union[:class:`~discord.Message`, :class:`~discord.MessageReference`, :class:`~discord.PartialMessage`]
1380+
reference: Union[:class:`~discord.Message`, :class:`~discord.MessageReference`,
1381+
:class:`~discord.PartialMessage`]
13871382
A reference to the :class:`~discord.Message` to which you are replying, this can be created using
13881383
:meth:`~discord.Message.to_reference` or passed directly as a :class:`~discord.Message`. You can control
1389-
whether this mentions the author of the referenced message using the :attr:`~discord.AllowedMentions.replied_user`
1390-
attribute of ``allowed_mentions`` or by setting ``mention_author``.
1384+
whether this mentions the author of the referenced message using the
1385+
:attr:`~discord.AllowedMentions.replied_user` attribute of ``allowed_mentions`` or by
1386+
setting ``mention_author``.
13911387
13921388
.. versionadded:: 1.6
13931389
@@ -1732,7 +1728,7 @@ def history(
17321728
If a datetime is provided, it is recommended to use a UTC aware datetime.
17331729
If the datetime is naive, it is assumed to be local time.
17341730
When using this argument, the maximum limit is 101. Note that if the limit is an
1735-
even number then this will return at most limit + 1 messages.
1731+
even number, then this will return at most limit + 1 messages.
17361732
oldest_first: Optional[:class:`bool`]
17371733
If set to ``True``, return messages in oldest->newest order. Defaults to ``True`` if
17381734
``after`` is specified, otherwise ``False``.

discord/activity.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,6 @@
9797
from .types.activity import Activity as ActivityPayload
9898
from .types.activity import (
9999
ActivityAssets,
100-
ActivityButton,
101100
ActivityParty,
102101
ActivityTimestamps,
103102
)
@@ -166,15 +165,15 @@ class Activity(BaseActivity):
166165
The user's current state. For example, "In Game".
167166
details: Optional[:class:`str`]
168167
The detail of the user's current activity.
169-
timestamps: :class:`dict`
168+
timestamps: Dict[:class:`str`, :class:`int`]
170169
A dictionary of timestamps. It contains the following optional keys:
171170
172171
- ``start``: Corresponds to when the user started doing the
173172
activity in milliseconds since Unix epoch.
174173
- ``end``: Corresponds to when the user will finish doing the
175174
activity in milliseconds since Unix epoch.
176175
177-
assets: :class:`dict`
176+
assets: Dict[:class:`str`, :class:`str`]
178177
A dictionary representing the images and their hover text of an activity.
179178
It contains the following optional keys:
180179
@@ -183,12 +182,12 @@ class Activity(BaseActivity):
183182
- ``small_image``: A string representing the ID for the small image asset.
184183
- ``small_text``: A string representing the text when hovering over the small image asset.
185184
186-
party: :class:`dict`
185+
party: Dict[:class:`str`, Union[:class:`str`, List[:class:`int`]]]
187186
A dictionary representing the activity party. It contains the following optional keys:
188187
189188
- ``id``: A string representing the party ID.
190189
- ``size``: A list of up to two integer elements denoting (current_size, maximum_size).
191-
buttons: Union[List[:class:`dict`], List[:class:`str`]]
190+
buttons: Union[List[Dict[:class:`str`, :class:`str`]], List[:class:`str`]]
192191
A list of dictionaries representing custom buttons shown in a rich presence.
193192
Each dictionary contains the following keys:
194193
@@ -197,7 +196,7 @@ class Activity(BaseActivity):
197196
198197
.. note::
199198
200-
Bots cannot access a user's activity button URLs. Therefore the type of this attribute
199+
Bots cannot access a user's activity button URLs. Therefore, the type of this attribute
201200
will be List[:class:`str`] when received through the gateway.
202201
203202
.. versionadded:: 2.0
@@ -475,8 +474,8 @@ class Streaming(BaseActivity):
475474
476475
url: :class:`str`
477476
The stream's URL.
478-
assets: :class:`dict`
479-
A dictionary comprising of similar keys than those in :attr:`Activity.assets`.
477+
assets: Dict[:class:`str`, :class:`str`]
478+
A dictionary comprised of similar keys than those in :attr:`Activity.assets`.
480479
"""
481480

482481
__slots__ = ("platform", "name", "game", "url", "details", "assets")
@@ -509,7 +508,7 @@ def twitch_name(self):
509508
"""Optional[:class:`str`]: If provided, the twitch name of the user streaming.
510509
511510
This corresponds to the ``large_image`` key of the :attr:`Streaming.assets`
512-
dictionary if it starts with ``twitch:``. Typically set by the Discord client.
511+
dictionary if it starts with ``twitch:``. Typically this is set by the Discord client.
513512
"""
514513

515514
try:

discord/appinfo.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ class AppInfo:
6767
Whether the bot can be invited by anyone or if it is locked
6868
to the application owner.
6969
bot_require_code_grant: :class:`bool`
70-
Whether the bot requires the completion of the full oauth2 code
70+
Whether the bot requires the completion of the full OAuth2 code
7171
grant flow to join.
7272
rpc_origins: Optional[List[:class:`str`]]
7373
A list of RPC origin URLs, if RPC is enabled.
@@ -188,7 +188,7 @@ def cover_image(self) -> Optional[Asset]:
188188
@property
189189
def guild(self) -> Optional[Guild]:
190190
"""Optional[:class:`Guild`]: If this application is a game sold on Discord,
191-
this field will be the guild to which it has been linked
191+
this field will be the guild to which it has been linked.
192192
193193
.. versionadded:: 1.3
194194
"""

discord/audit_logs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,7 @@ class AuditLogEntry(Hashable):
412412
The reason this action was done.
413413
extra: Any
414414
Extra information that this entry has that might be useful.
415-
For most actions, this is ``None``. However in some cases it
415+
For most actions, this is ``None``. However, in some cases it
416416
contains extra information. See :class:`AuditLogAction` for
417417
which actions have this field filled out.
418418
"""

discord/automod.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,11 @@ class AutoModActionMetadata:
7070
Attributes
7171
-----------
7272
channel_id: :class:`int`
73-
The ID of the channel to send the message to. Only for actions of type :attr:`AutoModActionType.send_alert_message`.
73+
The ID of the channel to send the message to.
74+
Only for actions of type :attr:`AutoModActionType.send_alert_message`.
7475
timeout_duration: :class:`datetime.timedelta`
75-
How long the member that triggered the action should be timed out for. Only for actions of type :attr:`AutoModActionType.timeout`.
76+
How long the member that triggered the action should be timed out for.
77+
Only for actions of type :attr:`AutoModActionType.timeout`.
7678
"""
7779
# maybe add a table of action types and attributes?
7880

@@ -124,7 +126,6 @@ def __repr__(self) -> str:
124126
return f"<AutoModActionMetadata {inner}>"
125127

126128

127-
128129
class AutoModAction:
129130
"""Represents an action for a guild's auto moderation rule.
130131
@@ -200,7 +201,7 @@ def to_dict(self) -> Dict:
200201
return data
201202

202203
@classmethod
203-
def from_dict(cls, data: AutoModActionMetadataPayload):
204+
def from_dict(cls, data: AutoModTriggerMetadataPayload):
204205
kwargs = {}
205206

206207
if (keyword_filter := data.get("keyword_filter")) is not None:
@@ -339,8 +340,8 @@ def exempt_roles(self) -> List[Union[Role, Object]]:
339340

340341
@cached_property
341342
def exempt_channels(self) -> List[Union[Union[TextChannel, ForumChannel, VoiceChannel], Object]]:
342-
"""List[Union[Union[:class:`TextChannel`, :class:`ForumChannel`, :class:`VoiceChannel`], :class:`Object`]]: The channels
343-
that are exempt from this rule.
343+
"""List[Union[Union[:class:`TextChannel`, :class:`ForumChannel`, :class:`VoiceChannel`], :class:`Object`]]:
344+
The channels that are exempt from this rule.
344345
345346
If a channel is not found in the guild's cache,
346347
then it will be returned as an :class:`Object`.

0 commit comments

Comments
 (0)