Skip to content

get_user_vote() returns the payload as a str instead of dict #95

@kelvbun

Description

@kelvbun
Traceback (most recent call last):
  File "/Users/kelvin/Documents/code/bot/venv/lib/python3.13/site-packages/discord/ext/commands/core.py", line 266, in wrapped
    ret = await coro(*args, **kwargs)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/kelvin/Documents/code/bot/utils/bases/cog.py", line 43, in wrapper
    voted = await self.bot.topgg.get_user_vote(ctx.author.id)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/kelvin/Documents/code/bot/venv/lib/python3.13/site-packages/topgg/client.py", line 348, in get_user_vote
    return bool(data["voted"])
                ~~~~^^^^^^^^^
TypeError: string indices must be integers, not 'str'

it seems like the get_user_vote() returns a dumped version of the payload. using json.loads() seems to fix this. i have checked pip freeze & im using topggpy==1.4.0 (assuming this is the latest version). not sure if theres double encoding on your end or not.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions