From 50bbe09dfbfb6f5300dfce7e2edad2bfd9819dbc Mon Sep 17 00:00:00 2001 From: MarkKoz Date: Fri, 14 Jun 2019 09:56:12 -0700 Subject: Snekbox: add a function to send a request to the API --- bot/cogs/snekbox.py | 7 +++++++ 1 file changed, 7 insertions(+) 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) -- cgit v1.2.3