|
1
|
|
|
# -*- coding: utf-8 -*- |
|
|
|
|
|
|
2
|
|
|
# MIT License |
|
3
|
|
|
# |
|
4
|
|
|
# Copyright (c) 2021 Pincer |
|
5
|
|
|
# |
|
6
|
|
|
# Permission is hereby granted, free of charge, to any person obtaining |
|
7
|
|
|
# a copy of this software and associated documentation files |
|
8
|
|
|
# (the "Software"), to deal in the Software without restriction, |
|
9
|
|
|
# including without limitation the rights to use, copy, modify, merge, |
|
10
|
|
|
# publish, distribute, sublicense, and/or sell copies of the Software, |
|
11
|
|
|
# and to permit persons to whom the Software is furnished to do so, |
|
12
|
|
|
# subject to the following conditions: |
|
13
|
|
|
# |
|
14
|
|
|
# The above copyright notice and this permission notice shall be |
|
15
|
|
|
# included in all copies or substantial portions of the Software. |
|
16
|
|
|
# |
|
17
|
|
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
|
18
|
|
|
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
|
19
|
|
|
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
|
20
|
|
|
# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY |
|
21
|
|
|
# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, |
|
22
|
|
|
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE |
|
23
|
|
|
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
|
24
|
|
|
from __future__ import annotations |
|
25
|
|
|
|
|
26
|
|
|
from dataclasses import dataclass |
|
27
|
|
|
from typing import Optional, List |
|
28
|
|
|
|
|
29
|
|
|
from ..objects.user import User |
|
30
|
|
|
from ..utils import APIObject, APINullable, MISSING, Snowflake, Timestamp, \ |
|
31
|
|
|
convert |
|
32
|
|
|
|
|
33
|
|
|
|
|
34
|
|
|
@dataclass |
|
|
|
|
|
|
35
|
|
|
class GuildMember(APIObject): |
|
36
|
|
|
""" |
|
37
|
|
|
Represents a member which resides in a guild/server. |
|
38
|
|
|
|
|
39
|
|
|
:param deaf: |
|
40
|
|
|
whether the user is deafened in voice channels |
|
41
|
|
|
|
|
42
|
|
|
:param joined_at: |
|
43
|
|
|
when the user joined the guild |
|
44
|
|
|
|
|
45
|
|
|
:param mute: |
|
46
|
|
|
whether the user is muted in voice channels |
|
47
|
|
|
|
|
48
|
|
|
:param roles: |
|
49
|
|
|
array of role object ids |
|
50
|
|
|
|
|
51
|
|
|
:param nick: |
|
52
|
|
|
this users guild nickname |
|
53
|
|
|
|
|
54
|
|
|
:param pending: |
|
55
|
|
|
whether the user has not yet passed the guild's Membership Screening |
|
56
|
|
|
requirements |
|
57
|
|
|
|
|
58
|
|
|
:param is_pending: |
|
59
|
|
|
Deprecated version of pending. |
|
60
|
|
|
|
|
61
|
|
|
:param permissions: |
|
62
|
|
|
total permissions of the member in the channel, including overwrites, |
|
63
|
|
|
returned when in the interaction object |
|
64
|
|
|
|
|
65
|
|
|
:param premium_since: |
|
66
|
|
|
when the user started boosting the guild |
|
67
|
|
|
|
|
68
|
|
|
:param user: |
|
69
|
|
|
the user this guild member represents |
|
70
|
|
|
""" |
|
71
|
|
|
|
|
72
|
|
|
deaf: bool |
|
73
|
|
|
joined_at: Timestamp |
|
74
|
|
|
mute: bool |
|
75
|
|
|
roles: List[Snowflake] |
|
76
|
|
|
|
|
77
|
|
|
nick: APINullable[Optional[str]] = MISSING |
|
78
|
|
|
pending: APINullable[bool] = MISSING |
|
79
|
|
|
is_pending: APINullable[bool] = MISSING |
|
80
|
|
|
permissions: APINullable[str] = MISSING |
|
81
|
|
|
premium_since: APINullable[Optional[Timestamp]] = MISSING |
|
82
|
|
|
user: APINullable[User] = MISSING |
|
83
|
|
|
avatar: APINullable[str] = MISSING |
|
84
|
|
|
|
|
85
|
|
|
def __post_init__(self): |
|
86
|
|
|
self.roles = convert(self.roles, Snowflake.from_string) |
|
87
|
|
|
self.premium_since = convert(self.premium_since, Timestamp.parse, |
|
88
|
|
|
Timestamp) |
|
89
|
|
|
self.user = convert(self.user, User.from_dict, User) |
|
90
|
|
|
|