【发布时间】:2021-03-25 06:47:32
【问题描述】:
我想在文本频道收到用户的多条消息后调用一个函数,但我不知道该怎么做。
startGame = False
async def on_message(message): # when a new message is detected in the server
if message.author == client.user: ## don't respond to own message sent by the bot
return
if not startGame:
if message.content == "?startGame": ## start asking for several inputs once user wants to start the game
await message.channel.send("age?") ## i want to ask for the user's age
## ask several other things and store them etc
startGame = True
但是,我现在不知道如何存储用户的年龄,因为机器人会发送“年龄?”在服务器中然后on_message 将被再次调用但在这种情况下不会做任何事情,所以我不能使用用户的输入
【问题讨论】:
-
你可能应该定义一个可以存储值的类 User()...
标签: python bots discord.py