DeepBlue/cogs/api/inspirobot.py

29 lines
938 B
Python
Raw Permalink Normal View History

2020-01-08 01:26:36 +00:00
'''
This is the cog that allows users to
fetch an AI-generated inspirational quote
made by Inspirobot
'''
2020-01-07 03:07:39 +00:00
import discord
from discord.ext import commands
from api import inspirobot
2020-01-08 01:08:07 +00:00
from util import config
2020-01-07 03:07:39 +00:00
class Inspirobot(commands.Cog):
2020-01-08 01:26:36 +00:00
def __init__(self, client : discord.Client):
2020-01-07 03:07:39 +00:00
self.client = client
@commands.command(name="Inspirobot", description="Sends a randomly generated inspirational quote", aliases=["inspiration", "inspiro"])
@commands.cooldown(1, 5)
2020-01-08 01:26:36 +00:00
async def inspirobot(self, ctx : commands.Context):
2020-01-07 03:07:39 +00:00
image = inspirobot.get_inspirational_quote()
if image is None:
await ctx.message.add_reaction("⚠️")
else:
2020-01-08 01:08:07 +00:00
embed = discord.Embed(title="InspiroBot", color=int(config.settings["color"], 16))
2020-01-07 03:07:39 +00:00
embed.set_image(url=image)
await ctx.send(embed=embed)
2020-01-08 01:26:36 +00:00
def setup(client : discord.Client):
2020-01-07 03:07:39 +00:00
client.add_cog(Inspirobot(client))