I'm trying to create a discord bot command to display a list from a data base, but after watching a video to learn how to do it and (to make sure everything works) copying a piece of code, I get a "TypeError: can only concatenate list (not "ObservedList") to list" error, and I don't understand what that means...
the code :
import discord
import os
import json
import random
from replit import db
client = discord.Client()
insulte_ = [
"fdp",
"pd",
"con",
"chier"
]
def update_insulte(nouvelle_insulte):
if "insulte" in db.keys():
insulte = db["insulte"]
insulte.append(nouvelle_insulte)
db["insulte"] = insulte
else:
db["insulte"] = [nouvelle_insulte]
def delete_insulte(index):
insulte = db["insulte"]
if len(insulte) > index:
del insulte[index]
db["insulte"] = insulte
@client.event
async def on_ready():
print('Je me suis lancé en {0.user}'.format(client))
@client.event
async def on_message(message):
if message.author == client.user:
return
#score = 30
msg = message.content
"""if msg.startswith('$cs hello'):
await message.channel.send('hello!')
if msg.startswith('$cs cs'):
await message.channel.send('vous avez ' + str(score))"""
options = insulte_
if "insulte" in db.keys():
options = options + db["insulte"]
if any(word in msg for word in options):
await message.channel.send('vous avez perdu 10 crédits.')
#score = score - 10
if msg.startswith("$cs new"):
nouvelle_insulte = msg.split("$cs new ",1)[1]
update_insulte(nouvelle_insulte)
await message.channel.send("nouvelle insulte ajoutée")
if msg.startswith("$cs del"):
insulte = []
if "insulte" in db.keys():
index = int(msg.split("cs del",1)[1])
delete_insulte(index)
insulte = db["insulte"]
await message.channel.send(insulte)
if msg.startswith("$cs insultes"):
await message.channel.send(str(options))
client.run(os.getenv('TOKEN'))