|
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 ...utils.api_object import APIObject |
|
|
|
|
|
|
11
|
|
|
from ...utils.snowflake import Snowflake |
|
12
|
|
|
from ...utils.timestamp import Timestamp |
|
|
|
|
|
|
13
|
|
|
from ...utils.types import MISSING |
|
14
|
|
|
|
|
15
|
|
|
if TYPE_CHECKING: |
|
16
|
|
|
from ... import Client |
|
17
|
|
|
from ...utils.types import APINullable |
|
18
|
|
|
|
|
19
|
|
|
|
|
20
|
|
|
@dataclass |
|
21
|
|
|
class BaseMember(APIObject): |
|
22
|
|
|
""" |
|
23
|
|
|
Represents the base of a guild member. |
|
24
|
|
|
|
|
25
|
|
|
:param deaf: |
|
26
|
|
|
whether the user is deafened in voice channels |
|
27
|
|
|
|
|
28
|
|
|
:param joined_at: |
|
29
|
|
|
when the user joined the guild |
|
30
|
|
|
|
|
31
|
|
|
:param mute: |
|
32
|
|
|
whether the user is muted in voice channels |
|
33
|
|
|
|
|
34
|
|
|
:param roles: |
|
35
|
|
|
array of role object ids |
|
36
|
|
|
|
|
37
|
|
|
:param hoisted_role: |
|
38
|
|
|
The user their top guild role! |
|
39
|
|
|
""" |
|
40
|
|
|
deaf: bool |
|
41
|
|
|
joined_at: Timestamp |
|
42
|
|
|
mute: bool |
|
43
|
|
|
roles: List[Snowflake] |
|
44
|
|
|
|
|
45
|
|
|
hoisted_role: APINullable[Snowflake] = MISSING |
|
46
|
|
|
|
|
47
|
|
|
|
|
48
|
|
|
@dataclass |
|
49
|
|
|
class PartialGuildMember(APIObject): |
|
50
|
|
|
""" |
|
51
|
|
|
Represents a partial guild member. |
|
52
|
|
|
This is a reference to a member from a guild which does not contain |
|
53
|
|
|
all information. |
|
54
|
|
|
|
|
55
|
|
|
This gets used in form example message mentions. |
|
56
|
|
|
|
|
57
|
|
|
:param id: |
|
58
|
|
|
the user's id |
|
59
|
|
|
|
|
60
|
|
|
:param username: |
|
61
|
|
|
the user's username, not unique across the platform |
|
62
|
|
|
|
|
63
|
|
|
:param discriminator: |
|
64
|
|
|
the user's 4-digit discord-tag |
|
65
|
|
|
|
|
66
|
|
|
:param avatar: |
|
67
|
|
|
the user's avatar hash |
|
68
|
|
|
|
|
69
|
|
|
:param public_flags: |
|
70
|
|
|
the flags on a user's account |
|
71
|
|
|
|
|
72
|
|
|
:param member: |
|
73
|
|
|
The user their (partial) guild information. |
|
74
|
|
|
""" |
|
75
|
|
|
id: Snowflake |
|
76
|
|
|
username: str |
|
77
|
|
|
discriminator: str |
|
78
|
|
|
avatar: str |
|
79
|
|
|
public_flags: int |
|
80
|
|
|
member: BaseMember |
|
81
|
|
|
|
|
82
|
|
|
|
|
83
|
|
|
@dataclass |
|
84
|
|
|
class GuildMember(BaseMember, APIObject): |
|
85
|
|
|
""" |
|
86
|
|
|
Represents a member which resides in a guild/server. |
|
87
|
|
|
|
|
88
|
|
|
:param _client: |
|
89
|
|
|
reference to the Client |
|
90
|
|
|
|
|
91
|
|
|
:param _http: |
|
92
|
|
|
reference to the HTTPClient |
|
93
|
|
|
|
|
94
|
|
|
:param nick: |
|
95
|
|
|
this users guild nickname |
|
96
|
|
|
|
|
97
|
|
|
:param pending: |
|
98
|
|
|
whether the user has not yet passed the guild's Membership |
|
99
|
|
|
Screening requirements |
|
100
|
|
|
|
|
101
|
|
|
:param is_pending: |
|
102
|
|
|
Deprecated version of pending. |
|
103
|
|
|
|
|
104
|
|
|
:param permissions: |
|
105
|
|
|
total permissions of the member in the channel, |
|
106
|
|
|
including overwrites, returned when in the interaction object |
|
107
|
|
|
|
|
108
|
|
|
:param premium_since: |
|
109
|
|
|
when the user started boosting the guild |
|
110
|
|
|
|
|
111
|
|
|
:param user: |
|
112
|
|
|
the user this guild member represents |
|
113
|
|
|
""" |
|
114
|
|
|
|
|
115
|
|
|
# _client: Client |
|
116
|
|
|
# _http: HTTPClient |
|
117
|
|
|
|
|
118
|
|
|
nick: APINullable[Optional[str]] = MISSING |
|
119
|
|
|
pending: APINullable[bool] = MISSING |
|
120
|
|
|
is_pending: APINullable[bool] = MISSING |
|
121
|
|
|
permissions: APINullable[str] = MISSING |
|
122
|
|
|
premium_since: APINullable[Optional[Timestamp]] = MISSING |
|
123
|
|
|
user: APINullable[User] = MISSING |
|
124
|
|
|
avatar: APINullable[str] = MISSING |
|
125
|
|
|
|
|
126
|
|
|
@classmethod |
|
127
|
|
|
async def from_id( |
|
|
|
|
|
|
128
|
|
|
cls, |
|
129
|
|
|
client: Client, |
|
130
|
|
|
guild_id: int, |
|
131
|
|
|
_id: int |
|
132
|
|
|
) -> GuildMember: |
|
133
|
|
|
data = await client.http.get(f"guilds/{guild_id}/members/{_id}") |
|
134
|
|
|
return cls.from_dict({**data, "_client": client, "_http": client.http}) |
|
135
|
|
|
|