Passed
Pull Request — main (#360)
by Yohann
01:48
created

GuildMemberUpdateEvent.__post_init__()   A

Complexity

Conditions 1

Size

Total Lines 3
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 3
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
nop 1
1
# Copyright Pincer 2021-Present
0 ignored issues
show
introduced by
Missing module docstring
Loading history...
2
# Full MIT License can be found in `LICENSE` at the project root.
3
from __future__ import annotations
4
5
from dataclasses import dataclass
6
from typing import TYPE_CHECKING
7
8
from ..guild.guild import Guild
9
from ..guild.member import GuildMember
10
from ..user import User
11
from ...utils.api_object import APIObject, GuildProperty
12
from ...utils.types import MISSING, APINullable
13
14
if TYPE_CHECKING:
15
    from typing import Any, List, Optional
16
17
    from ..guild.role import Role
18
    from ..message.emoji import Emoji
19
    from ..message.sticker import Sticker
20
    from ...utils.snowflake import Snowflake
21
    from ...utils.timestamp import Timestamp
22
    from .presence import PresenceUpdateEvent
23
24
25
@dataclass(repr=False)
26
class GuildBanAddEvent(APIObject, GuildProperty):
27
    """Sent when a user is banned from a guild.
28
29
    Attributes
30
    ----------
31
    guild_id: :class:`~pincer.utils.snowflake.Snowflake`
32
        Id of the guild
33
    user: :class:`~pincer.objects.user.user.User`
34
        The banned user
35
    """
36
37
    guild_id: Snowflake
38
    user: User
39
40
41
@dataclass(repr=False)
42
class GuildBanRemoveEvent(APIObject, GuildProperty):
43
    """Sent when a user is unbanned from a guild.
44
45
    Attributes
46
    ----------
47
    guild_id: :class:`~pincer.utils.snowflake.Snowflake`
48
        Id of the guild
49
    user: :class:`~pincer.objects.user.user.User`
50
        The unbanned user
51
    """
52
53
    guild_id: Snowflake
54
    user: User
55
56
57
@dataclass(repr=False)
58
class GuildEmojisUpdateEvent(APIObject, GuildProperty):
59
    """Sent when a guild's emojis have been updated.
60
61
    Attributes
62
    ----------
63
    guild_id: :class:`~pincer.utils.snowflake.Snowflake`
64
        Id of the guild
65
    emojis: List[:class:`~pincer.objects.message.emoji.Emoji`]
66
        Array of emojis
67
    """
68
69
    guild_id: Snowflake
70
    emojis: List[Emoji]
71
72
73
@dataclass(repr=False)
74
class GuildStickersUpdateEvent(APIObject, GuildProperty):
75
    """Sent when a guild's stickers have been updated.
76
77
    Attributes
78
    ----------
79
    guild_id: :class:`~pincer.utils.snowflake.Snowflake`
80
        Id of the guild
81
    stickers: List[:class:`~pincer.objects.message.sticker.Sticker`]
82
        Array of stickers
83
    """
84
85
    guild_id: Snowflake
86
    stickers: List[Sticker]
87
88
89
@dataclass(repr=False)
90
class GuildIntegrationsUpdateEvent(APIObject, GuildProperty):
91
    """Sent when a guild integration is updated.
92
93
    Attributes
94
    ----------
95
    guild_id: :class:`~pincer.utils.snowflake.Snowflake`
96
        Id of the guild whose integrations were updated
97
    """
98
99
    guild_id: Snowflake
100
101
102
@dataclass(repr=False)
103
class GuildMemberAddEvent(GuildMember, GuildProperty):
104
    """
105
    Sent when a user joins a guild.
106
107
    Attributes
108
    ----------
109
    guild_id: :class:`Snowflake`
110
        ID of the guild that the user joined.
111
    """
112
113
    # NOTE: This isn't a default value. I set it to this because you can't
114
    # have fields without default values after regular fields. Apparently that
115
    # carries over when you inherit from a dataclass.
116
    guild_id: Snowflake = 0
117
118
119
@dataclass(repr=False)
120
class GuildMemberRemoveEvent(APIObject, GuildProperty):
121
    """Sent when a user is removed from a guild (leave/kick/ban).
122
123
    Attributes
124
    ----------
125
    guild_id: :class:`~pincer.utils.snowflake.Snowflake`
126
        the id of the guild
127
    user: :class:`~pincer.objects.user.user.User`
128
        the user who was removed
129
    """
130
131
    guild_id: Snowflake
132
    user: User
133
134
135
@dataclass(repr=False)
136
class GuildMemberUpdateEvent(APIObject, GuildProperty):
0 ignored issues
show
best-practice introduced by
Too many instance attributes (9/7)
Loading history...
137
    """Sent when a guild member is updated.
138
    This will also fire when the user object
139
    of a guild member changes.
140
141
    Attributes
142
    ----------
143
    guild_id: :class:`~pincer.utils.snowflake.Snowflake`
144
        the id of the guild
145
    roles: List[:class:`~pincer.utils.snowflake.Snowflake`]
146
        user role ids
147
    user: :class:`~pincer.objects.user.user.User`
148
        the user
149
    nick: APINullable[Optional[:class:`str`]]
150
        nickname of the user in the guild
151
    joined_at: Optional[:class:`~pincer.utils.timestamp.Timestamp`]
152
        when the user joined the guild
153
    premium_since: APINullable[Optional[:class:`~pincer.utils.timestamp.Timestamp`]]
154
        when the user started boosting the guild
155
    deaf: APINullable[:class:`bool`]
156
        whether the user is deafened in voice channels
157
    mute: APINullable[:class:`bool`]
158
        whether the user is muted in voice channels
159
    pending: APINullable[:class:`bool`]
160
        whether the user has not yet passed the guild's
161
        Membership Screening requirements
162
    """
163
    # noqa: E501
164
165
    guild_id: Snowflake
166
    roles: List[Snowflake]
167
    user: User
168
    nick: APINullable[Optional[str]] = MISSING
169
    joined_at: Optional[Timestamp] = None
170
    premium_since: APINullable[Optional[Timestamp]] = MISSING
171
    deaf: APINullable[bool] = MISSING
172
    mute: APINullable[bool] = MISSING
173
    pending: APINullable[bool] = MISSING
174
175
176
@dataclass(repr=False)
177
class GuildMembersChunkEvent(APIObject, GuildProperty):
178
    """Sent in response to Guild Request Members.
179
    You can use the ``chunk_index`` and ``chunk_count``
180
    to calculate how many chunks are left for your request.
181
182
    Attributes
183
    ----------
184
    guild_id: :class:`~pincer.utils.snowflake.Snowflake`
185
        The id of the guild
186
    members: List[:class:`~pincer.objects.guild.member.GuildMember`]
187
        Set of guild members
188
    chunk_index: :class:`int`
189
        The chunk index in the expected chunks for this response
190
        (0 <= chunk_index < chunk_count)
191
    chunk_count: :class:`int`
192
        The total number of expected chunks for this response
193
    not_found: APINullable[List[Any]]
194
        If passing an invalid id to ``REQUEST_GUILD_MEMBERS``,
195
        it will be returned here
196
    presences: APINullable[:class:`~pincer.objects.events.presence.PresenceUpdateEvent`]
197
        If passing true to ``REQUEST_GUILD_MEMBERS``, presences
198
        of the returned members will be here
199
    nonce: APINullable[:class:`str`]
200
        The nonce used in the Guild Members Request
201
    """
202
    # noqa: E501
203
    guild_id: Snowflake
204
    members: List[GuildMember]
205
    chunk_index: int
206
    chunk_count: int
207
208
    not_found: APINullable[List[Any]] = MISSING
209
    presences: APINullable[PresenceUpdateEvent] = MISSING
210
    nonce: APINullable[str] = MISSING
211
212
213
@dataclass(repr=False)
214
class GuildRoleCreateEvent(APIObject, GuildProperty):
215
    """Sent when a guild role is created.
216
217
    Attributes
218
    ----------
219
    guild_id: :class:`~pincer.utils.snowflake.Snowflake`
220
        The id of the guild
221
    role: :class:`~pincer.objects.guild.role.Role`
222
        The role created
223
    """
224
225
    guild_id: Snowflake
226
    role: Role
227
228
229
@dataclass(repr=False)
230
class GuildRoleUpdateEvent(APIObject, GuildProperty):
231
    """Sent when a guild role is updated.
232
233
    Attributes
234
    ----------
235
    guild_id: :class:`~pincer.utils.snowflake.Snowflake`
236
        The id of the guild
237
    role: :class:`~pincer.objects.guild.role.Role`
238
        The role updated
239
    """
240
241
    guild_id: Snowflake
242
    role: Role
243
244
245
@dataclass(repr=False)
246
class GuildRoleDeleteEvent(APIObject, GuildProperty):
247
    """Sent when a guild role is deleted.
248
249
    Attributes
250
    ----------
251
    guild_id: :class:`~pincer.utils.snowflake.Snowflake`
252
        Id of the guild
253
    role_id: :class:`~pincer.utils.snowflake.Snowflake`
254
        Id of the role
255
    """
256
257
    guild_id: Snowflake
258
    role_id: Snowflake
259
260
261
@dataclass(repr=False)
262
class GuildStatusEvent(APIObject):
263
    """
264
    Sent when a subscribed server's state changes
265
266
    Attributes
267
    ----------
268
    guild : :class:`Guild`
269
        guild with requested id
270
271
    online : :class:`int`
272
        number of online users in guild (deprecated; always 0)
273
    """
274
275
    guild: Guild
276
    online: int = 0
277