Python message.content discord bot

隐身守侯 提交于 2021-02-10 18:43:50

问题


I would like a help, I am trying to make my bot in discord to respond automatically when someone writes some word, the problem is that the command only works if the word is the first thing to be written in the sentence. I wish my bot could respond to the message even when the word is in the middle of some sentence. What should I do?


回答1:


Bot = commands.Bot(command_prefix="")

@Bot.event

async def on_message(message):

     if "not" in message.content:
           await Bot.send_message(message.channel, 'yes')

To clarify - message.content.startswith will only check to see if the defined characters/string are at the start of the message, while message.content scans the entire message sent.



来源:https://stackoverflow.com/questions/49122684/python-message-content-discord-bot

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!