Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 13 additions & 14 deletions discord/abc.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
Protocol,
TypeAlias,
TypeVar,
Union,
overload,
runtime_checkable,
)
Expand Down Expand Up @@ -105,7 +104,7 @@
| PartialMessageable
)
MessageableChannel: TypeAlias = PartialMessageableChannel | GroupChannel
SnowflakeTime = Union["Snowflake", datetime]
SnowflakeTime = "Snowflake" | datetime

from .voice import VoiceClient, VoiceProtocol

Expand Down Expand Up @@ -615,7 +614,7 @@ def overwrites_for(self, obj: Role | User) -> PermissionOverwrite:

Parameters
----------
obj: Union[:class:`~discord.Role`, :class:`~discord.abc.User`]
obj: :class:`~discord.Role` | :class:`~discord.abc.User`
The role or user denoting
whose overwrite to get.

Expand Down Expand Up @@ -650,7 +649,7 @@ def overwrites(self) -> dict[Role | Member, PermissionOverwrite]:

Returns
-------
Dict[Union[:class:`~discord.Role`, :class:`~discord.Member`], :class:`~discord.PermissionOverwrite`]
Dict[:class:`~discord.Role` | :class:`~discord.Member`, :class:`~discord.PermissionOverwrite`]
The channel's permission overwrites.
"""
ret = {}
Expand Down Expand Up @@ -721,7 +720,7 @@ def permissions_for(self, obj: Member | Role, /) -> Permissions:

Parameters
----------
obj: Union[:class:`~discord.Member`, :class:`~discord.Role`]
obj: :class:`~discord.Member` | :class:`~discord.Role`
The object to resolve permissions for. This could be either
a member or a role. If it's a role then member overwrites
are not computed.
Expand Down Expand Up @@ -926,7 +925,7 @@ async def set_permissions(

Parameters
-----------
target: Union[:class:`~discord.Member`, :class:`~discord.Role`]
target: :class:`~discord.Member` | :class:`~discord.Role`
The member or role to overwrite permissions for.
overwrite: Optional[:class:`~discord.PermissionOverwrite`]
The permissions to allow and deny to the target, or ``None`` to
Expand Down Expand Up @@ -1271,7 +1270,7 @@ async def create_invite(

.. versionadded:: 2.0

roles: Optional[List[Union[:class:`.Role`, :class:`.Object`]]]
roles: Optional[List[:class:`.Role` | :class:`.Object`]]
The roles to give a user when joining through this invite.

You must have the :attr:`~Permissions.manage_roles` permission to do this and roles cannot be higher than your own.
Expand Down Expand Up @@ -1510,7 +1509,7 @@ 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: Union[:class:`str`, :class:`int`]
nonce: :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`]
Expand All @@ -1531,7 +1530,7 @@ async def send(

.. versionadded:: 1.4

reference: Union[:class:`~discord.Message`, :class:`~discord.MessageReference`, :class:`~discord.PartialMessage`]
reference: :class:`~discord.Message` | :class:`~discord.MessageReference` | :class:`~discord.PartialMessage`
A reference to the :class:`~discord.Message` being replied to or forwarded. This can be created using
:meth:`~discord.Message.to_reference`.
When replying, you can control whether this mentions the author of the referenced message using the
Expand All @@ -1550,7 +1549,7 @@ async def send(
A list of embeds to upload. Must be a maximum of 10.

.. versionadded:: 2.0
stickers: Sequence[Union[:class:`~discord.GuildSticker`, :class:`~discord.StickerItem`]]
stickers: Sequence[:class:`~discord.GuildSticker` | :class:`~discord.StickerItem`]
A list of stickers to upload. Must be a maximum of 3.

.. versionadded:: 2.0
Expand Down Expand Up @@ -1819,7 +1818,7 @@ def pins(
limit: Optional[:class:`int`]
The number of pinned messages to retrieve.
If ``None``, retrieves every pinned message in the channel.
before: Optional[Union[:class:`~discord.abc.Snowflake`, :class:`datetime.datetime`]]
before: Optional[:class:`~discord.abc.Snowflake` | :class:`datetime.datetime`]
Retrieve messages pinned before this datetime.
If a datetime is provided, it is recommended to use a UTC aware datetime.
If the datetime is naive, it is assumed to be local time.
Expand Down Expand Up @@ -1938,15 +1937,15 @@ def history(
The number of messages to retrieve.
If ``None``, retrieves every message in the channel. Note, however,
that this would make it a slow operation.
before: Optional[Union[:class:`~discord.abc.Snowflake`, :class:`datetime.datetime`]]
before: Optional[:class:`~discord.abc.Snowflake` | :class:`datetime.datetime`]
Retrieve messages before this date or message.
If a datetime is provided, it is recommended to use a UTC aware datetime.
If the datetime is naive, it is assumed to be local time.
after: Optional[Union[:class:`~discord.abc.Snowflake`, :class:`datetime.datetime`]]
after: Optional[:class:`~discord.abc.Snowflake` | :class:`datetime.datetime`]
Retrieve messages after this date or message.
If a datetime is provided, it is recommended to use a UTC aware datetime.
If the datetime is naive, it is assumed to be local time.
around: Optional[Union[:class:`~discord.abc.Snowflake`, :class:`datetime.datetime`]]
around: Optional[:class:`~discord.abc.Snowflake` | :class:`datetime.datetime`]
Retrieve messages around this date or message.
If a datetime is provided, it is recommended to use a UTC aware datetime.
If the datetime is naive, it is assumed to be local time.
Expand Down
8 changes: 4 additions & 4 deletions discord/activity.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
from __future__ import annotations

import datetime
from typing import TYPE_CHECKING, Any, Union, overload
from typing import TYPE_CHECKING, Any, overload

from .asset import Asset
from .colour import Colour
Expand Down Expand Up @@ -180,12 +180,12 @@ class Activity(BaseActivity):
- ``small_image``: A string representing the ID for the small image asset.
- ``small_text``: A string representing the text when hovering over the small image asset.

party: Dict[:class:`str`, Union[:class:`str`, List[:class:`int`]]]
party: Dict[:class:`str`, :class:`str` | List[:class:`int`]]
A dictionary representing the activity party. It contains the following optional keys:

- ``id``: A string representing the party ID.
- ``size``: A list of up to two integer elements denoting (current_size, maximum_size).
buttons: Union[List[Dict[:class:`str`, :class:`str`]], List[:class:`str`]]
buttons: List[Dict[:class:`str`, :class:`str`]] | List[:class:`str`]
A list of dictionaries representing custom buttons shown in a rich presence.
Each dictionary contains the following keys:

Expand Down Expand Up @@ -839,7 +839,7 @@ def __repr__(self) -> str:
return f"<CustomActivity name={self.name!r} emoji={self.emoji!r}>"


ActivityTypes = Union[Activity, Game, CustomActivity, Streaming, Spotify]
ActivityTypes = Activity | Game | CustomActivity | Streaming | Spotify


@overload
Expand Down
2 changes: 1 addition & 1 deletion discord/asset.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ async def save(

Parameters
----------
fp: Union[:class:`io.BufferedIOBase`, :class:`os.PathLike`]
fp: :class:`io.BufferedIOBase` | :class:`os.PathLike`
The file-like object to save this attachment to or the filename
to use. If a filename is passed then a file is created with that
filename and used instead.
Expand Down
2 changes: 1 addition & 1 deletion discord/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -1589,7 +1589,7 @@ async def is_owner(self, user: User | Member) -> bool:

Parameters
----------
user: Union[:class:`.abc.User`, :class:`.member.Member`]
user: :class:`.abc.User` | :class:`.member.Member`
The user to check for.

Returns
Expand Down
40 changes: 20 additions & 20 deletions discord/channel.py
Original file line number Diff line number Diff line change
Expand Up @@ -444,11 +444,11 @@ async def purge(
check: Callable[[:class:`Message`], :class:`bool`]
The function used to check if a message should be deleted.
It must take a :class:`Message` as its sole parameter.
before: Optional[Union[:class:`abc.Snowflake`, :class:`datetime.datetime`]]
before: Optional[:class:`abc.Snowflake` | :class:`datetime.datetime`]
Same as ``before`` in :meth:`history`.
after: Optional[Union[:class:`abc.Snowflake`, :class:`datetime.datetime`]]
after: Optional[:class:`abc.Snowflake` | :class:`datetime.datetime`]
Same as ``after`` in :meth:`history`.
around: Optional[Union[:class:`abc.Snowflake`, :class:`datetime.datetime`]]
around: Optional[:class:`abc.Snowflake` | :class:`datetime.datetime`]
Same as ``around`` in :meth:`history`.
oldest_first: Optional[:class:`bool`]
Same as ``oldest_first`` in :meth:`history`.
Expand Down Expand Up @@ -675,7 +675,7 @@ def archived_threads(
The number of threads to retrieve.
If ``None``, retrieves every archived thread in the channel. Note, however,
that this would make it a slow operation.
before: Optional[Union[:class:`abc.Snowflake`, :class:`datetime.datetime`]]
before: Optional[:class:`abc.Snowflake` | :class:`datetime.datetime`]
Retrieve archived channels before the given date or ID.
private: :class:`bool`
Whether to retrieve private archived threads.
Expand Down Expand Up @@ -856,7 +856,7 @@ async def edit(self, *, reason=None, **options):
is only available to guilds that contain ``NEWS`` in :attr:`Guild.features`.
reason: Optional[:class:`str`]
The reason for editing this channel. Shows up on the audit log.
overwrites: Dict[Union[:class:`Role`, :class:`Member`, :class:`~discord.abc.Snowflake`], :class:`PermissionOverwrite`]
overwrites: Dict[:class:`Role` | :class:`Member` | :class:`~discord.abc.Snowflake`, :class:`PermissionOverwrite`]
The overwrites to apply to channel permissions. Useful for creating secret channels.
default_auto_archive_duration: :class:`int`
The new default auto archive duration in minutes for threads created in this channel.
Expand Down Expand Up @@ -1157,7 +1157,7 @@ async def edit(self, *, reason=None, **options):
A value of `0` disables slowmode. The maximum value possible is `21600`.
reason: Optional[:class:`str`]
The reason for editing this channel. Shows up on the audit log.
overwrites: Dict[Union[:class:`Role`, :class:`Member`, :class:`~discord.abc.Snowflake`], :class:`PermissionOverwrite`]
overwrites: Dict[:class:`Role` | :class:`Member` | :class:`~discord.abc.Snowflake`, :class:`PermissionOverwrite`]
The overwrites to apply to channel permissions. Useful for creating secret channels.
default_auto_archive_duration: :class:`int`
The new default auto archive duration in minutes for threads created in this channel.
Expand Down Expand Up @@ -1255,11 +1255,11 @@ async def create_thread(
The file to upload.
files: List[:class:`~discord.File`]
A list of files to upload. Must be a maximum of 10.
stickers: Sequence[Union[:class:`~discord.GuildSticker`, :class:`~discord.StickerItem`]]
stickers: Sequence[:class:`~discord.GuildSticker` | :class:`~discord.StickerItem`]
A list of stickers to upload. Must be a maximum of 3.
delete_message_after: :class:`int`
The time to wait before deleting the thread.
nonce: Union[:class:`str`, :class:`int`]
nonce: :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.
allowed_mentions: :class:`~discord.AllowedMentions`
Expand Down Expand Up @@ -1535,7 +1535,7 @@ async def edit(self, *, reason=None, **options):
A value of `0` disables slowmode. The maximum value possible is `21600`.
reason: Optional[:class:`str`]
The reason for editing this channel. Shows up on the audit log.
overwrites: Dict[Union[:class:`Role`, :class:`Member`, :class:`~discord.abc.Snowflake`], :class:`PermissionOverwrite`]
overwrites: Dict[:class:`Role` | :class:`Member` | :class:`~discord.abc.Snowflake`, :class:`PermissionOverwrite`]
The overwrites to apply to channel permissions. Useful for creating secret channels.
default_auto_archive_duration: :class:`int`
The new default auto archive duration in minutes for threads created in this channel.
Expand Down Expand Up @@ -1947,11 +1947,11 @@ async def purge(
check: Callable[[:class:`Message`], :class:`bool`]
The function used to check if a message should be deleted.
It must take a :class:`Message` as its sole parameter.
before: Optional[Union[:class:`abc.Snowflake`, :class:`datetime.datetime`]]
before: Optional[:class:`abc.Snowflake` | :class:`datetime.datetime`]
Same as ``before`` in :meth:`history`.
after: Optional[Union[:class:`abc.Snowflake`, :class:`datetime.datetime`]]
after: Optional[:class:`abc.Snowflake` | :class:`datetime.datetime`]
Same as ``after`` in :meth:`history`.
around: Optional[Union[:class:`abc.Snowflake`, :class:`datetime.datetime`]]
around: Optional[:class:`abc.Snowflake` | :class:`datetime.datetime`]
Same as ``around`` in :meth:`history`.
oldest_first: Optional[:class:`bool`]
Same as ``oldest_first`` in :meth:`history`.
Expand Down Expand Up @@ -2133,7 +2133,7 @@ async def edit(self, *, reason=None, **options):
category.
reason: Optional[:class:`str`]
The reason for editing this channel. Shows up on the audit log.
overwrites: Dict[Union[:class:`Role`, :class:`Member`, :class:`~discord.abc.Snowflake`], :class:`PermissionOverwrite`]
overwrites: Dict[:class:`Role` | :class:`Member` | :class:`~discord.abc.Snowflake`, :class:`PermissionOverwrite`]
The overwrites to apply to channel permissions. Useful for creating secret channels.
rtc_region: Optional[:class:`VoiceRegion`]
The new region for the voice channel's voice communication.
Expand Down Expand Up @@ -2187,7 +2187,7 @@ async def create_activity_invite(

Parameters
----------
activity: Union[:class:`discord.EmbeddedActivity`, :class:`int`]
activity: :class:`discord.EmbeddedActivity` | :class:`int`
The activity to create an invite for which can be an application id as well.
max_age: :class:`int`
How long the invite should last in seconds. If it's 0 then the invite
Expand Down Expand Up @@ -2241,7 +2241,7 @@ async def set_status(

Parameters
----------
status: Union[:class:`str`, None]
status: :class:`str` | None
The new status.
reason: Optional[:class:`str`]
The reason for setting the status. Shows up on the audit log.
Expand Down Expand Up @@ -2535,11 +2535,11 @@ async def purge(
check: Callable[[:class:`Message`], :class:`bool`]
The function used to check if a message should be deleted.
It must take a :class:`Message` as its sole parameter.
before: Optional[Union[:class:`abc.Snowflake`, :class:`datetime.datetime`]]
before: Optional[:class:`abc.Snowflake` | :class:`datetime.datetime`]
Same as ``before`` in :meth:`history`.
after: Optional[Union[:class:`abc.Snowflake`, :class:`datetime.datetime`]]
after: Optional[:class:`abc.Snowflake` | :class:`datetime.datetime`]
Same as ``after`` in :meth:`history`.
around: Optional[Union[:class:`abc.Snowflake`, :class:`datetime.datetime`]]
around: Optional[:class:`abc.Snowflake` | :class:`datetime.datetime`]
Same as ``around`` in :meth:`history`.
oldest_first: Optional[:class:`bool`]
Same as ``oldest_first`` in :meth:`history`.
Expand Down Expand Up @@ -2814,7 +2814,7 @@ async def edit(self, *, reason=None, **options):
category.
reason: Optional[:class:`str`]
The reason for editing this channel. Shows up on the audit log.
overwrites: Dict[Union[:class:`Role`, :class:`Member`, :class:`~discord.abc.Snowflake`], :class:`PermissionOverwrite`]
overwrites: Dict[:class:`Role` | :class:`Member` | :class:`~discord.abc.Snowflake`, :class:`PermissionOverwrite`]
The overwrites to apply to channel permissions. Useful for creating secret channels.
rtc_region: Optional[:class:`VoiceRegion`]
The new region for the stage channel's voice communication.
Expand Down Expand Up @@ -2980,7 +2980,7 @@ async def edit(self, *, reason=None, **options):
The new category's position.
reason: Optional[:class:`str`]
The reason for editing this category. Shows up on the audit log.
overwrites: Dict[Union[:class:`Role`, :class:`Member`, :class:`~discord.abc.Snowflake`], :class:`PermissionOverwrite`]
overwrites: Dict[:class:`Role` | :class:`Member` | :class:`~discord.abc.Snowflake`, :class:`PermissionOverwrite`]
The overwrites to apply to channel permissions. Useful for creating secret channels.

Returns
Expand Down
Loading
Loading