@fluxerjs/util 1.2.2 → 1.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -5,21 +5,21 @@
5
5
  * Flags with values exceeding 2^30 may exhibit unexpected behavior. For permission-style
6
6
  * bitfields with more than 30 bits, consider using BigInt-based implementations.
7
7
  */
8
- type BitFieldResolvable<S extends string> = S | bigint | number | BitField<S> | (S | number | BitField<S>)[];
8
+ type BitFieldResolvable<S extends string> = S | bigint | number | BitField<S> | (S | number | bigint | BitField<S>)[];
9
9
  declare class BitField<S extends string> {
10
- static Flags: Record<string, number>;
10
+ static Flags: Record<string, bigint>;
11
11
  defaultBit: number;
12
- bitfield: number;
12
+ bitfield: bigint;
13
13
  constructor(bits?: BitFieldResolvable<S>);
14
14
  get [Symbol.toStringTag](): string;
15
- static resolve<S extends string>(bit: BitFieldResolvable<S>): number;
15
+ static resolve<S extends string>(bits: BitFieldResolvable<S>): bigint;
16
16
  has(bit: BitFieldResolvable<S>): boolean;
17
17
  add(...bits: BitFieldResolvable<S>[]): this;
18
18
  remove(...bits: BitFieldResolvable<S>[]): this;
19
19
  serialize(): Record<S, boolean>;
20
20
  toArray(): S[];
21
- toJSON(): number;
22
- valueOf(): number;
21
+ toJSON(): string;
22
+ valueOf(): string;
23
23
  equals(bitfield: BitField<S>): boolean;
24
24
  freeze(): Readonly<BitField<S>>;
25
25
  }
@@ -64,59 +64,95 @@ declare class SnowflakeUtil {
64
64
 
65
65
  /**
66
66
  * Permission flags aligned with Fluxer API (fluxer_api/src/constants/Channel.ts).
67
- * Bits 0–30 use 1<<n; bits 31+ use 2**n.
67
+ * Bit positions use BigInt shifts (1n << n).
68
68
  * Administrator (bit 3) implies all permissions. Guild owner bypasses role computation.
69
69
  *
70
70
  * @example
71
71
  * if (member.permissions.has(PermissionFlags.BanMembers)) { ... }
72
72
  * if (perms.has(PermissionFlags.Administrator)) { ... }
73
73
  */
74
- declare enum PermissionFlags {
75
- CreateInstantInvite = 1,
76
- KickMembers = 2,
77
- BanMembers = 4,
78
- Administrator = 8,
79
- ManageChannels = 16,
80
- ManageGuild = 32,
81
- AddReactions = 64,
82
- ViewAuditLog = 128,
83
- PrioritySpeaker = 256,
84
- Stream = 512,
85
- ViewChannel = 1024,
86
- SendMessages = 2048,
87
- SendTtsMessages = 4096,
88
- ManageMessages = 8192,
89
- EmbedLinks = 16384,
90
- AttachFiles = 32768,
91
- ReadMessageHistory = 65536,
92
- MentionEveryone = 131072,
93
- UseExternalEmojis = 262144,
94
- Connect = 1048576,
95
- Speak = 2097152,
96
- MuteMembers = 4194304,
97
- DeafenMembers = 8388608,
98
- MoveMembers = 16777216,
99
- UseVad = 33554432,
100
- ChangeNickname = 67108864,
101
- ManageNicknames = 134217728,
102
- ManageRoles = 268435456,
103
- ManageWebhooks = 536870912,
104
- ManageEmojisAndStickers = 1073741824,
105
- ManageExpressions = 1073741824,
106
- UseExternalStickers = 137438953472,
107
- ModerateMembers = 1099511627776,
108
- CreateExpressions = 8796093022208,
109
- PinMessages = 2251799813685248,
110
- BypassSlowmode = 4503599627370496,
111
- UpdateRtcRegion = 9007199254740992
112
- }
113
- /** Forward mapping (name -> number) for lookups. Enum has reverse mappings we must avoid. */
114
- declare const PermissionFlagsMap: Record<string, number>;
74
+ declare const PermissionFlags: {
75
+ readonly CreateInstantInvite: bigint;
76
+ readonly KickMembers: bigint;
77
+ readonly BanMembers: bigint;
78
+ readonly Administrator: bigint;
79
+ readonly ManageChannels: bigint;
80
+ readonly ManageGuild: bigint;
81
+ readonly AddReactions: bigint;
82
+ readonly ViewAuditLog: bigint;
83
+ readonly PrioritySpeaker: bigint;
84
+ readonly Stream: bigint;
85
+ readonly ViewChannel: bigint;
86
+ readonly SendMessages: bigint;
87
+ readonly SendTtsMessages: bigint;
88
+ readonly ManageMessages: bigint;
89
+ readonly EmbedLinks: bigint;
90
+ readonly AttachFiles: bigint;
91
+ readonly ReadMessageHistory: bigint;
92
+ readonly MentionEveryone: bigint;
93
+ readonly UseExternalEmojis: bigint;
94
+ readonly Connect: bigint;
95
+ readonly Speak: bigint;
96
+ readonly MuteMembers: bigint;
97
+ readonly DeafenMembers: bigint;
98
+ readonly MoveMembers: bigint;
99
+ readonly UseVad: bigint;
100
+ readonly ChangeNickname: bigint;
101
+ readonly ManageNicknames: bigint;
102
+ readonly ManageRoles: bigint;
103
+ readonly ManageWebhooks: bigint;
104
+ readonly ManageEmojisAndStickers: bigint;
105
+ readonly ManageExpressions: bigint;
106
+ readonly UseExternalStickers: bigint;
107
+ readonly ModerateMembers: bigint;
108
+ readonly CreateExpressions: bigint;
109
+ readonly PinMessages: bigint;
110
+ readonly BypassSlowmode: bigint;
111
+ readonly UpdateRtcRegion: bigint;
112
+ };
115
113
  /** BigInt OR of all permission flags. Used for guild owner override (owner has all perms). */
116
114
  declare const ALL_PERMISSIONS_BIGINT: bigint;
117
- type PermissionString = keyof typeof PermissionFlagsMap;
115
+ type PermissionString = keyof typeof PermissionFlags;
118
116
  declare class PermissionsBitField extends BitField<PermissionString> {
119
- static Flags: Record<string, number>;
117
+ static Flags: {
118
+ readonly CreateInstantInvite: bigint;
119
+ readonly KickMembers: bigint;
120
+ readonly BanMembers: bigint;
121
+ readonly Administrator: bigint;
122
+ readonly ManageChannels: bigint;
123
+ readonly ManageGuild: bigint;
124
+ readonly AddReactions: bigint;
125
+ readonly ViewAuditLog: bigint;
126
+ readonly PrioritySpeaker: bigint;
127
+ readonly Stream: bigint;
128
+ readonly ViewChannel: bigint;
129
+ readonly SendMessages: bigint;
130
+ readonly SendTtsMessages: bigint;
131
+ readonly ManageMessages: bigint;
132
+ readonly EmbedLinks: bigint;
133
+ readonly AttachFiles: bigint;
134
+ readonly ReadMessageHistory: bigint;
135
+ readonly MentionEveryone: bigint;
136
+ readonly UseExternalEmojis: bigint;
137
+ readonly Connect: bigint;
138
+ readonly Speak: bigint;
139
+ readonly MuteMembers: bigint;
140
+ readonly DeafenMembers: bigint;
141
+ readonly MoveMembers: bigint;
142
+ readonly UseVad: bigint;
143
+ readonly ChangeNickname: bigint;
144
+ readonly ManageNicknames: bigint;
145
+ readonly ManageRoles: bigint;
146
+ readonly ManageWebhooks: bigint;
147
+ readonly ManageEmojisAndStickers: bigint;
148
+ readonly ManageExpressions: bigint;
149
+ readonly UseExternalStickers: bigint;
150
+ readonly ModerateMembers: bigint;
151
+ readonly CreateExpressions: bigint;
152
+ readonly PinMessages: bigint;
153
+ readonly BypassSlowmode: bigint;
154
+ readonly UpdateRtcRegion: bigint;
155
+ };
120
156
  }
121
157
  type PermissionResolvable = BitFieldResolvable<PermissionString>;
122
158
  /**
@@ -135,18 +171,18 @@ declare function resolvePermissionsToBitfield(perms: PermissionResolvable): stri
135
171
  * Format: int32.
136
172
  */
137
173
  declare const MessageFlagsBits: {
138
- readonly SuppressEmbeds: number;
139
- readonly SuppressNotifications: number;
140
- readonly VoiceMessage: number;
141
- readonly CompactAttachments: number;
174
+ readonly SuppressEmbeds: bigint;
175
+ readonly SuppressNotifications: bigint;
176
+ readonly VoiceMessage: bigint;
177
+ readonly CompactAttachments: bigint;
142
178
  };
143
179
  type MessageFlagsString = keyof typeof MessageFlagsBits;
144
180
  declare class MessageFlagsBitField extends BitField<MessageFlagsString> {
145
181
  static Flags: {
146
- readonly SuppressEmbeds: number;
147
- readonly SuppressNotifications: number;
148
- readonly VoiceMessage: number;
149
- readonly CompactAttachments: number;
182
+ readonly SuppressEmbeds: bigint;
183
+ readonly SuppressNotifications: bigint;
184
+ readonly VoiceMessage: bigint;
185
+ readonly CompactAttachments: bigint;
150
186
  };
151
187
  }
152
188
  type MessageFlagsResolvable = BitFieldResolvable<MessageFlagsString>;
@@ -157,72 +193,72 @@ type MessageFlagsResolvable = BitFieldResolvable<MessageFlagsString>;
157
193
  * Note: BitField's has/add/remove use JS bitwise ops (32-bit); full values are for API serialization.
158
194
  */
159
195
  declare const UserFlagsBits: {
160
- readonly Staff: number;
161
- readonly CtpMember: number;
162
- readonly Partner: number;
163
- readonly BugHunter: number;
164
- readonly FriendlyBot: number;
165
- readonly FriendlyBotManualApproval: number;
166
- readonly HighGlobalRateLimit: 8589934592;
167
- readonly Deleted: 17179869184;
168
- readonly DisabledSuspiciousActivity: 34359738368;
169
- readonly SelfDeleted: 68719476736;
170
- readonly PremiumDiscriminator: 137438953472;
171
- readonly Disabled: 274877906944;
172
- readonly HasSessionStarted: 549755813888;
173
- readonly PremiumBadgeHidden: 1099511627776;
174
- readonly PremiumBadgeMasked: 2199023255552;
175
- readonly PremiumBadgeTimestampHidden: 4398046511104;
176
- readonly PremiumBadgeSequenceHidden: 8796093022208;
177
- readonly PremiumPerksSanitized: 17592186044416;
178
- readonly PremiumPurchaseDisabled: 35184372088832;
179
- readonly PremiumEnabledOverride: 70368744177664;
180
- readonly RateLimitBypass: 140737488355328;
181
- readonly ReportBanned: 281474976710656;
182
- readonly VerifiedNotUnderage: 562949953421312;
183
- readonly PendingManualVerification: 1125899906842624;
184
- readonly HasDismissedPremiumOnboarding: 2251799813685248;
185
- readonly UsedMobileClient: 4503599627370496;
186
- readonly AppStoreReviewer: number;
187
- readonly DmHistoryBackfilled: number;
188
- readonly HasRelationshipsIndexed: number;
189
- readonly MessagesByAuthorBackfilled: number;
190
- readonly StaffHidden: number;
196
+ readonly Staff: bigint;
197
+ readonly CtpMember: bigint;
198
+ readonly Partner: bigint;
199
+ readonly BugHunter: bigint;
200
+ readonly FriendlyBot: bigint;
201
+ readonly FriendlyBotManualApproval: bigint;
202
+ readonly HighGlobalRateLimit: bigint;
203
+ readonly Deleted: bigint;
204
+ readonly DisabledSuspiciousActivity: bigint;
205
+ readonly SelfDeleted: bigint;
206
+ readonly PremiumDiscriminator: bigint;
207
+ readonly Disabled: bigint;
208
+ readonly HasSessionStarted: bigint;
209
+ readonly PremiumBadgeHidden: bigint;
210
+ readonly PremiumBadgeMasked: bigint;
211
+ readonly PremiumBadgeTimestampHidden: bigint;
212
+ readonly PremiumBadgeSequenceHidden: bigint;
213
+ readonly PremiumPerksSanitized: bigint;
214
+ readonly PremiumPurchaseDisabled: bigint;
215
+ readonly PremiumEnabledOverride: bigint;
216
+ readonly RateLimitBypass: bigint;
217
+ readonly ReportBanned: bigint;
218
+ readonly VerifiedNotUnderage: bigint;
219
+ readonly PendingManualVerification: bigint;
220
+ readonly HasDismissedPremiumOnboarding: bigint;
221
+ readonly UsedMobileClient: bigint;
222
+ readonly AppStoreReviewer: bigint;
223
+ readonly DmHistoryBackfilled: bigint;
224
+ readonly HasRelationshipsIndexed: bigint;
225
+ readonly MessagesByAuthorBackfilled: bigint;
226
+ readonly StaffHidden: bigint;
191
227
  };
192
228
  type UserFlagsString = keyof typeof UserFlagsBits;
193
229
  declare class UserFlagsBitField extends BitField<UserFlagsString> {
194
230
  static Flags: {
195
- readonly Staff: number;
196
- readonly CtpMember: number;
197
- readonly Partner: number;
198
- readonly BugHunter: number;
199
- readonly FriendlyBot: number;
200
- readonly FriendlyBotManualApproval: number;
201
- readonly HighGlobalRateLimit: 8589934592;
202
- readonly Deleted: 17179869184;
203
- readonly DisabledSuspiciousActivity: 34359738368;
204
- readonly SelfDeleted: 68719476736;
205
- readonly PremiumDiscriminator: 137438953472;
206
- readonly Disabled: 274877906944;
207
- readonly HasSessionStarted: 549755813888;
208
- readonly PremiumBadgeHidden: 1099511627776;
209
- readonly PremiumBadgeMasked: 2199023255552;
210
- readonly PremiumBadgeTimestampHidden: 4398046511104;
211
- readonly PremiumBadgeSequenceHidden: 8796093022208;
212
- readonly PremiumPerksSanitized: 17592186044416;
213
- readonly PremiumPurchaseDisabled: 35184372088832;
214
- readonly PremiumEnabledOverride: 70368744177664;
215
- readonly RateLimitBypass: 140737488355328;
216
- readonly ReportBanned: 281474976710656;
217
- readonly VerifiedNotUnderage: 562949953421312;
218
- readonly PendingManualVerification: 1125899906842624;
219
- readonly HasDismissedPremiumOnboarding: 2251799813685248;
220
- readonly UsedMobileClient: 4503599627370496;
221
- readonly AppStoreReviewer: number;
222
- readonly DmHistoryBackfilled: number;
223
- readonly HasRelationshipsIndexed: number;
224
- readonly MessagesByAuthorBackfilled: number;
225
- readonly StaffHidden: number;
231
+ readonly Staff: bigint;
232
+ readonly CtpMember: bigint;
233
+ readonly Partner: bigint;
234
+ readonly BugHunter: bigint;
235
+ readonly FriendlyBot: bigint;
236
+ readonly FriendlyBotManualApproval: bigint;
237
+ readonly HighGlobalRateLimit: bigint;
238
+ readonly Deleted: bigint;
239
+ readonly DisabledSuspiciousActivity: bigint;
240
+ readonly SelfDeleted: bigint;
241
+ readonly PremiumDiscriminator: bigint;
242
+ readonly Disabled: bigint;
243
+ readonly HasSessionStarted: bigint;
244
+ readonly PremiumBadgeHidden: bigint;
245
+ readonly PremiumBadgeMasked: bigint;
246
+ readonly PremiumBadgeTimestampHidden: bigint;
247
+ readonly PremiumBadgeSequenceHidden: bigint;
248
+ readonly PremiumPerksSanitized: bigint;
249
+ readonly PremiumPurchaseDisabled: bigint;
250
+ readonly PremiumEnabledOverride: bigint;
251
+ readonly RateLimitBypass: bigint;
252
+ readonly ReportBanned: bigint;
253
+ readonly VerifiedNotUnderage: bigint;
254
+ readonly PendingManualVerification: bigint;
255
+ readonly HasDismissedPremiumOnboarding: bigint;
256
+ readonly UsedMobileClient: bigint;
257
+ readonly AppStoreReviewer: bigint;
258
+ readonly DmHistoryBackfilled: bigint;
259
+ readonly HasRelationshipsIndexed: bigint;
260
+ readonly MessagesByAuthorBackfilled: bigint;
261
+ readonly StaffHidden: bigint;
226
262
  };
227
263
  }
228
264
  type UserFlagsResolvable = BitFieldResolvable<UserFlagsString>;
@@ -326,4 +362,4 @@ declare function resolveTenorToImageUrl(tenorViewUrl: string): Promise<TenorMedi
326
362
 
327
363
  declare function emitDeprecationWarning(symbol: string, message: string): void;
328
364
 
329
- export { ALL_PERMISSIONS_BIGINT, BitField, type BitFieldResolvable, FLUXER_EPOCH, MessageFlagsBitField, MessageFlagsBits, type MessageFlagsResolvable, type MessageFlagsString, PermissionFlags, PermissionFlagsMap, type PermissionResolvable, type PermissionString, PermissionsBitField, SnowflakeUtil, type TenorMediaResult, UserFlagsBitField, UserFlagsBits, type UserFlagsResolvable, type UserFlagsString, emitDeprecationWarning, escapeMarkdown, formatColor, formatEmoji, formatTimestamp, getUnicodeFromShortcode, parseEmoji, parsePrefixCommand, parseRoleMention, parseUserMention, resolveColor, resolvePermissionsToBitfield, resolveTenorToImageUrl, truncate };
365
+ export { ALL_PERMISSIONS_BIGINT, BitField, type BitFieldResolvable, FLUXER_EPOCH, MessageFlagsBitField, MessageFlagsBits, type MessageFlagsResolvable, type MessageFlagsString, PermissionFlags, type PermissionResolvable, type PermissionString, PermissionsBitField, SnowflakeUtil, type TenorMediaResult, UserFlagsBitField, UserFlagsBits, type UserFlagsResolvable, type UserFlagsString, emitDeprecationWarning, escapeMarkdown, formatColor, formatEmoji, formatTimestamp, getUnicodeFromShortcode, parseEmoji, parsePrefixCommand, parseRoleMention, parseUserMention, resolveColor, resolvePermissionsToBitfield, resolveTenorToImageUrl, truncate };
package/dist/index.d.ts CHANGED
@@ -5,21 +5,21 @@
5
5
  * Flags with values exceeding 2^30 may exhibit unexpected behavior. For permission-style
6
6
  * bitfields with more than 30 bits, consider using BigInt-based implementations.
7
7
  */
8
- type BitFieldResolvable<S extends string> = S | bigint | number | BitField<S> | (S | number | BitField<S>)[];
8
+ type BitFieldResolvable<S extends string> = S | bigint | number | BitField<S> | (S | number | bigint | BitField<S>)[];
9
9
  declare class BitField<S extends string> {
10
- static Flags: Record<string, number>;
10
+ static Flags: Record<string, bigint>;
11
11
  defaultBit: number;
12
- bitfield: number;
12
+ bitfield: bigint;
13
13
  constructor(bits?: BitFieldResolvable<S>);
14
14
  get [Symbol.toStringTag](): string;
15
- static resolve<S extends string>(bit: BitFieldResolvable<S>): number;
15
+ static resolve<S extends string>(bits: BitFieldResolvable<S>): bigint;
16
16
  has(bit: BitFieldResolvable<S>): boolean;
17
17
  add(...bits: BitFieldResolvable<S>[]): this;
18
18
  remove(...bits: BitFieldResolvable<S>[]): this;
19
19
  serialize(): Record<S, boolean>;
20
20
  toArray(): S[];
21
- toJSON(): number;
22
- valueOf(): number;
21
+ toJSON(): string;
22
+ valueOf(): string;
23
23
  equals(bitfield: BitField<S>): boolean;
24
24
  freeze(): Readonly<BitField<S>>;
25
25
  }
@@ -64,59 +64,95 @@ declare class SnowflakeUtil {
64
64
 
65
65
  /**
66
66
  * Permission flags aligned with Fluxer API (fluxer_api/src/constants/Channel.ts).
67
- * Bits 0–30 use 1<<n; bits 31+ use 2**n.
67
+ * Bit positions use BigInt shifts (1n << n).
68
68
  * Administrator (bit 3) implies all permissions. Guild owner bypasses role computation.
69
69
  *
70
70
  * @example
71
71
  * if (member.permissions.has(PermissionFlags.BanMembers)) { ... }
72
72
  * if (perms.has(PermissionFlags.Administrator)) { ... }
73
73
  */
74
- declare enum PermissionFlags {
75
- CreateInstantInvite = 1,
76
- KickMembers = 2,
77
- BanMembers = 4,
78
- Administrator = 8,
79
- ManageChannels = 16,
80
- ManageGuild = 32,
81
- AddReactions = 64,
82
- ViewAuditLog = 128,
83
- PrioritySpeaker = 256,
84
- Stream = 512,
85
- ViewChannel = 1024,
86
- SendMessages = 2048,
87
- SendTtsMessages = 4096,
88
- ManageMessages = 8192,
89
- EmbedLinks = 16384,
90
- AttachFiles = 32768,
91
- ReadMessageHistory = 65536,
92
- MentionEveryone = 131072,
93
- UseExternalEmojis = 262144,
94
- Connect = 1048576,
95
- Speak = 2097152,
96
- MuteMembers = 4194304,
97
- DeafenMembers = 8388608,
98
- MoveMembers = 16777216,
99
- UseVad = 33554432,
100
- ChangeNickname = 67108864,
101
- ManageNicknames = 134217728,
102
- ManageRoles = 268435456,
103
- ManageWebhooks = 536870912,
104
- ManageEmojisAndStickers = 1073741824,
105
- ManageExpressions = 1073741824,
106
- UseExternalStickers = 137438953472,
107
- ModerateMembers = 1099511627776,
108
- CreateExpressions = 8796093022208,
109
- PinMessages = 2251799813685248,
110
- BypassSlowmode = 4503599627370496,
111
- UpdateRtcRegion = 9007199254740992
112
- }
113
- /** Forward mapping (name -> number) for lookups. Enum has reverse mappings we must avoid. */
114
- declare const PermissionFlagsMap: Record<string, number>;
74
+ declare const PermissionFlags: {
75
+ readonly CreateInstantInvite: bigint;
76
+ readonly KickMembers: bigint;
77
+ readonly BanMembers: bigint;
78
+ readonly Administrator: bigint;
79
+ readonly ManageChannels: bigint;
80
+ readonly ManageGuild: bigint;
81
+ readonly AddReactions: bigint;
82
+ readonly ViewAuditLog: bigint;
83
+ readonly PrioritySpeaker: bigint;
84
+ readonly Stream: bigint;
85
+ readonly ViewChannel: bigint;
86
+ readonly SendMessages: bigint;
87
+ readonly SendTtsMessages: bigint;
88
+ readonly ManageMessages: bigint;
89
+ readonly EmbedLinks: bigint;
90
+ readonly AttachFiles: bigint;
91
+ readonly ReadMessageHistory: bigint;
92
+ readonly MentionEveryone: bigint;
93
+ readonly UseExternalEmojis: bigint;
94
+ readonly Connect: bigint;
95
+ readonly Speak: bigint;
96
+ readonly MuteMembers: bigint;
97
+ readonly DeafenMembers: bigint;
98
+ readonly MoveMembers: bigint;
99
+ readonly UseVad: bigint;
100
+ readonly ChangeNickname: bigint;
101
+ readonly ManageNicknames: bigint;
102
+ readonly ManageRoles: bigint;
103
+ readonly ManageWebhooks: bigint;
104
+ readonly ManageEmojisAndStickers: bigint;
105
+ readonly ManageExpressions: bigint;
106
+ readonly UseExternalStickers: bigint;
107
+ readonly ModerateMembers: bigint;
108
+ readonly CreateExpressions: bigint;
109
+ readonly PinMessages: bigint;
110
+ readonly BypassSlowmode: bigint;
111
+ readonly UpdateRtcRegion: bigint;
112
+ };
115
113
  /** BigInt OR of all permission flags. Used for guild owner override (owner has all perms). */
116
114
  declare const ALL_PERMISSIONS_BIGINT: bigint;
117
- type PermissionString = keyof typeof PermissionFlagsMap;
115
+ type PermissionString = keyof typeof PermissionFlags;
118
116
  declare class PermissionsBitField extends BitField<PermissionString> {
119
- static Flags: Record<string, number>;
117
+ static Flags: {
118
+ readonly CreateInstantInvite: bigint;
119
+ readonly KickMembers: bigint;
120
+ readonly BanMembers: bigint;
121
+ readonly Administrator: bigint;
122
+ readonly ManageChannels: bigint;
123
+ readonly ManageGuild: bigint;
124
+ readonly AddReactions: bigint;
125
+ readonly ViewAuditLog: bigint;
126
+ readonly PrioritySpeaker: bigint;
127
+ readonly Stream: bigint;
128
+ readonly ViewChannel: bigint;
129
+ readonly SendMessages: bigint;
130
+ readonly SendTtsMessages: bigint;
131
+ readonly ManageMessages: bigint;
132
+ readonly EmbedLinks: bigint;
133
+ readonly AttachFiles: bigint;
134
+ readonly ReadMessageHistory: bigint;
135
+ readonly MentionEveryone: bigint;
136
+ readonly UseExternalEmojis: bigint;
137
+ readonly Connect: bigint;
138
+ readonly Speak: bigint;
139
+ readonly MuteMembers: bigint;
140
+ readonly DeafenMembers: bigint;
141
+ readonly MoveMembers: bigint;
142
+ readonly UseVad: bigint;
143
+ readonly ChangeNickname: bigint;
144
+ readonly ManageNicknames: bigint;
145
+ readonly ManageRoles: bigint;
146
+ readonly ManageWebhooks: bigint;
147
+ readonly ManageEmojisAndStickers: bigint;
148
+ readonly ManageExpressions: bigint;
149
+ readonly UseExternalStickers: bigint;
150
+ readonly ModerateMembers: bigint;
151
+ readonly CreateExpressions: bigint;
152
+ readonly PinMessages: bigint;
153
+ readonly BypassSlowmode: bigint;
154
+ readonly UpdateRtcRegion: bigint;
155
+ };
120
156
  }
121
157
  type PermissionResolvable = BitFieldResolvable<PermissionString>;
122
158
  /**
@@ -135,18 +171,18 @@ declare function resolvePermissionsToBitfield(perms: PermissionResolvable): stri
135
171
  * Format: int32.
136
172
  */
137
173
  declare const MessageFlagsBits: {
138
- readonly SuppressEmbeds: number;
139
- readonly SuppressNotifications: number;
140
- readonly VoiceMessage: number;
141
- readonly CompactAttachments: number;
174
+ readonly SuppressEmbeds: bigint;
175
+ readonly SuppressNotifications: bigint;
176
+ readonly VoiceMessage: bigint;
177
+ readonly CompactAttachments: bigint;
142
178
  };
143
179
  type MessageFlagsString = keyof typeof MessageFlagsBits;
144
180
  declare class MessageFlagsBitField extends BitField<MessageFlagsString> {
145
181
  static Flags: {
146
- readonly SuppressEmbeds: number;
147
- readonly SuppressNotifications: number;
148
- readonly VoiceMessage: number;
149
- readonly CompactAttachments: number;
182
+ readonly SuppressEmbeds: bigint;
183
+ readonly SuppressNotifications: bigint;
184
+ readonly VoiceMessage: bigint;
185
+ readonly CompactAttachments: bigint;
150
186
  };
151
187
  }
152
188
  type MessageFlagsResolvable = BitFieldResolvable<MessageFlagsString>;
@@ -157,72 +193,72 @@ type MessageFlagsResolvable = BitFieldResolvable<MessageFlagsString>;
157
193
  * Note: BitField's has/add/remove use JS bitwise ops (32-bit); full values are for API serialization.
158
194
  */
159
195
  declare const UserFlagsBits: {
160
- readonly Staff: number;
161
- readonly CtpMember: number;
162
- readonly Partner: number;
163
- readonly BugHunter: number;
164
- readonly FriendlyBot: number;
165
- readonly FriendlyBotManualApproval: number;
166
- readonly HighGlobalRateLimit: 8589934592;
167
- readonly Deleted: 17179869184;
168
- readonly DisabledSuspiciousActivity: 34359738368;
169
- readonly SelfDeleted: 68719476736;
170
- readonly PremiumDiscriminator: 137438953472;
171
- readonly Disabled: 274877906944;
172
- readonly HasSessionStarted: 549755813888;
173
- readonly PremiumBadgeHidden: 1099511627776;
174
- readonly PremiumBadgeMasked: 2199023255552;
175
- readonly PremiumBadgeTimestampHidden: 4398046511104;
176
- readonly PremiumBadgeSequenceHidden: 8796093022208;
177
- readonly PremiumPerksSanitized: 17592186044416;
178
- readonly PremiumPurchaseDisabled: 35184372088832;
179
- readonly PremiumEnabledOverride: 70368744177664;
180
- readonly RateLimitBypass: 140737488355328;
181
- readonly ReportBanned: 281474976710656;
182
- readonly VerifiedNotUnderage: 562949953421312;
183
- readonly PendingManualVerification: 1125899906842624;
184
- readonly HasDismissedPremiumOnboarding: 2251799813685248;
185
- readonly UsedMobileClient: 4503599627370496;
186
- readonly AppStoreReviewer: number;
187
- readonly DmHistoryBackfilled: number;
188
- readonly HasRelationshipsIndexed: number;
189
- readonly MessagesByAuthorBackfilled: number;
190
- readonly StaffHidden: number;
196
+ readonly Staff: bigint;
197
+ readonly CtpMember: bigint;
198
+ readonly Partner: bigint;
199
+ readonly BugHunter: bigint;
200
+ readonly FriendlyBot: bigint;
201
+ readonly FriendlyBotManualApproval: bigint;
202
+ readonly HighGlobalRateLimit: bigint;
203
+ readonly Deleted: bigint;
204
+ readonly DisabledSuspiciousActivity: bigint;
205
+ readonly SelfDeleted: bigint;
206
+ readonly PremiumDiscriminator: bigint;
207
+ readonly Disabled: bigint;
208
+ readonly HasSessionStarted: bigint;
209
+ readonly PremiumBadgeHidden: bigint;
210
+ readonly PremiumBadgeMasked: bigint;
211
+ readonly PremiumBadgeTimestampHidden: bigint;
212
+ readonly PremiumBadgeSequenceHidden: bigint;
213
+ readonly PremiumPerksSanitized: bigint;
214
+ readonly PremiumPurchaseDisabled: bigint;
215
+ readonly PremiumEnabledOverride: bigint;
216
+ readonly RateLimitBypass: bigint;
217
+ readonly ReportBanned: bigint;
218
+ readonly VerifiedNotUnderage: bigint;
219
+ readonly PendingManualVerification: bigint;
220
+ readonly HasDismissedPremiumOnboarding: bigint;
221
+ readonly UsedMobileClient: bigint;
222
+ readonly AppStoreReviewer: bigint;
223
+ readonly DmHistoryBackfilled: bigint;
224
+ readonly HasRelationshipsIndexed: bigint;
225
+ readonly MessagesByAuthorBackfilled: bigint;
226
+ readonly StaffHidden: bigint;
191
227
  };
192
228
  type UserFlagsString = keyof typeof UserFlagsBits;
193
229
  declare class UserFlagsBitField extends BitField<UserFlagsString> {
194
230
  static Flags: {
195
- readonly Staff: number;
196
- readonly CtpMember: number;
197
- readonly Partner: number;
198
- readonly BugHunter: number;
199
- readonly FriendlyBot: number;
200
- readonly FriendlyBotManualApproval: number;
201
- readonly HighGlobalRateLimit: 8589934592;
202
- readonly Deleted: 17179869184;
203
- readonly DisabledSuspiciousActivity: 34359738368;
204
- readonly SelfDeleted: 68719476736;
205
- readonly PremiumDiscriminator: 137438953472;
206
- readonly Disabled: 274877906944;
207
- readonly HasSessionStarted: 549755813888;
208
- readonly PremiumBadgeHidden: 1099511627776;
209
- readonly PremiumBadgeMasked: 2199023255552;
210
- readonly PremiumBadgeTimestampHidden: 4398046511104;
211
- readonly PremiumBadgeSequenceHidden: 8796093022208;
212
- readonly PremiumPerksSanitized: 17592186044416;
213
- readonly PremiumPurchaseDisabled: 35184372088832;
214
- readonly PremiumEnabledOverride: 70368744177664;
215
- readonly RateLimitBypass: 140737488355328;
216
- readonly ReportBanned: 281474976710656;
217
- readonly VerifiedNotUnderage: 562949953421312;
218
- readonly PendingManualVerification: 1125899906842624;
219
- readonly HasDismissedPremiumOnboarding: 2251799813685248;
220
- readonly UsedMobileClient: 4503599627370496;
221
- readonly AppStoreReviewer: number;
222
- readonly DmHistoryBackfilled: number;
223
- readonly HasRelationshipsIndexed: number;
224
- readonly MessagesByAuthorBackfilled: number;
225
- readonly StaffHidden: number;
231
+ readonly Staff: bigint;
232
+ readonly CtpMember: bigint;
233
+ readonly Partner: bigint;
234
+ readonly BugHunter: bigint;
235
+ readonly FriendlyBot: bigint;
236
+ readonly FriendlyBotManualApproval: bigint;
237
+ readonly HighGlobalRateLimit: bigint;
238
+ readonly Deleted: bigint;
239
+ readonly DisabledSuspiciousActivity: bigint;
240
+ readonly SelfDeleted: bigint;
241
+ readonly PremiumDiscriminator: bigint;
242
+ readonly Disabled: bigint;
243
+ readonly HasSessionStarted: bigint;
244
+ readonly PremiumBadgeHidden: bigint;
245
+ readonly PremiumBadgeMasked: bigint;
246
+ readonly PremiumBadgeTimestampHidden: bigint;
247
+ readonly PremiumBadgeSequenceHidden: bigint;
248
+ readonly PremiumPerksSanitized: bigint;
249
+ readonly PremiumPurchaseDisabled: bigint;
250
+ readonly PremiumEnabledOverride: bigint;
251
+ readonly RateLimitBypass: bigint;
252
+ readonly ReportBanned: bigint;
253
+ readonly VerifiedNotUnderage: bigint;
254
+ readonly PendingManualVerification: bigint;
255
+ readonly HasDismissedPremiumOnboarding: bigint;
256
+ readonly UsedMobileClient: bigint;
257
+ readonly AppStoreReviewer: bigint;
258
+ readonly DmHistoryBackfilled: bigint;
259
+ readonly HasRelationshipsIndexed: bigint;
260
+ readonly MessagesByAuthorBackfilled: bigint;
261
+ readonly StaffHidden: bigint;
226
262
  };
227
263
  }
228
264
  type UserFlagsResolvable = BitFieldResolvable<UserFlagsString>;
@@ -326,4 +362,4 @@ declare function resolveTenorToImageUrl(tenorViewUrl: string): Promise<TenorMedi
326
362
 
327
363
  declare function emitDeprecationWarning(symbol: string, message: string): void;
328
364
 
329
- export { ALL_PERMISSIONS_BIGINT, BitField, type BitFieldResolvable, FLUXER_EPOCH, MessageFlagsBitField, MessageFlagsBits, type MessageFlagsResolvable, type MessageFlagsString, PermissionFlags, PermissionFlagsMap, type PermissionResolvable, type PermissionString, PermissionsBitField, SnowflakeUtil, type TenorMediaResult, UserFlagsBitField, UserFlagsBits, type UserFlagsResolvable, type UserFlagsString, emitDeprecationWarning, escapeMarkdown, formatColor, formatEmoji, formatTimestamp, getUnicodeFromShortcode, parseEmoji, parsePrefixCommand, parseRoleMention, parseUserMention, resolveColor, resolvePermissionsToBitfield, resolveTenorToImageUrl, truncate };
365
+ export { ALL_PERMISSIONS_BIGINT, BitField, type BitFieldResolvable, FLUXER_EPOCH, MessageFlagsBitField, MessageFlagsBits, type MessageFlagsResolvable, type MessageFlagsString, PermissionFlags, type PermissionResolvable, type PermissionString, PermissionsBitField, SnowflakeUtil, type TenorMediaResult, UserFlagsBitField, UserFlagsBits, type UserFlagsResolvable, type UserFlagsString, emitDeprecationWarning, escapeMarkdown, formatColor, formatEmoji, formatTimestamp, getUnicodeFromShortcode, parseEmoji, parsePrefixCommand, parseRoleMention, parseUserMention, resolveColor, resolvePermissionsToBitfield, resolveTenorToImageUrl, truncate };
package/dist/index.js CHANGED
@@ -26,7 +26,6 @@ __export(index_exports, {
26
26
  MessageFlagsBitField: () => MessageFlagsBitField,
27
27
  MessageFlagsBits: () => MessageFlagsBits,
28
28
  PermissionFlags: () => PermissionFlags,
29
- PermissionFlagsMap: () => PermissionFlagsMap,
30
29
  PermissionsBitField: () => PermissionsBitField,
31
30
  SnowflakeUtil: () => SnowflakeUtil,
32
31
  UserFlagsBitField: () => UserFlagsBitField,
@@ -54,26 +53,35 @@ var BitField = class _BitField {
54
53
  defaultBit = 0;
55
54
  bitfield;
56
55
  constructor(bits = 0) {
57
- const Ctor = this.constructor;
58
- this.bitfield = Ctor.resolve(bits);
56
+ this.bitfield = this.constructor.resolve(bits);
59
57
  }
60
58
  get [Symbol.toStringTag]() {
61
59
  return `BitField${this.bitfield}`;
62
60
  }
63
- static resolve(bit) {
64
- const Flags = this.Flags;
65
- if (typeof bit === "number" && bit >= 0) return bit;
66
- if (bit instanceof _BitField) return bit.bitfield;
67
- if (Array.isArray(bit)) return bit.map((b) => this.resolve(b)).reduce((a, b) => a | b, 0);
68
- if (typeof bit === "string" && typeof Flags[bit] !== "undefined") return Flags[bit];
69
- throw new RangeError(`Invalid bitfield flag or number: ${bit}`);
61
+ static resolve(bits) {
62
+ if (typeof bits === "number" && bits >= 0) return BigInt(bits);
63
+ if (typeof bits === "bigint" && bits >= 0n) return bits;
64
+ if (bits instanceof _BitField) return bits.bitfield;
65
+ if (Array.isArray(bits))
66
+ return bits.map((b) => this.resolve(b)).reduce((a, b) => BigInt(a) | BigInt(b), 0n);
67
+ if (typeof bits === "string") {
68
+ if (bits in this.Flags) {
69
+ return this.Flags[bits];
70
+ }
71
+ try {
72
+ const value = BigInt(bits);
73
+ if (value >= 0n) return value;
74
+ } catch {
75
+ }
76
+ }
77
+ throw new RangeError(`Invalid bitfield flag or number: ${bits}`);
70
78
  }
71
79
  has(bit) {
72
80
  bit = this.constructor.resolve(bit);
73
81
  return (this.bitfield & bit) === bit;
74
82
  }
75
83
  add(...bits) {
76
- let total = 0;
84
+ let total = 0n;
77
85
  for (const bit of bits) {
78
86
  total |= this.constructor.resolve(bit);
79
87
  }
@@ -81,7 +89,7 @@ var BitField = class _BitField {
81
89
  return this;
82
90
  }
83
91
  remove(...bits) {
84
- let total = 0;
92
+ let total = 0n;
85
93
  for (const bit of bits) {
86
94
  total |= this.constructor.resolve(bit);
87
95
  }
@@ -101,10 +109,10 @@ var BitField = class _BitField {
101
109
  return Object.entries(Flags).filter(([, value]) => (this.bitfield & value) === value).map(([key]) => key);
102
110
  }
103
111
  toJSON() {
104
- return this.bitfield;
112
+ return this.bitfield.toString();
105
113
  }
106
114
  valueOf() {
107
- return this.bitfield;
115
+ return this.bitfield.toString();
108
116
  }
109
117
  equals(bitfield) {
110
118
  return this.bitfield === bitfield.bitfield;
@@ -165,69 +173,54 @@ var SnowflakeUtil = class {
165
173
  };
166
174
 
167
175
  // src/PermissionsBitField.ts
168
- var PermissionFlags = /* @__PURE__ */ ((PermissionFlags2) => {
169
- PermissionFlags2[PermissionFlags2["CreateInstantInvite"] = 1] = "CreateInstantInvite";
170
- PermissionFlags2[PermissionFlags2["KickMembers"] = 2] = "KickMembers";
171
- PermissionFlags2[PermissionFlags2["BanMembers"] = 4] = "BanMembers";
172
- PermissionFlags2[PermissionFlags2["Administrator"] = 8] = "Administrator";
173
- PermissionFlags2[PermissionFlags2["ManageChannels"] = 16] = "ManageChannels";
174
- PermissionFlags2[PermissionFlags2["ManageGuild"] = 32] = "ManageGuild";
175
- PermissionFlags2[PermissionFlags2["AddReactions"] = 64] = "AddReactions";
176
- PermissionFlags2[PermissionFlags2["ViewAuditLog"] = 128] = "ViewAuditLog";
177
- PermissionFlags2[PermissionFlags2["PrioritySpeaker"] = 256] = "PrioritySpeaker";
178
- PermissionFlags2[PermissionFlags2["Stream"] = 512] = "Stream";
179
- PermissionFlags2[PermissionFlags2["ViewChannel"] = 1024] = "ViewChannel";
180
- PermissionFlags2[PermissionFlags2["SendMessages"] = 2048] = "SendMessages";
181
- PermissionFlags2[PermissionFlags2["SendTtsMessages"] = 4096] = "SendTtsMessages";
182
- PermissionFlags2[PermissionFlags2["ManageMessages"] = 8192] = "ManageMessages";
183
- PermissionFlags2[PermissionFlags2["EmbedLinks"] = 16384] = "EmbedLinks";
184
- PermissionFlags2[PermissionFlags2["AttachFiles"] = 32768] = "AttachFiles";
185
- PermissionFlags2[PermissionFlags2["ReadMessageHistory"] = 65536] = "ReadMessageHistory";
186
- PermissionFlags2[PermissionFlags2["MentionEveryone"] = 131072] = "MentionEveryone";
187
- PermissionFlags2[PermissionFlags2["UseExternalEmojis"] = 262144] = "UseExternalEmojis";
188
- PermissionFlags2[PermissionFlags2["Connect"] = 1048576] = "Connect";
189
- PermissionFlags2[PermissionFlags2["Speak"] = 2097152] = "Speak";
190
- PermissionFlags2[PermissionFlags2["MuteMembers"] = 4194304] = "MuteMembers";
191
- PermissionFlags2[PermissionFlags2["DeafenMembers"] = 8388608] = "DeafenMembers";
192
- PermissionFlags2[PermissionFlags2["MoveMembers"] = 16777216] = "MoveMembers";
193
- PermissionFlags2[PermissionFlags2["UseVad"] = 33554432] = "UseVad";
194
- PermissionFlags2[PermissionFlags2["ChangeNickname"] = 67108864] = "ChangeNickname";
195
- PermissionFlags2[PermissionFlags2["ManageNicknames"] = 134217728] = "ManageNicknames";
196
- PermissionFlags2[PermissionFlags2["ManageRoles"] = 268435456] = "ManageRoles";
197
- PermissionFlags2[PermissionFlags2["ManageWebhooks"] = 536870912] = "ManageWebhooks";
198
- PermissionFlags2[PermissionFlags2["ManageEmojisAndStickers"] = 1073741824] = "ManageEmojisAndStickers";
199
- PermissionFlags2[PermissionFlags2["ManageExpressions"] = 1073741824] = "ManageExpressions";
200
- PermissionFlags2[PermissionFlags2["UseExternalStickers"] = 137438953472] = "UseExternalStickers";
201
- PermissionFlags2[PermissionFlags2["ModerateMembers"] = 1099511627776] = "ModerateMembers";
202
- PermissionFlags2[PermissionFlags2["CreateExpressions"] = 8796093022208] = "CreateExpressions";
203
- PermissionFlags2[PermissionFlags2["PinMessages"] = 2251799813685248] = "PinMessages";
204
- PermissionFlags2[PermissionFlags2["BypassSlowmode"] = 4503599627370496] = "BypassSlowmode";
205
- PermissionFlags2[PermissionFlags2["UpdateRtcRegion"] = 9007199254740992] = "UpdateRtcRegion";
206
- return PermissionFlags2;
207
- })(PermissionFlags || {});
208
- var PermissionFlagsMap = {};
209
- for (const [k, v] of Object.entries(PermissionFlags)) {
210
- if (typeof v === "number") PermissionFlagsMap[k] = v;
211
- }
212
- var ALL_PERMISSIONS_BIGINT = (() => {
213
- let acc = 0n;
214
- const seen = /* @__PURE__ */ new Set();
215
- for (const v of Object.values(PermissionFlagsMap)) {
216
- if (!seen.has(v)) {
217
- seen.add(v);
218
- acc |= BigInt(v);
219
- }
220
- }
221
- return acc;
222
- })();
176
+ var PermissionFlags = {
177
+ CreateInstantInvite: 1n << 0n,
178
+ KickMembers: 1n << 1n,
179
+ BanMembers: 1n << 2n,
180
+ Administrator: 1n << 3n,
181
+ ManageChannels: 1n << 4n,
182
+ ManageGuild: 1n << 5n,
183
+ AddReactions: 1n << 6n,
184
+ ViewAuditLog: 1n << 7n,
185
+ PrioritySpeaker: 1n << 8n,
186
+ Stream: 1n << 9n,
187
+ ViewChannel: 1n << 10n,
188
+ SendMessages: 1n << 11n,
189
+ SendTtsMessages: 1n << 12n,
190
+ ManageMessages: 1n << 13n,
191
+ EmbedLinks: 1n << 14n,
192
+ AttachFiles: 1n << 15n,
193
+ ReadMessageHistory: 1n << 16n,
194
+ MentionEveryone: 1n << 17n,
195
+ UseExternalEmojis: 1n << 18n,
196
+ Connect: 1n << 20n,
197
+ Speak: 1n << 21n,
198
+ MuteMembers: 1n << 22n,
199
+ DeafenMembers: 1n << 23n,
200
+ MoveMembers: 1n << 24n,
201
+ UseVad: 1n << 25n,
202
+ ChangeNickname: 1n << 26n,
203
+ ManageNicknames: 1n << 27n,
204
+ ManageRoles: 1n << 28n,
205
+ ManageWebhooks: 1n << 29n,
206
+ ManageEmojisAndStickers: 1n << 30n,
207
+ ManageExpressions: 1n << 30n,
208
+ UseExternalStickers: 1n << 37n,
209
+ ModerateMembers: 1n << 40n,
210
+ CreateExpressions: 1n << 43n,
211
+ PinMessages: 1n << 51n,
212
+ BypassSlowmode: 1n << 52n,
213
+ UpdateRtcRegion: 1n << 53n
214
+ };
215
+ var ALL_PERMISSIONS_BIGINT = Object.values(PermissionFlags).reduce((a, b) => a | b, 0n);
223
216
  var PermissionsBitField = class extends BitField {
224
- static Flags = PermissionFlagsMap;
217
+ static Flags = PermissionFlags;
225
218
  };
226
219
  function resolvePermissionsToBitfield(perms) {
227
220
  if (typeof perms === "string") {
228
221
  const num = Number(perms);
229
222
  if (!Number.isNaN(num) && perms.trim() !== "") return perms;
230
- const mapped = PermissionFlagsMap[perms];
223
+ const mapped = PermissionFlags[perms];
231
224
  if (mapped !== void 0) return String(mapped);
232
225
  throw new RangeError(`Invalid permission string: ${perms}`);
233
226
  }
@@ -240,7 +233,7 @@ function resolvePermissionsToBitfield(perms) {
240
233
  let v;
241
234
  if (typeof p === "number") v = BigInt(p);
242
235
  else if (typeof p === "string") {
243
- const mapped = PermissionFlagsMap[p];
236
+ const mapped = PermissionFlags[p];
244
237
  v = mapped !== void 0 ? BigInt(mapped) : BigInt(Number(p) || 0);
245
238
  } else v = BigInt(p.bitfield);
246
239
  acc |= v;
@@ -252,13 +245,13 @@ function resolvePermissionsToBitfield(perms) {
252
245
 
253
246
  // src/MessageFlagsBitField.ts
254
247
  var MessageFlagsBits = {
255
- SuppressEmbeds: 1 << 2,
248
+ SuppressEmbeds: 1n << 2n,
256
249
  // 4
257
- SuppressNotifications: 1 << 12,
250
+ SuppressNotifications: 1n << 12n,
258
251
  // 4096
259
- VoiceMessage: 1 << 13,
252
+ VoiceMessage: 1n << 13n,
260
253
  // 8192
261
- CompactAttachments: 1 << 17
254
+ CompactAttachments: 1n << 17n
262
255
  // 131072
263
256
  };
264
257
  var MessageFlagsBitField = class extends BitField {
@@ -267,38 +260,37 @@ var MessageFlagsBitField = class extends BitField {
267
260
 
268
261
  // src/UserFlagsBitField.ts
269
262
  var UserFlagsBits = {
270
- Staff: 1 << 0,
271
- CtpMember: 1 << 1,
272
- Partner: 1 << 2,
273
- BugHunter: 1 << 3,
274
- FriendlyBot: 1 << 4,
275
- FriendlyBotManualApproval: 1 << 5,
276
- HighGlobalRateLimit: 8589934592,
277
- Deleted: 17179869184,
278
- DisabledSuspiciousActivity: 34359738368,
279
- SelfDeleted: 68719476736,
280
- PremiumDiscriminator: 137438953472,
281
- Disabled: 274877906944,
282
- HasSessionStarted: 549755813888,
283
- PremiumBadgeHidden: 1099511627776,
284
- PremiumBadgeMasked: 2199023255552,
285
- PremiumBadgeTimestampHidden: 4398046511104,
286
- PremiumBadgeSequenceHidden: 8796093022208,
287
- PremiumPerksSanitized: 17592186044416,
288
- PremiumPurchaseDisabled: 35184372088832,
289
- PremiumEnabledOverride: 70368744177664,
290
- RateLimitBypass: 140737488355328,
291
- ReportBanned: 281474976710656,
292
- VerifiedNotUnderage: 562949953421312,
293
- PendingManualVerification: 1125899906842624,
294
- HasDismissedPremiumOnboarding: 2251799813685248,
295
- UsedMobileClient: 4503599627370496,
296
- // API int64 flags >= 2^53 (use exponentiation to avoid precision-loss lint).
297
- AppStoreReviewer: 2 ** 53,
298
- DmHistoryBackfilled: 2 ** 54,
299
- HasRelationshipsIndexed: 2 ** 55,
300
- MessagesByAuthorBackfilled: 2 ** 56,
301
- StaffHidden: 2 ** 57
263
+ Staff: 1n << 0n,
264
+ CtpMember: 1n << 1n,
265
+ Partner: 1n << 2n,
266
+ BugHunter: 1n << 3n,
267
+ FriendlyBot: 1n << 4n,
268
+ FriendlyBotManualApproval: 1n << 5n,
269
+ HighGlobalRateLimit: 1n << 33n,
270
+ Deleted: 1n << 34n,
271
+ DisabledSuspiciousActivity: 1n << 35n,
272
+ SelfDeleted: 1n << 36n,
273
+ PremiumDiscriminator: 1n << 37n,
274
+ Disabled: 1n << 38n,
275
+ HasSessionStarted: 1n << 39n,
276
+ PremiumBadgeHidden: 1n << 40n,
277
+ PremiumBadgeMasked: 1n << 41n,
278
+ PremiumBadgeTimestampHidden: 1n << 42n,
279
+ PremiumBadgeSequenceHidden: 1n << 43n,
280
+ PremiumPerksSanitized: 1n << 44n,
281
+ PremiumPurchaseDisabled: 1n << 45n,
282
+ PremiumEnabledOverride: 1n << 46n,
283
+ RateLimitBypass: 1n << 47n,
284
+ ReportBanned: 1n << 48n,
285
+ VerifiedNotUnderage: 1n << 49n,
286
+ PendingManualVerification: 1n << 50n,
287
+ HasDismissedPremiumOnboarding: 1n << 51n,
288
+ UsedMobileClient: 1n << 52n,
289
+ AppStoreReviewer: 1n << 53n,
290
+ DmHistoryBackfilled: 1n << 54n,
291
+ HasRelationshipsIndexed: 1n << 55n,
292
+ MessagesByAuthorBackfilled: 1n << 56n,
293
+ StaffHidden: 1n << 57n
302
294
  };
303
295
  var UserFlagsBitField = class extends BitField {
304
296
  static Flags = UserFlagsBits;
@@ -488,7 +480,6 @@ function emitDeprecationWarning(symbol, message) {
488
480
  MessageFlagsBitField,
489
481
  MessageFlagsBits,
490
482
  PermissionFlags,
491
- PermissionFlagsMap,
492
483
  PermissionsBitField,
493
484
  SnowflakeUtil,
494
485
  UserFlagsBitField,
package/dist/index.mjs CHANGED
@@ -4,26 +4,35 @@ var BitField = class _BitField {
4
4
  defaultBit = 0;
5
5
  bitfield;
6
6
  constructor(bits = 0) {
7
- const Ctor = this.constructor;
8
- this.bitfield = Ctor.resolve(bits);
7
+ this.bitfield = this.constructor.resolve(bits);
9
8
  }
10
9
  get [Symbol.toStringTag]() {
11
10
  return `BitField${this.bitfield}`;
12
11
  }
13
- static resolve(bit) {
14
- const Flags = this.Flags;
15
- if (typeof bit === "number" && bit >= 0) return bit;
16
- if (bit instanceof _BitField) return bit.bitfield;
17
- if (Array.isArray(bit)) return bit.map((b) => this.resolve(b)).reduce((a, b) => a | b, 0);
18
- if (typeof bit === "string" && typeof Flags[bit] !== "undefined") return Flags[bit];
19
- throw new RangeError(`Invalid bitfield flag or number: ${bit}`);
12
+ static resolve(bits) {
13
+ if (typeof bits === "number" && bits >= 0) return BigInt(bits);
14
+ if (typeof bits === "bigint" && bits >= 0n) return bits;
15
+ if (bits instanceof _BitField) return bits.bitfield;
16
+ if (Array.isArray(bits))
17
+ return bits.map((b) => this.resolve(b)).reduce((a, b) => BigInt(a) | BigInt(b), 0n);
18
+ if (typeof bits === "string") {
19
+ if (bits in this.Flags) {
20
+ return this.Flags[bits];
21
+ }
22
+ try {
23
+ const value = BigInt(bits);
24
+ if (value >= 0n) return value;
25
+ } catch {
26
+ }
27
+ }
28
+ throw new RangeError(`Invalid bitfield flag or number: ${bits}`);
20
29
  }
21
30
  has(bit) {
22
31
  bit = this.constructor.resolve(bit);
23
32
  return (this.bitfield & bit) === bit;
24
33
  }
25
34
  add(...bits) {
26
- let total = 0;
35
+ let total = 0n;
27
36
  for (const bit of bits) {
28
37
  total |= this.constructor.resolve(bit);
29
38
  }
@@ -31,7 +40,7 @@ var BitField = class _BitField {
31
40
  return this;
32
41
  }
33
42
  remove(...bits) {
34
- let total = 0;
43
+ let total = 0n;
35
44
  for (const bit of bits) {
36
45
  total |= this.constructor.resolve(bit);
37
46
  }
@@ -51,10 +60,10 @@ var BitField = class _BitField {
51
60
  return Object.entries(Flags).filter(([, value]) => (this.bitfield & value) === value).map(([key]) => key);
52
61
  }
53
62
  toJSON() {
54
- return this.bitfield;
63
+ return this.bitfield.toString();
55
64
  }
56
65
  valueOf() {
57
- return this.bitfield;
66
+ return this.bitfield.toString();
58
67
  }
59
68
  equals(bitfield) {
60
69
  return this.bitfield === bitfield.bitfield;
@@ -115,69 +124,54 @@ var SnowflakeUtil = class {
115
124
  };
116
125
 
117
126
  // src/PermissionsBitField.ts
118
- var PermissionFlags = /* @__PURE__ */ ((PermissionFlags2) => {
119
- PermissionFlags2[PermissionFlags2["CreateInstantInvite"] = 1] = "CreateInstantInvite";
120
- PermissionFlags2[PermissionFlags2["KickMembers"] = 2] = "KickMembers";
121
- PermissionFlags2[PermissionFlags2["BanMembers"] = 4] = "BanMembers";
122
- PermissionFlags2[PermissionFlags2["Administrator"] = 8] = "Administrator";
123
- PermissionFlags2[PermissionFlags2["ManageChannels"] = 16] = "ManageChannels";
124
- PermissionFlags2[PermissionFlags2["ManageGuild"] = 32] = "ManageGuild";
125
- PermissionFlags2[PermissionFlags2["AddReactions"] = 64] = "AddReactions";
126
- PermissionFlags2[PermissionFlags2["ViewAuditLog"] = 128] = "ViewAuditLog";
127
- PermissionFlags2[PermissionFlags2["PrioritySpeaker"] = 256] = "PrioritySpeaker";
128
- PermissionFlags2[PermissionFlags2["Stream"] = 512] = "Stream";
129
- PermissionFlags2[PermissionFlags2["ViewChannel"] = 1024] = "ViewChannel";
130
- PermissionFlags2[PermissionFlags2["SendMessages"] = 2048] = "SendMessages";
131
- PermissionFlags2[PermissionFlags2["SendTtsMessages"] = 4096] = "SendTtsMessages";
132
- PermissionFlags2[PermissionFlags2["ManageMessages"] = 8192] = "ManageMessages";
133
- PermissionFlags2[PermissionFlags2["EmbedLinks"] = 16384] = "EmbedLinks";
134
- PermissionFlags2[PermissionFlags2["AttachFiles"] = 32768] = "AttachFiles";
135
- PermissionFlags2[PermissionFlags2["ReadMessageHistory"] = 65536] = "ReadMessageHistory";
136
- PermissionFlags2[PermissionFlags2["MentionEveryone"] = 131072] = "MentionEveryone";
137
- PermissionFlags2[PermissionFlags2["UseExternalEmojis"] = 262144] = "UseExternalEmojis";
138
- PermissionFlags2[PermissionFlags2["Connect"] = 1048576] = "Connect";
139
- PermissionFlags2[PermissionFlags2["Speak"] = 2097152] = "Speak";
140
- PermissionFlags2[PermissionFlags2["MuteMembers"] = 4194304] = "MuteMembers";
141
- PermissionFlags2[PermissionFlags2["DeafenMembers"] = 8388608] = "DeafenMembers";
142
- PermissionFlags2[PermissionFlags2["MoveMembers"] = 16777216] = "MoveMembers";
143
- PermissionFlags2[PermissionFlags2["UseVad"] = 33554432] = "UseVad";
144
- PermissionFlags2[PermissionFlags2["ChangeNickname"] = 67108864] = "ChangeNickname";
145
- PermissionFlags2[PermissionFlags2["ManageNicknames"] = 134217728] = "ManageNicknames";
146
- PermissionFlags2[PermissionFlags2["ManageRoles"] = 268435456] = "ManageRoles";
147
- PermissionFlags2[PermissionFlags2["ManageWebhooks"] = 536870912] = "ManageWebhooks";
148
- PermissionFlags2[PermissionFlags2["ManageEmojisAndStickers"] = 1073741824] = "ManageEmojisAndStickers";
149
- PermissionFlags2[PermissionFlags2["ManageExpressions"] = 1073741824] = "ManageExpressions";
150
- PermissionFlags2[PermissionFlags2["UseExternalStickers"] = 137438953472] = "UseExternalStickers";
151
- PermissionFlags2[PermissionFlags2["ModerateMembers"] = 1099511627776] = "ModerateMembers";
152
- PermissionFlags2[PermissionFlags2["CreateExpressions"] = 8796093022208] = "CreateExpressions";
153
- PermissionFlags2[PermissionFlags2["PinMessages"] = 2251799813685248] = "PinMessages";
154
- PermissionFlags2[PermissionFlags2["BypassSlowmode"] = 4503599627370496] = "BypassSlowmode";
155
- PermissionFlags2[PermissionFlags2["UpdateRtcRegion"] = 9007199254740992] = "UpdateRtcRegion";
156
- return PermissionFlags2;
157
- })(PermissionFlags || {});
158
- var PermissionFlagsMap = {};
159
- for (const [k, v] of Object.entries(PermissionFlags)) {
160
- if (typeof v === "number") PermissionFlagsMap[k] = v;
161
- }
162
- var ALL_PERMISSIONS_BIGINT = (() => {
163
- let acc = 0n;
164
- const seen = /* @__PURE__ */ new Set();
165
- for (const v of Object.values(PermissionFlagsMap)) {
166
- if (!seen.has(v)) {
167
- seen.add(v);
168
- acc |= BigInt(v);
169
- }
170
- }
171
- return acc;
172
- })();
127
+ var PermissionFlags = {
128
+ CreateInstantInvite: 1n << 0n,
129
+ KickMembers: 1n << 1n,
130
+ BanMembers: 1n << 2n,
131
+ Administrator: 1n << 3n,
132
+ ManageChannels: 1n << 4n,
133
+ ManageGuild: 1n << 5n,
134
+ AddReactions: 1n << 6n,
135
+ ViewAuditLog: 1n << 7n,
136
+ PrioritySpeaker: 1n << 8n,
137
+ Stream: 1n << 9n,
138
+ ViewChannel: 1n << 10n,
139
+ SendMessages: 1n << 11n,
140
+ SendTtsMessages: 1n << 12n,
141
+ ManageMessages: 1n << 13n,
142
+ EmbedLinks: 1n << 14n,
143
+ AttachFiles: 1n << 15n,
144
+ ReadMessageHistory: 1n << 16n,
145
+ MentionEveryone: 1n << 17n,
146
+ UseExternalEmojis: 1n << 18n,
147
+ Connect: 1n << 20n,
148
+ Speak: 1n << 21n,
149
+ MuteMembers: 1n << 22n,
150
+ DeafenMembers: 1n << 23n,
151
+ MoveMembers: 1n << 24n,
152
+ UseVad: 1n << 25n,
153
+ ChangeNickname: 1n << 26n,
154
+ ManageNicknames: 1n << 27n,
155
+ ManageRoles: 1n << 28n,
156
+ ManageWebhooks: 1n << 29n,
157
+ ManageEmojisAndStickers: 1n << 30n,
158
+ ManageExpressions: 1n << 30n,
159
+ UseExternalStickers: 1n << 37n,
160
+ ModerateMembers: 1n << 40n,
161
+ CreateExpressions: 1n << 43n,
162
+ PinMessages: 1n << 51n,
163
+ BypassSlowmode: 1n << 52n,
164
+ UpdateRtcRegion: 1n << 53n
165
+ };
166
+ var ALL_PERMISSIONS_BIGINT = Object.values(PermissionFlags).reduce((a, b) => a | b, 0n);
173
167
  var PermissionsBitField = class extends BitField {
174
- static Flags = PermissionFlagsMap;
168
+ static Flags = PermissionFlags;
175
169
  };
176
170
  function resolvePermissionsToBitfield(perms) {
177
171
  if (typeof perms === "string") {
178
172
  const num = Number(perms);
179
173
  if (!Number.isNaN(num) && perms.trim() !== "") return perms;
180
- const mapped = PermissionFlagsMap[perms];
174
+ const mapped = PermissionFlags[perms];
181
175
  if (mapped !== void 0) return String(mapped);
182
176
  throw new RangeError(`Invalid permission string: ${perms}`);
183
177
  }
@@ -190,7 +184,7 @@ function resolvePermissionsToBitfield(perms) {
190
184
  let v;
191
185
  if (typeof p === "number") v = BigInt(p);
192
186
  else if (typeof p === "string") {
193
- const mapped = PermissionFlagsMap[p];
187
+ const mapped = PermissionFlags[p];
194
188
  v = mapped !== void 0 ? BigInt(mapped) : BigInt(Number(p) || 0);
195
189
  } else v = BigInt(p.bitfield);
196
190
  acc |= v;
@@ -202,13 +196,13 @@ function resolvePermissionsToBitfield(perms) {
202
196
 
203
197
  // src/MessageFlagsBitField.ts
204
198
  var MessageFlagsBits = {
205
- SuppressEmbeds: 1 << 2,
199
+ SuppressEmbeds: 1n << 2n,
206
200
  // 4
207
- SuppressNotifications: 1 << 12,
201
+ SuppressNotifications: 1n << 12n,
208
202
  // 4096
209
- VoiceMessage: 1 << 13,
203
+ VoiceMessage: 1n << 13n,
210
204
  // 8192
211
- CompactAttachments: 1 << 17
205
+ CompactAttachments: 1n << 17n
212
206
  // 131072
213
207
  };
214
208
  var MessageFlagsBitField = class extends BitField {
@@ -217,38 +211,37 @@ var MessageFlagsBitField = class extends BitField {
217
211
 
218
212
  // src/UserFlagsBitField.ts
219
213
  var UserFlagsBits = {
220
- Staff: 1 << 0,
221
- CtpMember: 1 << 1,
222
- Partner: 1 << 2,
223
- BugHunter: 1 << 3,
224
- FriendlyBot: 1 << 4,
225
- FriendlyBotManualApproval: 1 << 5,
226
- HighGlobalRateLimit: 8589934592,
227
- Deleted: 17179869184,
228
- DisabledSuspiciousActivity: 34359738368,
229
- SelfDeleted: 68719476736,
230
- PremiumDiscriminator: 137438953472,
231
- Disabled: 274877906944,
232
- HasSessionStarted: 549755813888,
233
- PremiumBadgeHidden: 1099511627776,
234
- PremiumBadgeMasked: 2199023255552,
235
- PremiumBadgeTimestampHidden: 4398046511104,
236
- PremiumBadgeSequenceHidden: 8796093022208,
237
- PremiumPerksSanitized: 17592186044416,
238
- PremiumPurchaseDisabled: 35184372088832,
239
- PremiumEnabledOverride: 70368744177664,
240
- RateLimitBypass: 140737488355328,
241
- ReportBanned: 281474976710656,
242
- VerifiedNotUnderage: 562949953421312,
243
- PendingManualVerification: 1125899906842624,
244
- HasDismissedPremiumOnboarding: 2251799813685248,
245
- UsedMobileClient: 4503599627370496,
246
- // API int64 flags >= 2^53 (use exponentiation to avoid precision-loss lint).
247
- AppStoreReviewer: 2 ** 53,
248
- DmHistoryBackfilled: 2 ** 54,
249
- HasRelationshipsIndexed: 2 ** 55,
250
- MessagesByAuthorBackfilled: 2 ** 56,
251
- StaffHidden: 2 ** 57
214
+ Staff: 1n << 0n,
215
+ CtpMember: 1n << 1n,
216
+ Partner: 1n << 2n,
217
+ BugHunter: 1n << 3n,
218
+ FriendlyBot: 1n << 4n,
219
+ FriendlyBotManualApproval: 1n << 5n,
220
+ HighGlobalRateLimit: 1n << 33n,
221
+ Deleted: 1n << 34n,
222
+ DisabledSuspiciousActivity: 1n << 35n,
223
+ SelfDeleted: 1n << 36n,
224
+ PremiumDiscriminator: 1n << 37n,
225
+ Disabled: 1n << 38n,
226
+ HasSessionStarted: 1n << 39n,
227
+ PremiumBadgeHidden: 1n << 40n,
228
+ PremiumBadgeMasked: 1n << 41n,
229
+ PremiumBadgeTimestampHidden: 1n << 42n,
230
+ PremiumBadgeSequenceHidden: 1n << 43n,
231
+ PremiumPerksSanitized: 1n << 44n,
232
+ PremiumPurchaseDisabled: 1n << 45n,
233
+ PremiumEnabledOverride: 1n << 46n,
234
+ RateLimitBypass: 1n << 47n,
235
+ ReportBanned: 1n << 48n,
236
+ VerifiedNotUnderage: 1n << 49n,
237
+ PendingManualVerification: 1n << 50n,
238
+ HasDismissedPremiumOnboarding: 1n << 51n,
239
+ UsedMobileClient: 1n << 52n,
240
+ AppStoreReviewer: 1n << 53n,
241
+ DmHistoryBackfilled: 1n << 54n,
242
+ HasRelationshipsIndexed: 1n << 55n,
243
+ MessagesByAuthorBackfilled: 1n << 56n,
244
+ StaffHidden: 1n << 57n
252
245
  };
253
246
  var UserFlagsBitField = class extends BitField {
254
247
  static Flags = UserFlagsBits;
@@ -437,7 +430,6 @@ export {
437
430
  MessageFlagsBitField,
438
431
  MessageFlagsBits,
439
432
  PermissionFlags,
440
- PermissionFlagsMap,
441
433
  PermissionsBitField,
442
434
  SnowflakeUtil,
443
435
  UserFlagsBitField,
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "1.2.2",
6
+ "version": "1.2.3",
7
7
  "description": "Shared utilities for @fluxerjs/core",
8
8
  "repository": {
9
9
  "type": "git",
@@ -20,7 +20,7 @@
20
20
  ],
21
21
  "license": "Apache-2.0",
22
22
  "dependencies": {
23
- "@fluxerjs/types": "1.2.2"
23
+ "@fluxerjs/types": "1.2.3"
24
24
  },
25
25
  "main": "./dist/index.js",
26
26
  "module": "./dist/index.mjs",