Merge pull request #125 from bobloy/launchlib_develop

Library updated, use the new functioning async api calls
pull/127/head
bobloy 4 years ago committed by GitHub
commit 834a0f462d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -8,7 +8,7 @@
"install_msg": "Thank you for installing LaunchLib. Get started with `[p]load launchlib`, then `[p]help LaunchLib`", "install_msg": "Thank you for installing LaunchLib. Get started with `[p]load launchlib`, then `[p]help LaunchLib`",
"short": "Access launch data for space flights", "short": "Access launch data for space flights",
"end_user_data_statement": "This cog does not store any End User Data", "end_user_data_statement": "This cog does not store any End User Data",
"requirements": ["python-launch-library"], "requirements": ["python-launch-library>=1.0.6"],
"tags": [ "tags": [
"bobloy", "bobloy",
"utils", "utils",

@ -34,10 +34,10 @@ class LaunchLib(commands.Cog):
"""Nothing to delete""" """Nothing to delete"""
return return
async def _embed_launch_data(self, launch: ll.Launch): async def _embed_launch_data(self, launch: ll.AsyncLaunch):
status: ll.LaunchStatus = launch.get_status() status: ll.AsyncLaunchStatus = await launch.get_status()
rocket: ll.Rocket = launch.rocket rocket: ll.AsyncRocket = launch.rocket
title = launch.name title = launch.name
description = status.description description = status.description
@ -105,15 +105,13 @@ class LaunchLib(commands.Cog):
@launchlib.command() @launchlib.command()
async def next(self, ctx: commands.Context, num_launches: int = 1): async def next(self, ctx: commands.Context, num_launches: int = 1):
# launches = await api.async_next_launches(num_launches) # launches = await api.async_next_launches(num_launches)
loop = asyncio.get_running_loop() # loop = asyncio.get_running_loop()
#
launches = await loop.run_in_executor( # launches = await loop.run_in_executor(
None, functools.partial(self.api.fetch_launch, num=num_launches) # None, functools.partial(self.api.fetch_launch, num=num_launches)
) # )
#
# launches = self.api.fetch_launch(num=num_launches) launches = await self.api.async_fetch_launch(num=num_launches)
print(len(launches))
async with ctx.typing(): async with ctx.typing():
for x, launch in enumerate(launches): for x, launch in enumerate(launches):

Loading…
Cancel
Save