diff options
-rw-r--r-- | bot/seasons/evergreen/space.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/bot/seasons/evergreen/space.py b/bot/seasons/evergreen/space.py index f4faeb48..4684f8f7 100644 --- a/bot/seasons/evergreen/space.py +++ b/bot/seasons/evergreen/space.py @@ -5,6 +5,7 @@ from typing import Any, Dict, Optional, Union from urllib.parse import urlencode from discord import Embed +from discord.ext import tasks from discord.ext.commands import BadArgument, Cog, Context, Converter, group from bot.bot import SeasonalBot @@ -42,6 +43,20 @@ class Space(Cog): self.bot = bot self.http_session = bot.http_session + self.rovers = {} + self.get_rovers.start() + + @tasks.loop(hours=24) + async def get_rovers(self) -> None: + """Get listing of rovers from NASA API and info about their start and end dates.""" + data = await self.fetch_from_nasa("mars-photos/api/v1/rovers", params={"api_key": Tokens.nasa}) + + for rover in data["rovers"]: + self.rovers[rover["name"].lower()] = { + "min_date": rover["landing_date"], + "max_date": rover["max_date"] + } + @group(name="space", invoke_without_command=True) async def space(self, ctx: Context) -> None: """Head command that contains commands about space.""" |