Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
8d8d5e1
fix docs for soundboard_sound_update event
owocado Jun 20, 2025
7f16a06
Copy Select options when creating View class
LeoCx1000 Jun 20, 2025
3e48119
Fix unreachable code not triggering privileged intent error
frxctura Jun 20, 2025
0ce1154
Add discord.Permissions.apps()
Depreca1ed Jun 20, 2025
aa5f4bd
Fix poll parameter defaulting to MISSING instead of None for Context.…
Soheab Jun 20, 2025
680fe9b
Add channel select to component type documentation
Tari-dev Jun 20, 2025
e84edf4
Add colours for new Discord themes
LeoCx1000 Jun 20, 2025
e177b4a
Fix EmbedMediaProxy boolean check
AbstractUmbra Jun 20, 2025
ef06d7d
Add Interaction.filesize_limit
LeoCx1000 Jun 20, 2025
b28a4a1
Fix potentially stuck ratelimit buckets
mikeshardmind Jun 20, 2025
adb93f4
Add deprecation warning to create_guild functions
Gooraeng Jun 20, 2025
4a8817a
Document return object for Guild.create_template
Soheab Jun 20, 2025
667e7c9
Fixed to_dict() bug for user-defined embed classes
cyberoby Jun 20, 2025
2bcbd49
Add __repr__ method to various classes
owocado Jun 20, 2025
c524f65
Use human_join internal helper in BaseChannelTransformer
owocado Jun 20, 2025
826aa22
Add platform key in __repr__ method for Game and Streaming
owocado Jun 20, 2025
fe942d1
Properly transform media channels in app commands
owocado Jun 20, 2025
d00c124
Add MessageApplication.__str__
owocado Jun 20, 2025
4862ea2
Return invites when deleting them via Invite.delete or Client.delete_…
owocado Jun 20, 2025
f6e0f72
Add ability to create a media-only forum channel
Soheab Jun 20, 2025
6af9de0
Ensure COPYING notice is included
mikeshardmind Jun 20, 2025
7fe1102
Allow creating NSFW voice/stage channels
Soheab Jun 20, 2025
e9f807e
Fix Thread.applied_tags for media channels
owocado Jun 20, 2025
44fb360
Add new role parameters for creation of gradient and holographic roles
makerze Jun 20, 2025
4d05813
Fix: throw exception when color is used together with colors parameters
makerze Jun 20, 2025
89961e5
linter
makerze Jun 20, 2025
e230384
black format
makerze Jun 20, 2025
59a35a2
black format
makerze Jun 20, 2025
c8542c4
format
makerze Jun 20, 2025
a62b25c
Add missing attributes in AppCommandChannel
owocado Jun 20, 2025
9e78b95
Merge branch 'Rapptz:master' into add-role-parameters
makerze Jun 20, 2025
d26e4d6
Update discord/guild.py
makerze Jun 21, 2025
f1047a5
Add alias to primary, secondary and tertiary color
makerze Jun 21, 2025
8bcc0c7
Update discord/guild.py
makerze Jun 23, 2025
8644374
Apply suggestions from code review
makerze Jun 23, 2025
8b5895c
Apply suggestions from code review
makerze Jun 23, 2025
ee963d0
Fix: color=primary_color and add types
makerze Jun 23, 2025
95c4744
Fix: types and broken none
makerze Jun 26, 2025
98e3668
refactor: Colour assigns only primary_color and added version strings
makerze Jul 6, 2025
343130f
Apply suggestions from code review
makerze Jul 6, 2025
70b5a17
Update discord/role.py
makerze Jul 7, 2025
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
2 changes: 1 addition & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
include README.rst
include LICENSE
include requirements.txt
include discord/bin/*.dll
include discord/bin/*
include discord/py.typed
4 changes: 2 additions & 2 deletions discord/activity.py
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ def __str__(self) -> str:
return str(self.name)

def __repr__(self) -> str:
return f'<Game name={self.name!r}>'
return f'<Game name={self.name!r} platform={self.platform!r}>'

def to_dict(self) -> Dict[str, Any]:
timestamps: Dict[str, Any] = {}
Expand Down Expand Up @@ -514,7 +514,7 @@ def __str__(self) -> str:
return str(self.name)

def __repr__(self) -> str:
return f'<Streaming name={self.name!r}>'
return f'<Streaming name={self.name!r} platform={self.platform!r}>'

@property
def twitch_name(self) -> Optional[str]:
Expand Down
6 changes: 6 additions & 0 deletions discord/app_commands/installs.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ def __init__(self, *, guild: Optional[bool] = None, user: Optional[bool] = None)
self._guild: Optional[bool] = guild
self._user: Optional[bool] = user

def __repr__(self):
return f'<AppInstallationType guild={self.guild!r} user={self.user!r}>'

@property
def guild(self) -> bool:
""":class:`bool`: Whether the integration is a guild install."""
Expand Down Expand Up @@ -142,6 +145,9 @@ def __init__(
self._dm_channel: Optional[bool] = dm_channel
self._private_channel: Optional[bool] = private_channel

def __repr__(self) -> str:
return f'<AppCommandContext guild={self.guild!r} dm_channel={self.dm_channel!r} private_channel={self.private_channel!r}>'

@property
def guild(self) -> bool:
""":class:`bool`: Whether the context allows usage in a guild."""
Expand Down
75 changes: 74 additions & 1 deletion discord/app_commands/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
from datetime import datetime

from .errors import MissingApplicationID
from ..flags import AppCommandContext, AppInstallationType
from ..flags import AppCommandContext, AppInstallationType, ChannelFlags
from .translator import TranslationContextLocation, TranslationContext, locale_str, Translator
from ..permissions import Permissions
from ..enums import (
Expand Down Expand Up @@ -575,6 +575,35 @@ class AppCommandChannel(Hashable):
the application command in that channel.
guild_id: :class:`int`
The guild ID this channel belongs to.
category_id: Optional[:class:`int`]
The category channel ID this channel belongs to, if applicable.

.. versionadded:: 2.6
topic: Optional[:class:`str`]
The channel's topic. ``None`` if it doesn't exist.

.. versionadded:: 2.6
position: :class:`int`
The position in the channel list. This is a number that starts at 0. e.g. the
top channel is position 0.

.. versionadded:: 2.6
last_message_id: Optional[:class:`int`]
The last message ID of the message sent to this channel. It may
*not* point to an existing or valid message.

.. versionadded:: 2.6
slowmode_delay: :class:`int`
The number of seconds a member must wait between sending messages
in this channel. A value of ``0`` denotes that it is disabled.
Bots and users with :attr:`~discord.Permissions.manage_channels` or
:attr:`~discord.Permissions.manage_messages` bypass slowmode.

.. versionadded:: 2.6
nsfw: :class:`bool`
If the channel is marked as "not safe for work" or "age restricted".

.. versionadded:: 2.6
"""

__slots__ = (
Expand All @@ -583,6 +612,14 @@ class AppCommandChannel(Hashable):
'name',
'permissions',
'guild_id',
'topic',
'nsfw',
'position',
'category_id',
'slowmode_delay',
'last_message_id',
'_last_pin',
'_flags',
'_state',
)

Expand All @@ -599,6 +636,14 @@ def __init__(
self.type: ChannelType = try_enum(ChannelType, data['type'])
self.name: str = data['name']
self.permissions: Permissions = Permissions(int(data['permissions']))
self.topic: Optional[str] = data.get('topic')
self.position: int = data.get('position') or 0
self.nsfw: bool = data.get('nsfw') or False
self.category_id: Optional[int] = _get_as_snowflake(data, 'parent_id')
self.slowmode_delay: int = data.get('rate_limit_per_user') or 0
self.last_message_id: Optional[int] = _get_as_snowflake(data, 'last_message_id')
self._last_pin: Optional[datetime] = parse_time(data.get('last_pin_timestamp'))
self._flags: int = data.get('flags', 0)

def __str__(self) -> str:
return self.name
Expand All @@ -611,6 +656,28 @@ def guild(self) -> Optional[Guild]:
"""Optional[:class:`~discord.Guild`]: The channel's guild, from cache, if found."""
return self._state._get_guild(self.guild_id)

@property
def flags(self) -> ChannelFlags:
""":class:`~discord.ChannelFlags`: The flags associated with this channel object.

.. versionadded:: 2.6
"""
return ChannelFlags._from_value(self._flags)

def is_nsfw(self) -> bool:
""":class:`bool`: Checks if the channel is NSFW.

.. versionadded:: 2.6
"""
return self.nsfw

def is_news(self) -> bool:
""":class:`bool`: Checks if the channel is a news channel.

.. versionadded:: 2.6
"""
return self.type == ChannelType.news

def resolve(self) -> Optional[GuildChannel]:
"""Resolves the application command channel to the appropriate channel
from cache if found.
Expand Down Expand Up @@ -1063,6 +1130,9 @@ def __init__(self, *, data: ApplicationCommandPermissions, guild: Guild, state:

self.target: Union[Object, User, Member, Role, AllChannels, GuildChannel] = _object

def __repr__(self) -> str:
return f'<AppCommandPermissions id={self.id} type={self.type!r} guild={self.guild!r} permission={self.permission}>'

def to_dict(self) -> ApplicationCommandPermissions:
return {
'id': self.target.id,
Expand Down Expand Up @@ -1106,6 +1176,9 @@ def __init__(self, *, data: GuildApplicationCommandPermissions, state: Connectio
AppCommandPermissions(data=value, guild=guild, state=self._state) for value in data['permissions']
]

def __repr__(self) -> str:
return f'<GuildAppCommandPermissions id={self.id!r} guild_id={self.guild_id!r} permissions={self.permissions!r}>'

def to_dict(self) -> Dict[str, Any]:
return {'permissions': [p.to_dict() for p in self.permissions]}

Expand Down
8 changes: 5 additions & 3 deletions discord/app_commands/transformers.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
from ..abc import GuildChannel
from ..threads import Thread
from ..enums import Enum as InternalEnum, AppCommandOptionType, ChannelType, Locale
from ..utils import MISSING, maybe_coroutine
from ..utils import MISSING, maybe_coroutine, _human_join
from ..user import User
from ..role import Role
from ..member import Member
Expand Down Expand Up @@ -631,7 +631,7 @@ def __init__(self, *channel_types: Type[Any]) -> None:
display_name = channel_types[0].__name__
types = CHANNEL_TO_TYPES[channel_types[0]]
else:
display_name = '{}, and {}'.format(', '.join(t.__name__ for t in channel_types[:-1]), channel_types[-1].__name__)
display_name = _human_join([t.__name__ for t in channel_types])
types = []

for t in channel_types:
Expand Down Expand Up @@ -689,6 +689,7 @@ async def transform(self, interaction: Interaction[ClientT], value: Any, /):
ChannelType.news,
ChannelType.category,
ChannelType.forum,
ChannelType.media,
],
GuildChannel: [
ChannelType.stage_voice,
Expand All @@ -697,14 +698,15 @@ async def transform(self, interaction: Interaction[ClientT], value: Any, /):
ChannelType.news,
ChannelType.category,
ChannelType.forum,
ChannelType.media,
],
AppCommandThread: [ChannelType.news_thread, ChannelType.private_thread, ChannelType.public_thread],
Thread: [ChannelType.news_thread, ChannelType.private_thread, ChannelType.public_thread],
StageChannel: [ChannelType.stage_voice],
VoiceChannel: [ChannelType.voice],
TextChannel: [ChannelType.text, ChannelType.news],
CategoryChannel: [ChannelType.category],
ForumChannel: [ChannelType.forum],
ForumChannel: [ChannelType.forum, ChannelType.media],
}

BUILT_IN_TRANSFORMERS: Dict[Any, Transformer] = {
Expand Down
11 changes: 8 additions & 3 deletions discord/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
from .http import HTTPClient
from .state import ConnectionState
from . import utils
from .utils import MISSING, time_snowflake
from .utils import MISSING, time_snowflake, deprecated
from .object import Object
from .backoff import ExponentialBackoff
from .webhook import Webhook
Expand Down Expand Up @@ -2388,6 +2388,7 @@ async def fetch_guild_preview(self, guild_id: int) -> GuildPreview:
data = await self.http.get_guild_preview(guild_id)
return GuildPreview(data=data, state=self._connection)

@deprecated()
async def create_guild(
self,
*,
Expand All @@ -2408,6 +2409,9 @@ async def create_guild(
This function will now raise :exc:`ValueError` instead of
``InvalidArgument``.

.. deprecated:: 2.6
This function is deprecated and will be removed in a future version.

Parameters
----------
name: :class:`str`
Expand Down Expand Up @@ -2546,7 +2550,7 @@ async def fetch_invite(
)
return Invite.from_incomplete(state=self._connection, data=data)

async def delete_invite(self, invite: Union[Invite, str], /) -> None:
async def delete_invite(self, invite: Union[Invite, str], /) -> Invite:
"""|coro|

Revokes an :class:`.Invite`, URL, or ID to an invite.
Expand Down Expand Up @@ -2574,7 +2578,8 @@ async def delete_invite(self, invite: Union[Invite, str], /) -> None:
"""

resolved = utils.resolve_invite(invite)
await self.http.delete_invite(resolved.code)
data = await self.http.delete_invite(resolved.code)
return Invite.from_incomplete(state=self._connection, data=data)

# Miscellaneous stuff

Expand Down
83 changes: 75 additions & 8 deletions discord/colour.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.
"""

from __future__ import annotations

import colorsys
Expand Down Expand Up @@ -457,20 +458,59 @@ def greyple(cls) -> Self:
"""
return cls(0x99AAB5)

@classmethod
def ash_theme(cls) -> Self:
"""A factory method that returns a :class:`Colour` with a value of ``0x2E2E34``.

This will appear transparent on Discord's ash theme.

.. colour:: #2E2E34

.. versionadded:: 2.6
"""
return cls(0x2E2E34)

@classmethod
def dark_theme(cls) -> Self:
"""A factory method that returns a :class:`Colour` with a value of ``0x313338``.
"""A factory method that returns a :class:`Colour` with a value of ``0x1A1A1E``.

This will appear transparent on Discord's dark theme.

.. colour:: #313338
.. colour:: #1A1A1E

.. versionadded:: 1.5

.. versionchanged:: 2.2
Updated colour from previous ``0x36393F`` to reflect discord theme changes.

.. versionchanged:: 2.6
Updated colour from previous ``0x313338`` to reflect discord theme changes.
"""
return cls(0x313338)
return cls(0x1A1A1E)

@classmethod
def onyx_theme(cls) -> Self:
"""A factory method that returns a :class:`Colour` with a value of ``0x070709``.

This will appear transparent on Discord's onyx theme.

.. colour:: #070709

.. versionadded:: 2.6
"""
return cls(0x070709)

@classmethod
def light_theme(cls) -> Self:
"""A factory method that returns a :class:`Colour` with a value of ``0xFBFBFB``.

This will appear transparent on Discord's light theme.

.. colour:: #FBFBFB

.. versionadded:: 2.6
"""
return cls(0xFBFBFB)

@classmethod
def fuchsia(cls) -> Self:
Expand All @@ -492,25 +532,52 @@ def yellow(cls) -> Self:
"""
return cls(0xFEE75C)

@classmethod
def ash_embed(cls) -> Self:
"""A factory method that returns a :class:`Colour` with a value of ``0x37373E``.

.. colour:: #37373E

.. versionadded:: 2.6

"""
return cls(0x37373E)

@classmethod
def dark_embed(cls) -> Self:
"""A factory method that returns a :class:`Colour` with a value of ``0x2B2D31``.
"""A factory method that returns a :class:`Colour` with a value of ``0x242429``.

.. colour:: #2B2D31
.. colour:: #242429

.. versionadded:: 2.2

.. versionchanged:: 2.6
Updated colour from previous ``0x2B2D31`` to reflect discord theme changes.
"""
return cls(0x242429)

@classmethod
def onyx_embed(cls) -> Self:
"""A factory method that returns a :class:`Colour` with a value of ``0x131416``.

.. colour:: #131416

.. versionadded:: 2.6
"""
return cls(0x2B2D31)
return cls(0x131416)

@classmethod
def light_embed(cls) -> Self:
"""A factory method that returns a :class:`Colour` with a value of ``0xEEEFF1``.
"""A factory method that returns a :class:`Colour` with a value of ``0xFFFFFF``.

.. colour:: #EEEFF1

.. versionadded:: 2.2

.. versionchanged:: 2.6
Updated colour from previous ``0xEEEFF1`` to reflect discord theme changes.
"""
return cls(0xEEEFF1)
return cls(0xFFFFFF)

@classmethod
def pink(cls) -> Self:
Expand Down
3 changes: 3 additions & 0 deletions discord/components.py
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,9 @@ def to_dict(self) -> SelectOptionPayload:

return payload

def copy(self) -> SelectOption:
return self.__class__.from_dict(self.to_dict())


class TextInput(Component):
"""Represents a text input from the Discord Bot UI Kit.
Expand Down
Loading