aboutsummaryrefslogtreecommitdiffstats
path: root/bot/exts/fun/fun.py
diff options
context:
space:
mode:
authorGravatar Diabolical5777 <[email protected]>2022-07-27 16:37:24 +0400
committerGravatar GitHub <[email protected]>2022-07-27 14:37:24 +0200
commita7624603983a7d04fb40de78066ee421ded5e36c (patch)
treeb4b8178812765028ea3d2f4bd4f8c44d3305f48c /bot/exts/fun/fun.py
parentFix incorrect type hints (#1073) (diff)
Add jokes command (#1081)
Add jokes command
Diffstat (limited to 'bot/exts/fun/fun.py')
-rw-r--r--bot/exts/fun/fun.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/bot/exts/fun/fun.py b/bot/exts/fun/fun.py
index a27ad85f..9ec9b9ee 100644
--- a/bot/exts/fun/fun.py
+++ b/bot/exts/fun/fun.py
@@ -3,8 +3,9 @@ import logging
import random
from collections.abc import Iterable
from pathlib import Path
-from typing import Callable, Optional, Union
+from typing import Callable, Literal, Optional, Union
+import pyjokes
from discord import Embed, Message
from discord.ext import commands
from discord.ext.commands import BadArgument, Cog, Context, MessageConverter, clean_content
@@ -41,7 +42,6 @@ class Fun(Cog):
def __init__(self, bot: Bot):
self.bot = bot
-
self._caesar_cipher_embed = json.loads(Path("bot/resources/fun/caesar_info.json").read_text("UTF-8"))
@staticmethod
@@ -212,6 +212,12 @@ class Fun(Cog):
return Embed.from_dict(embed_dict)
+ @commands.command()
+ async def joke(self, ctx: commands.Context, category: Literal["neutral", "chuck", "all"] = "all") -> None:
+ """Retrieves a joke of the specified `category` from the pyjokes api."""
+ joke = pyjokes.get_joke(category=category)
+ await ctx.send(joke)
+
def setup(bot: Bot) -> None:
"""Load the Fun cog."""