How to make my discord bot detects two or more specific words and responds

Viewed 52

I’m trying to make my discord bot respond when it detected two or more specific words in other's msg. Something like when someone has sent a message with “Bot” and “jokes” like “Hey Bot, tell me some jokes!”, the bot will respond to it. These are my code: (Cause I'm a Hongkonger and this bot are also designed for the Hongkongers so there are some Chinese in my code, but I'll write down the meaning behind the # then U guys can understand it.)

import discord
import time
import random

client = discord.Client()

@client.event
async def on_message(message):
    name = message.author.display_name
    if message.author == client.user:
        return

    if message.content.startswith("喂Rikky!"): #"喂" is mean "Hey!". So this part mean "Hey Rikky!"
        await message.channel.send('係到!咩事呢?') #This Part is too hard to explain cause this is Cantonese. It is the same meaning as "I'm here, what's up?"

    if "Rikky, 講個笑話嚟聽下" in message.content: #This part mean "Rikky, tell me a joke!"
        await message.channel.send("我唔識講笑話架,你當我係Siri咩?") #This part mean "I'm not good at telling jokes"

client.run('***')

This is part of my code. I've tried

    if "Bot" + "joke" in message.content:
        await message.channel.send("我唔識講笑話架,你當我係Siri咩?")

but it doesn't work.

If it is possible, please tell me how. Thanks for spending so much time reading this question! Thank you!

1 Answers

Try this:

if "bot" and "joke" in message.content.lower(): await message.channel.send("我唔識講笑話架,你當我係Siri咩?")

or

if "bot" in message.content.lower() and "joke" in message.content.lower():
    await message.channel.send("我唔識講笑話架,你當我係Siri咩?")
Related