📜  discord api python 将 id 放入列表中 - Python 代码示例

📅  最后修改于: 2022-03-11 14:45:29.490000             🧑  作者: Mango

代码示例1
@client.event
async def on_ready():
    guilds = client.guilds
    data = {}
    for guild in guilds:
        data[guild.id] = []
        for channel in guild.channels:
            data[guild.id].append(channel.id)
    with open("./data/guilds.json", "w") as file:
        json.dump(data, file, indent=4)