Inspirational Discord Bot API function not working

Hi there,
I’ve been following the Python Discord Bot tutorial and appear to have hit an issue.
When I run the code and send the “$inspire” message in the server, the bot responds with:
“<function get_quote at 0x7f2d3bc86280>”
There’s no error when running the code, so I figured it just isn’t reading the api correctly but I’m not sure.
Any help would be appreciated and I’ve also posted my code

import discord
import os
import requests
import json

client = discord.Client()

def get_quote():
  response = requests.get("https://zenquotes.io/api/random")
  print(response)
  json_data = json.loads(response.text)
  quote = json_data[0]["q"] + " - " + json_data[0]["a"]
  return (quote)

@client.event
async def on_ready():
  print("We have logged in as {0.user}".format(client))

@client.event
async def on_message(message):
  if message.author == client.user:
    return

  if message.content.startswith("$hello"):
    await message.channel.send("Hello!")

  if message.content.startswith("$inspire"):
    quote = get_quote
    await message.channel.send(quote)

client.run(os.environ['token'])

you are defining here what is printed, and get_quote is a function
maybe you wanted to call the function so to get its output?

Thank you!
Turns out I was just missing the () after get_quote, it’s all working find now :smiley:

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.