discord py error typeerror string indices are integers

I think I know the problem

The JSON data is from here

game_servers = await r.json()

The variable is named game_servers with a _

Here

    for gameserver in game_servers:
        raw_ip = gameserver['raw_ip']
        server_status = gameserver['on']

The variable gameserver without the _ is equal to the first dictionary value (for example, say game_servers is { "id": "string", "name": "string"} then gameserver is going to be "id", "name". See this)

So it should be

        raw_ip = game_servers['raw_ip']
        server_status = game_servers['on']

WITH the _ instead of

        raw_ip = gameserver['raw_ip']
        server_status = gameserver['on']

The for loop is also unnecessary

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top