import discord
import os
import requests
import json
import random
from replit import db
client = discord.Client()
sad_words = ["sad", "depressed", "annoyed", "fuck life"]
starter_encouragements =["Remember you are not Nitai",
"At least you are not Nitai",
"You are great!",
"Life goes on"
]
def update_encouragements(encouraging_message):
if "encouragements" in db.keys():
encouragements = db["encouragements"]
encouragements.append(encouraging_message)
db["encouragements"] = encouragements
else:
db["encouragements"] = [encouraging_message]
def delete_encouragement(index):
encouragements = db["encouragements"]
if len(encouragements) > index:
del encouragements[index]
db["encouragements"] = encouragements
options = starter_encouragements
if "encouragements" in db.keys():
options = options + db["encouragements"]
def get_quote():
response = requests.get("https://zenquotes.io/api/random")
json_data = json.loads(response.text)
quote = json_data[0]['q'] + " -" + json_data[0]['a']
return(quote)
@client.event
async def on_ready():
print('We have logged in as {0.user}'
.format(client))
@client.event
async def on_message(message):
if message.author == client.user:
return
msg = message.content
if message.content.startswith("!inspire"):
quote = get_quote()
await message.channel.send(quote)
if any(word in msg for word in sad_words):
await message.channel.send(random.choice(options))
if msg.startswith("!show"):
await message.channel.send(options)
client.run(
os.environ['TOKEN']
)
Line 37
options = options + db["encouragements]
TyepError : can only concatenate list (not "ObservedList") to list
Hello there.
Do you have a question?
If so, please edit your post to include it.
Learning to describe problems is an important part of learning how to code.
Also, the more information you give us, the more likely we are to be able to help.
1 Like
This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.