dolfies / discord.py-self

A fork of the popular discord.py for user accounts.
https://discordpy-self.rtfd.io/en/latest/
MIT License
718 stars 165 forks source link

some messages have empty content #593

Closed Godwhitelight closed 1 year ago

Godwhitelight commented 1 year ago

Summary

Some messages have empty content

Reproduction Steps

a specific bot message gives empty content messages but he does send content image the second message has empty content when I get it on the on_message event. It happens only on that specific message that the bot sending. It does not happen on every image

Code

from discord import Client, MessageType
from src.comperator.comparator import Comparator

class SelfBot(Comparator, Client):
    def __init__(self):
        Comparator.__init__(self)
        Client.__init__(self)

    async def what_ball(self, message):
        print(message.reference)
        if not message.reference or message.reference.message_id not in self.update_required:
            return

        # Content here is empty for some reason
        ball_name = message.content.split('You caught ')[1].split('!')[0]
        # DO STUFF HERE
        print(f'Updated {message.reference.message_id} to {ball_name} ({photo_hash}).')

    async def on_message(self, message):
        if message.author.id not in [999736048596816014, 665963480712740884]:
            return

        if message.content == 'A wild countryball appeared!':
            await self.ball_appeared(message)
            return

        if 'You caught' in message.content:
            # Will never happen because message.content is empty for some reason.
            print('caught')
            await self.what_ball(message)
            return

Expected Results

the if should return True and do the thingy

Actual Results

message.content is empty and thus not getting on the if

System Information

❯ python -m discord -v

Checklist

Additional Information

I was hoping you could fix it ASAP or give other libs that might work instead

Spordy commented 1 year ago

Im doing the same thing at it works fine for me, try updating to the development version using pip uninstall discord.py-self pip install git+https://github.com/dolfies/discord.py-self.git

Godwhitelight commented 1 year ago

Im doing the same thing at it works fine for me, try updating to the development version using pip uninstall discord.py-self pip install git+https://github.com/dolfies/discord.py-self.git

could i speak to u via discord? itsgodwhitelight

mallusrgreatv2 commented 1 year ago

This usually happens when a user does an interaction, whether that be use slash commands, click buttons, submit modals, etc. The bot has an option to defer the reaction. After deferring, the reaction can be followed up by a new message or edited for the next 15 minutes, as opposed to 3 seconds without deferring. When sent, the message content is an empty string. Later, an edit request is sent which changes the message. You should be listening to message edit events for this.

dolfies commented 1 year ago

The bot has an option to defer the reaction. After deferring, the reaction can be followed up by a new message or edited for the next 15 minutes, as opposed to 3 seconds without deferring. When sent, the message content is an empty string. Later, an edit request is sent which changes the message. You should be listening to message edit events for this.

This is correct.