首页 文章

Python message.content discord bot

提问于
浏览
1

我想要一个帮助,我试图让我的不和谐机器人在有人写一些单词时自动响应,问题是该命令只有在这个单词是第一个写在句子中时才有效 . 我希望我的机器人能够对这个消息作出回应,即使这个词在某个句子的中间 . 我该怎么办?

1 回答

  • 3
    Bot = commands.Bot(command_prefix="")
    
    @Bot.event
    
    async def on_message(message):
    
         if "not" in message.content:
               await Bot.send_message(message.channel, 'yes')
    

    为了澄清 - message.content.startswith 将只检查定义的字符/字符串是否在消息的开头,而message.content扫描发送的整个消息 .

相关问题