This repository has been archived by the owner. It is now read-only.
Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Chat-Bot/jokes.py
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
30 lines (21 sloc)
820 Bytes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import discord | |
from discord.ext import commands | |
import random | |
import requests | |
""" THIS CODE IS NOT OURS CODE IT'S FROM THE INTERNET """ | |
"""Source of the code: https://gist.github.com/EvieePy/d78c061a4798ae81be9825468fe146be """ | |
class JokesCog: | |
def __init__(self, client): | |
self.client = client | |
@commands.command() | |
async def jokes(self, ctx): | |
# Using api.chucknorris.io/jokes API | |
url = 'https://safe-falls-22549.herokuapp.com/random_joke' | |
res = requests.get(url) | |
data = res.json() | |
setup = data['setup'] | |
punchline = data ['punchline'] | |
await ctx.send (data['setup']) | |
await ctx.send (data['punchline']) | |
def setup(client): | |
client.add_cog(JokesCog(client)) |