DeepBlue/cogs/api/nasa.py

26 lines
710 B
Python
Raw Normal View History

2020-01-08 01:26:36 +00:00
'''
This cog is capable of communicating with the
NASA API
'''
2020-01-08 01:08:07 +00:00
import discord
from discord.ext import commands
from api import nasa
from util import config
class Nasa(commands.Cog):
2020-01-08 01:26:36 +00:00
def __init__(self, client: discord.Client):
2020-01-08 01:08:07 +00:00
self.client = client
@commands.command(name="APOD", description="Posts NASA's picture of the day.")
@commands.cooldown(1, 30)
2020-01-08 01:26:36 +00:00
async def apod(self, ctx: commands.Context):
2020-01-08 01:08:07 +00:00
url = nasa.image_of_the_day()
embed = discord.Embed(title="Astronomy Picture of the day", color=int(config.settings["color"], 16))
embed.set_image(url=url)
await ctx.send(embed=embed)
2020-01-08 01:26:36 +00:00
def setup(client: discord.Client):
2020-01-08 01:08:07 +00:00
client.add_cog(Nasa(client))