I need help with my encouragement bot database

Hii everyone. So I’ve been working on this Python bot for 7 months, and I have recently added a database function based off the python Discord Bot tutorial. The link is below. So far it’s gone pretty smooth but I’ve run into an error with the $del command. Since my code is very long I’ll just paste the delete_encouragements function and the $del command here. The replit link is attached to this post if you want to see the entire thing.

This is my code:

#del
def delete_encouragment(index):
  encouragements = db["encouragements"]
  if len(encouragements) > index:
    del encouragements[index]
  db["encouragements"] = encouragements

    if msg.startswith("$del"):
      encouragements = []
      if "encouragements" in db.keys():
        index = int(msg.split("$del",1)[1])
        delete_encouragment(index)
        encouragements = db["encouragements"]
      await message.channel.send(encouragements)

And this is the error that I have received:

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 549, in on_message
** delete_encouragment(index)

** File “main.py”, line 52, in delete_encouragment
*
** if len(encouragements) > index:**
TypeError: ‘>’ not supported between instances of ‘int’ and 'str’
172.18.0.1 - - [20/Apr/2022 04:10:25] “HEAD / HTTP/1.1” 200 -

The stuff in bold are those that I think are important.

Any help would be much appreciated.

How to code a python discord bot

Misfortune cookie bot

this seems pretty clear. what data type is index?


I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (’).