From c052248cfeacb3d8624bf1a170c0f47958e336ac Mon Sep 17 00:00:00 2001 From: Dustin Pianalto Date: Thu, 3 May 2018 12:36:27 -0800 Subject: [PATCH] Moved generating iss image to tpe --- exts/utils.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/exts/utils.py b/exts/utils.py index 5b25256..6fbc4fa 100644 --- a/exts/utils.py +++ b/exts/utils.py @@ -536,10 +536,7 @@ class Utils: @commands.command(name='iss') async def iss_loc(self, ctx): - def gen_image(): - async with self.bot.aio_session.get('https://api.wheretheiss.at/v1/satellites/25544') as response: - iss_loc = await response.json() - + def gen_image(iss_loc): lat = iss_loc['latitude'] lon = iss_loc['longitude'] plt.figure(figsize=(8, 8)) @@ -555,7 +552,9 @@ class Utils: return img async with ctx.typing(): - async with self.bot.loop.run_in_executor(self.bot.tpe, gen_image) as output: + async with self.bot.aio_session.get('https://api.wheretheiss.at/v1/satellites/25544') as response: + loc = await response.json() + async with self.bot.loop.run_in_executor(self.bot.tpe, gen_image, loc) as output: await ctx.send(file=discord.File(output, 'output.png')) # TODO Create Help command