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

Fix incorrect activities and permissions on Interaction and Option objects #1365

Merged
merged 11 commits into from
Jun 10, 2022

Conversation

baronkobama
Copy link
Contributor

@baronkobama baronkobama commented May 17, 2022

Summary

This PR fixes an issue in the Interaction object wherein activities and status were being represented incorrectly. Atop of this, Option objects also no longer return invalid activities and statuses on discord.Member. Option objects also now return correct permissions for discord.GuildChannel classes. Also fixes an issue wherein roles updates were not being reflected properly.

Current TODO:

  • Obtain correct activities/statues in Interaction objects.
  • Obtain correct activities/statues in Option objects.
  • Obtain correct channel permissions in Option objects.

PR is open for contributions.

Closes #891, closes #1194, closes #1278, closes #1283, closes #1312

Checklist

  • If code changes were made then they have been tested.
    • I have updated the documentation to reflect the changes.
  • If type: ignore comments were used, a comment is also left explaining why
  • This PR fixes an issue.
  • This PR adds something new (e.g. new method or parameters).
  • This PR is a breaking change (e.g. methods or parameters removed/renamed)
  • This PR is not a code change (e.g. documentation, README, typehinting, examples, ...)

Notes

There is a minor fix to the docs of the InteractionResponse.send_message() method in this PR. I figured it was likely not worth a separate PR so it was placed here.

@plun1331
Copy link
Member

Bob didn't do this because the cache could be outdated, and thus return an outdated member object. Perhaps we could consider caching the member when an interaction is received?

@plun1331 plun1331 added bug Something isn't working priority: high High Priority status: in progress Work in Progess labels May 17, 2022
@baronkobama
Copy link
Contributor Author

Perhaps we could consider caching the member when an interaction is received?

Considering that the data that is received in the interaction from Discord is lacking in information, mainly activities/statues/permissions, how would we go about caching only the fields that are valid? Potentially a new method in member like _interaction_update(data: Member) that updates only fields that are known to be valid from Discord's sent interaction?

@plun1331
Copy link
Member

Perhaps we could consider caching the member when an interaction is received?

Considering that the data that is received in the interaction from Discord is lacking in information, mainly activities/statues/permissions, how would we go about caching only the fields that are valid? Potentially a new method in member like _interaction_update(data: Member) that updates only fields that are known to be valid from Discord's sent interaction?

I believe the normal Member._update method could be used as it doesn't update presence data.

@baronkobama baronkobama marked this pull request as ready for review May 18, 2022 03:23
@baronkobama baronkobama changed the title [WIP] Fix incorrect activities and permissions on Interaction and Option objects Fix incorrect activities and permissions on Interaction and Option objects May 18, 2022
@plun1331 plun1331 added status: awaiting review Awaiting review from a maintainer and removed status: in progress Work in Progess labels May 18, 2022
discord/commands/core.py Show resolved Hide resolved
discord/guild.py Outdated Show resolved Hide resolved
@Lulalaby Lulalaby enabled auto-merge (squash) May 19, 2022 08:44
@Dorukyum
Copy link
Member

Need to make sure that this has been extensively tested.

@Lulalaby Lulalaby disabled auto-merge May 19, 2022 20:29
@baronkobama
Copy link
Contributor Author

I have been testing this code on my personal bot for a while now, and I haven't run into any issues yet. If anyone wants to test their bots on this branch that'd be nice as I don't have a public bot to test on right now. Otherwise, I think this PR is ready to be merged.

Copy link
Member

@plun1331 plun1331 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other than things I commented on, looks good

discord/flags.py Outdated Show resolved Hide resolved
discord/guild.py Outdated Show resolved Hide resolved
amachn and others added 3 commits June 2, 2022 14:07
Co-authored-by: plun1331 <49261529+plun1331@users.noreply.github.com>
@Lulalaby Lulalaby enabled auto-merge (squash) June 4, 2022 22:27
@plun1331 plun1331 requested a review from krittick June 6, 2022 21:00
@Lulalaby Lulalaby requested a review from BobDotCom June 9, 2022 23:40
Copy link
Member

@Dorukyum Dorukyum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thank you

@Lulalaby Lulalaby merged commit 783404f into Pycord-Development:master Jun 10, 2022
Lulalaby added a commit that referenced this pull request Jun 11, 2022
…` objects (#1365)

* Update interactions.py

* Cache members on interaction/option

* Update core.py

* Implement channel cache updating in Options

* Implement new flags for member caching

* Update guild.py

Co-authored-by: plun1331 <49261529+plun1331@users.noreply.github.com>

* Remove MemberCacheFlags.option

Co-authored-by: Lala Sabathil <lala@pycord.dev>
Co-authored-by: plun1331 <49261529+plun1331@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working priority: high High Priority status: awaiting review Awaiting review from a maintainer
Projects
Status: No status
5 participants