pythondiscorddiscord.pymonitoring

message.embeds from discord.py library cant see embed from SD.C Monitoring bot


Im trying to make discord bot with simple bump counter with leaderboard. When server is bumped - bot that makes connection with server monitoring sends an embed in chat which says that server is bumped. I use that to get discord user that bumped the server and calculate different stuff for him.

Everything works fine with Disboard, DSMonitoring, Server Monitoring, I also can get embed contents of other bots if i want. But message.embeds cant see embed of SD.C Monitoring and I cant understand why.

here is what gives message.embeds for SD.C Monitoring, although I can see on my test discord server that embed exists: []

here is an example of what gives message.embeds for any other message with embed: [<discord.embeds.Embed object at 0x0000020B7AD017E0>]

Here is part of code that seems to contain everything relevant for this problem:your text

from typing import Final
import os
import json
from dotenv import load_dotenv
from discord import Intents, Client, Message
from responses import get_response
from dataStoring import StoreDataInJson
from commands import bot
load_dotenv()
TOKEN: Final[str] = os.getenv("DISCORD_TOKEN")

intents: Intents = Intents.default()
intents.message_content = True
client: Client = Client(intents=intents)

@client.event
async def on_ready() -> None:
    print(f'{client.user} is now running')

@client.event
async def on_message(message: Message) -> None:
    if message.author == client.user:
        return

    username: str = str(message.author)
    user_message: str = message.content
    channel: str = str(message.channel)

    print(f'[{channel}] {username}:       <{message.embeds}> ')


def main() -> None:
    client.run(token=TOKEN)
    bot.run(token=TOKEN)

if __name__ == '__main__':
    main()

Solution

  • The bot seems to be deferring the response and sending a follow-up. When it defers, the on_message is called. That's why it doesn't have embeds. After it sends a follow-up, the on_message_edit will be called.

    @client.event
    async def on_message_edit(before,after):
        if before.embeds != after.embeds:
            # your code here