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 message_pin, message_unpin target id being None #10061

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

iyad-f
Copy link
Contributor

@iyad-f iyad-f commented Dec 29, 2024

Summary

This PR adds a check to AuditLogEntry._convert_target_message for handling None target_id.

Checklist

  • If code changes were made then they have been tested.
    • I have updated the documentation to reflect the changes.
  • 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, ...)

discord/audit_logs.py Outdated Show resolved Hide resolved
discord/audit_logs.py Outdated Show resolved Hide resolved
iyad-f and others added 2 commits December 29, 2024 23:27
@Error44s
Copy link

I took a look at it and changed it for me, I don't know if that could go through as a possible fix.

5c7faa1

@iyad-f
Copy link
Contributor Author

iyad-f commented Dec 29, 2024

if target_id is None we just return None just like AuditLogAction._convert_target_user

@Error44s
Copy link

In this case it is then one of the two or simply copy the one from AuditLogAction._convert_target_user ig.

def _convert_target_message(self, target_id: Optional[int]) -> Union[Member, User, Object, None]:
    if target_id is None:
        return None  # Explicitly handle None
    return self._get_member(target_id) or Object(id=target_id, type=Member)

or

def _convert_target_message(self, target_id: Optional[int]) -> Union[Member, User, Object, None]:
    return None if target_id is None else self._get_member(target_id) or Object(id=target_id, type=Member)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants