mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-06-07 20:28:38 +00:00
parent
3381d1e089
commit
02e21a8905
@ -127,6 +127,7 @@ class WebhookAdapter:
|
|||||||
|
|
||||||
response: Optional[Response] = None
|
response: Optional[Response] = None
|
||||||
data: Optional[Union[Dict[str, Any], str]] = None
|
data: Optional[Union[Dict[str, Any], str]] = None
|
||||||
|
file_data: Optional[Dict[str, Any]] = None
|
||||||
method = route.method
|
method = route.method
|
||||||
url = route.url
|
url = route.url
|
||||||
webhook_id = route.webhook_id
|
webhook_id = route.webhook_id
|
||||||
@ -137,13 +138,16 @@ class WebhookAdapter:
|
|||||||
file.reset(seek=attempt)
|
file.reset(seek=attempt)
|
||||||
|
|
||||||
if multipart:
|
if multipart:
|
||||||
form_data: Dict[str, Any] = {}
|
file_data = {}
|
||||||
for p in multipart:
|
for p in multipart:
|
||||||
form_data[p['name']] = (p['filename'], p['value'], p['content_type'])
|
name = p['name']
|
||||||
to_send = form_data
|
if name == 'payload_json':
|
||||||
|
to_send = { 'payload_json': p['value'] }
|
||||||
|
else:
|
||||||
|
file_data[name] = (p['filename'], p['value'], p['content_type'])
|
||||||
|
|
||||||
try:
|
try:
|
||||||
with session.request(method, url, data=to_send, headers=headers, params=params) as response:
|
with session.request(method, url, data=to_send, files=file_data, headers=headers, params=params) as response:
|
||||||
log.debug(
|
log.debug(
|
||||||
'Webhook ID %s with %s %s has returned status code %s',
|
'Webhook ID %s with %s %s has returned status code %s',
|
||||||
webhook_id,
|
webhook_id,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user