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

fix: allow removing files and embeds by editing #1697

Merged
merged 2 commits into from
Jun 20, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
6 changes: 5 additions & 1 deletion interactions/api/http/http_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,11 @@ def _process_payload(
else:
payload = [dict_filter(x) if isinstance(x, dict) else x for x in payload]

if not files:
if files is None:
return payload

if files == []:
payload["attachments"] = []
return payload

if not isinstance(files, list):
Expand Down
2 changes: 1 addition & 1 deletion interactions/models/discord/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -701,7 +701,7 @@ async def edit(
)
message_payload = process_message_payload(
content=content,
embeds=embeds or embed,
embeds=embed if embeds is None else embeds,
components=components,
allowed_mentions=allowed_mentions,
attachments=attachments,
Expand Down
10 changes: 6 additions & 4 deletions interactions/models/internal/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -633,7 +633,7 @@ async def edit(
) -> "interactions.Message":
message_payload = process_message_payload(
content=content,
embeds=embeds or embed,
embeds=embed if embeds is None else embeds,
components=components,
allowed_mentions=allowed_mentions,
attachments=attachments,
Expand Down Expand Up @@ -875,7 +875,7 @@ async def edit_origin(

message_payload = process_message_payload(
content=content,
embeds=embeds or embed,
embeds=embed if embeds is None else embeds,
components=components,
allowed_mentions=allowed_mentions,
tts=tts,
Expand All @@ -889,13 +889,15 @@ async def edit_origin(
)

message_data = await self.client.http.edit_interaction_message(
message_payload, self.client.app.id, self.token, files=files or file
message_payload, self.client.app.id, self.token, files=file if files is None else files
)
self.deferred = False
self.editing_origin = False
else:
payload = {"type": CallbackType.UPDATE_MESSAGE, "data": message_payload}
await self.client.http.post_initial_response(payload, str(self.id), self.token, files=files or file)
await self.client.http.post_initial_response(
payload, str(self.id), self.token, files=file if files is None else files
)
message_data = await self.client.http.get_interaction_message(self.client.app.id, self.token)

if message_data:
Expand Down
Loading