Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

before and after Member objects have same values #6020

Closed
4 tasks done
Tawmy opened this issue Nov 7, 2020 · 1 comment
Closed
4 tasks done

before and after Member objects have same values #6020

Tawmy opened this issue Nov 7, 2020 · 1 comment
Labels
question This is a question about the library

Comments

@Tawmy
Copy link

Tawmy commented Nov 7, 2020

Summary

Certain events trigger both on_user_update and on_member_update. I have tested this with avatar and username changes.

While I can see the old and new username/avatar in the on_user_update event as expected, both the before and after object only have the new values in the on_member_update event. The URL for the avatar is the same, new one in both, and the username is also the new one in both. If this is intended and only the on_user_update event is supposed to have the correct information in both objects, on_member_update should probably not be triggering.

Reproduction Steps

Implemented the events using:

@commands.Cog.listener()
    async def on_member_update(self, before: Member, after: Member):

@commands.Cog.listener()
    async def on_user_update(self, before: User, after: User):

Bot and user were part of the same guild. Changed username and avatar in separate instances and each time, the described issue happened.

Expected Results

Both events trigger on username and avatar changes, so I expect the before and after objects in both events to actually reflect the state before and after the event.

Actual Results

The before object in on_member_update has the information from after the event, equal to the information from the after object. The information is correct in both objects in the on_user_update event.

Intents

discord.Intents.all()

Checklist

  • I have searched the open issues for duplicates.
  • I have shown the entire traceback, if possible.
  • I have removed my token from display, if visible.
  • I have provided the intents that my bot is using.

System Information

@Tawmy Tawmy added the bug This is a bug with the library. label Nov 7, 2020
@Rapptz Rapptz added question This is a question about the library and removed bug This is a bug with the library. labels Nov 8, 2020
@Rapptz
Copy link
Owner

Rapptz commented Nov 8, 2020

That's because members share the same global user cache instance in order to save on memory. This is the reason the on_user_update event exists, since it allows the library to call it during the first time it detects this change.

@Rapptz Rapptz closed this as completed Nov 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question This is a question about the library
Projects
None yet
Development

No branches or pull requests

2 participants