[V3] Cleanup
This commit is contained in:
16
inspirobot/info.json
Normal file
16
inspirobot/info.json
Normal 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"
|
||||
}
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user