|
@ -24,7 +24,7 @@ DEALINGS IN THE SOFTWARE. |
|
|
|
|
|
|
|
|
from __future__ import annotations |
|
|
from __future__ import annotations |
|
|
|
|
|
|
|
|
from typing import Any, Dict, List, Optional, Type, TypeVar, TYPE_CHECKING |
|
|
from typing import Any, Dict, List, Optional, Union, Type, TypeVar, TYPE_CHECKING |
|
|
|
|
|
|
|
|
import discord.abc |
|
|
import discord.abc |
|
|
from .asset import Asset |
|
|
from .asset import Asset |
|
@ -41,7 +41,10 @@ if TYPE_CHECKING: |
|
|
from .message import Message |
|
|
from .message import Message |
|
|
from .state import ConnectionState |
|
|
from .state import ConnectionState |
|
|
from .types.channel import DMChannel as DMChannelPayload |
|
|
from .types.channel import DMChannel as DMChannelPayload |
|
|
from .types.user import User as UserPayload |
|
|
from .types.user import ( |
|
|
|
|
|
PartialUser as PartialUserPayload, |
|
|
|
|
|
User as UserPayload, |
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
__all__ = ( |
|
|
__all__ = ( |
|
@ -83,7 +86,7 @@ class BaseUser(_UserTag): |
|
|
_accent_colour: Optional[int] |
|
|
_accent_colour: Optional[int] |
|
|
_public_flags: int |
|
|
_public_flags: int |
|
|
|
|
|
|
|
|
def __init__(self, *, state: ConnectionState, data: UserPayload) -> None: |
|
|
def __init__(self, *, state: ConnectionState, data: Union[UserPayload, PartialUserPayload]) -> None: |
|
|
self._state = state |
|
|
self._state = state |
|
|
self._update(data) |
|
|
self._update(data) |
|
|
|
|
|
|
|
@ -105,7 +108,7 @@ class BaseUser(_UserTag): |
|
|
def __hash__(self) -> int: |
|
|
def __hash__(self) -> int: |
|
|
return self.id >> 22 |
|
|
return self.id >> 22 |
|
|
|
|
|
|
|
|
def _update(self, data: UserPayload) -> None: |
|
|
def _update(self, data: Union[UserPayload, PartialUserPayload]) -> None: |
|
|
self.name = data['username'] |
|
|
self.name = data['username'] |
|
|
self.id = int(data['id']) |
|
|
self.id = int(data['id']) |
|
|
self.discriminator = data['discriminator'] |
|
|
self.discriminator = data['discriminator'] |
|
|