diff options
author | 2020-12-18 00:22:54 +0300 | |
---|---|---|
committer | 2020-12-18 00:22:54 +0300 | |
commit | cbd38cebcc32940de14eaa4af3927430026e9cea (patch) | |
tree | 7660e6eda4854be9a66193ea0e7710028a0a09b4 /backend/routes/forms/submit.py | |
parent | Merge branch 'main' into discord-webhook (diff) |
Sends Embed Asynchronously
Signed-off-by: Hassan Abouelela <[email protected]>
Diffstat (limited to 'backend/routes/forms/submit.py')
-rw-r--r-- | backend/routes/forms/submit.py | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/backend/routes/forms/submit.py b/backend/routes/forms/submit.py index c476468..538a5b9 100644 --- a/backend/routes/forms/submit.py +++ b/backend/routes/forms/submit.py @@ -152,7 +152,7 @@ class SubmitForm(Route): }) @staticmethod - def send_submission_webhook(form: Form, response: FormResponse) -> None: + async def send_submission_webhook(form: Form, response: FormResponse) -> None: """Helper to send a submission message to a discord webhook.""" # Stop if webhook is not available if form.meta.webhook is None: @@ -189,7 +189,9 @@ class SubmitForm(Route): # Set hook message message = form.meta.webhook.message if message: - hook["content"] = message.replace("_USER_MENTION_", f"<@{user.id}>") + hook["content"] = message.replace("_USER_MENTION_", user_mention) # Post hook - httpx.post(form.meta.webhook.url, json=hook).raise_for_status() + async with httpx.AsyncClient() as client: + r = await client.post(form.meta.webhook.url, json=hook) + r.raise_for_status() |