React to message if embed includes <Insert word here>

0

I have a piece of code that reacts to a specific bot in a channel but the piece of code reacts to everything the bot says. The bot only types out in embed messages and I wasn't sure how to make the code look inside the embedded message and react to the message only if a certain keyword is said inside of the embed. Code:


client = discord.Client()
token = ("<discord token>")

@client.event
async def on_message(message):
    channel = client.get_channel(825437474871312387)
    if message.channel == channel and message.author.id == 342644185800769537:
        if message.content == "test":
            await message.add_reaction("❤️")
            print("done")



if __name__ == '__main__':

    client.run(token, bot=False)
    print("can you see me?")
discord discord.py python
2021-11-24 00:49:11
1

0

Yes you can add reaction only to the embed with a specific title.

@client.event
async def on_message(message):
    channel = client.get_channel(825437474871312387)
    if message.embeds and message.channel == channel and message.author.id == 342644185800769537:
        if message.embeds[0].title == "test":
            await message.add_reaction("❤️")
            print("done")

I added one more check to if statement (if message.embeds) to make sure that the message has embed inside it. Then I use message.embeds[0] because message.embeds returns a list of embeds. After that you can get information from the embed like title, author etc. (discord.Embed in docs).

2021-11-24 19:13:56

Thank you for your help but when I send an embed with the title "test" the bot doesn't seem to pick it up because I am not getting any error messages or reactions on the embed.
Vanden

In other languages

This page is in other languages

Русский
..................................................................................................................
Italiano
..................................................................................................................
Polski
..................................................................................................................
Română
..................................................................................................................
한국어
..................................................................................................................
हिन्दी
..................................................................................................................
Français
..................................................................................................................
Türk
..................................................................................................................
Česk
..................................................................................................................
Português
..................................................................................................................
ไทย
..................................................................................................................
中文
..................................................................................................................
Español
..................................................................................................................
Slovenský
..................................................................................................................