From 441748250d397a29de67696fe9c8b5ac44c33bb7 Mon Sep 17 00:00:00 2001 From: James Johnson Date: Fri, 30 Jul 2021 03:00:19 +0000 Subject: [PATCH] Add docmentation for web requests --- docs/content/features/auto-responses/index.md | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/docs/content/features/auto-responses/index.md b/docs/content/features/auto-responses/index.md index 9b583444..b9846673 100644 --- a/docs/content/features/auto-responses/index.md +++ b/docs/content/features/auto-responses/index.md @@ -239,6 +239,26 @@ assert(sum(nums) == 5050) assert(sum(values) == 10.0) ``` +#### Get +The `get` function acts as an HTTP get request. It requires a url as a parameter and can optionally take a dict of headers. + +```py +resp = get("https://my-api.host.com/endpoint", headers={"my-header": "my-data"}) +``` + +#### Post +The `post` function acts as an HTTP post request. It requires a url as a parameter and can optionally take a dict of headers, a dict of json data, or raw data as keyword parameters. The keywords are "headers", "json", and "data" respectively. + + + +Only one of the json or headers keyword parameters can be used at a time. If they are both passed to the function, json will take priority and data will be ignored. + + + +```py +resp = post("https://api.archit.us/guild-count", headers={"custom-header": "value"}, json={"data": 1234}) +``` + ### Global Variables Architus adds several global variables to the script environment to allow users to access information about the message, author, and channel that triggered the auto-response: