I’m developing a Discord bot using Python, and I would like it to respond to any message that matches an entry in a specified list. Currently, it only reacts when the provided phrases are at the beginning of a message. I need assistance on how to make it compare the entire message to the list of phrases and send an appropriate reply whenever a match is found.
Python version: 3.8.2
Example Code:
import discord
from discord.ext import commands
bot = commands.Bot(command_prefix='!')
response_list = ['HELLO', 'WORLD', 'TEST', 'PYTHON']
@bot.event
async def on_ready():
print('Bot is online!')
@bot.event
async def on_message(msg):
if any(phrase in msg.content for phrase in response_list):
await msg.channel.send('Matched!')