Files
aikaterna-cogs/dadjokes/dadjokes.py
Vault108 3bc65b688e Fix Encoding (#234)
Output would randomly show ’ instead of '
2021-06-03 09:28:07 -07:00

22 lines
612 B
Python

from redbot.core import commands
import aiohttp
class DadJokes(commands.Cog):
"""Random dad jokes from icanhazdadjoke.com"""
async def red_delete_data_for_user(self, **kwargs):
""" Nothing to delete """
return
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(encoding="UTF-8")
await ctx.send(f"`{result}`")