Discord.py | Bot responses when it is pinged

If I do something like if message.content.startswith('hello'): it works fine. But I can't to find a way to make it work for pings. I tried bot ID and name. My code with bot ID:

async def on_message(message):
    await client.process_commands(message)
    if message.content.startswith('<@741352621826375781>'):
        embed = discord.Embed(
            colour = discord.Colour.red())
        embed.add_field(name='Hello', value='''My prefix is `.`, type `.help` for help.''', inline=False)
        await message.channel.send(embed=embed)

Can somebody help?

Read more here: https://stackoverflow.com/questions/64941713/discord-py-bot-responses-when-it-is-pinged

Content Attribution

This content was originally published by CheryX at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: