feat: joke command

This commit is contained in:
rainy 2024-08-10 15:20:30 -07:00
parent 08740c8df9
commit 86dba83c34
1 changed files with 17 additions and 0 deletions

17
plugins/fun.py Normal file
View File

@ -0,0 +1,17 @@
from disnake.ext import plugins
import disnake
import aiohttp
plugin = plugins.Plugin()
@plugin.slash_command()
async def joke(inter: disnake.CommandInteraction):
async with aiohttp.ClientSession() as cs:
async with cs.get("https://v2.jokeapi.dev/joke/Programming,Miscellaneous?blacklistFlags=nsfw,political&type=single") as resp:
resp = await resp.json()
em = disnake.Embed(title="A joke for you!", description=resp["joke"], color=disnake.Color.random())
em.set_footer(text="powered by v2.jokeapi.dev")
await inter.response.send_message(embed=em)
setup, teardown = plugin.create_extension_handlers()