I am programming a discord bot using the following link: https://www.youtube.com/watch?v=SPTfmiYiuok
It's a bot that's meant to give an inspiring message when called, and users can add and delete said messages as well. The problem I am facing :
A) Whenever I type anything, it gives the received command of 'New encouraging message added', even though I'm not calling that function.
B) The code itself is giving me an error stating that the list index is out of range.
For reference, here is the block of code in which the error message is occurring, and the range of which I suspect the error to be at. The actual error is the line towards the bottom:
index = int(msg.split("+del",1)[1])'):
And here is the code
if msg.startswith('+inspire'):
quote = get_quote()
await message.channel.send(quote)
options = starter_encouragements
if "encouragements" in db.keys():
options = options + db["encouragements"].value
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 encouraging message added :)")
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)
android
andios
tags?{ }
to yourIF
statements, I think that with the lack of whitespace,await message.channel.send("New encouraging message added :)")
is always firing.