[V3] Cleanup

This commit is contained in:
aikaterna
2018-08-08 21:54:06 -07:00
parent aabe0cd6a5
commit be13d0f686
21 changed files with 431 additions and 175 deletions

16
inspirobot/info.json Normal file
View File

@@ -0,0 +1,16 @@
{
"author": [
"aikaterna"
],
"description": "Fetch a random 'inspiring' message from http://inspirobot.me",
"install_msg": "Thanks for installing, have fun.",
"permissions" : [
"embed_links"
],
"short": "Fetch 'inspiring' messages.",
"tags": [
"inspire",
"inspirobot"
],
"type": "COG"
}

View File

@@ -2,8 +2,8 @@ import aiohttp
import discord
from redbot.core import commands
class Inspirobot:
class Inspirobot:
def __init__(self, bot):
self.bot = bot
self.session = aiohttp.ClientSession()
@@ -12,13 +12,15 @@ class Inspirobot:
async def inspireme(self, ctx):
"""Fetch a random "inspirational message" from the bot."""
try:
async with self.session.request("GET", "http://inspirobot.me/api?generate=true") as page:
pic = await page.text(encoding='utf-8')
async with self.session.request(
"GET", "http://inspirobot.me/api?generate=true"
) as page:
pic = await page.text(encoding="utf-8")
em = discord.Embed()
em.set_image(url=pic)
await ctx.send(embed=em)
except Exception as e:
await ctx.send(f"Oops, there was a problem: {e}")
await ctx.send(f"Oops, there was a problem: {e}")
def __unload(self):
self.session.close()