Discord.py: Command has no attribute load

Created on 22 Oct 2019  ·  3Comments  ·  Source: Rapptz/discord.py

Whenever my code tries to run anything asking for "checkforprofile", it gives an error saying:

gp = json.load(g) AttributeError: 'Command' object has no attribute 'load'

Here is my code for it:

```def checkforprofile(userid):
with open("gp.json", mode="r") as g:
gp = json.load(g)
user = "userid_" + str(userid)
if user not in gp:
addprofile(userid);
print("Profile " + str(user) + "created");
rules = discord.Embed(title=".",description='.')
rules.add_field(name="ADB profile created!", value=":)")
bot.get_user(userid).send(embed=rules)
else: print("Profile creation request cancelled")

```
Just a note: It was working the night before this post

off-topic

All 3 comments

It isn’t a library issue. Most likely you have defined “json” command somewhere.

Sorry for being rude, but better learn python then
https://automatetheboringstuff.com/ (for complete beginners to programming)
https://learnxinyminutes.com/docs/python3/ (for people who know programming already)
https://docs.python.org/3/tutorial/ (official tutorial)
http://python.swaroopch.com/ (useful book)
http://greenteapress.com/wp/think-python-2e/ (another decent book)
see also: http://www.codeabbey.com/ (exercises for beginners)

This is not an issue with discord.py.
You're likely shadowing/overriding your import of the json standard library with a command function named json.

GitHub issues for this repository should be used to report issues with this library.
They are not a medium for requesting help with Python.
For further help specific to using this library, you should join either the official discord.py server or the Discord API server, as the README also links.

Was this page helpful?
0 / 5 - 0 ratings