From 8fc1ff176f073faf5494fc0503fcb572c59f769c Mon Sep 17 00:00:00 2001 From: aikaterna <20862007+aikaterna@users.noreply.github.com> Date: Tue, 8 Oct 2019 17:37:09 -0700 Subject: [PATCH] [DadJokes] Initial commit --- README.md | 2 ++ dadjokes/__init__.py | 5 +++++ dadjokes/dadjokes.py | 16 ++++++++++++++++ dadjokes/info.json | 10 ++++++++++ 4 files changed, 33 insertions(+) create mode 100644 dadjokes/__init__.py create mode 100644 dadjokes/dadjokes.py create mode 100644 dadjokes/info.json diff --git a/README.md b/README.md index 0be72c5..8cb8c08 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,8 @@ cah - Cards Against Humanity, played in DM's. This can rate limit large bots via chatchart - Generates a pie chart to display chat activity over the last 5000 messages. Requested by violetnyte. +dadjokes - Another UltimatePancake cog. Get some dad jokes on command. + dictonary - I stole this from UltimatePancake's v2 cogs, defines words via a dictonary. Only the "define" command for now until the dependency owner updates their files with a pending PR. dungeon - New users with new accounts will be shuffled off to a locked channel on-join to help mitigate raiders. Please see the dungeon_readme.md file on this repo for more information. diff --git a/dadjokes/__init__.py b/dadjokes/__init__.py new file mode 100644 index 0000000..7196d02 --- /dev/null +++ b/dadjokes/__init__.py @@ -0,0 +1,5 @@ +from .dadjokes import DadJokes + + +def setup(bot): + bot.add_cog(DadJokes(bot)) diff --git a/dadjokes/dadjokes.py b/dadjokes/dadjokes.py new file mode 100644 index 0000000..3a5b492 --- /dev/null +++ b/dadjokes/dadjokes.py @@ -0,0 +1,16 @@ +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}`") diff --git a/dadjokes/info.json b/dadjokes/info.json new file mode 100644 index 0000000..58c1d1b --- /dev/null +++ b/dadjokes/info.json @@ -0,0 +1,10 @@ +{ + "author": [ + "UltimatePancake" + ], + "description": "Gets a random dad joke from icanhazdadjoke.com", + "install_msg": "Gets a random dad joke from icanhazdadjoke.com. Thanks for installing.", + "short": "Random dad jokes", + "tags": ["jokes", "dad", "dadjokes"], + "type": "COG" +}