From 7957ac0f7ab3dd8763d0cccc2aac38ca0ed162e7 Mon Sep 17 00:00:00 2001 From: Purpur <43528123+Pemigrade@users.noreply.github.com> Date: Fri, 26 Feb 2021 14:46:56 -0600 Subject: [PATCH] Make Binflop uploads async --- bot.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bot.py b/bot.py index 95cd959..f0eeb79 100644 --- a/bot.py +++ b/bot.py @@ -1,6 +1,5 @@ import os import discord -import requests import json import logging import sys @@ -50,8 +49,9 @@ async def on_message(message): if len(text) > 100000: text = text[:99999] truncated = True - req = requests.post('https://bin.birdflop.com/documents', data=text) - key = json.loads(req.content)['key'] + async with aiohttp.ClientSession() as session: + async with session.post('https://bin.birdflop.com/documents', data=text) as req: + key = json.loads(await req.read())['key'] response = "" response = response + "https://bin.birdflop.com/" + key response = response + "\nRequested by " + message.author.mention