From e38ba27dda5c74c0761546d6da86f48d3a9f94ba Mon Sep 17 00:00:00 2001 From: Victor <67214928+Victorsitou@users.noreply.github.com> Date: Fri, 29 Sep 2023 18:35:24 -0300 Subject: [PATCH 1/4] feat(StageInstance): add `guild_scheduled_event` field to create instance (#882) --- changelog/882.feature.rst | 1 + disnake/channel.py | 15 +++++++++++++-- disnake/http.py | 1 + 3 files changed, 15 insertions(+), 2 deletions(-) create mode 100644 changelog/882.feature.rst diff --git a/changelog/882.feature.rst b/changelog/882.feature.rst new file mode 100644 index 0000000000..177ab171bf --- /dev/null +++ b/changelog/882.feature.rst @@ -0,0 +1 @@ +Add ``guild_scheduled_event`` parameter to :meth:`StageChannel.create_instance`. diff --git a/disnake/channel.py b/disnake/channel.py index d98a48339b..263735e24e 100644 --- a/disnake/channel.py +++ b/disnake/channel.py @@ -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| @@ -2213,8 +2214,6 @@ 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. @@ -2222,6 +2221,15 @@ async def create_instance( .. 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 @@ -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) diff --git a/disnake/http.py b/disnake/http.py index 558b0b1ff6..f8c4b44694 100644 --- a/disnake/http.py +++ b/disnake/http.py @@ -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} From 1f6104dcc86c38f391ba4dfee515b1b0929655f2 Mon Sep 17 00:00:00 2001 From: shiftinv <8530778+shiftinv@users.noreply.github.com> Date: Wed, 4 Oct 2023 15:47:43 +0200 Subject: [PATCH 2/4] feat: add `RawReactionActionEvent.message_author_id` (#1079) --- changelog/1079.feature.rst | 1 + disnake/raw_models.py | 23 ++++++++++++++++++++--- disnake/types/gateway.py | 1 + 3 files changed, 22 insertions(+), 3 deletions(-) create mode 100644 changelog/1079.feature.rst diff --git a/changelog/1079.feature.rst b/changelog/1079.feature.rst new file mode 100644 index 0000000000..3c13c28b9f --- /dev/null +++ b/changelog/1079.feature.rst @@ -0,0 +1 @@ +Add :attr:`RawReactionActionEvent.message_author_id`. diff --git a/disnake/raw_models.py b/disnake/raw_models.py index cbd3686644..8c4b57bdea 100644 --- a/disnake/raw_models.py +++ b/disnake/raw_models.py @@ -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 @@ -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 @@ -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, @@ -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): diff --git a/disnake/types/gateway.py b/disnake/types/gateway.py index 39d46d3062..d71af27ab6 100644 --- a/disnake/types/gateway.py +++ b/disnake/types/gateway.py @@ -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 From 3b604f6e03cc375519422a283a3193ac3b270e67 Mon Sep 17 00:00:00 2001 From: arl Date: Mon, 9 Oct 2023 18:31:20 -0400 Subject: [PATCH 3/4] build(deps): update black to v23.9.1 (#1000) Co-authored-by: shiftinv <8530778+shiftinv@users.noreply.github.com> --- .pre-commit-config.yaml | 4 ++-- pyproject.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index eef6240f46..db6ec422f0 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -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" diff --git a/pyproject.toml b/pyproject.toml index f7f2b98b62..369abf8c04 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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 = [ From 2b6aeadf834fcee0245d755fe10d1b9fdc755607 Mon Sep 17 00:00:00 2001 From: shiftinv <8530778+shiftinv@users.noreply.github.com> Date: Tue, 10 Oct 2023 17:24:58 +0200 Subject: [PATCH 4/4] feat(colour): update and add new theme color values (#1102) ## Summary Resolves #1100. Adds `light_embed` and `dark_embed`, and updates `dark_theme` to match the latest dark theme. ![image](https://github.com/DisnakeDev/disnake/assets/8530778/0303397d-0aae-4a22-be1c-00d3f8e3e34c) ![image](https://github.com/DisnakeDev/disnake/assets/8530778/98c1e2d2-26b2-4f79-b874-e87e5c9acee1) ## Checklist - [x] If code changes were made, then they have been tested - [x] I have updated the documentation to reflect the changes - [x] I have formatted the code properly by running `pdm lint` - [x] I have type-checked the code by running `pdm pyright` - [x] This PR fixes an issue - [x] This PR adds something new (e.g. new method or parameters) - [ ] This PR is a breaking change (e.g. methods or parameters removed/renamed) - [ ] This PR is **not** a code change (e.g. documentation, README, ...) --- changelog/1102.bugfix.rst | 1 + changelog/1102.feature.rst | 1 + disnake/colour.py | 22 ++++++++++++++++++++-- 3 files changed, 22 insertions(+), 2 deletions(-) create mode 100644 changelog/1102.bugfix.rst create mode 100644 changelog/1102.feature.rst diff --git a/changelog/1102.bugfix.rst b/changelog/1102.bugfix.rst new file mode 100644 index 0000000000..13874bafc9 --- /dev/null +++ b/changelog/1102.bugfix.rst @@ -0,0 +1 @@ +Update :meth:`Colour.dark_theme` to match Discord theme change. diff --git a/changelog/1102.feature.rst b/changelog/1102.feature.rst new file mode 100644 index 0000000000..7cd21e237d --- /dev/null +++ b/changelog/1102.feature.rst @@ -0,0 +1 @@ +Add new :class:`Colour`\s: :meth:`~Colour.light_embed` and :meth:`~Colour.dark_embed`. diff --git a/disnake/colour.py b/disnake/colour.py index 8480e2f964..82e8ef1bb3 100644 --- a/disnake/colour.py +++ b/disnake/colour.py @@ -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: @@ -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