Browse Source

Add Note.value alias

pull/10109/head
dolfies 3 years ago
parent
commit
7e1dda6695
  1. 25
      discord/user.py

25
discord/user.py

@ -93,6 +93,8 @@ class Note:
def note(self) -> Optional[str]: def note(self) -> Optional[str]:
"""Returns the note. """Returns the note.
There is an alias for this named :attr:`value`.
Raises Raises
------- -------
ClientException ClientException
@ -102,13 +104,22 @@ class Note:
raise ClientException('Note is not fetched') raise ClientException('Note is not fetched')
return self._note return self._note
@cached_slot_property('_user') @property
def user(self) -> _Snowflake: def value(self) -> Optional[str]:
""":class:`Snowflake`: Returns the :class:`User` the note belongs to. """Returns the note.
This is an alias of :attr:`note`.
If the user isn't in the cache, it returns a Raises
:class:`Object` instead. -------
ClientException
Attempted to access note without fetching it.
""" """
return self.note
@cached_slot_property('_user')
def user(self) -> _Snowflake:
""":class:`Snowflake`: Returns the :class:`User` or :class:`Object` the note belongs to."""
user_id = self._user_id user_id = self._user_id
user = self._state.get_user(user_id) user = self._state.get_user(user_id)
@ -177,8 +188,8 @@ class Note:
base = f'<Note user={self.user!r}' base = f'<Note user={self.user!r}'
note = self._note note = self._note
if note is not MISSING: if note is not MISSING:
note = note or '""' note = note or ''
base += f' note={note}' base += f' note={note!r}'
return base + '>' return base + '>'
def __len__(self) -> int: def __len__(self) -> int:

Loading…
Cancel
Save