From eaec0181c8daccdac6e8b8067fe830793c7cb052 Mon Sep 17 00:00:00 2001 From: Toricane Date: Mon, 2 May 2022 17:26:19 -0700 Subject: [PATCH 1/3] feat: ability to suppress embeds on message edit --- interactions/api/models/message.py | 8 +++++ interactions/api/models/message.pyi | 53 ++++++++++++++++++++++------- 2 files changed, 48 insertions(+), 13 deletions(-) diff --git a/interactions/api/models/message.py b/interactions/api/models/message.py index 31bf46812..fc8caf85e 100644 --- a/interactions/api/models/message.py +++ b/interactions/api/models/message.py @@ -346,6 +346,7 @@ async def edit( tts: Optional[bool] = MISSING, files: Optional[Union[File, List[File]]] = MISSING, embeds: Optional[Union["Embed", List["Embed"]]] = MISSING, + suppress_embeds: Optional[bool] = MISSING, allowed_mentions: Optional["MessageInteraction"] = MISSING, message_reference: Optional["MessageReference"] = MISSING, components: Optional[ @@ -370,6 +371,8 @@ async def edit( :type files: Optional[Union[File, List[File]]] :param embeds?: An embed, or list of embeds for the message. :type embeds: Optional[Union[Embed, List[Embed]]] + :param suppress_embeds?: Whether to suppress embeds in the message. + :type suppress_embeds: Optional[bool] :param allowed_mentions?: The message interactions/mention limits that the message can refer to. :type allowed_mentions: Optional[MessageInteraction] :param components?: A component, or list of components for the message. If `[]` the components will be removed @@ -381,6 +384,10 @@ async def edit( raise AttributeError("HTTPClient not found!") if self.flags == 64: raise TypeError("You cannot edit a hidden message!") + if suppress_embeds is not MISSING and suppress_embeds: + self.flags |= 1 << 2 + elif suppress_embeds is not MISSING: + self.flags &= ~1 << 2 from ...client.models.component import _build_components @@ -420,6 +427,7 @@ async def edit( allowed_mentions=_allowed_mentions, message_reference=_message_reference, components=_components, + flags=self.flags, ) _dct = await self._client.edit_message( diff --git a/interactions/api/models/message.pyi b/interactions/api/models/message.pyi index 0d60f0ba1..b7582e646 100644 --- a/interactions/api/models/message.pyi +++ b/interactions/api/models/message.pyi @@ -8,10 +8,9 @@ from .role import Role from .team import Application from .user import User from ..http.client import HTTPClient -from ...models.component import ActionRow, Button, SelectMenu +from ...client.models.component import ActionRow, Button, SelectMenu from .guild import Guild - class MessageActivity(DictSerializerMixin): _json: dict type: int @@ -101,6 +100,7 @@ class Message(DictSerializerMixin): tts: Optional[bool] = MISSING, files: Optional[Union[File, List[File]]] = MISSING, embeds: Optional[Union["Embed", List["Embed"]]] = MISSING, + suppress_embeds: Optional[bool] = MISSING, allowed_mentions: Optional["MessageInteraction"] = MISSING, message_reference: Optional["MessageReference"] = MISSING, components: Optional[ @@ -114,7 +114,6 @@ class Message(DictSerializerMixin): ] ] = MISSING, ) -> "Message": ... - async def reply( self, content: Optional[str] = MISSING, @@ -160,9 +159,7 @@ class Message(DictSerializerMixin): emoji: Union[str, "Emoji"], ) -> None: ... async def remove_reaction_from( - self, - emoji: Union[str, "Emoji"], - user: Union[Member, User, int] + self, emoji: Union[str, "Emoji"], user: Union[Member, User, int] ) -> None: ... @classmethod async def get_from_url( @@ -291,12 +288,42 @@ class Embed(DictSerializerMixin): def __setattr__(self, key, value) -> None: ... def add_field(self, name: str, value: str, inline: Optional[bool] = False) -> None: ... def clear_fields(self) -> None: ... - def insert_field_at(self, index: int, name: str, value: str, inline: Optional[bool] = False) -> None: ... - def set_field_at(self, index: int, name: str, value: str, inline: Optional[bool] = False) -> None: ... + def insert_field_at( + self, index: int, name: str, value: str, inline: Optional[bool] = False + ) -> None: ... + def set_field_at( + self, index: int, name: str, value: str, inline: Optional[bool] = False + ) -> None: ... def remove_field(self, index: int) -> None: ... def remove_author(self) -> None: ... - def set_author(self, name: str, url: Optional[str] = None, icon_url: Optional[str] = None, proxy_icon_url: Optional[str] = None) -> None: ... - def set_footer(self, text: str, icon_url: Optional[str] = None, proxy_icon_url: Optional[str] = None) -> None: ... - def set_image(self, url: str, proxy_url: Optional[str] = None, height: Optional[int] = None, width: Optional[int] = None) -> None: ... - def set_video(self, url: str, proxy_url: Optional[str] = None, height: Optional[int] = None, width: Optional[int] = None) -> None: ... - def set_thumbnail(self, url: str, proxy_url: Optional[str] = None, height: Optional[int] = None, width: Optional[int] = None) -> None: ... + def set_author( + self, + name: str, + url: Optional[str] = None, + icon_url: Optional[str] = None, + proxy_icon_url: Optional[str] = None, + ) -> None: ... + def set_footer( + self, text: str, icon_url: Optional[str] = None, proxy_icon_url: Optional[str] = None + ) -> None: ... + def set_image( + self, + url: str, + proxy_url: Optional[str] = None, + height: Optional[int] = None, + width: Optional[int] = None, + ) -> None: ... + def set_video( + self, + url: str, + proxy_url: Optional[str] = None, + height: Optional[int] = None, + width: Optional[int] = None, + ) -> None: ... + def set_thumbnail( + self, + url: str, + proxy_url: Optional[str] = None, + height: Optional[int] = None, + width: Optional[int] = None, + ) -> None: ... From 87a0e10e4e1ad019888992835679dc05a7eb52e9 Mon Sep 17 00:00:00 2001 From: Toricane <73972068+Toricane@users.noreply.github.com> Date: Tue, 10 May 2022 18:06:56 -0700 Subject: [PATCH 2/3] Update interactions/api/models/message.py Co-authored-by: EdVraz <88881326+EdVraz@users.noreply.github.com> --- interactions/api/models/message.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/interactions/api/models/message.py b/interactions/api/models/message.py index a3764e1ae..88389edc8 100644 --- a/interactions/api/models/message.py +++ b/interactions/api/models/message.py @@ -384,10 +384,11 @@ async def edit( raise AttributeError("HTTPClient not found!") if self.flags == 64: raise TypeError("You cannot edit a hidden message!") + _flags = self.flags if suppress_embeds is not MISSING and suppress_embeds: - self.flags |= 1 << 2 + _flags |= 1 << 2 elif suppress_embeds is not MISSING: - self.flags &= ~1 << 2 + _flags &= ~1 << 2 from ...client.models.component import _build_components From cb01585640812f33d6e6673a770f5ba500514429 Mon Sep 17 00:00:00 2001 From: Toricane <73972068+Toricane@users.noreply.github.com> Date: Tue, 10 May 2022 18:07:01 -0700 Subject: [PATCH 3/3] Update interactions/api/models/message.py Co-authored-by: EdVraz <88881326+EdVraz@users.noreply.github.com> --- interactions/api/models/message.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interactions/api/models/message.py b/interactions/api/models/message.py index 88389edc8..b32fa8ae9 100644 --- a/interactions/api/models/message.py +++ b/interactions/api/models/message.py @@ -428,7 +428,7 @@ async def edit( allowed_mentions=_allowed_mentions, message_reference=_message_reference, components=_components, - flags=self.flags, + flags=_flags, ) _dct = await self._client.edit_message(