Files
aikaterna-cogs/dadjokes/dadjokes.py
2019-10-08 17:37:09 -07:00

17 lines
489 B
Python

from redbot.core import commands
import aiohttp
class DadJokes(commands.Cog):
"""Random dad jokes from icanhazdadjoke.com"""
def __init__(self, bot):
self.bot = bot
@commands.command()
async def dadjoke(self, ctx):
"""Gets a random dad joke."""
api = 'https://icanhazdadjoke.com/'
async with aiohttp.request('GET', api, headers={'Accept': 'text/plain'}) as r:
result = await r.text()
await ctx.send(f"`{result}`")