1
|
|
|
# Copyright Pincer 2021-Present |
|
|
|
|
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): |
|
|
|
|
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
|
|
|
|
164
|
|
|
# noqa: E501 |
165
|
|
|
|
166
|
|
|
guild_id: Snowflake |
167
|
|
|
roles: List[Snowflake] |
168
|
|
|
user: User |
169
|
|
|
nick: APINullable[Optional[str]] = MISSING |
170
|
|
|
joined_at: Optional[Timestamp] = None |
171
|
|
|
premium_since: APINullable[Optional[Timestamp]] = MISSING |
172
|
|
|
deaf: APINullable[bool] = MISSING |
173
|
|
|
mute: APINullable[bool] = MISSING |
174
|
|
|
pending: APINullable[bool] = MISSING |
175
|
|
|
|
176
|
|
|
|
177
|
|
|
@dataclass(repr=False) |
178
|
|
|
class GuildMembersChunkEvent(APIObject, GuildProperty): |
179
|
|
|
"""Sent in response to Guild Request Members. |
180
|
|
|
You can use the ``chunk_index`` and ``chunk_count`` |
181
|
|
|
to calculate how many chunks are left for your request. |
182
|
|
|
|
183
|
|
|
Attributes |
184
|
|
|
---------- |
185
|
|
|
guild_id: :class:`~pincer.utils.snowflake.Snowflake` |
186
|
|
|
The id of the guild |
187
|
|
|
members: List[:class:`~pincer.objects.guild.member.GuildMember`] |
188
|
|
|
Set of guild members |
189
|
|
|
chunk_index: :class:`int` |
190
|
|
|
The chunk index in the expected chunks for this response |
191
|
|
|
(0 <= chunk_index < chunk_count) |
192
|
|
|
chunk_count: :class:`int` |
193
|
|
|
The total number of expected chunks for this response |
194
|
|
|
not_found: APINullable[List[Any]] |
195
|
|
|
If passing an invalid id to ``REQUEST_GUILD_MEMBERS``, |
196
|
|
|
it will be returned here |
197
|
|
|
presences: APINullable[:class:`~pincer.objects.events.presence.PresenceUpdateEvent`] |
198
|
|
|
If passing true to ``REQUEST_GUILD_MEMBERS``, presences |
199
|
|
|
of the returned members will be here |
200
|
|
|
nonce: APINullable[:class:`str`] |
201
|
|
|
The nonce used in the Guild Members Request |
202
|
|
|
""" |
203
|
|
|
|
204
|
|
|
# noqa: E501 |
205
|
|
|
guild_id: Snowflake |
206
|
|
|
members: List[GuildMember] |
207
|
|
|
chunk_index: int |
208
|
|
|
chunk_count: int |
209
|
|
|
|
210
|
|
|
not_found: APINullable[List[Any]] = MISSING |
211
|
|
|
presences: APINullable[PresenceUpdateEvent] = MISSING |
212
|
|
|
nonce: APINullable[str] = MISSING |
213
|
|
|
|
214
|
|
|
|
215
|
|
|
@dataclass(repr=False) |
216
|
|
|
class GuildRoleCreateEvent(APIObject, GuildProperty): |
217
|
|
|
"""Sent when a guild role is created. |
218
|
|
|
|
219
|
|
|
Attributes |
220
|
|
|
---------- |
221
|
|
|
guild_id: :class:`~pincer.utils.snowflake.Snowflake` |
222
|
|
|
The id of the guild |
223
|
|
|
role: :class:`~pincer.objects.guild.role.Role` |
224
|
|
|
The role created |
225
|
|
|
""" |
226
|
|
|
|
227
|
|
|
guild_id: Snowflake |
228
|
|
|
role: Role |
229
|
|
|
|
230
|
|
|
|
231
|
|
|
@dataclass(repr=False) |
232
|
|
|
class GuildRoleUpdateEvent(APIObject, GuildProperty): |
233
|
|
|
"""Sent when a guild role is updated. |
234
|
|
|
|
235
|
|
|
Attributes |
236
|
|
|
---------- |
237
|
|
|
guild_id: :class:`~pincer.utils.snowflake.Snowflake` |
238
|
|
|
The id of the guild |
239
|
|
|
role: :class:`~pincer.objects.guild.role.Role` |
240
|
|
|
The role updated |
241
|
|
|
""" |
242
|
|
|
|
243
|
|
|
guild_id: Snowflake |
244
|
|
|
role: Role |
245
|
|
|
|
246
|
|
|
|
247
|
|
|
@dataclass(repr=False) |
248
|
|
|
class GuildRoleDeleteEvent(APIObject, GuildProperty): |
249
|
|
|
"""Sent when a guild role is deleted. |
250
|
|
|
|
251
|
|
|
Attributes |
252
|
|
|
---------- |
253
|
|
|
guild_id: :class:`~pincer.utils.snowflake.Snowflake` |
254
|
|
|
Id of the guild |
255
|
|
|
role_id: :class:`~pincer.utils.snowflake.Snowflake` |
256
|
|
|
Id of the role |
257
|
|
|
""" |
258
|
|
|
|
259
|
|
|
guild_id: Snowflake |
260
|
|
|
role_id: Snowflake |
261
|
|
|
|
262
|
|
|
|
263
|
|
|
@dataclass(repr=False) |
264
|
|
|
class GuildStatusEvent(APIObject): |
265
|
|
|
""" |
266
|
|
|
Sent when a subscribed server's state changes |
267
|
|
|
|
268
|
|
|
Attributes |
269
|
|
|
---------- |
270
|
|
|
guild : :class:`Guild` |
271
|
|
|
guild with requested id |
272
|
|
|
|
273
|
|
|
online : :class:`int` |
274
|
|
|
number of online users in guild (deprecated; always 0) |
275
|
|
|
""" |
276
|
|
|
|
277
|
|
|
guild: Guild |
278
|
|
|
online: int = 0 |
279
|
|
|
|