Search code examples
python-3.xdiscord.pykeyerror

Command raised an exception: KeyError: '248120040153415681'


I made a Discord Bot who gives esperience and lvl to user. I want to add +rank in order to see what rank the user is and how much he has on exp. Now i tried coding it but i get this error: error

and this is my code: code

my json file is named expe.

whole experience code


Solution

  • I guess you use the rewrite version of discord.py, so you have to access it with [str(user.id)] because IDs are now integers and keys of dictionaries in JSON must always be strings.