【发布时间】:2018-06-19 20:23:16
【问题描述】:
所以,我想要一个机器人让每 25 个注册用户中有 1 个通过交谈获得一个有 5 个硬币的箱子。
代码:
@bot.event
async def on_message(ctx):
primary_id = ctx.message.author.id
if primary_id not in amounts:
print("")
else:
bob = random.randint(1,25)
if bob == 1:
await bot.say("You got a crate! It contained 5 coins!")
amounts[primary_id] += 5
with open('amounts.json', 'w+') as f:
json.dump(amounts, f)
else:
print("")
每当我输入内容时出错:
Ignoring exception in on_message
Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/discord/client.py", line 307, in _run_event
yield from getattr(self, event)(*args, **kwargs)
File "/home/zorin/Desktop/den.py", line 68, in on_message
id = ctx.message.author.id
AttributeError: 'Message' object has no attribute 'message'
【问题讨论】:
标签: python discord.py