【发布时间】:2022-01-15 00:14:34
【问题描述】:
我正在尝试编写一个不和谐的机器人,其中所有用户都有一个可自定义的配置文件。每当他们运行命令!profile 时,机器人都会显示一个嵌入的生物。嵌入将是他们选择的自定义嵌入颜色和其他信息,如他们的硬币等。我想让它每当他们运行!bio test之类的东西时,他们的个人资料嵌入将有消息test,如果他们运行!bio Lorem,他们的自定义个人资料生物将被编辑为Lorem等等。但是,当我尝试执行 !bio test 命令时,它不起作用
def saveJson(data, file):
json.dump(data, open(file, "w"), indent = 4)
@client.command(aliases=["b"])
async def bio(ctx, *, message):
user = ctx.author.id
username = str(ctx.author)
desciption['users'].append({
'id':user,
'name':username,
'description': [message]
})
saveJson(description, "./profile.json")
稍后在 profile 命令中,我的机器人将在 json 文件中找到描述部分,并在有人检查您的个人资料时显示它
【问题讨论】:
-
这里有什么问题?
-
我尝试执行 !bio 命令但它不起作用
标签: python json discord profile