discord.py detect message code example
Example 1: how to check if a message includes a word discord.py
@bot.event
async def on_message(msg):
if 'word' in msg.content:
print('Keyword found')
Example 2: python discord
import discord
class MyClient(discord.Client):
async def on_ready(self):
print('Logged on as', self.user)
async def on_message(self, message):
if message.author == self.user:
return
if message.content == 'ping':
await message.channel.send('pong')
client = MyClient()
client.run('token')