Added display typing while generating image for iss

release-1.0.0
DustyP 8 years ago
parent e62e2c252f
commit bfe7f5835d

@ -536,23 +536,23 @@ class Utils:
@commands.command(name='iss') @commands.command(name='iss')
async def iss_loc(self, ctx): async def iss_loc(self, ctx):
async with self.bot.aio_session.get('https://api.wheretheiss.at/v1/satellites/25544') as response: async with ctx.typing():
iss_loc = await response.json() 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'] lat = iss_loc['latitude']
plt.figure(figsize=(8, 8)) lon = iss_loc['longitude']
m = Basemap(projection='ortho', resolution=None, lat_0=lat, lon_0=lon) plt.figure(figsize=(8, 8))
m.bluemarble(scale=0.5) m = Basemap(projection='ortho', resolution=None, lat_0=lat, lon_0=lon)
x, y = m(lon, lat) m.bluemarble(scale=0.5)
plt.plot(x, y, 'ok', markersize=10, color='red') x, y = m(lon, lat)
plt.text(x, y, ' ISS', fontsize=20, color='red') 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(): with BytesIO() as output:
plt.savefig(output, format='png', transparent=True) plt.savefig(output, format='png', transparent=True)
output.seek(0) 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 # TODO Create Help command

Loading…
Cancel
Save