【问题标题】:How to check for message after command used; Discord.py使用命令后如何检查消息;不和谐.py
【发布时间】:2021-06-11 17:16:08
【问题描述】:

所以我正在制作一个类似于战斗模拟器 discord python bot,对于用户实际战斗的命令,我需要在使用战斗命令后检查消息。

@client.command
async def on_message(message):
  if message.content == ('.fight'):
    await message.channel.send('Do you want to defend or attack?')

    #check for message here

在机器人检查消息后,如果发送的消息等于“防御”,我希望机器人执行某些操作,如果发送的消息等于“攻击”,则执行其他操作。

任何帮助将不胜感激。谢谢!

【问题讨论】:

    标签: python discord.py


    【解决方案1】:

    试试-

    def check(m):
        return ctx.author == m.author #To make sure it is the only message author is getting
    msg = await self.bot.wait_for('message', timeout=60.0, check=check)
    

    然后-

    if msg.content.lower() == 'defend':
      #Your code
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-06-28
      • 2019-07-18
      • 2021-09-05
      • 1970-01-01
      • 1970-01-01
      • 2018-12-15
      相关资源
      最近更新 更多