I'm coding a discord bot that cheers people up by recognizing keywords, and users are able to add their own motivational messages to the database too. Additionally, I've created a command that shows the list of user-added messages when the user uses '+list'. While this works to a certain extent, it always shows 'ObservedList(value=', and then shows the actual list. Is there any way to stop this?
For reference, here is the range of code where I suspect there may be an error:
if msg.startswith("+del"):
encouragements = []
if "encouragements" in db.keys():
index = int(msg.split("+del",1)[1])
delete_encouragement(index)
encouragements = db["encouragements"]
await message.channel.send(encouragements)
if any(word in msg for word in happy_words):
await message.channel.send(random.choice(responses))
if msg.startswith("+list"):
encouragements = []
if "encouragements" in db.keys():
encouragements = db["encouragements"]
await message.channel.send(encouragements)
Additionally, the error shown in the following code is that the index is out of range. How can I fix that?
if msg.startswith("+responding"):
value = msg.split("+responding ",1)[1]
if value.lower() == "true":
db["responding"] = True
await message.channel.send("Responding is on.")
else:
db["responding"] = False
await message.channel.send("Responding is off.")
Thanks for your time.