-
-
Notifications
You must be signed in to change notification settings - Fork 112
/
common.ts
344 lines (336 loc) · 8.49 KB
/
common.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
import type { LocaleString } from '../rest/common';
/**
* https://discord.com/developers/docs/topics/permissions#permissions-bitwise-permission-flags
*
* These flags are exported as `BigInt`s and NOT numbers. Wrapping them in `Number()`
* may cause issues, try to use BigInts as much as possible or modules that can
* replicate them in some way
*/
export const PermissionFlagsBits = {
/**
* Allows creation of instant invites
*
* Applies to channel types: Text, Voice, Stage
*/
CreateInstantInvite: 1n << 0n,
/**
* Allows kicking members
*/
// eslint-disable-next-line sonarjs/no-identical-expressions
KickMembers: 1n << 1n,
/**
* Allows banning members
*/
BanMembers: 1n << 2n,
/**
* Allows all permissions and bypasses channel permission overwrites
*/
Administrator: 1n << 3n,
/**
* Allows management and editing of channels
*
* Applies to channel types: Text, Voice, Stage
*/
ManageChannels: 1n << 4n,
/**
* Allows management and editing of the guild
*/
ManageGuild: 1n << 5n,
/**
* Allows for the addition of reactions to messages
*
* Applies to channel types: Text, Voice, Stage
*/
AddReactions: 1n << 6n,
/**
* Allows for viewing of audit logs
*/
ViewAuditLog: 1n << 7n,
/**
* Allows for using priority speaker in a voice channel
*
* Applies to channel types: Voice
*/
PrioritySpeaker: 1n << 8n,
/**
* Allows the user to go live
*
* Applies to channel types: Voice, Stage
*/
Stream: 1n << 9n,
/**
* Allows guild members to view a channel, which includes reading messages in text channels and joining voice channels
*
* Applies to channel types: Text, Voice, Stage
*/
ViewChannel: 1n << 10n,
/**
* Allows for sending messages in a channel and creating threads in a forum
* (does not allow sending messages in threads)
*
* Applies to channel types: Text, Voice, Stage
*/
SendMessages: 1n << 11n,
/**
* Allows for sending of `/tts` messages
*
* Applies to channel types: Text, Voice, Stage
*/
SendTTSMessages: 1n << 12n,
/**
* Allows for deletion of other users messages
*
* Applies to channel types: Text, Voice, Stage
*/
ManageMessages: 1n << 13n,
/**
* Links sent by users with this permission will be auto-embedded
*
* Applies to channel types: Text, Voice, Stage
*/
EmbedLinks: 1n << 14n,
/**
* Allows for uploading images and files
*
* Applies to channel types: Text, Voice, Stage
*/
AttachFiles: 1n << 15n,
/**
* Allows for reading of message history
*
* Applies to channel types: Text, Voice, Stage
*/
ReadMessageHistory: 1n << 16n,
/**
* Allows for using the `@everyone` tag to notify all users in a channel,
* and the `@here` tag to notify all online users in a channel
*
* Applies to channel types: Text, Voice, Stage
*/
MentionEveryone: 1n << 17n,
/**
* Allows the usage of custom emojis from other servers
*
* Applies to channel types: Text, Voice, Stage
*/
UseExternalEmojis: 1n << 18n,
/**
* Allows for viewing guild insights
*/
ViewGuildInsights: 1n << 19n,
/**
* Allows for joining of a voice channel
*
* Applies to channel types: Voice, Stage
*/
Connect: 1n << 20n,
/**
* Allows for speaking in a voice channel
*
* Applies to channel types: Voice
*/
Speak: 1n << 21n,
/**
* Allows for muting members in a voice channel
*
* Applies to channel types: Voice, Stage
*/
MuteMembers: 1n << 22n,
/**
* Allows for deafening of members in a voice channel
*
* Applies to channel types: Voice
*/
DeafenMembers: 1n << 23n,
/**
* Allows for moving of members between voice channels
*
* Applies to channel types: Voice, Stage
*/
MoveMembers: 1n << 24n,
/**
* Allows for using voice-activity-detection in a voice channel
*
* Applies to channel types: Voice
*/
UseVAD: 1n << 25n,
/**
* Allows for modification of own nickname
*/
ChangeNickname: 1n << 26n,
/**
* Allows for modification of other users nicknames
*/
ManageNicknames: 1n << 27n,
/**
* Allows management and editing of roles
*
* Applies to channel types: Text, Voice, Stage
*/
ManageRoles: 1n << 28n,
/**
* Allows management and editing of webhooks
*
* Applies to channel types: Text, Voice, Stage
*/
ManageWebhooks: 1n << 29n,
/**
* Allows management and editing of emojis, stickers, and soundboard sounds
*
* @deprecated This is the old name for {@apilink PermissionFlagsBits#ManageGuildExpressions}
*/
ManageEmojisAndStickers: 1n << 30n,
/**
* Allows for editing and deleting emojis, stickers, and soundboard sounds created by all users
*/
ManageGuildExpressions: 1n << 30n,
/**
* Allows members to use application commands, including slash commands and context menu commands
*
* Applies to channel types: Text, Voice, Stage
*/
UseApplicationCommands: 1n << 31n,
/**
* Allows for requesting to speak in stage channels
*
* Applies to channel types: Stage
*/
RequestToSpeak: 1n << 32n,
/**
* Allows for editing and deleting scheduled events created by all users
*
* Applies to channel types: Voice, Stage
*/
ManageEvents: 1n << 33n,
/**
* Allows for deleting and archiving threads, and viewing all private threads
*
* Applies to channel types: Text
*/
ManageThreads: 1n << 34n,
/**
* Allows for creating public and announcement threads
*
* Applies to channel types: Text
*/
CreatePublicThreads: 1n << 35n,
/**
* Allows for creating private threads
*
* Applies to channel types: Text
*/
CreatePrivateThreads: 1n << 36n,
/**
* Allows the usage of custom stickers from other servers
*
* Applies to channel types: Text, Voice, Stage
*/
UseExternalStickers: 1n << 37n,
/**
* Allows for sending messages in threads
*
* Applies to channel types: Text
*/
SendMessagesInThreads: 1n << 38n,
/**
* Allows for using Activities (applications with the {@apilink ApplicationFlags.Embedded} flag) in a voice channel
*
* Applies to channel types: Voice
*/
UseEmbeddedActivities: 1n << 39n,
/**
* Allows for timing out users to prevent them from sending or reacting to messages in chat and threads,
* and from speaking in voice and stage channels
*/
ModerateMembers: 1n << 40n,
/**
* Allows for viewing role subscription insights
*/
ViewCreatorMonetizationAnalytics: 1n << 41n,
/**
* Allows for using soundboard in a voice channel
*
* Applies to channel types: Voice
*/
UseSoundboard: 1n << 42n,
/**
* Allows for creating emojis, stickers, and soundboard sounds, and editing and deleting those created by the current user
*/
CreateGuildExpressions: 1n << 43n,
/**
* Allows for creating scheduled events, and editing and deleting those created by the current user
*
* Applies to channel types: Voice, Stage
*/
CreateEvents: 1n << 44n,
/**
* Allows the usage of custom soundboard sounds from other servers
*
* Applies to channel types: Voice
*/
UseExternalSounds: 1n << 45n,
/**
* Allows sending voice messages
*
* Applies to channel types: Text, Voice, Stage
*/
SendVoiceMessages: 1n << 46n,
/**
* Allows sending polls
*
* Applies to channel types: Text, Voice, Stage
*/
SendPolls: 1n << 49n,
/**
* Allows user-installed apps to send public responses. When disabled, users will still be allowed to use their apps but the responses will be ephemeral. This only applies to apps not also installed to the server
*
* Applies to channel types: Text, Voice, Stage
*/
UseExternalApps: 1n << 50n,
} as const;
/**
* Freeze the object of bits, preventing any modifications to it
*
* @internal
*/
Object.freeze(PermissionFlagsBits);
export type LocalizationMap = Partial<Record<LocaleString, string | null>>;
/**
* https://discord.com/developers/docs/topics/opcodes-and-status-codes#json
*/
export interface RESTError {
code: number;
message: string;
errors?: RESTErrorData;
}
export interface RESTErrorFieldInformation {
code: string;
message: string;
}
export interface RESTErrorGroupWrapper {
_errors: RESTErrorData[];
}
export type RESTErrorData = RESTErrorFieldInformation | RESTErrorGroupWrapper | string | { [k: string]: RESTErrorData };
/**
* https://discord.com/developers/docs/topics/rate-limits#exceeding-a-rate-limit-rate-limit-response-structure
*/
export interface RESTRateLimit {
/**
* An error code for some limits
*
* {@link RESTJSONErrorCodes}
*/
code?: number;
/**
* A value indicating if you are being globally rate limited or not
*/
global: boolean;
/**
* A message saying you are being rate limited.
*/
message: string;
/**
* The number of seconds to wait before submitting another request.
*/
retry_after: number;
}