【发布时间】:2019-05-23 00:12:05
【问题描述】:
所以问题是,我正在使用 python.py 在 python 中制作一个不和谐的机器人,并且我正在通过将某人的用户 ID 放在一个 json 文件中来发出一个命令来静音。
@client.command()
async def mute(user):
with open("muted.json", 'r') as f:
data = json.load(f)
if not user.id in data:
data[user.id] = {}
else:
await client.send_message(message.channel, "The user is already muted")
在“if not user.id in data:”中说“AttributeError: 'str' object has no attribute 'id'” 我该如何解决?
【问题讨论】:
-
尝试使用
'user.id'而不是user.id(在这两种情况下)。
标签: python string discord.py