|
1
|
|
|
# Copyright Pincer 2021-Present
|
|
|
|
|
|
|
2
|
|
|
# Full MIT License can be found in `LICENSE` at the project root.
|
|
3
|
|
|
|
|
4
|
|
|
from __future__ import annotations
|
|
5
|
|
|
|
|
6
|
|
|
from dataclasses import dataclass
|
|
7
|
|
|
from typing import Optional, List, TYPE_CHECKING
|
|
8
|
|
|
|
|
9
|
|
|
from ..user import User
|
|
10
|
|
|
from ...core.http import HTTPClient
|
|
11
|
|
|
from ...utils.api_object import APIObject
|
|
12
|
|
|
from ...utils.conversion import convert
|
|
13
|
|
|
from ...utils.snowflake import Snowflake
|
|
14
|
|
|
from ...utils.timestamp import Timestamp
|
|
|
|
|
|
|
15
|
|
|
from ...utils.types import MISSING
|
|
16
|
|
|
|
|
17
|
|
|
if TYPE_CHECKING:
|
|
18
|
|
|
from ... import Client
|
|
19
|
|
|
from ...utils.types import APINullable
|
|
20
|
|
|
|
|
21
|
|
|
|
|
22
|
|
|
@dataclass
|
|
|
|
|
|
|
23
|
|
|
class GuildMember(APIObject):
|
|
24
|
|
|
"""
|
|
25
|
|
|
Represents a member which resides in a guild/server.
|
|
26
|
|
|
|
|
27
|
|
|
:param _client:
|
|
28
|
|
|
reference to the Client
|
|
29
|
|
|
|
|
30
|
|
|
:param _http:
|
|
31
|
|
|
reference to the HTTPClient
|
|
32
|
|
|
|
|
33
|
|
|
:param deaf:
|
|
34
|
|
|
whether the user is deafened in voice channels
|
|
35
|
|
|
|
|
36
|
|
|
:param joined_at:
|
|
37
|
|
|
when the user joined the guild
|
|
38
|
|
|
|
|
39
|
|
|
:param mute:
|
|
40
|
|
|
whether the user is muted in voice channels
|
|
41
|
|
|
|
|
42
|
|
|
:param roles:
|
|
43
|
|
|
array of role object ids
|
|
44
|
|
|
|
|
45
|
|
|
:param nick:
|
|
46
|
|
|
this users guild nickname
|
|
47
|
|
|
|
|
48
|
|
|
:param pending:
|
|
49
|
|
|
whether the user has not yet passed the guild's Membership
|
|
50
|
|
|
Screening requirements
|
|
51
|
|
|
|
|
52
|
|
|
:param is_pending:
|
|
53
|
|
|
Deprecated version of pending.
|
|
54
|
|
|
|
|
55
|
|
|
:param permissions:
|
|
56
|
|
|
total permissions of the member in the channel,
|
|
57
|
|
|
including overwrites, returned when in the interaction object
|
|
58
|
|
|
|
|
59
|
|
|
:param premium_since:
|
|
60
|
|
|
when the user started boosting the guild
|
|
61
|
|
|
|
|
62
|
|
|
:param user:
|
|
63
|
|
|
the user this guild member represents
|
|
64
|
|
|
"""
|
|
65
|
|
|
|
|
66
|
|
|
_client: Client
|
|
67
|
|
|
_http: HTTPClient
|
|
68
|
|
|
|
|
69
|
|
|
deaf: bool
|
|
70
|
|
|
joined_at: Timestamp
|
|
71
|
|
|
mute: bool
|
|
72
|
|
|
roles: List[Snowflake]
|
|
73
|
|
|
|
|
74
|
|
|
hoisted_role: APINullable[Snowflake] = MISSING
|
|
75
|
|
|
nick: APINullable[Optional[str]] = MISSING
|
|
76
|
|
|
pending: APINullable[bool] = MISSING
|
|
77
|
|
|
is_pending: APINullable[bool] = MISSING
|
|
78
|
|
|
permissions: APINullable[str] = MISSING
|
|
79
|
|
|
premium_since: APINullable[Optional[Timestamp]] = MISSING
|
|
80
|
|
|
user: APINullable[User] = MISSING
|
|
81
|
|
|
avatar: APINullable[str] = MISSING
|
|
82
|
|
|
|
|
83
|
|
|
def __post_init__(self):
|
|
84
|
|
|
self.roles = convert(self.roles, Snowflake.from_string)
|
|
85
|
|
|
self.user = convert(self.user, User.from_dict, User, self._client)
|
|
86
|
|
|
self.premium_since = convert(
|
|
87
|
|
|
self.premium_since, Timestamp.parse, Timestamp
|
|
88
|
|
|
)
|
|
89
|
|
|
|
|
90
|
|
|
@classmethod
|
|
91
|
|
|
async def from_id(
|
|
|
|
|
|
|
92
|
|
|
cls,
|
|
93
|
|
|
client: Client,
|
|
94
|
|
|
guild_id: int,
|
|
95
|
|
|
_id: int
|
|
96
|
|
|
) -> GuildMember:
|
|
97
|
|
|
data = await client.http.get(f"guilds/{guild_id}/members/{_id}")
|
|
98
|
|
|
return cls.from_dict({**data, "_client": client, "_http": client.http})
|
|
99
|
|
|
|