【发布时间】:2018-08-01 16:42:06
【问题描述】:
我在 python 中创建了一个不和谐的机器人,为了将数据保存在我的计算机上,我在文本文件中使用了一个字典,但是如果我想要多服务器支持类似 config 的东西,我需要知道服务器的 ID。我发现唯一可行的是discord.Server.id,但它返回<member 'id' of 'Server' objects>。我想知道在python中是否还有其他方法可以做到这一点?我的确切代码是这样的:
@bot.command(pass_context=True)
async def info(ctx):
await bot.say("ID: {}".format(discord.Server.id))
返回
ID: <member 'id' of 'Server' objects>
当我运行 c*info 时(c* 是我的机器人的前缀)。我不知道这个错误的原因或我做错了什么,所以请帮忙!
谢谢
【问题讨论】:
标签: python-3.x discord.py