Hi everyone!
I was following the tutorial of BeauCarnes on youtube called “Code a Discord Bot with Python - Host for Free in the Cloud”.
the first issue I had was TypeError: can only concatenate list (not “observedlist”) to list.
So I looked it up and was able to change my input from options = options + db[“encouragements”] to options = options.extend(db[“encouragements”]).
But now I have an error saying: File “main.py”, line 63, in on_message
await message.channel.send (random.choice (options) )
& TypeError: object of type ‘NoneType’ has no len()
HERE IS THE CODE:
if db["responding"]:
options = starter_encouragements
if "encouragements" in db.keys():
options = options.extend(db["encouragements"])
if any(word in msg for word in sad_words):
await message.channel.send(random.choice(options))
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.
If options is a list, using list.extend extends the list in place (so it appends the items of the argument to the original list), but it does not return anything.
Yeah, because you left away the argument as well - I didn’t write the actual code…
This is your code: options = options.extend(db[“encouragements”])
This part is the assignment: options =
This is the part your are supposed to keep: options.extend(db[“encouragements”])