aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--discord/webhook.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/discord/webhook.py b/discord/webhook.py
index d44a5e94..6343b852 100644
--- a/discord/webhook.py
+++ b/discord/webhook.py
@@ -137,14 +137,17 @@ class WebhookAdapter:
files_to_pass = None
url = '%s?wait=%d' % (self._request_url, wait)
+ maybe_coro = None
try:
maybe_coro = self.request('POST', url, multipart=multipart, payload=data, files=files_to_pass)
finally:
- if cleanup is not None:
+ if maybe_coro is not None and cleanup is not None:
if not asyncio.iscoroutine(maybe_coro):
cleanup()
else:
maybe_coro = self._wrap_coroutine_and_cleanup(maybe_coro, cleanup)
+
+ # if request raises up there then this should never be `None`
return self.handle_execution_response(maybe_coro, wait=wait)
class AsyncWebhookAdapter(WebhookAdapter):