【发布时间】:2021-12-02 07:32:48
【问题描述】:
需要帮助 我希望它在每次运行命令时再次添加服务器数据 目标是最终将其更改为 on_guild_join 所以每次它加入服务器时,它都会创建一个类似的服务器设置 公会 ID、名称和类似数据存储,供机器人的其他部分访问
错误:
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
代码:
with open("./serverconfigs.json") as f:
data = json.load(f)
newserver = configData["Servers"]
@client.event
async def on_ready():
print(client.user.name)
print(client.user.id)
print('Client ready!')
@client.command()
async def test1(ctx):
with open('serverconfigs.json', 'r+') as f:
serverdata = {
"guildid":"",
"guildname":"",
"bannedwords":[],
"blacklistedchannels":[],
"modrole":[]
}
serverdata.append(newserver)
data = json.load(f)
json.dump(data, f, indent=2)
await ctx.send('Data Collected.')
【问题讨论】:
标签: python json python-3.x discord.py