Browse Source

Fix webhooks and interactions not closing files after a request

pull/10109/head
Rapptz 2 years ago
committed by dolfies
parent
commit
57b118b393
  1. 8
      discord/message.py
  2. 9
      discord/webhook/async_.py
  3. 10
      discord/webhook/sync.py

8
discord/message.py

@ -825,12 +825,12 @@ class PartialMessage(Hashable):
else: else:
previous_allowed_mentions = None previous_allowed_mentions = None
params = handle_message_parameters( with handle_message_parameters(
content=content, content=content,
attachments=attachments, attachments=attachments,
allowed_mentions=allowed_mentions, allowed_mentions=allowed_mentions,
previous_allowed_mentions=previous_allowed_mentions, previous_allowed_mentions=previous_allowed_mentions,
) ) as params:
data = await self._state.http.edit_message(self.channel.id, self.id, params=params) data = await self._state.http.edit_message(self.channel.id, self.id, params=params)
message = Message(state=self._state, channel=self.channel, data=data) message = Message(state=self._state, channel=self.channel, data=data)
@ -1999,13 +1999,13 @@ class Message(PartialMessage, Hashable):
else: else:
flags = MISSING flags = MISSING
params = handle_message_parameters( with handle_message_parameters(
content=content, content=content,
flags=flags, flags=flags,
attachments=attachments, attachments=attachments,
allowed_mentions=allowed_mentions, allowed_mentions=allowed_mentions,
previous_allowed_mentions=previous_allowed_mentions, previous_allowed_mentions=previous_allowed_mentions,
) ) as params:
data = await self._state.http.edit_message(self.channel.id, self.id, params=params) data = await self._state.http.edit_message(self.channel.id, self.id, params=params)
message = Message(state=self._state, channel=self.channel, data=data) message = Message(state=self._state, channel=self.channel, data=data)

9
discord/webhook/async_.py

@ -1462,7 +1462,7 @@ class Webhook(BaseWebhook):
if thread_name is not MISSING and thread is not MISSING: if thread_name is not MISSING and thread is not MISSING:
raise TypeError('Cannot mix thread_name and thread keyword arguments.') raise TypeError('Cannot mix thread_name and thread keyword arguments.')
params = handle_message_parameters( with handle_message_parameters(
content=content, content=content,
username=username, username=username,
avatar_url=avatar_url, avatar_url=avatar_url,
@ -1475,7 +1475,7 @@ class Webhook(BaseWebhook):
thread_name=thread_name, thread_name=thread_name,
allowed_mentions=allowed_mentions, allowed_mentions=allowed_mentions,
previous_allowed_mentions=previous_mentions, previous_allowed_mentions=previous_mentions,
) ) as params:
adapter = async_context.get() adapter = async_context.get()
thread_id: Optional[int] = None thread_id: Optional[int] = None
if thread is not MISSING: if thread is not MISSING:
@ -1624,15 +1624,14 @@ class Webhook(BaseWebhook):
raise ValueError('This webhook does not have a token associated with it') raise ValueError('This webhook does not have a token associated with it')
previous_mentions: Optional[AllowedMentions] = getattr(self._state, 'allowed_mentions', None) previous_mentions: Optional[AllowedMentions] = getattr(self._state, 'allowed_mentions', None)
params = handle_message_parameters( with handle_message_parameters(
content=content, content=content,
attachments=attachments, attachments=attachments,
embed=embed, embed=embed,
embeds=embeds, embeds=embeds,
allowed_mentions=allowed_mentions, allowed_mentions=allowed_mentions,
previous_allowed_mentions=previous_mentions, previous_allowed_mentions=previous_mentions,
) ) as params:
thread_id: Optional[int] = None thread_id: Optional[int] = None
if thread is not MISSING: if thread is not MISSING:
thread_id = thread.id thread_id = thread.id

10
discord/webhook/sync.py

@ -1004,7 +1004,7 @@ class SyncWebhook(BaseWebhook):
if thread_name is not MISSING and thread is not MISSING: if thread_name is not MISSING and thread is not MISSING:
raise TypeError('Cannot mix thread_name and thread keyword arguments.') raise TypeError('Cannot mix thread_name and thread keyword arguments.')
params = handle_message_parameters( with handle_message_parameters(
content=content, content=content,
username=username, username=username,
avatar_url=avatar_url, avatar_url=avatar_url,
@ -1017,7 +1017,7 @@ class SyncWebhook(BaseWebhook):
allowed_mentions=allowed_mentions, allowed_mentions=allowed_mentions,
previous_allowed_mentions=previous_mentions, previous_allowed_mentions=previous_mentions,
flags=flags, flags=flags,
) ) as params:
adapter: WebhookAdapter = _get_webhook_adapter() adapter: WebhookAdapter = _get_webhook_adapter()
thread_id: Optional[int] = None thread_id: Optional[int] = None
if thread is not MISSING: if thread is not MISSING:
@ -1033,6 +1033,7 @@ class SyncWebhook(BaseWebhook):
thread_id=thread_id, thread_id=thread_id,
wait=wait, wait=wait,
) )
if wait: if wait:
return self._create_message(data, thread=thread) return self._create_message(data, thread=thread)
@ -1141,15 +1142,14 @@ class SyncWebhook(BaseWebhook):
raise ValueError('This webhook does not have a token associated with it') raise ValueError('This webhook does not have a token associated with it')
previous_mentions: Optional[AllowedMentions] = getattr(self._state, 'allowed_mentions', None) previous_mentions: Optional[AllowedMentions] = getattr(self._state, 'allowed_mentions', None)
params = handle_message_parameters( with handle_message_parameters(
content=content, content=content,
attachments=attachments, attachments=attachments,
embed=embed, embed=embed,
embeds=embeds, embeds=embeds,
allowed_mentions=allowed_mentions, allowed_mentions=allowed_mentions,
previous_allowed_mentions=previous_mentions, previous_allowed_mentions=previous_mentions,
) ) as params:
thread_id: Optional[int] = None thread_id: Optional[int] = None
if thread is not MISSING: if thread is not MISSING:
thread_id = thread.id thread_id = thread.id

Loading…
Cancel
Save