问题
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