“Command”没有“Load”属性

2024-10-03 17:17:17 发布

您现在位置:Python中文网/ 问答频道 /正文

我有一个discord bot,但是当我尝试运行其中一个代码时,它会说“command”没有“load”属性,如果我修复了这个问题,它会出现大量其他JSON错误

我试图不加载和使用实际的东西,但后来又出现了另一个问题。我将discord.py重写与bot.commands和bot.events一起使用,还使用JSON

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")

我得到的错误是:

line 117, in checkforprofile
    gp = json.load(g)
AttributeError: 'Command' object has no attribute 'load'

我希望它停止给出所有的错误,因为当这个得到修复时,它可能会给出一个新的错误 提前谢谢


Tags: injsonbot错误loadprofilerulesgp