Browse Source

Add missing friend suggestion field

pull/10109/head
dolfies 2 years ago
parent
commit
6cf916b012
  1. 7
      discord/relationship.py
  2. 1
      discord/types/user.py

7
discord/relationship.py

@ -382,17 +382,20 @@ class FriendSuggestion(Hashable):
The suggested user. The suggested user.
reasons: List[:class:`FriendSuggestionReason`] reasons: List[:class:`FriendSuggestionReason`]
The reasons why the user was suggested. The reasons why the user was suggested.
from_user_contacts: :class:`bool`
Whether the suggested user had the current user in their contacts.
""" """
__slots__ = ('user', 'reasons', '_state') __slots__ = ('user', 'reasons', 'from_user_contacts', '_state')
def __init__(self, *, state: ConnectionState, data: FriendSuggestionPayload): def __init__(self, *, state: ConnectionState, data: FriendSuggestionPayload):
self._state = state self._state = state
self.user = state.store_user(data['suggested_user']) self.user = state.store_user(data['suggested_user'])
self.reasons = [FriendSuggestionReason(r) for r in data.get('reasons', [])] self.reasons = [FriendSuggestionReason(r) for r in data.get('reasons', [])]
self.from_user_contacts: bool = data.get('from_suggested_user_contacts', False)
def __repr__(self) -> str: def __repr__(self) -> str:
return f'<FriendSuggestion user={self.user!r} reasons={self.reasons!r}>' return f'<FriendSuggestion user={self.user!r} reasons={self.reasons!r} from_user_contacts={self.from_user_contacts!r}>'
async def accept(self) -> None: async def accept(self) -> None:
"""|coro| """|coro|

1
discord/types/user.py

@ -236,6 +236,7 @@ class FriendSuggestionReason(TypedDict):
class FriendSuggestion(TypedDict): class FriendSuggestion(TypedDict):
suggested_user: PartialUser suggested_user: PartialUser
reasons: List[FriendSuggestionReason] reasons: List[FriendSuggestionReason]
from_suggested_user_contacts: NotRequired[bool]
class Report(TypedDict): class Report(TypedDict):

Loading…
Cancel
Save