Discord Bot Encouraging Message API

import discord
import os
import requests
import json 
from keep_alive import keep_alive

def get_quote():
  quote=json_data[0]['q'] + " -" +json_data[0]['a']

client = discord.Client()

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

#db!hello script
async def on_message(message):
  if message.author==client.user:

  if message.content.startswith(';inspire'):
    await message.channel.send(quote)



Code exactly as written in video: https://www.youtube.com/watch?v=SPTfmiYiuok

The bot outputs: <function get_quote at 0x7f89b4dbe1f0> though!

Hello there.

Do you have a question?

If so, please edit your post to include it in the Tell us what’s happening section.

Learning to describe problems is an important part of learning how to code.

Also, the more information you give us, the more likely we are to be able to help.

I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (’).

The bot keeps outputting <function get_quote at 0x7f89b4dbe1f0>

We’re going to need more than that. What do you want it to do instead? Where in the video are you?

It just outputs that. No quotes.

I’m at 33:07

send the quotes. like in the video

I’m not an expert in this video, but in this line you are setting the variable quote to the function get_quote. You probably want to call this function with get_quote().

what could i put then


Like in the video. The ()s are important. Without the ()s you are talking about the function itself as an object. With the ()s you are calling (or invoking) the function to get it to produce a result (a quote in this case).

You are a life saver! I just realised i missed out the brackets after quote=get_quote.

1 Like

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