Skip to content

Commit bc29f58

Browse files
committed
Merge branch 'feat/components-v2' of https://github.com/DA-344/d.py into akiko
2 parents 53927e8 + b699e7e commit bc29f58

Some content is hidden

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

41 files changed

+909
-423
lines changed

discord/abc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1678,7 +1678,7 @@ async def send(
16781678
data = await state.http.send_message(channel.id, params=params)
16791679

16801680
ret = state.create_message(channel=channel, data=data)
1681-
if view and not view.is_finished():
1681+
if view and not view.is_finished() and view.is_dispatchable():
16821682
state.store_view(view, ret.id)
16831683

16841684
if poll:

discord/activity.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,7 @@ def __str__(self) -> str:
418418
return str(self.name)
419419

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

423423
def to_dict(self) -> Dict[str, Any]:
424424
timestamps: Dict[str, Any] = {}
@@ -514,7 +514,7 @@ def __str__(self) -> str:
514514
return str(self.name)
515515

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

519519
@property
520520
def twitch_name(self) -> Optional[str]:

discord/app_commands/installs.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@ def __init__(self, *, guild: Optional[bool] = None, user: Optional[bool] = None)
5757
self._guild: Optional[bool] = guild
5858
self._user: Optional[bool] = user
5959

60+
def __repr__(self):
61+
return f'<AppInstallationType guild={self.guild!r} user={self.user!r}>'
62+
6063
@property
6164
def guild(self) -> bool:
6265
""":class:`bool`: Whether the integration is a guild install."""
@@ -142,6 +145,9 @@ def __init__(
142145
self._dm_channel: Optional[bool] = dm_channel
143146
self._private_channel: Optional[bool] = private_channel
144147

148+
def __repr__(self) -> str:
149+
return f'<AppCommandContext guild={self.guild!r} dm_channel={self.dm_channel!r} private_channel={self.private_channel!r}>'
150+
145151
@property
146152
def guild(self) -> bool:
147153
""":class:`bool`: Whether the context allows usage in a guild."""

discord/app_commands/models.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1063,6 +1063,9 @@ def __init__(self, *, data: ApplicationCommandPermissions, guild: Guild, state:
10631063

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

1066+
def __repr__(self) -> str:
1067+
return f'<AppCommandPermissions id={self.id} type={self.type!r} guild={self.guild!r} permission={self.permission}>'
1068+
10661069
def to_dict(self) -> ApplicationCommandPermissions:
10671070
return {
10681071
'id': self.target.id,
@@ -1106,6 +1109,9 @@ def __init__(self, *, data: GuildApplicationCommandPermissions, state: Connectio
11061109
AppCommandPermissions(data=value, guild=guild, state=self._state) for value in data['permissions']
11071110
]
11081111

1112+
def __repr__(self) -> str:
1113+
return f'<GuildAppCommandPermissions id={self.id!r} guild_id={self.guild_id!r} permissions={self.permissions!r}>'
1114+
11091115
def to_dict(self) -> Dict[str, Any]:
11101116
return {'permissions': [p.to_dict() for p in self.permissions]}
11111117

discord/app_commands/transformers.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
from ..abc import GuildChannel
5353
from ..threads import Thread
5454
from ..enums import Enum as InternalEnum, AppCommandOptionType, ChannelType, Locale
55-
from ..utils import MISSING, maybe_coroutine
55+
from ..utils import MISSING, maybe_coroutine, _human_join
5656
from ..user import User
5757
from ..role import Role
5858
from ..member import Member
@@ -631,7 +631,7 @@ def __init__(self, *channel_types: Type[Any]) -> None:
631631
display_name = channel_types[0].__name__
632632
types = CHANNEL_TO_TYPES[channel_types[0]]
633633
else:
634-
display_name = '{}, and {}'.format(', '.join(t.__name__ for t in channel_types[:-1]), channel_types[-1].__name__)
634+
display_name = _human_join([t.__name__ for t in channel_types])
635635
types = []
636636

637637
for t in channel_types:
@@ -689,6 +689,7 @@ async def transform(self, interaction: Interaction[ClientT], value: Any, /):
689689
ChannelType.news,
690690
ChannelType.category,
691691
ChannelType.forum,
692+
ChannelType.media,
692693
],
693694
GuildChannel: [
694695
ChannelType.stage_voice,
@@ -697,14 +698,15 @@ async def transform(self, interaction: Interaction[ClientT], value: Any, /):
697698
ChannelType.news,
698699
ChannelType.category,
699700
ChannelType.forum,
701+
ChannelType.media,
700702
],
701703
AppCommandThread: [ChannelType.news_thread, ChannelType.private_thread, ChannelType.public_thread],
702704
Thread: [ChannelType.news_thread, ChannelType.private_thread, ChannelType.public_thread],
703705
StageChannel: [ChannelType.stage_voice],
704706
VoiceChannel: [ChannelType.voice],
705707
TextChannel: [ChannelType.text, ChannelType.news],
706708
CategoryChannel: [ChannelType.category],
707-
ForumChannel: [ChannelType.forum],
709+
ForumChannel: [ChannelType.forum, ChannelType.media],
708710
}
709711

710712
BUILT_IN_TRANSFORMERS: Dict[Any, Transformer] = {

discord/channel.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2852,6 +2852,7 @@ async def create_thread(
28522852
files: Sequence[File] = ...,
28532853
allowed_mentions: AllowedMentions = ...,
28542854
mention_author: bool = ...,
2855+
applied_tags: Sequence[ForumTag] = ...,
28552856
view: LayoutView,
28562857
suppress_embeds: bool = ...,
28572858
reason: Optional[str] = ...,
@@ -3026,7 +3027,7 @@ async def create_thread(
30263027
data = await state.http.start_thread_in_forum(self.id, params=params, reason=reason)
30273028
thread = Thread(guild=self.guild, state=self._state, data=data)
30283029
message = Message(state=self._state, channel=thread, data=data['message'])
3029-
if view and not view.is_finished():
3030+
if view and not view.is_finished() and view.is_dispatchable():
30303031
self._state.store_view(view, message.id)
30313032

30323033
return ThreadWithMessage(thread=thread, message=message)

discord/client.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767
from .http import HTTPClient
6868
from .state import ConnectionState
6969
from . import utils
70-
from .utils import MISSING, time_snowflake
70+
from .utils import MISSING, time_snowflake, deprecated
7171
from .object import Object
7272
from .backoff import ExponentialBackoff
7373
from .webhook import Webhook
@@ -2393,6 +2393,7 @@ async def fetch_guild_preview(self, guild_id: int) -> GuildPreview:
23932393
data = await self.http.get_guild_preview(guild_id)
23942394
return GuildPreview(data=data, state=self._connection)
23952395

2396+
@deprecated()
23962397
async def create_guild(
23972398
self,
23982399
*,
@@ -2413,6 +2414,9 @@ async def create_guild(
24132414
This function will now raise :exc:`ValueError` instead of
24142415
``InvalidArgument``.
24152416
2417+
.. deprecated:: 2.6
2418+
This function is deprecated and will be removed in a future version.
2419+
24162420
Parameters
24172421
----------
24182422
name: :class:`str`

discord/colour.py

Lines changed: 75 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
2222
DEALINGS IN THE SOFTWARE.
2323
"""
24+
2425
from __future__ import annotations
2526

2627
import colorsys
@@ -457,20 +458,59 @@ def greyple(cls) -> Self:
457458
"""
458459
return cls(0x99AAB5)
459460

461+
@classmethod
462+
def ash_theme(cls) -> Self:
463+
"""A factory method that returns a :class:`Colour` with a value of ``0x2E2E34``.
464+
465+
This will appear transparent on Discord's ash theme.
466+
467+
.. colour:: #2E2E34
468+
469+
.. versionadded:: 2.6
470+
"""
471+
return cls(0x2E2E34)
472+
460473
@classmethod
461474
def dark_theme(cls) -> Self:
462-
"""A factory method that returns a :class:`Colour` with a value of ``0x313338``.
475+
"""A factory method that returns a :class:`Colour` with a value of ``0x1A1A1E``.
463476
464477
This will appear transparent on Discord's dark theme.
465478
466-
.. colour:: #313338
479+
.. colour:: #1A1A1E
467480
468481
.. versionadded:: 1.5
469482
470483
.. versionchanged:: 2.2
471484
Updated colour from previous ``0x36393F`` to reflect discord theme changes.
485+
486+
.. versionchanged:: 2.6
487+
Updated colour from previous ``0x313338`` to reflect discord theme changes.
472488
"""
473-
return cls(0x313338)
489+
return cls(0x1A1A1E)
490+
491+
@classmethod
492+
def onyx_theme(cls) -> Self:
493+
"""A factory method that returns a :class:`Colour` with a value of ``0x070709``.
494+
495+
This will appear transparent on Discord's onyx theme.
496+
497+
.. colour:: #070709
498+
499+
.. versionadded:: 2.6
500+
"""
501+
return cls(0x070709)
502+
503+
@classmethod
504+
def light_theme(cls) -> Self:
505+
"""A factory method that returns a :class:`Colour` with a value of ``0xFBFBFB``.
506+
507+
This will appear transparent on Discord's light theme.
508+
509+
.. colour:: #FBFBFB
510+
511+
.. versionadded:: 2.6
512+
"""
513+
return cls(0xFBFBFB)
474514

475515
@classmethod
476516
def fuchsia(cls) -> Self:
@@ -492,25 +532,52 @@ def yellow(cls) -> Self:
492532
"""
493533
return cls(0xFEE75C)
494534

535+
@classmethod
536+
def ash_embed(cls) -> Self:
537+
"""A factory method that returns a :class:`Colour` with a value of ``0x37373E``.
538+
539+
.. colour:: #37373E
540+
541+
.. versionadded:: 2.6
542+
543+
"""
544+
return cls(0x37373E)
545+
495546
@classmethod
496547
def dark_embed(cls) -> Self:
497-
"""A factory method that returns a :class:`Colour` with a value of ``0x2B2D31``.
548+
"""A factory method that returns a :class:`Colour` with a value of ``0x242429``.
498549
499-
.. colour:: #2B2D31
550+
.. colour:: #242429
500551
501552
.. versionadded:: 2.2
553+
554+
.. versionchanged:: 2.6
555+
Updated colour from previous ``0x2B2D31`` to reflect discord theme changes.
556+
"""
557+
return cls(0x242429)
558+
559+
@classmethod
560+
def onyx_embed(cls) -> Self:
561+
"""A factory method that returns a :class:`Colour` with a value of ``0x131416``.
562+
563+
.. colour:: #131416
564+
565+
.. versionadded:: 2.6
502566
"""
503-
return cls(0x2B2D31)
567+
return cls(0x131416)
504568

505569
@classmethod
506570
def light_embed(cls) -> Self:
507-
"""A factory method that returns a :class:`Colour` with a value of ``0xEEEFF1``.
571+
"""A factory method that returns a :class:`Colour` with a value of ``0xFFFFFF``.
508572
509573
.. colour:: #EEEFF1
510574
511575
.. versionadded:: 2.2
576+
577+
.. versionchanged:: 2.6
578+
Updated colour from previous ``0xEEEFF1`` to reflect discord theme changes.
512579
"""
513-
return cls(0xEEEFF1)
580+
return cls(0xFFFFFF)
514581

515582
@classmethod
516583
def pink(cls) -> Self:

0 commit comments

Comments
 (0)