-
-
Notifications
You must be signed in to change notification settings - Fork 114
/
common.ts
98 lines (90 loc) · 2.55 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
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 = {
CreateInstantInvite: 1n << 0n,
KickMembers: 1n << 1n,
BanMembers: 1n << 2n,
Administrator: 1n << 3n,
ManageChannels: 1n << 4n,
ManageGuild: 1n << 5n,
AddReactions: 1n << 6n,
ViewAuditLog: 1n << 7n,
PrioritySpeaker: 1n << 8n,
Stream: 1n << 9n,
ViewChannel: 1n << 10n,
SendMessages: 1n << 11n,
SendTTSMessages: 1n << 12n,
ManageMessages: 1n << 13n,
EmbedLinks: 1n << 14n,
AttachFiles: 1n << 15n,
ReadMessageHistory: 1n << 16n,
MentionEveryone: 1n << 17n,
UseExternalEmojis: 1n << 18n,
ViewGuildInsights: 1n << 19n,
Connect: 1n << 20n,
Speak: 1n << 21n,
MuteMembers: 1n << 22n,
DeafenMembers: 1n << 23n,
MoveMembers: 1n << 24n,
UseVAD: 1n << 25n,
ChangeNickname: 1n << 26n,
ManageNicknames: 1n << 27n,
ManageRoles: 1n << 28n,
ManageWebhooks: 1n << 29n,
ManageEmojisAndStickers: 1n << 30n,
UseApplicationCommands: 1n << 31n,
RequestToSpeak: 1n << 32n,
ManageEvents: 1n << 33n,
ManageThreads: 1n << 34n,
CreatePublicThreads: 1n << 35n,
CreatePrivateThreads: 1n << 36n,
UseExternalStickers: 1n << 37n,
SendMessagesInThreads: 1n << 38n,
UseEmbeddedActivities: 1n << 39n,
ModerateMembers: 1n << 40n,
} 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 = RESTErrorGroupWrapper | RESTErrorFieldInformation | { [k: string]: RESTErrorData } | string;
/**
* https://discord.com/developers/docs/topics/rate-limits#exceeding-a-rate-limit-rate-limit-response-structure
*/
export interface RESTRateLimit {
/**
* 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;
}