aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar MarkKoz <[email protected]>2019-06-14 09:56:12 -0700
committerGravatar MarkKoz <[email protected]>2019-06-14 21:07:46 -0700
commit50bbe09dfbfb6f5300dfce7e2edad2bfd9819dbc (patch)
tree30361655cc36ff285218846f374b0be66d8ca133
parentAdd snekbox endpoint to constants (diff)
Snekbox: add a function to send a request to the API
-rw-r--r--bot/cogs/snekbox.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/bot/cogs/snekbox.py b/bot/cogs/snekbox.py
index 1988303f1..70a19db87 100644
--- a/bot/cogs/snekbox.py
+++ b/bot/cogs/snekbox.py
@@ -57,6 +57,13 @@ class Snekbox:
self.bot = bot
self.jobs = {}
+ async def post_eval(self, code: str) -> dict:
+ """Send a POST request to the Snekbox API to evaluate code and return the results."""
+ url = URLs.snekbox_eval_api
+ data = {"input": code}
+ async with self.bot.http_session.post(url, json=data, raise_for_status=True) as resp:
+ return await resp.json()
+
@command(name='eval', aliases=('e',))
@guild_only()
@in_channel(Channels.bot, bypass_roles=BYPASS_ROLES)