Problem regarding Discord Bot

None of the other feature work other than $inspire , don’t know why

import os
import discord
import requests
import json
import random
from replit import db

client = discord.Client()

sad_words = ["sad", "depressed", "unhappy", "angry", "miserable", "depressing"]

starter_encouragements = [
  "Cheer Up!",
  "Hang in there",
  "You are a great person!"

if "responding" not in db.keys():
  db["responding"] = True

def get_quote():
  response = requests.get("")
  json_data = json.loads(response.text)
  quote = json_data[0]['q'] + " -" + json_data[0]['a']

def update_encouragements(encouraging_message):
  if "encouragements" in db.keys():
    encouragements = db["encouragements"]
    db["encouragements"] = encouragements
    db["encouragements"] = [encouraging_message]

def delete_encouragement(index):
  encouragements = db["encouragements"]
  if len (encouragements) > index:
    del encouragements[index]
    db["encouragements"] = encouragements

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

async def on_message(message):
    if == client.user:

    msg = message.content

    if msg.startswith('$inspire'):
        quote = get_quote()
    if db["responding"]:
        options = starter_encouragements
        if "encouragements" in db.keys():

        if any(word in msg for word in sad_words):

        if msg.startswith("$add"):
          encouraging_message = msg.split("$add ",1)[1]
          await"New encouraging message added! :white_check_mark:")

        if msg.startswith("$del"):
          encouragements = []
          if "encouragements" in db.keys():
            index = int(msg.split("$del",1)[1])
            encouragements = db["encouragements"]

        if msg.startswith("$list"):
          encouragements = []
          if "encouragements" in db.keys():
            encouragements = db["encouragements"]

        if msg.startswith("$responding"):
          value = msg.split("$responding ",1)[1]

          if value.lower() == "true":
           db["responding"] = True
           await"Responding is on.")
          db["responding"] = False
          await"Responding is off")

my_secret = os.environ['TOKEN']

check your indentation, I’m not sure the if statements are nested correctly

do you know where exactly the problem is at.?

no, but for example here if the message doesn’t start with $responding then responding is turned off

Yea, but I started it with $responding and still the problem continues, it’s not only $responding but all others except $inspire isn’t working

To clarify, your indentation in that snippet Ilenia pointed to says:

“If the message starts with responding, and value is “true” , set responding to true. If the message does NOT start with responding, set responding to false.”

It’s because that snippet make this execute

so then this

is never entered

you need to organize better how those parts are nested in each other

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