mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-09-05 17:36:15 +00:00
Fix webhooks and interactions not closing files after a request
This commit is contained in:
@ -1005,7 +1005,7 @@ class SyncWebhook(BaseWebhook):
|
||||
if thread_name is not MISSING and thread is not MISSING:
|
||||
raise TypeError('Cannot mix thread_name and thread keyword arguments.')
|
||||
|
||||
params = handle_message_parameters(
|
||||
with handle_message_parameters(
|
||||
content=content,
|
||||
username=username,
|
||||
avatar_url=avatar_url,
|
||||
@ -1018,22 +1018,23 @@ class SyncWebhook(BaseWebhook):
|
||||
allowed_mentions=allowed_mentions,
|
||||
previous_allowed_mentions=previous_mentions,
|
||||
flags=flags,
|
||||
)
|
||||
adapter: WebhookAdapter = _get_webhook_adapter()
|
||||
thread_id: Optional[int] = None
|
||||
if thread is not MISSING:
|
||||
thread_id = thread.id
|
||||
) as params:
|
||||
adapter: WebhookAdapter = _get_webhook_adapter()
|
||||
thread_id: Optional[int] = None
|
||||
if thread is not MISSING:
|
||||
thread_id = thread.id
|
||||
|
||||
data = adapter.execute_webhook(
|
||||
self.id,
|
||||
self.token,
|
||||
session=self.session,
|
||||
payload=params.payload,
|
||||
multipart=params.multipart,
|
||||
files=params.files,
|
||||
thread_id=thread_id,
|
||||
wait=wait,
|
||||
)
|
||||
|
||||
data = adapter.execute_webhook(
|
||||
self.id,
|
||||
self.token,
|
||||
session=self.session,
|
||||
payload=params.payload,
|
||||
multipart=params.multipart,
|
||||
files=params.files,
|
||||
thread_id=thread_id,
|
||||
wait=wait,
|
||||
)
|
||||
if wait:
|
||||
return self._create_message(data, thread=thread)
|
||||
|
||||
@ -1142,31 +1143,30 @@ class SyncWebhook(BaseWebhook):
|
||||
raise ValueError('This webhook does not have a token associated with it')
|
||||
|
||||
previous_mentions: Optional[AllowedMentions] = getattr(self._state, 'allowed_mentions', None)
|
||||
params = handle_message_parameters(
|
||||
with handle_message_parameters(
|
||||
content=content,
|
||||
attachments=attachments,
|
||||
embed=embed,
|
||||
embeds=embeds,
|
||||
allowed_mentions=allowed_mentions,
|
||||
previous_allowed_mentions=previous_mentions,
|
||||
)
|
||||
) as params:
|
||||
thread_id: Optional[int] = None
|
||||
if thread is not MISSING:
|
||||
thread_id = thread.id
|
||||
|
||||
thread_id: Optional[int] = None
|
||||
if thread is not MISSING:
|
||||
thread_id = thread.id
|
||||
|
||||
adapter: WebhookAdapter = _get_webhook_adapter()
|
||||
data = adapter.edit_webhook_message(
|
||||
self.id,
|
||||
self.token,
|
||||
message_id,
|
||||
session=self.session,
|
||||
payload=params.payload,
|
||||
multipart=params.multipart,
|
||||
files=params.files,
|
||||
thread_id=thread_id,
|
||||
)
|
||||
return self._create_message(data, thread=thread)
|
||||
adapter: WebhookAdapter = _get_webhook_adapter()
|
||||
data = adapter.edit_webhook_message(
|
||||
self.id,
|
||||
self.token,
|
||||
message_id,
|
||||
session=self.session,
|
||||
payload=params.payload,
|
||||
multipart=params.multipart,
|
||||
files=params.files,
|
||||
thread_id=thread_id,
|
||||
)
|
||||
return self._create_message(data, thread=thread)
|
||||
|
||||
def delete_message(self, message_id: int, /, *, thread: Snowflake = MISSING) -> None:
|
||||
"""Deletes a message owned by this webhook.
|
||||
|
Reference in New Issue
Block a user