diff --git a/discord/enums.py b/discord/enums.py index aaaf94e65..647297d12 100644 --- a/discord/enums.py +++ b/discord/enums.py @@ -69,6 +69,7 @@ __all__ = ( 'ApplicationCommandOptionType', 'AppCommandOptionType', 'RelationshipType', + 'FriendSuggestionReasonType', 'HypeSquadHouse', 'PremiumType', 'UserContentFilter', @@ -445,6 +446,10 @@ class RelationshipType(Enum): suggestion = 6 # Unused +class FriendSuggestionReasonType(Enum): + external_friend = 1 + + class NotificationLevel(Enum, comparable=True): all_messages = 0 all = 0 diff --git a/discord/relationship.py b/discord/relationship.py index ffee73230..feac88034 100644 --- a/discord/relationship.py +++ b/discord/relationship.py @@ -26,7 +26,7 @@ from __future__ import annotations from typing import TYPE_CHECKING, Optional, Tuple, Union -from .enums import ConnectionType, RelationshipAction, RelationshipType, Status, try_enum +from .enums import ConnectionType, FriendSuggestionReasonType, RelationshipAction, RelationshipType, Status, try_enum from .mixins import Hashable from .object import Object from .utils import MISSING, parse_time @@ -336,20 +336,22 @@ class FriendSuggestionReason: Attributes ----------- + type: :class:`FriendSuggestionReasonType` + The type of friend suggestion reason. platform: :class:`ConnectionType` The platform the user was suggested from. - name: Optional[:class:`str`] + name: :class:`str` The user's name on the platform. """ __slots__ = ('type', 'platform', 'name') def __init__(self, data: FriendSuggestionReasonPayload): - # This entire model is mostly unused by any client, so I have no idea what the type is + # This entire model is mostly unused by any client, so I can't be sure on types # Also because of this, I'm treating everything as optional just in case - self.type: int = data.get('type', 0) + self.type: FriendSuggestionReasonType = try_enum(FriendSuggestionReasonType, data.get('type', 0)) self.platform: ConnectionType = try_enum(ConnectionType, data.get('platform')) - self.name: Optional[str] = data.get('name') + self.name: str = data.get('name') or '' def __repr__(self) -> str: return f'' diff --git a/discord/types/user.py b/discord/types/user.py index c491713fe..ebcde3043 100644 --- a/discord/types/user.py +++ b/discord/types/user.py @@ -160,9 +160,9 @@ class Note(TypedDict): class FriendSuggestionReason(TypedDict): - name: Optional[str] + name: str platform_type: ConnectionType - type: int + type: Literal[1] class FriendSuggestion(TypedDict): diff --git a/docs/api.rst b/docs/api.rst index 209fca733..1556bdb3b 100644 --- a/docs/api.rst +++ b/docs/api.rst @@ -3787,6 +3787,16 @@ of :class:`enum.Enum`. .. versionadded:: 2.0 +.. class:: FriendSuggestionReasonType + + Specifies the type of :class:`FriendSuggestionReason`. + + .. versionadded:: 2.1 + + .. attribute:: external_friend + + You are friends with this user on another platform. + .. class:: UserContentFilter Represents the options found in ``Settings > Privacy & Safety > Safe Direct Messaging``