Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: ability to suppress embeds on message edit #774

Merged
merged 5 commits into from
May 19, 2022
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
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
8 changes: 8 additions & 0 deletions interactions/api/models/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -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[
Expand All @@ -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
Expand All @@ -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
Toricane marked this conversation as resolved.
Show resolved Hide resolved

from ...client.models.component import _build_components

Expand Down Expand Up @@ -420,6 +427,7 @@ async def edit(
allowed_mentions=_allowed_mentions,
message_reference=_message_reference,
components=_components,
flags=self.flags,
Toricane marked this conversation as resolved.
Show resolved Hide resolved
)

_dct = await self._client.edit_message(
Expand Down
53 changes: 40 additions & 13 deletions interactions/api/models/message.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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[
Expand All @@ -114,7 +114,6 @@ class Message(DictSerializerMixin):
]
] = MISSING,
) -> "Message": ...

async def reply(
self,
content: Optional[str] = MISSING,
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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: ...