DEV Community

Hazrat Ummar Shaikh
Hazrat Ummar Shaikh

Posted on

Create a simple joke command for discord in python

Any Suggestions Appreciated I'm Sharing what I'm Learning Right Now

@commands.hybrid_command(name="joke", descriptio = "Tells a random joke.")
    async def joke(self, ctx: commands.Context):
        url = "https://official-joke-api.appspot.com/random_joke"
        response = requests.get(url)
        data = response.json()
        setup = data["setup"]
        paunch_line = data["punchline"]

        await ctx.send(setup)
        await asyncio.sleep(3)
        await ctx.send(paunch_line)
Enter fullscreen mode Exit fullscreen mode

Top comments (0)