[英]Discord Bot Python. I'm trying to get my bot to see a command from a user, then take the next message content (will always be a bot)
[英]I'm trying to get my discord bot to wait for the user to send another message after they did the original command
抱歉,如果標題沒有意義,我正在制作一個 discord 機器人,我正在嘗試制作一個小的 8 球命令。 我想讓機器人做的是,在用戶輸入“$8ball”后,機器人會說“你有什么問題?” 然后等待用戶輸入他們的問題,然后用我為它做出的一系列響應進行響應。
@client.event
async def on_message(message):
if message.author == client.user:
return
if message.content.startswith("$8Ball"):
await message.channel.send("What is your question?")
(這就是我到目前為止的所有代碼)
您可以嘗試存儲用戶的 ID 並對該用戶的下一條消息做出反應。
嘗試這個。 question
將是用戶輸入的內容。 它在與原始命令相同的頻道中等待一條消息,並且來自執行該命令的同一用戶
@client.event
async def on_message(message, author):
if message.content.startswith('$8Ball'):
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
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.