i kinda coded the starter encouragements different to fit my style
import os
import discord
import requests
import json
import random
from replit import db
client = discord.Client()
sad_words = ["quote"]
starter_encouragements = [
"Iron Sword Huh? What Are You Killing? Butterflies?",
"Let Me Guess, Someone Stole Your Sweetroll",
"You'll Make A Fine Rug, Cat!",
"I Used To Be An Adventurer Like You, Then I Took An Arrow In The Knee",
"Do You Get To The Touch Grass Very Often? Oh, What Am I Saying, Of Course You Don't",
"DEFEND THE PRESIDENT!",
"Fredom For You Mason Not For Me",
"Are We Russing In Or Are Going Sneaky Peaky Like?",
"Watch Out. These Boys Have Got A Bit Of An Arsenal And They Don't Mind Using It!",
"Right...what the hell kind of name is Soap, eh? How'd a muppet like you pass selection?",
"Roses are red, Violets are blue, Soap trusted you i thought i could to, Then why in the bloody hell does makarov knows you"
]
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)
def update_encouragements(encouraging_message):
if "encouragements" in db.keys():
encouragements = db["encouragements"]
encouragements.appen(encouraging_message)
db["encouragements"] = encouragements
else:
db["encouragements"] = [encouraging_message]
def delete_encouragement(index):
encouraging_message = db["encouragements"]
if len(encouragements) > index:
del encouragements[index]
db ["encouragements"] = encouragements
@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)
options = starter_encouragements
if "encouragements" in db.keys():
options = options + db["encouragements"]
if any(word in msg for word in sad_words):
await message.channel.send(random.choice(options))
if msg.startswith("$new"):
encouraging_message = msg.split("$new ",1)[1]
update_encouragements(encouraging_message)
await message.channel.send("New Quote Added.")
if msg.startswith("$del"):
encouragements = []
if "encouragements" in db.keys():
index = int(msg.split("$del",1)[1])
delete_encouragements(index)
encouragements = db["encouragements"]
await messgae.channel.send(encouragements)
my_secret = os.environ['Token']
client.run(my_secret)
and the error is
Ignoring exception in on_message
Traceback (most recent call last):
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/client.py", line 343, in _run_event
await coro(*args, **kwargs)
File "main.py", line 65, in on_message
options = options + db["encouragements"]
TypeError: can only concatenate list (not "ObservedList") to list
im still a newbie with coding so please say what i coded wrong in a way a person who just started coding with no experience can understand. Thank you