我试图让我的不和谐机器人等待用户在执行原始命令后发送另一条消息
I'm trying to get my discord bot to wait for the user to send another message after they did the original command
抱歉,如果标题没有意义,我正在制作一个不和谐的机器人,我正在尝试制作一个小的 8 球命令。我想让机器人做的是,在用户输入“$8ball”后,机器人会说“你有什么问题?”然后等待用户输入他们的问题,然后用我为它做出的一系列回应来回应。
@client.event
async def on_message(message):
if message.author == client.user:
return
if message.content.startswith("Ball"):
await message.channel.send("What is your question?")
(这是我目前所有的代码)
您可以尝试存储用户的id,并对该用户的下一条消息做出反应。
试试这个。 question
将是用户输入的内容。它在与原始命令相同的频道中等待一条消息,并且来自执行该命令的同一用户
@client.event
async def on_message(message, author):
if message.content.startswith('Ball'):
channel = message.channel
author = message.author
await channel.send('What is your question?')
def check(m):
return m.author == author and m.channel == channel
msg = await client.wait_for('message', check=check)
question = msg.content
告诉我进展如何:D
抱歉,如果标题没有意义,我正在制作一个不和谐的机器人,我正在尝试制作一个小的 8 球命令。我想让机器人做的是,在用户输入“$8ball”后,机器人会说“你有什么问题?”然后等待用户输入他们的问题,然后用我为它做出的一系列回应来回应。
@client.event
async def on_message(message):
if message.author == client.user:
return
if message.content.startswith("Ball"):
await message.channel.send("What is your question?")
(这是我目前所有的代码)
您可以尝试存储用户的id,并对该用户的下一条消息做出反应。
试试这个。 question
将是用户输入的内容。它在与原始命令相同的频道中等待一条消息,并且来自执行该命令的同一用户
@client.event
async def on_message(message, author):
if message.content.startswith('Ball'):
channel = message.channel
author = message.author
await channel.send('What is your question?')
def check(m):
return m.author == author and m.channel == channel
msg = await client.wait_for('message', check=check)
question = msg.content
告诉我进展如何:D