Skip to content

Commit 8ac724c

Browse files
committed
Can't even begin to summarize this
1 parent b2b9f3c commit 8ac724c

Some content is hidden

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

71 files changed

+644
-524
lines changed

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, set by the Discord client.
513512
"""
514513

515514
try:

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`.

discord/bot.py

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,11 @@ def get_application_command(
211211
return
212212
return command
213213

214-
async def get_desynced_commands(self, guild_id: Optional[int] = None, prefetched=None) -> List[Dict[str, Any]]:
214+
async def get_desynced_commands(
215+
self,
216+
guild_id: Optional[int] = None,
217+
prefetched: Optional[List[ApplicationCommand]] = None
218+
) -> List[Dict[str, Any]]:
215219
"""|coro|
216220
217221
Gets the list of commands that are desynced from discord. If ``guild_id`` is specified, it will only return
@@ -228,12 +232,12 @@ async def get_desynced_commands(self, guild_id: Optional[int] = None, prefetched
228232
----------
229233
guild_id: Optional[:class:`int`]
230234
The guild id to get the desynced commands for, else global commands if unspecified.
231-
prefetched
235+
prefetched: Optional[List[:class:`.ApplicationCommand`]]
232236
If you already fetched the commands, you can pass them here to be used. Not recommended for typical usage.
233237
234238
Returns
235239
-------
236-
List[Dict[str, Any]]
240+
List[Dict[:class:`str`, Any]]
237241
A list of the desynced commands. Each will come with at least the ``cmd`` and ``action`` keys, which
238242
respectively contain the command and the action to perform. Other keys may also be present depending on
239243
the action, including ``id``.
@@ -355,8 +359,8 @@ async def register_command(
355359
) -> None:
356360
"""|coro|
357361
358-
Registers a command. If the command has ``guild_ids`` set, or if the ``guild_ids`` parameter is passed, the command will
359-
be registered as a guild command for those guilds.
362+
Registers a command. If the command has ``guild_ids`` set, or if the ``guild_ids`` parameter is passed,
363+
the command will be registered as a guild command for those guilds.
360364
361365
Parameters
362366
----------
@@ -644,8 +648,6 @@ async def sync_commands(
644648
guild_commands, guild_id=guild_id, method=method, force=force, delete_existing=delete_existing
645649
)
646650

647-
global_permissions: List = []
648-
649651
for i in registered_commands:
650652
cmd = get(
651653
self.pending_application_commands,
@@ -925,7 +927,7 @@ async def get_application_context(self, interaction: Interaction, cls=None) -> A
925927
Returns the invocation context from the interaction.
926928
927929
This is a more low-level counter-part for :meth:`.process_application_commands`
928-
to allow users more fine grained control over the processing.
930+
to allow users more fine-grained control over the processing.
929931
930932
Parameters
931933
-----------
@@ -953,7 +955,7 @@ async def get_autocomplete_context(self, interaction: Interaction, cls=None) ->
953955
Returns the autocomplete context from the interaction.
954956
955957
This is a more low-level counter-part for :meth:`.process_application_commands`
956-
to allow users more fine grained control over the processing.
958+
to allow users more fine-grained control over the processing.
957959
958960
Parameters
959961
-----------
@@ -1006,10 +1008,7 @@ def _bot(self) -> Union["Bot", "AutoShardedBot"]:
10061008
class BotBase(ApplicationCommandMixin, CogMixin, ABC):
10071009
_supports_prefixed_commands = False
10081010

1009-
# TODO I think
10101011
def __init__(self, description=None, *args, **options):
1011-
# super(Client, self).__init__(*args, **kwargs)
1012-
# I replaced ^ with v and it worked
10131012
super().__init__(*args, **options)
10141013
self.extra_events = {} # TYPE: Dict[str, List[CoroFunc]]
10151014
self.__cogs = {} # TYPE: Dict[str, Cog]
@@ -1048,7 +1047,7 @@ async def on_application_command_error(self, context: ApplicationContext, except
10481047
10491048
The default command error handler provided by the bot.
10501049
1051-
By default this prints to :data:`sys.stderr` however it could be
1050+
By default, this prints to :data:`sys.stderr` however it could be
10521051
overridden to have a different implementation.
10531052
10541053
This only fires if you do not specify any listeners for command error.
@@ -1072,7 +1071,7 @@ async def on_application_command_error(self, context: ApplicationContext, except
10721071

10731072
def check(self, func):
10741073
"""A decorator that adds a global check to the bot. A global check is similar to a :func:`.check` that is
1075-
applied on a per command basis except it is run before any command checks have been verified and applies to
1074+
applied on a per-command basis except it is run before any command checks have been verified and applies to
10761075
every command the bot has.
10771076
10781077
.. note::
@@ -1126,10 +1125,10 @@ def remove_check(self, func, *, call_once: bool = False) -> None:
11261125
the :meth:`.Bot.add_check` call or using :meth:`.check_once`.
11271126
11281127
"""
1129-
l = self._check_once if call_once else self._checks
1128+
checks = self._check_once if call_once else self._checks
11301129

11311130
try:
1132-
l.remove(func)
1131+
checks.remove(func)
11331132
except ValueError:
11341133
pass
11351134

@@ -1374,7 +1373,7 @@ class Bot(BotBase, Client):
13741373
anything that you can do with a :class:`discord.Client` you can do with
13751374
this bot.
13761375
1377-
This class also subclasses :class:`.ApplicationCommandMixin` to provide the functionality
1376+
This class also subclasses ``ApplicationCommandMixin`` to provide the functionality
13781377
to manage commands.
13791378
13801379
.. versionadded:: 2.0
@@ -1401,7 +1400,7 @@ class Bot(BotBase, Client):
14011400
14021401
.. versionadded:: 2.0
14031402
auto_sync_commands: :class:`bool`
1404-
Whether or not to automatically sync slash commands. This will call sync_commands in on_connect, and in
1403+
Whether to automatically sync slash commands. This will call sync_commands in on_connect, and in
14051404
:attr:`.process_application_commands` if the command is not found. Defaults to ``True``.
14061405
14071406
.. versionadded:: 2.0

0 commit comments

Comments
 (0)