Skip to content

Commit

Permalink
Merge branch 'master' into docs_fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Snipy7374 authored Oct 11, 2023
2 parents 9d2bd53 + 2b6aead commit 50622f3
Show file tree
Hide file tree
Showing 11 changed files with 62 additions and 10 deletions.
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ repos:
name: "run isort in examples"
files: ^examples/

- repo: https://github.com/psf/black
rev: 23.1.0
- repo: https://github.com/psf/black-pre-commit-mirror
rev: 23.9.1
hooks:
- id: black
name: "run black in all files"
Expand Down
1 change: 1 addition & 0 deletions changelog/1079.feature.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add :attr:`RawReactionActionEvent.message_author_id`.
1 change: 1 addition & 0 deletions changelog/1102.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Update :meth:`Colour.dark_theme` to match Discord theme change.
1 change: 1 addition & 0 deletions changelog/1102.feature.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add new :class:`Colour`\s: :meth:`~Colour.light_embed` and :meth:`~Colour.dark_embed`.
1 change: 1 addition & 0 deletions changelog/882.feature.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add ``guild_scheduled_event`` parameter to :meth:`StageChannel.create_instance`.
15 changes: 13 additions & 2 deletions disnake/channel.py
Original file line number Diff line number Diff line change
Expand Up @@ -2193,6 +2193,7 @@ async def create_instance(
topic: str,
privacy_level: StagePrivacyLevel = MISSING,
notify_everyone: bool = False,
guild_scheduled_event: Snowflake = MISSING,
reason: Optional[str] = None,
) -> StageInstance:
"""|coro|
Expand All @@ -2213,15 +2214,22 @@ async def create_instance(
The stage instance's topic.
privacy_level: :class:`StagePrivacyLevel`
The stage instance's privacy level. Defaults to :attr:`StagePrivacyLevel.guild_only`.
reason: Optional[:class:`str`]
The reason the stage instance was created. Shows up on the audit log.
notify_everyone: :class:`bool`
Whether to notify ``@everyone`` that the stage instance has started.
Requires the :attr:`~Permissions.mention_everyone` permission on the stage channel.
Defaults to ``False``.
.. versionadded:: 2.5
guild_scheduled_event: :class:`abc.Snowflake`
The guild scheduled event associated with the stage instance.
Setting this will automatically start the event.
.. versionadded:: 2.10
reason: Optional[:class:`str`]
The reason the stage instance was created. Shows up on the audit log.
Raises
------
Forbidden
Expand Down Expand Up @@ -2253,6 +2261,9 @@ async def create_instance(

payload["privacy_level"] = privacy_level.value

if guild_scheduled_event is not MISSING:
payload["guild_scheduled_event_id"] = guild_scheduled_event.id

data = await self._state.http.create_stage_instance(**payload, reason=reason)
return StageInstance(guild=self.guild, state=self._state, data=data)

Expand Down
22 changes: 20 additions & 2 deletions disnake/colour.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,12 +278,12 @@ def greyple(cls) -> Self:

@classmethod
def dark_theme(cls) -> Self:
"""A factory method that returns a :class:`Colour` with a value of ``0x36393F``.
"""A factory method that returns a :class:`Colour` with a value of ``0x313338``.
This will appear transparent on Discord's dark theme.
.. versionadded:: 1.5
"""
return cls(0x36393F)
return cls(0x313338)

@classmethod
def fuchsia(cls) -> Self:
Expand All @@ -301,5 +301,23 @@ def yellow(cls) -> Self:
"""
return cls(0xFEE75C)

@classmethod
def light_embed(cls) -> Self:
"""A factory method that returns a :class:`Colour` with a value of ``0xF2F3F5``.
This matches the embed background colour on Discord's light theme.
.. versionadded:: 2.10
"""
return cls(0xF2F3F5)

@classmethod
def dark_embed(cls) -> Self:
"""A factory method that returns a :class:`Colour` with a value of ``0x2B2D31``.
This matches the embed background colour on Discord's dark theme.
.. versionadded:: 2.10
"""
return cls(0x2B2D31)


Color = Colour
1 change: 1 addition & 0 deletions disnake/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -2005,6 +2005,7 @@ def create_stage_instance(
"topic",
"privacy_level",
"send_start_notification",
"guild_scheduled_event_id",
)
payload = {k: v for k, v in payload.items() if k in valid_keys}

Expand Down
23 changes: 20 additions & 3 deletions disnake/raw_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from typing import TYPE_CHECKING, List, Literal, Optional, Set, Union, cast

from .enums import ChannelType, try_enum
from .utils import get_slots
from .utils import _get_as_snowflake, get_slots

if TYPE_CHECKING:
from .member import Member
Expand Down Expand Up @@ -169,7 +169,7 @@ class RawReactionActionEvent(_RawReprMixin):
This now also includes the correct :attr:`~PartialEmoji.animated` value when a reaction was removed.
member: Optional[:class:`Member`]
The member who added the reaction. Only available if `event_type` is `REACTION_ADD` and the reaction is inside a guild.
The member who added the reaction. Only available if :attr:`event_type` is ``REACTION_ADD`` and the reaction is inside a guild.
.. versionadded:: 1.3
Expand All @@ -179,9 +179,25 @@ class RawReactionActionEvent(_RawReprMixin):
``REACTION_REMOVE`` for reaction removal.
.. versionadded:: 1.3
message_author_id: Optional[:class:`int`]
The ID of the author who created the message that got a reaction.
Only available if :attr:`event_type` is ``REACTION_ADD``.
May also be ``None`` if the message was created by a webhook.
.. versionadded:: 2.10
"""

__slots__ = ("message_id", "user_id", "channel_id", "guild_id", "emoji", "event_type", "member")
__slots__ = (
"message_id",
"user_id",
"channel_id",
"guild_id",
"emoji",
"event_type",
"member",
"message_author_id",
)

def __init__(
self,
Expand All @@ -199,6 +215,7 @@ def __init__(
self.guild_id: Optional[int] = int(data["guild_id"])
except KeyError:
self.guild_id: Optional[int] = None
self.message_author_id: Optional[int] = _get_as_snowflake(data, "message_author_id")


class RawReactionClearEvent(_RawReprMixin):
Expand Down
1 change: 1 addition & 0 deletions disnake/types/gateway.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,7 @@ class _BaseReactionEvent(TypedDict):
# https://discord.com/developers/docs/topics/gateway-events#message-reaction-add
class MessageReactionAddEvent(_BaseReactionEvent):
member: NotRequired[MemberWithUser]
message_author_id: NotRequired[Snowflake]


# https://discord.com/developers/docs/topics/gateway-events#message-reaction-remove
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ tools = [
codemod = [
# run codemods on the respository (mostly automated typing)
"libcst~=0.4.9",
"black==23.1.0",
"black==23.9.1",
"autotyping==23.2.0",
]
typing = [
Expand Down

0 comments on commit 50622f3

Please sign in to comment.