From bfe7f5835d37ef3375c0cfc855e6557e6f228ca0 Mon Sep 17 00:00:00 2001 From: Dustin Pianalto Date: Thu, 3 May 2018 12:08:45 -0800 Subject: [PATCH] Added display typing while generating image for iss --- exts/utils.py | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/exts/utils.py b/exts/utils.py index cc463c1..85ef806 100644 --- a/exts/utils.py +++ b/exts/utils.py @@ -536,23 +536,23 @@ class Utils: @commands.command(name='iss') async def iss_loc(self, ctx): - async with self.bot.aio_session.get('https://api.wheretheiss.at/v1/satellites/25544') as response: - iss_loc = await response.json() - - lat = iss_loc['latitude'] - lon = iss_loc['longitude'] - plt.figure(figsize=(8, 8)) - m = Basemap(projection='ortho', resolution=None, lat_0=lat, lon_0=lon) - m.bluemarble(scale=0.5) - x, y = m(lon, lat) - plt.plot(x, y, 'ok', markersize=10, color='red') - plt.text(x, y, ' ISS', fontsize=20, color='red') - - with BytesIO() as output: - async with ctx.typing(): + async with ctx.typing(): + async with self.bot.aio_session.get('https://api.wheretheiss.at/v1/satellites/25544') as response: + iss_loc = await response.json() + + lat = iss_loc['latitude'] + lon = iss_loc['longitude'] + plt.figure(figsize=(8, 8)) + m = Basemap(projection='ortho', resolution=None, lat_0=lat, lon_0=lon) + m.bluemarble(scale=0.5) + x, y = m(lon, lat) + plt.plot(x, y, 'ok', markersize=10, color='red') + plt.text(x, y, ' ISS', fontsize=20, color='red') + + with BytesIO() as output: plt.savefig(output, format='png', transparent=True) output.seek(0) - await ctx.send(file=discord.File(output, 'output.png')) + await ctx.send(file=discord.File(output, 'output.png')) # TODO Create Help command