我正在使用 discord 模块制作一个 discord bot,但我没有使用异步功能的经验。
这是代码中不起作用的部分:
@client.command()
async def bank(ctx):
global bal
if ctx.author.name in users:
bal.append(0)
else:
print("nope")
print(bal)
bal
之前设置为所有函数之外的空列表。
它返回一个巨大的错误,但主要是说:
AttributeError: 'Command' object has no attribute 'append'
读取错误AttributeError: 'Command' object has no attribute 'append'
,看起来bal
变量是类型object
而不是列表。
您可以通过检查 if 语句之前的类型来验证这一点,如下所示:
print(type(bal))
请确保类型是append
要工作的列表。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句