Skip to content
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
5 changes: 3 additions & 2 deletions discord_webhook/async_webhook.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,9 @@ async def execute(self, remove_embeds=False) -> "httpx.Response":
if remove_embeds:
self.remove_embeds()
self.remove_files(clear_attachments=False)
if webhook_id := json.loads(response.content.decode("utf-8")).get("id"):
self.id = webhook_id
if response.content: # don't parse if response has no content (204 response code)
if webhook_id := json.loads(response.content.decode("utf-8")).get("id"):
self.id = webhook_id
return response

async def edit(self) -> "httpx.Response":
Expand Down
11 changes: 6 additions & 5 deletions discord_webhook/webhook.py
Original file line number Diff line number Diff line change
Expand Up @@ -470,11 +470,12 @@ def execute(self, remove_embeds: bool = False) -> "requests.Response":
if remove_embeds:
self.remove_embeds()
self.remove_files(clear_attachments=False)
response_content = json.loads(response.content.decode("utf-8"))
if webhook_id := response_content.get("id"):
self.id = webhook_id
if attachments := response_content.get("attachments"):
self.attachments = attachments
if response.content: # don't parse if response has no content (204 response code)
response_content = json.loads(response.content.decode("utf-8"))
if webhook_id := response_content.get("id"):
self.id = webhook_id
if attachments := response_content.get("attachments"):
self.attachments = attachments
return response

def edit(self) -> "requests.Response":
Expand Down