aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bot/exts/fun/fun.py10
-rw-r--r--poetry.lock17
-rw-r--r--pyproject.toml1
3 files changed, 24 insertions, 4 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."""
diff --git a/poetry.lock b/poetry.lock
index c3bea820..08d0de7e 100644
--- a/poetry.lock
+++ b/poetry.lock
@@ -236,8 +236,8 @@ six = ">=1.12"
sortedcontainers = "*"
[package.extras]
-aioredis = ["aioredis"]
lua = ["lupa"]
+aioredis = ["aioredis"]
[[package]]
name = "filelock"
@@ -605,6 +605,18 @@ optional = false
python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*"
[[package]]
+name = "pyjokes"
+version = "0.6.0"
+description = "One line jokes for programmers (jokes as a service)"
+category = "main"
+optional = false
+python-versions = "*"
+
+[package.extras]
+test = ["tox", "coverage", "pytest"]
+doc = ["mkdocs"]
+
+[[package]]
name = "pyparsing"
version = "3.0.6"
description = "Python parsing module"
@@ -835,7 +847,7 @@ multidict = ">=4.0"
[metadata]
lock-version = "1.1"
python-versions = "^3.9"
-content-hash = "7b443f1df31c4119783474342f05852ec35bcb4b21c07160ea6aa1ed9164fa34"
+content-hash = "86ef4c274176e805702da51d96711698a09ca6e04c145b607258c34d04638b9e"
[metadata.files]
aiodns = []
@@ -891,6 +903,7 @@ pycodestyle = []
pycparser = []
pydocstyle = []
pyflakes = []
+pyjokes = []
pyparsing = []
pyreadline3 = []
python-dateutil = []
diff --git a/pyproject.toml b/pyproject.toml
index 076f9676..729d67fa 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -22,6 +22,7 @@ coloredlogs = "~=15.0"
colorama = { version = "~=0.4.3", markers = "sys_platform == 'win32'" }
lxml = "~=4.9"
emoji = "^1.6.1"
+pyjokes = "0.6.0"
[tool.poetry.dev-dependencies]
flake8 = "~=3.8"