dolfies / discord.py-self

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

[BUG] "message.author" and "message.author.avatar_url" not working correctly #65

Closed L-o-s-t closed 3 years ago

L-o-s-t commented 3 years ago

Summary

When other users are triggering commands/events using "message.author" and "message.author.avatar_url" it returns as "None"

Reproduction Steps

1. Get a different user to send the command that uses "message.author". In my case the command used was ">test"

Code

Relevant code that shows the bug.
class MyClient(discord.Client):
    async def on_ready(self):
        print('Logged on as', self.user)

    async def on_message(self, message):
        if message.content.startswith(">test"):
            await message.channel.send(message.author.avatar_url)

Expected Results

It's supposed to return the correct author tag, and avatar url

Actual Results

It's sending "none"

System Info

Run python -m discord --version and paste the information below.
- Python v3.9.6-final
- discord.py v1.8.1-final
- aiohttp v3.7.4.post0
- system info: Windows 10 10.0.19042

Checklist

Let's make sure this issue is valid!
caiocinel commented 3 years ago

https://github.com/dolfies/discord.py-self/blob/e62a56d2f06d95db15f962507fae410b482aa3ec/discord/client.py#L869

According to the documentation and example codes, the on_message event requires only the "message" parameter, so everything will work normally.

image

This example uses Development branch, but also works in 1.8.1

L-o-s-t commented 3 years ago

https://github.com/dolfies/discord.py-self/blob/e62a56d2f06d95db15f962507fae410b482aa3ec/discord/client.py#L869

According to the documentation and example codes, the on_message event requires only the "message" parameter, so everything will work normally.

image

This example uses Development branch, but also works in 1.8.1

Even so, other users using commands that includes "message.author" are greeted with "None#0"

Result: Screenshot_13

Code:

from discord.ext import commands

client = commands.Bot(command_prefix=">", self_bot=False)

@client.event
async def on_message(message):
    if message.content.startswith('$greet'):
        channel = message.channel
        await channel.send('Say hello!')

        def check(m):
            return m.content == 'hello' and m.channel == channel

        msg = await client.wait_for('message', check=check)
        await channel.send(f'Hello {msg.author}!')

client.run('token')
caiocinel commented 3 years ago

I recommend you to use breakpoints to get more details of this type of problem, as you can see in the image I sent you, to get the user's nick it's necessary to use message.author.display_name, and ID with message.author.discriminator

dolfies commented 3 years ago

This is a problem related to LazyUsers, which are going to be removed in the next version. The beta is in the development branch.