Ask coding questions
Does anyone know how to add a API or something so it can print a random joke. c:
@8ryn8ryn you can use this code to get random jokes and their answers.
page = requests.get('https://official-joke-api.appspot.com/random_joke')
jokesource = json.loads(page.content)
joke = jokesource['setup']
answer = jokesource['punchline']
Since this is a discord bot and you are using client, you are going to replace the print functions with await message.channel.send(#content). Upvote and choose this as the correct answer if it is!
search up "joke api" if there isnt one, you can consider webscraping, however if thats too advanced just put your own jokes in an array, and write a function to randomly select one.
@rediar Thanks ill do that c:
Hey could you help with that?I'm having a tough time navigate through the json although the documentation is pretty [email protected]