My encouragements code is having some errors

i kinda coded the starter encouragements different to fit my style

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

client = discord.Client()

sad_words = ["quote"]

starter_encouragements = [
 "Iron Sword Huh? What Are You Killing? Butterflies?",
 "Let Me Guess, Someone Stole Your Sweetroll",
 "You'll Make A Fine Rug, Cat!",
 "I Used To Be An Adventurer Like You, Then I Took An Arrow In The Knee",
 "Do You Get To The Touch Grass Very Often? Oh, What Am I Saying, Of Course You Don't",
 "Fredom For You Mason Not For Me",
 "Are We Russing In Or Are Going Sneaky Peaky Like?",
 "Watch Out. These Boys Have Got A Bit Of An Arsenal And They Don't Mind Using It!",
 "Right...what the hell kind of name is Soap, eh? How'd a muppet like you pass selection?",
 "Roses are red, Violets are blue, Soap trusted you i thought i could to, Then why in the bloody hell does makarov knows you"


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):
  encouraging_message = 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 message.content.startswith('$inspire'):
    quote = get_quote()

  options = starter_encouragements
  if "encouragements" in db.keys():
    options = options + db["encouragements"]

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

  if msg.startswith("$new"):
    encouraging_message = msg.split("$new ",1)[1]
    await"New Quote Added.")

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

my_secret = os.environ['Token']

and the error is

Ignoring exception in on_message
Traceback (most recent call last):
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/", line 343, in _run_event
    await coro(*args, **kwargs)
  File "", line 65, in on_message
    options = options + db["encouragements"]
TypeError: can only concatenate list (not "ObservedList") to list

im still a newbie with coding so please say what i coded wrong in a way a person who just started coding with no experience can understand. Thank you

This question seems to be come up every now and then. Here’s some answered posts on the subject.

Basically, the replit database isn’t returning a standard python list but an object they’ve called an ObservedList. Python knows how to concatenate a standard list object with another standard list object via the + operand, but in this code you’re trying to concatenate the standard list options with another object of type ObservedList.
This is why you get a TypeError. It is saying the operation options + db["encouragements"] expected two objects of type list, but is being given one list object and one ObservedList object and doesn’t know what to do with the latter.

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