Code a discord bot video

I copied the " Code a Discord Bot with Python - Host for Free in the Cloud" video’s code to see if it would work and it keeps giving me this error: 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 63, in on_message
options = options + db[“encouragements”]
TypeError: can only concatenate list (not “ObservedList”) to list

My current code:

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

client = discord.Client()

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

starter_encouragements = [
"If you're gonna be sad please do this somewhere else.",
  "K i dont care",
  "Fuck you too <3",
  "No need to be depressed! You don't deserve love.",
  "Why are you still here lmfao",
  "Please leave and never come back",

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_encouragment(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():
      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 encouraging message added.")

  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.")'TOKEN'))

How do I fix this?

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 (’).

Oh okay, thanks for letting me know.

Try adding [:] at the end of this line, like:

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

It seems db["encouragements"] is an observedlist and can’ t be concatenated to a list automatically.

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