lunibee 0.1.6 → 0.1.7
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/README.md +3 -3
- package/dist/builders/commands.d.ts +37 -0
- package/dist/builders/components.d.ts +19 -12
- package/dist/builders/embed.d.ts +3 -1
- package/dist/builders/index.d.ts +1 -1
- package/dist/builders/index.js +146 -19
- package/dist/builders/index.js.map +8 -7
- package/dist/collection/index.d.ts +30 -0
- package/dist/collection/index.js +78 -5
- package/dist/collection/index.js.map +4 -4
- package/dist/core/events.d.ts +2 -0
- package/dist/core/index.d.ts +38 -0
- package/dist/core/index.js +754 -175
- package/dist/core/index.js.map +24 -22
- package/dist/core/permissions.d.ts +112 -53
- package/dist/formatters/index.d.ts +43 -3
- package/dist/formatters/index.js +64 -1
- package/dist/formatters/index.js.map +3 -3
- package/dist/handlers/index.js.map +2 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1762 -291
- package/dist/index.js.map +43 -38
- package/dist/managers/emoji.d.ts +38 -0
- package/dist/managers/guild.d.ts +112 -1
- package/dist/managers/index.d.ts +31 -1
- package/dist/managers/index.js +803 -77
- package/dist/managers/index.js.map +21 -20
- package/dist/rest/index.d.ts +101 -11
- package/dist/rest/index.js +301 -45
- package/dist/rest/index.js.map +8 -6
- package/dist/rest/redis.d.ts +37 -0
- package/dist/rest/routes.d.ts +22 -0
- package/dist/rest/store.d.ts +38 -0
- package/dist/rest/webhook.d.ts +2 -2
- package/dist/sharding/cluster.d.ts +61 -0
- package/dist/sharding/index.d.ts +8 -0
- package/dist/sharding/index.js +286 -18
- package/dist/sharding/index.js.map +8 -7
- package/dist/structures/audit-log.d.ts +26 -0
- package/dist/structures/base.d.ts +32 -0
- package/dist/structures/index.d.ts +29 -1
- package/dist/structures/index.js +1022 -86
- package/dist/structures/index.js.map +14 -10
- package/dist/structures/resources.d.ts +192 -4
- package/dist/types/index.d.ts +76 -0
- package/dist/types/index.js.map +2 -2
- package/dist/utils/index.js.map +2 -2
- package/dist/voice/index.d.ts +88 -0
- package/dist/voice/index.js +204 -5
- package/dist/voice/index.js.map +3 -3
- package/dist/ws/index.d.ts +40 -1
- package/dist/ws/index.js +102 -18
- package/dist/ws/index.js.map +4 -4
- package/package.json +16 -16
- package/dist/structures/permissions.d.ts +0 -73
package/dist/structures/index.js
CHANGED
|
@@ -141,6 +141,13 @@ class Guild extends BaseStructure {
|
|
|
141
141
|
vanityUrlCode;
|
|
142
142
|
nsfwLevel;
|
|
143
143
|
discoverySplash;
|
|
144
|
+
rulesChannelId;
|
|
145
|
+
systemChannelId;
|
|
146
|
+
systemChannelFlags;
|
|
147
|
+
maxMembers;
|
|
148
|
+
mfaLevel;
|
|
149
|
+
explicitContentFilter;
|
|
150
|
+
defaultMessageNotifications;
|
|
144
151
|
constructor(data) {
|
|
145
152
|
super(data.id);
|
|
146
153
|
if (!data.name)
|
|
@@ -162,6 +169,14 @@ class Guild extends BaseStructure {
|
|
|
162
169
|
this.vanityUrlCode = data.vanity_url_code ?? null;
|
|
163
170
|
this.nsfwLevel = data.nsfw_level ?? 0;
|
|
164
171
|
this.discoverySplash = data.discovery_splash ?? null;
|
|
172
|
+
const d = data;
|
|
173
|
+
this.rulesChannelId = d.rules_channel_id ?? null;
|
|
174
|
+
this.systemChannelId = d.system_channel_id ?? null;
|
|
175
|
+
this.systemChannelFlags = d.system_channel_flags ?? 0;
|
|
176
|
+
this.maxMembers = d.max_members ?? 0;
|
|
177
|
+
this.mfaLevel = d.mfa_level ?? 0;
|
|
178
|
+
this.explicitContentFilter = d.explicit_content_filter ?? 0;
|
|
179
|
+
this.defaultMessageNotifications = d.default_message_notifications ?? 0;
|
|
165
180
|
}
|
|
166
181
|
iconURL(options = {}) {
|
|
167
182
|
if (!this.icon)
|
|
@@ -183,12 +198,27 @@ class Guild extends BaseStructure {
|
|
|
183
198
|
return null;
|
|
184
199
|
return cdnURL(`/discovery-splashes/${this.id}`, this.discoverySplash, options);
|
|
185
200
|
}
|
|
201
|
+
widgetImageURL(style = "shield") {
|
|
202
|
+
return `https://discord.com/api/guilds/${this.id}/widget.png?style=${style}`;
|
|
203
|
+
}
|
|
186
204
|
hasFeature(feature) {
|
|
187
205
|
return this.features.includes(feature);
|
|
188
206
|
}
|
|
189
207
|
get isCommunity() {
|
|
190
208
|
return this.hasFeature("COMMUNITY");
|
|
191
209
|
}
|
|
210
|
+
get isPartnered() {
|
|
211
|
+
return this.hasFeature("PARTNERED");
|
|
212
|
+
}
|
|
213
|
+
get isVerified() {
|
|
214
|
+
return this.hasFeature("VERIFIED");
|
|
215
|
+
}
|
|
216
|
+
get isBoosted() {
|
|
217
|
+
return this.premiumSubscriptionCount > 0;
|
|
218
|
+
}
|
|
219
|
+
get boostLevel() {
|
|
220
|
+
return this.premiumTier;
|
|
221
|
+
}
|
|
192
222
|
get hasVanityUrl() {
|
|
193
223
|
return this.vanityUrlCode !== null;
|
|
194
224
|
}
|
|
@@ -199,7 +229,58 @@ class Guild extends BaseStructure {
|
|
|
199
229
|
return this.name;
|
|
200
230
|
}
|
|
201
231
|
}
|
|
202
|
-
// packages/
|
|
232
|
+
// packages/core/src/permissions.ts
|
|
233
|
+
var Permission = {
|
|
234
|
+
createInstantInvite: 1n << 0n,
|
|
235
|
+
kickMembers: 1n << 1n,
|
|
236
|
+
banMembers: 1n << 2n,
|
|
237
|
+
administrator: 1n << 3n,
|
|
238
|
+
manageChannels: 1n << 4n,
|
|
239
|
+
manageGuild: 1n << 5n,
|
|
240
|
+
addReactions: 1n << 6n,
|
|
241
|
+
viewAuditLog: 1n << 7n,
|
|
242
|
+
prioritySpeaker: 1n << 8n,
|
|
243
|
+
stream: 1n << 9n,
|
|
244
|
+
viewChannel: 1n << 10n,
|
|
245
|
+
sendMessages: 1n << 11n,
|
|
246
|
+
sendTTSMessages: 1n << 12n,
|
|
247
|
+
manageMessages: 1n << 13n,
|
|
248
|
+
embedLinks: 1n << 14n,
|
|
249
|
+
attachFiles: 1n << 15n,
|
|
250
|
+
readMessageHistory: 1n << 16n,
|
|
251
|
+
mentionEveryone: 1n << 17n,
|
|
252
|
+
useExternalEmojis: 1n << 18n,
|
|
253
|
+
viewGuildInsights: 1n << 19n,
|
|
254
|
+
connect: 1n << 20n,
|
|
255
|
+
speak: 1n << 21n,
|
|
256
|
+
muteMembers: 1n << 22n,
|
|
257
|
+
deafenMembers: 1n << 23n,
|
|
258
|
+
moveMembers: 1n << 24n,
|
|
259
|
+
useVAD: 1n << 25n,
|
|
260
|
+
changeNickname: 1n << 26n,
|
|
261
|
+
manageNicknames: 1n << 27n,
|
|
262
|
+
manageRoles: 1n << 28n,
|
|
263
|
+
manageWebhooks: 1n << 29n,
|
|
264
|
+
manageGuildExpressions: 1n << 30n,
|
|
265
|
+
useApplicationCommands: 1n << 31n,
|
|
266
|
+
requestToSpeak: 1n << 32n,
|
|
267
|
+
manageEvents: 1n << 33n,
|
|
268
|
+
manageThreads: 1n << 34n,
|
|
269
|
+
createPublicThreads: 1n << 35n,
|
|
270
|
+
createPrivateThreads: 1n << 36n,
|
|
271
|
+
useExternalStickers: 1n << 37n,
|
|
272
|
+
sendMessagesInThreads: 1n << 38n,
|
|
273
|
+
useEmbeddedActivities: 1n << 39n,
|
|
274
|
+
moderateMembers: 1n << 40n,
|
|
275
|
+
viewCreatorMonetizationAnalytics: 1n << 41n,
|
|
276
|
+
useSoundboard: 1n << 42n,
|
|
277
|
+
createGuildExpressions: 1n << 43n,
|
|
278
|
+
createEvents: 1n << 44n,
|
|
279
|
+
useExternalSounds: 1n << 45n,
|
|
280
|
+
sendVoiceMessages: 1n << 46n,
|
|
281
|
+
sendPolls: 1n << 49n,
|
|
282
|
+
useExternalApps: 1n << 50n
|
|
283
|
+
};
|
|
203
284
|
var Permissions = {
|
|
204
285
|
CreateInstantInvite: 1n << 0n,
|
|
205
286
|
KickMembers: 1n << 1n,
|
|
@@ -251,6 +332,57 @@ var Permissions = {
|
|
|
251
332
|
SendPolls: 1n << 49n,
|
|
252
333
|
UseExternalApps: 1n << 50n
|
|
253
334
|
};
|
|
335
|
+
var PermissionFlagsBits = {
|
|
336
|
+
CreateInstantInvite: 1n << 0n,
|
|
337
|
+
KickMembers: 1n << 1n,
|
|
338
|
+
BanMembers: 1n << 2n,
|
|
339
|
+
Administrator: 1n << 3n,
|
|
340
|
+
ManageChannels: 1n << 4n,
|
|
341
|
+
ManageGuild: 1n << 5n,
|
|
342
|
+
AddReactions: 1n << 6n,
|
|
343
|
+
ViewAuditLog: 1n << 7n,
|
|
344
|
+
PrioritySpeaker: 1n << 8n,
|
|
345
|
+
Stream: 1n << 9n,
|
|
346
|
+
ViewChannel: 1n << 10n,
|
|
347
|
+
SendMessages: 1n << 11n,
|
|
348
|
+
SendTTSMessages: 1n << 12n,
|
|
349
|
+
ManageMessages: 1n << 13n,
|
|
350
|
+
EmbedLinks: 1n << 14n,
|
|
351
|
+
AttachFiles: 1n << 15n,
|
|
352
|
+
ReadMessageHistory: 1n << 16n,
|
|
353
|
+
MentionEveryone: 1n << 17n,
|
|
354
|
+
UseExternalEmojis: 1n << 18n,
|
|
355
|
+
ViewGuildInsights: 1n << 19n,
|
|
356
|
+
Connect: 1n << 20n,
|
|
357
|
+
Speak: 1n << 21n,
|
|
358
|
+
MuteMembers: 1n << 22n,
|
|
359
|
+
DeafenMembers: 1n << 23n,
|
|
360
|
+
MoveMembers: 1n << 24n,
|
|
361
|
+
UseVAD: 1n << 25n,
|
|
362
|
+
ChangeNickname: 1n << 26n,
|
|
363
|
+
ManageNicknames: 1n << 27n,
|
|
364
|
+
ManageRoles: 1n << 28n,
|
|
365
|
+
ManageWebhooks: 1n << 29n,
|
|
366
|
+
ManageGuildExpressions: 1n << 30n,
|
|
367
|
+
UseApplicationCommands: 1n << 31n,
|
|
368
|
+
RequestToSpeak: 1n << 32n,
|
|
369
|
+
ManageEvents: 1n << 33n,
|
|
370
|
+
ManageThreads: 1n << 34n,
|
|
371
|
+
CreatePublicThreads: 1n << 35n,
|
|
372
|
+
CreatePrivateThreads: 1n << 36n,
|
|
373
|
+
UseExternalStickers: 1n << 37n,
|
|
374
|
+
SendMessagesInThreads: 1n << 38n,
|
|
375
|
+
UseEmbeddedActivities: 1n << 39n,
|
|
376
|
+
ModerateMembers: 1n << 40n,
|
|
377
|
+
ViewCreatorMonetizationAnalytics: 1n << 41n,
|
|
378
|
+
UseSoundboard: 1n << 42n,
|
|
379
|
+
CreateGuildExpressions: 1n << 43n,
|
|
380
|
+
CreateEvents: 1n << 44n,
|
|
381
|
+
UseExternalSounds: 1n << 45n,
|
|
382
|
+
SendVoiceMessages: 1n << 46n,
|
|
383
|
+
SendPolls: 1n << 49n,
|
|
384
|
+
UseExternalApps: 1n << 50n
|
|
385
|
+
};
|
|
254
386
|
|
|
255
387
|
class PermissionSet {
|
|
256
388
|
bitfield;
|
|
@@ -258,8 +390,9 @@ class PermissionSet {
|
|
|
258
390
|
try {
|
|
259
391
|
if (Array.isArray(value)) {
|
|
260
392
|
let bit = 0n;
|
|
261
|
-
for (const item of value)
|
|
393
|
+
for (const item of value) {
|
|
262
394
|
bit |= this.#resolve(item);
|
|
395
|
+
}
|
|
263
396
|
this.bitfield = bit;
|
|
264
397
|
} else if (value instanceof PermissionSet) {
|
|
265
398
|
this.bitfield = value.bitfield;
|
|
@@ -275,22 +408,195 @@ class PermissionSet {
|
|
|
275
408
|
throw new TypeError("Permission bitfield must be a valid non-negative integer.", { cause: error });
|
|
276
409
|
}
|
|
277
410
|
}
|
|
411
|
+
get createInstantInvite() {
|
|
412
|
+
return (this.bitfield & Permission.createInstantInvite) === Permission.createInstantInvite;
|
|
413
|
+
}
|
|
414
|
+
get kickMembers() {
|
|
415
|
+
return (this.bitfield & Permission.kickMembers) === Permission.kickMembers;
|
|
416
|
+
}
|
|
417
|
+
get banMembers() {
|
|
418
|
+
return (this.bitfield & Permission.banMembers) === Permission.banMembers;
|
|
419
|
+
}
|
|
420
|
+
get administrator() {
|
|
421
|
+
return (this.bitfield & Permission.administrator) === Permission.administrator;
|
|
422
|
+
}
|
|
423
|
+
get manageChannels() {
|
|
424
|
+
return (this.bitfield & Permission.manageChannels) === Permission.manageChannels;
|
|
425
|
+
}
|
|
426
|
+
get manageGuild() {
|
|
427
|
+
return (this.bitfield & Permission.manageGuild) === Permission.manageGuild;
|
|
428
|
+
}
|
|
429
|
+
get addReactions() {
|
|
430
|
+
return (this.bitfield & Permission.addReactions) === Permission.addReactions;
|
|
431
|
+
}
|
|
432
|
+
get viewAuditLog() {
|
|
433
|
+
return (this.bitfield & Permission.viewAuditLog) === Permission.viewAuditLog;
|
|
434
|
+
}
|
|
435
|
+
get prioritySpeaker() {
|
|
436
|
+
return (this.bitfield & Permission.prioritySpeaker) === Permission.prioritySpeaker;
|
|
437
|
+
}
|
|
438
|
+
get stream() {
|
|
439
|
+
return (this.bitfield & Permission.stream) === Permission.stream;
|
|
440
|
+
}
|
|
441
|
+
get viewChannel() {
|
|
442
|
+
return (this.bitfield & Permission.viewChannel) === Permission.viewChannel;
|
|
443
|
+
}
|
|
444
|
+
get sendMessages() {
|
|
445
|
+
return (this.bitfield & Permission.sendMessages) === Permission.sendMessages;
|
|
446
|
+
}
|
|
447
|
+
get sendTTSMessages() {
|
|
448
|
+
return (this.bitfield & Permission.sendTTSMessages) === Permission.sendTTSMessages;
|
|
449
|
+
}
|
|
450
|
+
get manageMessages() {
|
|
451
|
+
return (this.bitfield & Permission.manageMessages) === Permission.manageMessages;
|
|
452
|
+
}
|
|
453
|
+
get embedLinks() {
|
|
454
|
+
return (this.bitfield & Permission.embedLinks) === Permission.embedLinks;
|
|
455
|
+
}
|
|
456
|
+
get attachFiles() {
|
|
457
|
+
return (this.bitfield & Permission.attachFiles) === Permission.attachFiles;
|
|
458
|
+
}
|
|
459
|
+
get readMessageHistory() {
|
|
460
|
+
return (this.bitfield & Permission.readMessageHistory) === Permission.readMessageHistory;
|
|
461
|
+
}
|
|
462
|
+
get mentionEveryone() {
|
|
463
|
+
return (this.bitfield & Permission.mentionEveryone) === Permission.mentionEveryone;
|
|
464
|
+
}
|
|
465
|
+
get useExternalEmojis() {
|
|
466
|
+
return (this.bitfield & Permission.useExternalEmojis) === Permission.useExternalEmojis;
|
|
467
|
+
}
|
|
468
|
+
get viewGuildInsights() {
|
|
469
|
+
return (this.bitfield & Permission.viewGuildInsights) === Permission.viewGuildInsights;
|
|
470
|
+
}
|
|
471
|
+
get connect() {
|
|
472
|
+
return (this.bitfield & Permission.connect) === Permission.connect;
|
|
473
|
+
}
|
|
474
|
+
get speak() {
|
|
475
|
+
return (this.bitfield & Permission.speak) === Permission.speak;
|
|
476
|
+
}
|
|
477
|
+
get muteMembers() {
|
|
478
|
+
return (this.bitfield & Permission.muteMembers) === Permission.muteMembers;
|
|
479
|
+
}
|
|
480
|
+
get deafenMembers() {
|
|
481
|
+
return (this.bitfield & Permission.deafenMembers) === Permission.deafenMembers;
|
|
482
|
+
}
|
|
483
|
+
get moveMembers() {
|
|
484
|
+
return (this.bitfield & Permission.moveMembers) === Permission.moveMembers;
|
|
485
|
+
}
|
|
486
|
+
get useVAD() {
|
|
487
|
+
return (this.bitfield & Permission.useVAD) === Permission.useVAD;
|
|
488
|
+
}
|
|
489
|
+
get changeNickname() {
|
|
490
|
+
return (this.bitfield & Permission.changeNickname) === Permission.changeNickname;
|
|
491
|
+
}
|
|
492
|
+
get manageNicknames() {
|
|
493
|
+
return (this.bitfield & Permission.manageNicknames) === Permission.manageNicknames;
|
|
494
|
+
}
|
|
495
|
+
get manageRoles() {
|
|
496
|
+
return (this.bitfield & Permission.manageRoles) === Permission.manageRoles;
|
|
497
|
+
}
|
|
498
|
+
get manageWebhooks() {
|
|
499
|
+
return (this.bitfield & Permission.manageWebhooks) === Permission.manageWebhooks;
|
|
500
|
+
}
|
|
501
|
+
get manageGuildExpressions() {
|
|
502
|
+
return (this.bitfield & Permission.manageGuildExpressions) === Permission.manageGuildExpressions;
|
|
503
|
+
}
|
|
504
|
+
get useApplicationCommands() {
|
|
505
|
+
return (this.bitfield & Permission.useApplicationCommands) === Permission.useApplicationCommands;
|
|
506
|
+
}
|
|
507
|
+
get requestToSpeak() {
|
|
508
|
+
return (this.bitfield & Permission.requestToSpeak) === Permission.requestToSpeak;
|
|
509
|
+
}
|
|
510
|
+
get manageEvents() {
|
|
511
|
+
return (this.bitfield & Permission.manageEvents) === Permission.manageEvents;
|
|
512
|
+
}
|
|
513
|
+
get manageThreads() {
|
|
514
|
+
return (this.bitfield & Permission.manageThreads) === Permission.manageThreads;
|
|
515
|
+
}
|
|
516
|
+
get createPublicThreads() {
|
|
517
|
+
return (this.bitfield & Permission.createPublicThreads) === Permission.createPublicThreads;
|
|
518
|
+
}
|
|
519
|
+
get createPrivateThreads() {
|
|
520
|
+
return (this.bitfield & Permission.createPrivateThreads) === Permission.createPrivateThreads;
|
|
521
|
+
}
|
|
522
|
+
get useExternalStickers() {
|
|
523
|
+
return (this.bitfield & Permission.useExternalStickers) === Permission.useExternalStickers;
|
|
524
|
+
}
|
|
525
|
+
get sendMessagesInThreads() {
|
|
526
|
+
return (this.bitfield & Permission.sendMessagesInThreads) === Permission.sendMessagesInThreads;
|
|
527
|
+
}
|
|
528
|
+
get useEmbeddedActivities() {
|
|
529
|
+
return (this.bitfield & Permission.useEmbeddedActivities) === Permission.useEmbeddedActivities;
|
|
530
|
+
}
|
|
531
|
+
get moderateMembers() {
|
|
532
|
+
return (this.bitfield & Permission.moderateMembers) === Permission.moderateMembers;
|
|
533
|
+
}
|
|
534
|
+
get viewCreatorMonetizationAnalytics() {
|
|
535
|
+
return (this.bitfield & Permission.viewCreatorMonetizationAnalytics) === Permission.viewCreatorMonetizationAnalytics;
|
|
536
|
+
}
|
|
537
|
+
get useSoundboard() {
|
|
538
|
+
return (this.bitfield & Permission.useSoundboard) === Permission.useSoundboard;
|
|
539
|
+
}
|
|
540
|
+
get createGuildExpressions() {
|
|
541
|
+
return (this.bitfield & Permission.createGuildExpressions) === Permission.createGuildExpressions;
|
|
542
|
+
}
|
|
543
|
+
get createEvents() {
|
|
544
|
+
return (this.bitfield & Permission.createEvents) === Permission.createEvents;
|
|
545
|
+
}
|
|
546
|
+
get useExternalSounds() {
|
|
547
|
+
return (this.bitfield & Permission.useExternalSounds) === Permission.useExternalSounds;
|
|
548
|
+
}
|
|
549
|
+
get sendVoiceMessages() {
|
|
550
|
+
return (this.bitfield & Permission.sendVoiceMessages) === Permission.sendVoiceMessages;
|
|
551
|
+
}
|
|
552
|
+
get sendPolls() {
|
|
553
|
+
return (this.bitfield & Permission.sendPolls) === Permission.sendPolls;
|
|
554
|
+
}
|
|
555
|
+
get useExternalApps() {
|
|
556
|
+
return (this.bitfield & Permission.useExternalApps) === Permission.useExternalApps;
|
|
557
|
+
}
|
|
278
558
|
has(...permissions) {
|
|
279
|
-
|
|
559
|
+
if (permissions.length === 1) {
|
|
560
|
+
const p = permissions[0];
|
|
561
|
+
const bit = typeof p === "bigint" ? p : this.#resolve(p);
|
|
562
|
+
return (this.bitfield & bit) === bit;
|
|
563
|
+
}
|
|
564
|
+
for (let i = 0;i < permissions.length; i++) {
|
|
565
|
+
const p = permissions[i];
|
|
566
|
+
const bit = typeof p === "bigint" ? p : this.#resolve(p);
|
|
567
|
+
if ((this.bitfield & bit) !== bit)
|
|
568
|
+
return false;
|
|
569
|
+
}
|
|
570
|
+
return true;
|
|
280
571
|
}
|
|
281
572
|
any(...permissions) {
|
|
282
|
-
|
|
573
|
+
if (permissions.length === 1) {
|
|
574
|
+
const p = permissions[0];
|
|
575
|
+
const bit = typeof p === "bigint" ? p : this.#resolve(p);
|
|
576
|
+
return (this.bitfield & bit) !== 0n;
|
|
577
|
+
}
|
|
578
|
+
for (let i = 0;i < permissions.length; i++) {
|
|
579
|
+
const p = permissions[i];
|
|
580
|
+
const bit = typeof p === "bigint" ? p : this.#resolve(p);
|
|
581
|
+
if ((this.bitfield & bit) !== 0n)
|
|
582
|
+
return true;
|
|
583
|
+
}
|
|
584
|
+
return false;
|
|
283
585
|
}
|
|
284
586
|
add(...permissions) {
|
|
285
587
|
let bitfield = this.bitfield;
|
|
286
|
-
for (
|
|
287
|
-
|
|
588
|
+
for (let i = 0;i < permissions.length; i++) {
|
|
589
|
+
const p = permissions[i];
|
|
590
|
+
bitfield |= typeof p === "bigint" ? p : this.#resolve(p);
|
|
591
|
+
}
|
|
288
592
|
return new PermissionSet(bitfield);
|
|
289
593
|
}
|
|
290
594
|
remove(...permissions) {
|
|
291
595
|
let bitfield = this.bitfield;
|
|
292
|
-
for (
|
|
293
|
-
|
|
596
|
+
for (let i = 0;i < permissions.length; i++) {
|
|
597
|
+
const p = permissions[i];
|
|
598
|
+
bitfield &= ~(typeof p === "bigint" ? p : this.#resolve(p));
|
|
599
|
+
}
|
|
294
600
|
return new PermissionSet(bitfield);
|
|
295
601
|
}
|
|
296
602
|
equals(other) {
|
|
@@ -300,27 +606,31 @@ class PermissionSet {
|
|
|
300
606
|
return this.bitfield.toString();
|
|
301
607
|
}
|
|
302
608
|
toArray() {
|
|
303
|
-
return Object.keys(
|
|
609
|
+
return Object.keys(Permission).filter((permission) => this.has(permission));
|
|
304
610
|
}
|
|
305
611
|
#resolve(permission) {
|
|
306
|
-
if (permission instanceof PermissionSet)
|
|
307
|
-
return permission.bitfield;
|
|
308
612
|
if (typeof permission === "bigint")
|
|
309
613
|
return permission;
|
|
310
614
|
if (typeof permission === "number")
|
|
311
615
|
return BigInt(permission);
|
|
616
|
+
if (permission instanceof PermissionSet)
|
|
617
|
+
return permission.bitfield;
|
|
312
618
|
if (Array.isArray(permission)) {
|
|
313
619
|
let bit = 0n;
|
|
314
|
-
for (
|
|
315
|
-
bit |= this.#resolve(
|
|
620
|
+
for (let i = 0;i < permission.length; i++)
|
|
621
|
+
bit |= this.#resolve(permission[i]);
|
|
316
622
|
return bit;
|
|
317
623
|
}
|
|
318
624
|
if (typeof permission === "string") {
|
|
625
|
+
if (permission in Permission)
|
|
626
|
+
return Permission[permission];
|
|
319
627
|
if (permission in Permissions)
|
|
320
628
|
return Permissions[permission];
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
629
|
+
if (permission in PermissionFlagsBits)
|
|
630
|
+
return PermissionFlagsBits[permission];
|
|
631
|
+
const lower = permission.charAt(0).toLowerCase() + permission.slice(1);
|
|
632
|
+
if (lower in Permission)
|
|
633
|
+
return Permission[lower];
|
|
324
634
|
return BigInt(permission);
|
|
325
635
|
}
|
|
326
636
|
return 0n;
|
|
@@ -328,12 +638,357 @@ class PermissionSet {
|
|
|
328
638
|
}
|
|
329
639
|
|
|
330
640
|
class PermissionsBitField extends PermissionSet {
|
|
641
|
+
static Flags = PermissionFlagsBits;
|
|
642
|
+
static All = Permission;
|
|
331
643
|
constructor(value = 0n) {
|
|
332
644
|
super(value);
|
|
333
645
|
}
|
|
334
646
|
}
|
|
647
|
+
// packages/types/src/index.ts
|
|
648
|
+
var GatewayIntentBits = {
|
|
649
|
+
Guilds: 1 << 0,
|
|
650
|
+
GuildMembers: 1 << 1,
|
|
651
|
+
GuildModeration: 1 << 2,
|
|
652
|
+
GuildExpressions: 1 << 3,
|
|
653
|
+
GuildIntegrations: 1 << 4,
|
|
654
|
+
GuildWebhooks: 1 << 5,
|
|
655
|
+
GuildInvites: 1 << 6,
|
|
656
|
+
GuildVoiceStates: 1 << 7,
|
|
657
|
+
GuildPresences: 1 << 8,
|
|
658
|
+
GuildMessages: 1 << 9,
|
|
659
|
+
GuildMessageReactions: 1 << 10,
|
|
660
|
+
GuildMessageTyping: 1 << 11,
|
|
661
|
+
DirectMessages: 1 << 12,
|
|
662
|
+
DirectMessageReactions: 1 << 13,
|
|
663
|
+
DirectMessageTyping: 1 << 14,
|
|
664
|
+
MessageContent: 1 << 15,
|
|
665
|
+
GuildScheduledEvents: 1 << 16,
|
|
666
|
+
AutoModerationConfiguration: 1 << 20,
|
|
667
|
+
AutoModerationExecution: 1 << 21,
|
|
668
|
+
GuildMessagePolls: 1 << 24,
|
|
669
|
+
DirectMessagePolls: 1 << 25
|
|
670
|
+
};
|
|
671
|
+
var IntentBits = {
|
|
672
|
+
guild: 1 << 0,
|
|
673
|
+
guilds: 1 << 0,
|
|
674
|
+
guildMembers: 1 << 1,
|
|
675
|
+
guildModeration: 1 << 2,
|
|
676
|
+
guildBans: 1 << 2,
|
|
677
|
+
guildExpressions: 1 << 3,
|
|
678
|
+
guildEmojis: 1 << 3,
|
|
679
|
+
guildEmojisAndStickers: 1 << 3,
|
|
680
|
+
guildIntegrations: 1 << 4,
|
|
681
|
+
guildWebhooks: 1 << 5,
|
|
682
|
+
guildInvites: 1 << 6,
|
|
683
|
+
guildVoiceStates: 1 << 7,
|
|
684
|
+
guildPresences: 1 << 8,
|
|
685
|
+
guildMessages: 1 << 9,
|
|
686
|
+
guildMessage: 1 << 9,
|
|
687
|
+
guildMessageReactions: 1 << 10,
|
|
688
|
+
guildMessageTyping: 1 << 11,
|
|
689
|
+
directMessages: 1 << 12,
|
|
690
|
+
directMessageReactions: 1 << 13,
|
|
691
|
+
directMessageTyping: 1 << 14,
|
|
692
|
+
messageContent: 1 << 15,
|
|
693
|
+
guildScheduledEvents: 1 << 16,
|
|
694
|
+
autoModerationConfiguration: 1 << 20,
|
|
695
|
+
autoModerationExecution: 1 << 21,
|
|
696
|
+
guildMessagePolls: 1 << 24,
|
|
697
|
+
directMessagePolls: 1 << 25
|
|
698
|
+
};
|
|
699
|
+
var InteractionResponseType = {
|
|
700
|
+
Pong: 1,
|
|
701
|
+
ChannelMessage: 4,
|
|
702
|
+
DeferredChannelMessage: 5,
|
|
703
|
+
DeferredMessageUpdate: 6,
|
|
704
|
+
MessageUpdate: 7,
|
|
705
|
+
Autocomplete: 8,
|
|
706
|
+
Modal: 9
|
|
707
|
+
};
|
|
708
|
+
// packages/collection/src/index.ts
|
|
709
|
+
class Collection extends Map {
|
|
710
|
+
first() {
|
|
711
|
+
for (const value of this.values())
|
|
712
|
+
return value;
|
|
713
|
+
return;
|
|
714
|
+
}
|
|
715
|
+
firstKey() {
|
|
716
|
+
for (const key of this.keys())
|
|
717
|
+
return key;
|
|
718
|
+
return;
|
|
719
|
+
}
|
|
720
|
+
last() {
|
|
721
|
+
let value;
|
|
722
|
+
for (const item of this.values())
|
|
723
|
+
value = item;
|
|
724
|
+
return value;
|
|
725
|
+
}
|
|
726
|
+
lastKey() {
|
|
727
|
+
let key;
|
|
728
|
+
for (const item of this.keys())
|
|
729
|
+
key = item;
|
|
730
|
+
return key;
|
|
731
|
+
}
|
|
732
|
+
find(predicate) {
|
|
733
|
+
for (const [key, value] of this) {
|
|
734
|
+
if (predicate(value, key, this))
|
|
735
|
+
return value;
|
|
736
|
+
}
|
|
737
|
+
return;
|
|
738
|
+
}
|
|
739
|
+
filter(predicate) {
|
|
740
|
+
const result = new Collection;
|
|
741
|
+
for (const [key, value] of this) {
|
|
742
|
+
if (predicate(value, key, this))
|
|
743
|
+
result.set(key, value);
|
|
744
|
+
}
|
|
745
|
+
return result;
|
|
746
|
+
}
|
|
747
|
+
map(transform) {
|
|
748
|
+
const result = [];
|
|
749
|
+
for (const [key, value] of this) {
|
|
750
|
+
result.push(transform(value, key, this));
|
|
751
|
+
}
|
|
752
|
+
return result;
|
|
753
|
+
}
|
|
754
|
+
some(predicate) {
|
|
755
|
+
for (const [key, value] of this) {
|
|
756
|
+
if (predicate(value, key, this))
|
|
757
|
+
return true;
|
|
758
|
+
}
|
|
759
|
+
return false;
|
|
760
|
+
}
|
|
761
|
+
every(predicate) {
|
|
762
|
+
for (const [key, value] of this) {
|
|
763
|
+
if (!predicate(value, key, this))
|
|
764
|
+
return false;
|
|
765
|
+
}
|
|
766
|
+
return true;
|
|
767
|
+
}
|
|
768
|
+
each(callback) {
|
|
769
|
+
for (const [key, value] of this) {
|
|
770
|
+
callback(value, key, this);
|
|
771
|
+
}
|
|
772
|
+
return this;
|
|
773
|
+
}
|
|
774
|
+
array() {
|
|
775
|
+
return [...this.values()];
|
|
776
|
+
}
|
|
777
|
+
keyArray() {
|
|
778
|
+
return [...this.keys()];
|
|
779
|
+
}
|
|
780
|
+
entriesArray() {
|
|
781
|
+
return [...this.entries()];
|
|
782
|
+
}
|
|
783
|
+
clone() {
|
|
784
|
+
const copy = new Collection;
|
|
785
|
+
for (const [key, value] of this)
|
|
786
|
+
copy.set(key, value);
|
|
787
|
+
return copy;
|
|
788
|
+
}
|
|
789
|
+
hasAll(...keys) {
|
|
790
|
+
for (let i = 0;i < keys.length; i++) {
|
|
791
|
+
if (!this.has(keys[i]))
|
|
792
|
+
return false;
|
|
793
|
+
}
|
|
794
|
+
return true;
|
|
795
|
+
}
|
|
796
|
+
hasAny(...keys) {
|
|
797
|
+
for (let i = 0;i < keys.length; i++) {
|
|
798
|
+
if (this.has(keys[i]))
|
|
799
|
+
return true;
|
|
800
|
+
}
|
|
801
|
+
return false;
|
|
802
|
+
}
|
|
803
|
+
findKey(predicate) {
|
|
804
|
+
for (const [key, value] of this) {
|
|
805
|
+
if (predicate(value, key, this))
|
|
806
|
+
return key;
|
|
807
|
+
}
|
|
808
|
+
return;
|
|
809
|
+
}
|
|
810
|
+
someEntry(predicate) {
|
|
811
|
+
return this.some(predicate);
|
|
812
|
+
}
|
|
813
|
+
sweep(predicate) {
|
|
814
|
+
let removed = 0;
|
|
815
|
+
for (const [key, value] of this) {
|
|
816
|
+
if (predicate(value, key, this) && this.delete(key))
|
|
817
|
+
removed++;
|
|
818
|
+
}
|
|
819
|
+
return removed;
|
|
820
|
+
}
|
|
821
|
+
firstEntry() {
|
|
822
|
+
for (const [key, value] of this)
|
|
823
|
+
return [key, value];
|
|
824
|
+
return;
|
|
825
|
+
}
|
|
826
|
+
lastEntry() {
|
|
827
|
+
let entry;
|
|
828
|
+
for (const item of this)
|
|
829
|
+
entry = [item[0], item[1]];
|
|
830
|
+
return entry;
|
|
831
|
+
}
|
|
832
|
+
union(other) {
|
|
833
|
+
const result = this.clone();
|
|
834
|
+
for (const [key, value] of other)
|
|
835
|
+
result.set(key, value);
|
|
836
|
+
return result;
|
|
837
|
+
}
|
|
838
|
+
intersection(other) {
|
|
839
|
+
const result = new Collection;
|
|
840
|
+
for (const [key, value] of this) {
|
|
841
|
+
if (other.has(key))
|
|
842
|
+
result.set(key, value);
|
|
843
|
+
}
|
|
844
|
+
return result;
|
|
845
|
+
}
|
|
846
|
+
difference(other) {
|
|
847
|
+
const result = new Collection;
|
|
848
|
+
for (const [key, value] of this) {
|
|
849
|
+
if (!other.has(key))
|
|
850
|
+
result.set(key, value);
|
|
851
|
+
}
|
|
852
|
+
return result;
|
|
853
|
+
}
|
|
854
|
+
partition(predicate) {
|
|
855
|
+
const pass = new Collection;
|
|
856
|
+
const fail = new Collection;
|
|
857
|
+
for (const [key, value] of this) {
|
|
858
|
+
if (predicate(value, key, this))
|
|
859
|
+
pass.set(key, value);
|
|
860
|
+
else
|
|
861
|
+
fail.set(key, value);
|
|
862
|
+
}
|
|
863
|
+
return [pass, fail];
|
|
864
|
+
}
|
|
865
|
+
tap(fn) {
|
|
866
|
+
fn(this);
|
|
867
|
+
return this;
|
|
868
|
+
}
|
|
869
|
+
flatMap(transform) {
|
|
870
|
+
const result = [];
|
|
871
|
+
for (const [key, value] of this) {
|
|
872
|
+
for (const item of transform(value, key, this))
|
|
873
|
+
result.push(item);
|
|
874
|
+
}
|
|
875
|
+
return result;
|
|
876
|
+
}
|
|
877
|
+
reduce(fn, initialValue) {
|
|
878
|
+
let acc = initialValue;
|
|
879
|
+
for (const [key, value] of this)
|
|
880
|
+
acc = fn(acc, value, key, this);
|
|
881
|
+
return acc;
|
|
882
|
+
}
|
|
883
|
+
sorted(comparator) {
|
|
884
|
+
const decorated = [...this.entries()].map((entry, index) => ({
|
|
885
|
+
entry,
|
|
886
|
+
index
|
|
887
|
+
}));
|
|
888
|
+
if (comparator)
|
|
889
|
+
decorated.sort((x, y) => {
|
|
890
|
+
const comparison = comparator(x.entry[1], y.entry[1], x.entry[0], y.entry[0]);
|
|
891
|
+
return comparison !== 0 ? comparison : x.index - y.index;
|
|
892
|
+
});
|
|
893
|
+
const result = new Collection;
|
|
894
|
+
for (const { entry } of decorated)
|
|
895
|
+
result.set(entry[0], entry[1]);
|
|
896
|
+
return result;
|
|
897
|
+
}
|
|
898
|
+
random() {
|
|
899
|
+
const arr = [...this.values()];
|
|
900
|
+
if (!arr.length)
|
|
901
|
+
return;
|
|
902
|
+
return arr[Math.floor(Math.random() * arr.length)];
|
|
903
|
+
}
|
|
904
|
+
randomKey() {
|
|
905
|
+
const arr = [...this.keys()];
|
|
906
|
+
if (!arr.length)
|
|
907
|
+
return;
|
|
908
|
+
return arr[Math.floor(Math.random() * arr.length)];
|
|
909
|
+
}
|
|
910
|
+
at(index) {
|
|
911
|
+
const arr = [...this.values()];
|
|
912
|
+
const i = index < 0 ? arr.length + index : index;
|
|
913
|
+
return arr[i];
|
|
914
|
+
}
|
|
915
|
+
keyAt(index) {
|
|
916
|
+
const arr = [...this.keys()];
|
|
917
|
+
const i = index < 0 ? arr.length + index : index;
|
|
918
|
+
return arr[i];
|
|
919
|
+
}
|
|
920
|
+
toJSON() {
|
|
921
|
+
return [...this.entries()];
|
|
922
|
+
}
|
|
923
|
+
}
|
|
335
924
|
|
|
925
|
+
// packages/managers/src/base.ts
|
|
926
|
+
class Manager {
|
|
927
|
+
cache = new Collection;
|
|
928
|
+
get(id) {
|
|
929
|
+
return this.cache.get(id);
|
|
930
|
+
}
|
|
931
|
+
has(id) {
|
|
932
|
+
return this.cache.has(id);
|
|
933
|
+
}
|
|
934
|
+
set(id, value) {
|
|
935
|
+
this.cache.set(id, value);
|
|
936
|
+
return this;
|
|
937
|
+
}
|
|
938
|
+
delete(id) {
|
|
939
|
+
return this.cache.delete(id);
|
|
940
|
+
}
|
|
941
|
+
clear() {
|
|
942
|
+
this.cache.clear();
|
|
943
|
+
}
|
|
944
|
+
get size() {
|
|
945
|
+
return this.cache.size;
|
|
946
|
+
}
|
|
947
|
+
first() {
|
|
948
|
+
return this.cache.first();
|
|
949
|
+
}
|
|
950
|
+
values() {
|
|
951
|
+
return this.cache.array();
|
|
952
|
+
}
|
|
953
|
+
find(predicate) {
|
|
954
|
+
return this.cache.find(predicate);
|
|
955
|
+
}
|
|
956
|
+
[Symbol.iterator]() {
|
|
957
|
+
return this.cache[Symbol.iterator]();
|
|
958
|
+
}
|
|
959
|
+
}
|
|
960
|
+
// packages/rest/package.json
|
|
961
|
+
var package_default = {
|
|
962
|
+
name: "@lunibee/rest",
|
|
963
|
+
version: "0.1.7",
|
|
964
|
+
type: "module",
|
|
965
|
+
module: "./src/index.ts",
|
|
966
|
+
types: "./src/index.ts",
|
|
967
|
+
exports: {
|
|
968
|
+
".": "./src/index.ts"
|
|
969
|
+
}
|
|
970
|
+
};
|
|
971
|
+
// packages/rest/src/index.ts
|
|
972
|
+
var LIBRARY_VERSION = package_default.version;
|
|
973
|
+
var LIBRARY_URL = "https://github.com/Ekretos/lunibee";
|
|
974
|
+
var USER_AGENT = `DiscordBot (${LIBRARY_URL}, ${package_default.version})`;
|
|
975
|
+
var REQUEST_DATA_KEYS = new Set([
|
|
976
|
+
"body",
|
|
977
|
+
"files",
|
|
978
|
+
"query",
|
|
979
|
+
"headers",
|
|
980
|
+
"reason",
|
|
981
|
+
"auth",
|
|
982
|
+
"signal"
|
|
983
|
+
]);
|
|
336
984
|
// packages/structures/src/resources.ts
|
|
985
|
+
function toDateOrNull(value) {
|
|
986
|
+
if (!value)
|
|
987
|
+
return null;
|
|
988
|
+
const date = new Date(value);
|
|
989
|
+
return Number.isNaN(date.getTime()) ? null : date;
|
|
990
|
+
}
|
|
991
|
+
|
|
337
992
|
class GuildMember {
|
|
338
993
|
user;
|
|
339
994
|
guildId;
|
|
@@ -342,6 +997,10 @@ class GuildMember {
|
|
|
342
997
|
pending;
|
|
343
998
|
joinedAt;
|
|
344
999
|
permissions;
|
|
1000
|
+
avatarHash;
|
|
1001
|
+
premiumSince;
|
|
1002
|
+
timedOutUntil;
|
|
1003
|
+
flags;
|
|
345
1004
|
constructor(data) {
|
|
346
1005
|
this.user = new User(data.user);
|
|
347
1006
|
if (!/^\d{1,20}$/.test(data.guild_id))
|
|
@@ -354,10 +1013,25 @@ class GuildMember {
|
|
|
354
1013
|
if (this.joinedAt?.toString() === "Invalid Date")
|
|
355
1014
|
throw new RangeError("Member joined_at must be a valid date.");
|
|
356
1015
|
this.permissions = new PermissionsBitField(data.permissions ?? 0n);
|
|
1016
|
+
this.avatarHash = data.avatar ?? null;
|
|
1017
|
+
this.premiumSince = toDateOrNull(data.premium_since);
|
|
1018
|
+
this.timedOutUntil = toDateOrNull(data.communication_disabled_until);
|
|
1019
|
+
this.flags = data.flags ?? 0;
|
|
357
1020
|
}
|
|
358
1021
|
get displayName() {
|
|
359
1022
|
return this.nickname ?? this.user.displayName;
|
|
360
1023
|
}
|
|
1024
|
+
get isTimedOut() {
|
|
1025
|
+
return this.timedOutUntil !== null && this.timedOutUntil > new Date;
|
|
1026
|
+
}
|
|
1027
|
+
avatarURL(options = {}) {
|
|
1028
|
+
if (this.avatarHash)
|
|
1029
|
+
return cdnURL(`/guilds/${this.guildId}/users/${this.user.id}/avatars`, this.avatarHash, options);
|
|
1030
|
+
return this.user.avatarURL(options);
|
|
1031
|
+
}
|
|
1032
|
+
displayAvatarURL(options = {}) {
|
|
1033
|
+
return this.avatarURL(options) ?? this.user.displayAvatarURL(options);
|
|
1034
|
+
}
|
|
361
1035
|
toString() {
|
|
362
1036
|
return this.user.toString();
|
|
363
1037
|
}
|
|
@@ -370,6 +1044,10 @@ class Role extends BaseStructure {
|
|
|
370
1044
|
permissions;
|
|
371
1045
|
managed;
|
|
372
1046
|
mentionable;
|
|
1047
|
+
position;
|
|
1048
|
+
unicodeEmoji;
|
|
1049
|
+
iconHash;
|
|
1050
|
+
tags;
|
|
373
1051
|
constructor(data) {
|
|
374
1052
|
super(data.id);
|
|
375
1053
|
if (!data.name)
|
|
@@ -380,6 +1058,21 @@ class Role extends BaseStructure {
|
|
|
380
1058
|
this.permissions = new PermissionsBitField(data.permissions ?? 0n);
|
|
381
1059
|
this.managed = data.managed ?? false;
|
|
382
1060
|
this.mentionable = data.mentionable ?? false;
|
|
1061
|
+
this.position = data.position ?? 0;
|
|
1062
|
+
this.unicodeEmoji = data.unicode_emoji ?? null;
|
|
1063
|
+
this.iconHash = data.icon ?? null;
|
|
1064
|
+
this.tags = data.tags ?? null;
|
|
1065
|
+
}
|
|
1066
|
+
get colorHex() {
|
|
1067
|
+
return `#${this.color.toString(16).padStart(6, "0").toUpperCase()}`;
|
|
1068
|
+
}
|
|
1069
|
+
iconURL(options = {}) {
|
|
1070
|
+
if (!this.iconHash)
|
|
1071
|
+
return null;
|
|
1072
|
+
return cdnURL(`/role-icons/${this.id}`, this.iconHash, options);
|
|
1073
|
+
}
|
|
1074
|
+
isEveryone(guildId) {
|
|
1075
|
+
return this.id === guildId;
|
|
383
1076
|
}
|
|
384
1077
|
toString() {
|
|
385
1078
|
return `<@&${this.id}>`;
|
|
@@ -394,68 +1087,218 @@ class TextChannel extends Channel {
|
|
|
394
1087
|
return `<#${this.id}>`;
|
|
395
1088
|
}
|
|
396
1089
|
}
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
guildPresences: 1 << 8,
|
|
435
|
-
guildMessages: 1 << 9,
|
|
436
|
-
guildMessage: 1 << 9,
|
|
437
|
-
guildMessageReactions: 1 << 10,
|
|
438
|
-
guildMessageTyping: 1 << 11,
|
|
439
|
-
directMessages: 1 << 12,
|
|
440
|
-
directMessageReactions: 1 << 13,
|
|
441
|
-
directMessageTyping: 1 << 14,
|
|
442
|
-
messageContent: 1 << 15,
|
|
443
|
-
guildScheduledEvents: 1 << 16,
|
|
444
|
-
autoModerationConfiguration: 1 << 20,
|
|
445
|
-
autoModerationExecution: 1 << 21,
|
|
446
|
-
guildMessagePolls: 1 << 24,
|
|
447
|
-
directMessagePolls: 1 << 25
|
|
448
|
-
};
|
|
449
|
-
var InteractionResponseType = {
|
|
450
|
-
Pong: 1,
|
|
451
|
-
ChannelMessage: 4,
|
|
452
|
-
DeferredChannelMessage: 5,
|
|
453
|
-
DeferredMessageUpdate: 6,
|
|
454
|
-
MessageUpdate: 7,
|
|
455
|
-
Autocomplete: 8,
|
|
456
|
-
Modal: 9
|
|
1090
|
+
|
|
1091
|
+
class Invite {
|
|
1092
|
+
code;
|
|
1093
|
+
guildId;
|
|
1094
|
+
channelId;
|
|
1095
|
+
inviter;
|
|
1096
|
+
uses;
|
|
1097
|
+
maxUses;
|
|
1098
|
+
maxAge;
|
|
1099
|
+
temporary;
|
|
1100
|
+
createdAt;
|
|
1101
|
+
expiresAt;
|
|
1102
|
+
constructor(data) {
|
|
1103
|
+
if (!data.code)
|
|
1104
|
+
throw new TypeError("An invite requires a code.");
|
|
1105
|
+
this.code = data.code;
|
|
1106
|
+
this.guildId = data.guild?.id ?? null;
|
|
1107
|
+
this.channelId = data.channel?.id ?? null;
|
|
1108
|
+
this.inviter = data.inviter ? new User(data.inviter) : null;
|
|
1109
|
+
this.uses = data.uses ?? 0;
|
|
1110
|
+
this.maxUses = data.max_uses ?? 0;
|
|
1111
|
+
this.maxAge = data.max_age ?? 0;
|
|
1112
|
+
this.temporary = data.temporary ?? false;
|
|
1113
|
+
this.createdAt = data.created_at ? new Date(data.created_at) : null;
|
|
1114
|
+
this.expiresAt = data.expires_at ? new Date(data.expires_at) : null;
|
|
1115
|
+
}
|
|
1116
|
+
get url() {
|
|
1117
|
+
return `https://discord.gg/${this.code}`;
|
|
1118
|
+
}
|
|
1119
|
+
toString() {
|
|
1120
|
+
return this.url;
|
|
1121
|
+
}
|
|
1122
|
+
}
|
|
1123
|
+
var WebhookType = {
|
|
1124
|
+
Incoming: 1,
|
|
1125
|
+
ChannelFollower: 2,
|
|
1126
|
+
Application: 3
|
|
457
1127
|
};
|
|
458
1128
|
|
|
1129
|
+
class Webhook extends BaseStructure {
|
|
1130
|
+
type;
|
|
1131
|
+
name;
|
|
1132
|
+
avatarHash;
|
|
1133
|
+
channelId;
|
|
1134
|
+
guildId;
|
|
1135
|
+
applicationId;
|
|
1136
|
+
token;
|
|
1137
|
+
constructor(data) {
|
|
1138
|
+
super(data.id);
|
|
1139
|
+
this.type = data.type ?? WebhookType.Incoming;
|
|
1140
|
+
this.name = data.name ?? null;
|
|
1141
|
+
this.avatarHash = data.avatar ?? null;
|
|
1142
|
+
this.channelId = data.channel_id ?? null;
|
|
1143
|
+
this.guildId = data.guild_id ?? null;
|
|
1144
|
+
this.applicationId = data.application_id ?? null;
|
|
1145
|
+
this.token = data.token ?? null;
|
|
1146
|
+
}
|
|
1147
|
+
avatarURL(options = {}) {
|
|
1148
|
+
if (!this.avatarHash)
|
|
1149
|
+
return null;
|
|
1150
|
+
return cdnURL(`/avatars/${this.id}`, this.avatarHash, options);
|
|
1151
|
+
}
|
|
1152
|
+
get url() {
|
|
1153
|
+
return this.token ? `https://discord.com/api/webhooks/${this.id}/${this.token}` : null;
|
|
1154
|
+
}
|
|
1155
|
+
toString() {
|
|
1156
|
+
return this.url ?? this.id;
|
|
1157
|
+
}
|
|
1158
|
+
}
|
|
1159
|
+
|
|
1160
|
+
class Emoji extends BaseStructure {
|
|
1161
|
+
name;
|
|
1162
|
+
roleIds;
|
|
1163
|
+
user;
|
|
1164
|
+
requireColons;
|
|
1165
|
+
managed;
|
|
1166
|
+
animated;
|
|
1167
|
+
available;
|
|
1168
|
+
constructor(data) {
|
|
1169
|
+
super(data.id ?? "unicode");
|
|
1170
|
+
this.name = data.name;
|
|
1171
|
+
this.roleIds = data.roles ?? [];
|
|
1172
|
+
this.user = data.user ? new User(data.user) : null;
|
|
1173
|
+
this.requireColons = data.require_colons ?? false;
|
|
1174
|
+
this.managed = data.managed ?? false;
|
|
1175
|
+
this.animated = data.animated ?? false;
|
|
1176
|
+
this.available = data.available ?? true;
|
|
1177
|
+
}
|
|
1178
|
+
url(options = {}) {
|
|
1179
|
+
if (!this.id || this.id === "unicode")
|
|
1180
|
+
return null;
|
|
1181
|
+
const ext = options.extension ?? (this.animated ? "gif" : "png");
|
|
1182
|
+
const size = options.size ? `?size=${options.size}` : "";
|
|
1183
|
+
return `${CDN_BASE}/emojis/${this.id}.${ext}${size}`;
|
|
1184
|
+
}
|
|
1185
|
+
toString() {
|
|
1186
|
+
return this.id !== "unicode" ? `<${this.animated ? "a" : ""}:${this.name}:${this.id}>` : this.name ?? "";
|
|
1187
|
+
}
|
|
1188
|
+
}
|
|
1189
|
+
|
|
1190
|
+
class AutoModerationRule extends BaseStructure {
|
|
1191
|
+
guildId;
|
|
1192
|
+
name;
|
|
1193
|
+
creatorId;
|
|
1194
|
+
eventType;
|
|
1195
|
+
triggerType;
|
|
1196
|
+
triggerMetadata;
|
|
1197
|
+
actions;
|
|
1198
|
+
enabled;
|
|
1199
|
+
exemptRoles;
|
|
1200
|
+
exemptChannels;
|
|
1201
|
+
constructor(data) {
|
|
1202
|
+
super(data.id);
|
|
1203
|
+
if (!/^\d{1,20}$/.test(data.guild_id))
|
|
1204
|
+
throw new TypeError("AutoModerationRule guild_id must be a valid snowflake.");
|
|
1205
|
+
this.guildId = data.guild_id;
|
|
1206
|
+
this.name = data.name;
|
|
1207
|
+
this.creatorId = data.creator_id;
|
|
1208
|
+
this.eventType = data.event_type;
|
|
1209
|
+
this.triggerType = data.trigger_type;
|
|
1210
|
+
this.triggerMetadata = data.trigger_metadata;
|
|
1211
|
+
this.actions = data.actions;
|
|
1212
|
+
this.enabled = data.enabled;
|
|
1213
|
+
this.exemptRoles = data.exempt_roles;
|
|
1214
|
+
this.exemptChannels = data.exempt_channels;
|
|
1215
|
+
}
|
|
1216
|
+
toJSON() {
|
|
1217
|
+
return {
|
|
1218
|
+
id: this.id,
|
|
1219
|
+
guildId: this.guildId,
|
|
1220
|
+
name: this.name,
|
|
1221
|
+
creatorId: this.creatorId,
|
|
1222
|
+
eventType: this.eventType,
|
|
1223
|
+
triggerType: this.triggerType,
|
|
1224
|
+
triggerMetadata: this.triggerMetadata,
|
|
1225
|
+
actions: this.actions,
|
|
1226
|
+
enabled: this.enabled,
|
|
1227
|
+
exemptRoles: this.exemptRoles,
|
|
1228
|
+
exemptChannels: this.exemptChannels
|
|
1229
|
+
};
|
|
1230
|
+
}
|
|
1231
|
+
}
|
|
1232
|
+
|
|
1233
|
+
class WelcomeScreenChannel {
|
|
1234
|
+
channelId;
|
|
1235
|
+
description;
|
|
1236
|
+
emojiId;
|
|
1237
|
+
emojiName;
|
|
1238
|
+
constructor(data) {
|
|
1239
|
+
this.channelId = data.channel_id;
|
|
1240
|
+
this.description = data.description;
|
|
1241
|
+
this.emojiId = data.emoji_id;
|
|
1242
|
+
this.emojiName = data.emoji_name;
|
|
1243
|
+
}
|
|
1244
|
+
}
|
|
1245
|
+
|
|
1246
|
+
class GuildWelcomeScreen2 {
|
|
1247
|
+
description;
|
|
1248
|
+
channels;
|
|
1249
|
+
constructor(data) {
|
|
1250
|
+
this.description = data.description;
|
|
1251
|
+
this.channels = data.welcome_channels.map((c) => new WelcomeScreenChannel(c));
|
|
1252
|
+
}
|
|
1253
|
+
}
|
|
1254
|
+
|
|
1255
|
+
class OnboardingPromptOption extends BaseStructure {
|
|
1256
|
+
channelIds;
|
|
1257
|
+
roleIds;
|
|
1258
|
+
emoji;
|
|
1259
|
+
title;
|
|
1260
|
+
description;
|
|
1261
|
+
constructor(data) {
|
|
1262
|
+
super(data.id);
|
|
1263
|
+
this.channelIds = data.channel_ids;
|
|
1264
|
+
this.roleIds = data.role_ids;
|
|
1265
|
+
this.emoji = data.emoji;
|
|
1266
|
+
this.title = data.title;
|
|
1267
|
+
this.description = data.description;
|
|
1268
|
+
}
|
|
1269
|
+
}
|
|
1270
|
+
|
|
1271
|
+
class OnboardingPrompt extends BaseStructure {
|
|
1272
|
+
type;
|
|
1273
|
+
options;
|
|
1274
|
+
title;
|
|
1275
|
+
singleSelect;
|
|
1276
|
+
required;
|
|
1277
|
+
inOnboarding;
|
|
1278
|
+
constructor(data) {
|
|
1279
|
+
super(data.id);
|
|
1280
|
+
this.type = data.type;
|
|
1281
|
+
this.options = data.options.map((o) => new OnboardingPromptOption(o));
|
|
1282
|
+
this.title = data.title;
|
|
1283
|
+
this.singleSelect = data.single_select;
|
|
1284
|
+
this.required = data.required;
|
|
1285
|
+
this.inOnboarding = data.in_onboarding;
|
|
1286
|
+
}
|
|
1287
|
+
}
|
|
1288
|
+
|
|
1289
|
+
class GuildOnboarding2 extends BaseStructure {
|
|
1290
|
+
prompts;
|
|
1291
|
+
defaultChannelIds;
|
|
1292
|
+
enabled;
|
|
1293
|
+
mode;
|
|
1294
|
+
constructor(data) {
|
|
1295
|
+
super(data.guild_id);
|
|
1296
|
+
this.prompts = data.prompts.map((p) => new OnboardingPrompt(p));
|
|
1297
|
+
this.defaultChannelIds = data.default_channel_ids;
|
|
1298
|
+
this.enabled = data.enabled;
|
|
1299
|
+
this.mode = data.mode;
|
|
1300
|
+
}
|
|
1301
|
+
}
|
|
459
1302
|
// packages/structures/src/interactions.ts
|
|
460
1303
|
var InteractionType = {
|
|
461
1304
|
Ping: 1,
|
|
@@ -652,7 +1495,7 @@ class InteractionResponse {
|
|
|
652
1495
|
}
|
|
653
1496
|
}
|
|
654
1497
|
|
|
655
|
-
class
|
|
1498
|
+
class Interaction2 {
|
|
656
1499
|
id;
|
|
657
1500
|
applicationId;
|
|
658
1501
|
token;
|
|
@@ -737,7 +1580,7 @@ class Interaction {
|
|
|
737
1580
|
}
|
|
738
1581
|
}
|
|
739
1582
|
|
|
740
|
-
class CommandInteraction extends
|
|
1583
|
+
class CommandInteraction extends Interaction2 {
|
|
741
1584
|
options;
|
|
742
1585
|
get commandName() {
|
|
743
1586
|
return typeof this.data.data?.name === "string" ? this.data.data.name : "";
|
|
@@ -746,12 +1589,11 @@ class CommandInteraction extends Interaction {
|
|
|
746
1589
|
super(client, data);
|
|
747
1590
|
const rawOptions = data.data?.options ?? [];
|
|
748
1591
|
const resolved = data.data?.resolved ?? {};
|
|
749
|
-
|
|
750
|
-
this.options = new CommandOptions(sub?.options ?? rawOptions, resolved);
|
|
1592
|
+
this.options = new CommandOptions(rawOptions, resolved);
|
|
751
1593
|
}
|
|
752
1594
|
}
|
|
753
1595
|
|
|
754
|
-
class ComponentInteraction extends
|
|
1596
|
+
class ComponentInteraction extends Interaction2 {
|
|
755
1597
|
get customId() {
|
|
756
1598
|
return this.data?.data?.custom_id ?? "";
|
|
757
1599
|
}
|
|
@@ -775,7 +1617,7 @@ class ComponentInteraction extends Interaction {
|
|
|
775
1617
|
}
|
|
776
1618
|
}
|
|
777
1619
|
|
|
778
|
-
class ModalSubmitInteraction extends
|
|
1620
|
+
class ModalSubmitInteraction extends Interaction2 {
|
|
779
1621
|
get customId() {
|
|
780
1622
|
return this.data?.data?.custom_id ?? "";
|
|
781
1623
|
}
|
|
@@ -797,7 +1639,7 @@ class ModalSubmitInteraction extends Interaction {
|
|
|
797
1639
|
}
|
|
798
1640
|
}
|
|
799
1641
|
|
|
800
|
-
class AutocompleteInteraction extends
|
|
1642
|
+
class AutocompleteInteraction extends Interaction2 {
|
|
801
1643
|
get commandName() {
|
|
802
1644
|
return this.data?.data?.name ?? "";
|
|
803
1645
|
}
|
|
@@ -836,7 +1678,7 @@ function createInteraction(client, data) {
|
|
|
836
1678
|
case InteractionType.ModalSubmit:
|
|
837
1679
|
return new ModalSubmitInteraction(client, data);
|
|
838
1680
|
default:
|
|
839
|
-
return new
|
|
1681
|
+
return new Interaction2(client, data);
|
|
840
1682
|
}
|
|
841
1683
|
}
|
|
842
1684
|
// packages/structures/src/embed.ts
|
|
@@ -977,8 +1819,38 @@ class Embed {
|
|
|
977
1819
|
return new Embed(data);
|
|
978
1820
|
}
|
|
979
1821
|
}
|
|
1822
|
+
// packages/structures/src/audit-log.ts
|
|
1823
|
+
class AuditLogEntry extends BaseStructure {
|
|
1824
|
+
targetId;
|
|
1825
|
+
userId;
|
|
1826
|
+
actionType;
|
|
1827
|
+
changes;
|
|
1828
|
+
options;
|
|
1829
|
+
reason;
|
|
1830
|
+
constructor(data) {
|
|
1831
|
+
super(data.id);
|
|
1832
|
+
this.targetId = data.target_id;
|
|
1833
|
+
this.userId = data.user_id;
|
|
1834
|
+
this.actionType = data.action_type;
|
|
1835
|
+
this.changes = data.changes ?? [];
|
|
1836
|
+
this.options = data.options ?? null;
|
|
1837
|
+
this.reason = data.reason ?? null;
|
|
1838
|
+
}
|
|
1839
|
+
}
|
|
1840
|
+
|
|
1841
|
+
class AuditLog {
|
|
1842
|
+
entries;
|
|
1843
|
+
constructor(data) {
|
|
1844
|
+
this.entries = new Map;
|
|
1845
|
+
for (const entryData of data.audit_log_entries) {
|
|
1846
|
+
this.entries.set(entryData.id, new AuditLogEntry(entryData));
|
|
1847
|
+
}
|
|
1848
|
+
}
|
|
1849
|
+
}
|
|
980
1850
|
|
|
981
1851
|
// packages/structures/src/index.ts
|
|
1852
|
+
var NON_SYSTEM_MESSAGE_TYPES = new Set([0, 19, 20, 23]);
|
|
1853
|
+
|
|
982
1854
|
class Message extends BaseStructure {
|
|
983
1855
|
content;
|
|
984
1856
|
author;
|
|
@@ -1024,6 +1896,12 @@ class Message extends BaseStructure {
|
|
|
1024
1896
|
get embedsSuppressed() {
|
|
1025
1897
|
return (this.flags & 4) !== 0;
|
|
1026
1898
|
}
|
|
1899
|
+
get createdTimestamp() {
|
|
1900
|
+
return this.timestamp.getTime();
|
|
1901
|
+
}
|
|
1902
|
+
get createdAt() {
|
|
1903
|
+
return this.timestamp;
|
|
1904
|
+
}
|
|
1027
1905
|
edit(options) {
|
|
1028
1906
|
if (!this.#context)
|
|
1029
1907
|
throw new Error("This message is not attached to a client.");
|
|
@@ -1078,8 +1956,56 @@ class Message extends BaseStructure {
|
|
|
1078
1956
|
throw new Error("This message is not attached to a client.");
|
|
1079
1957
|
return this.#context.unpinMessage(this.channelId, this.id);
|
|
1080
1958
|
}
|
|
1959
|
+
get isEphemeral() {
|
|
1960
|
+
return (this.flags & 64) !== 0;
|
|
1961
|
+
}
|
|
1962
|
+
get isPinned() {
|
|
1963
|
+
return this.pinned;
|
|
1964
|
+
}
|
|
1965
|
+
get isSystemMessage() {
|
|
1966
|
+
return !NON_SYSTEM_MESSAGE_TYPES.has(this.type);
|
|
1967
|
+
}
|
|
1968
|
+
get isCrosspost() {
|
|
1969
|
+
return (this.flags & 2) !== 0;
|
|
1970
|
+
}
|
|
1971
|
+
get hasAttachments() {
|
|
1972
|
+
return this.attachments.length > 0;
|
|
1973
|
+
}
|
|
1974
|
+
get hasEmbeds() {
|
|
1975
|
+
return this.embeds.length > 0;
|
|
1976
|
+
}
|
|
1977
|
+
get hasComponents() {
|
|
1978
|
+
return this.components.length > 0;
|
|
1979
|
+
}
|
|
1980
|
+
suppressEmbeds() {
|
|
1981
|
+
return this.edit({ flags: this.flags | 4 });
|
|
1982
|
+
}
|
|
1983
|
+
toJSON() {
|
|
1984
|
+
return {
|
|
1985
|
+
id: this.id,
|
|
1986
|
+
content: this.content,
|
|
1987
|
+
channelId: this.channelId,
|
|
1988
|
+
guildId: this.guildId,
|
|
1989
|
+
flags: this.flags,
|
|
1990
|
+
pinned: this.pinned,
|
|
1991
|
+
mentionEveryone: this.mentionEveryone,
|
|
1992
|
+
type: this.type,
|
|
1993
|
+
timestamp: this.timestamp.toISOString(),
|
|
1994
|
+
author: { id: this.author.id, username: this.author.username },
|
|
1995
|
+
attachments: [...this.attachments],
|
|
1996
|
+
embeds: [...this.embeds],
|
|
1997
|
+
components: [...this.components],
|
|
1998
|
+
mentions: this.mentions.map((u) => u.id),
|
|
1999
|
+
mentionRoles: [...this.mentionRoles],
|
|
2000
|
+
reference: this.reference,
|
|
2001
|
+
referencedMessage: this.referencedMessage ? this.referencedMessage.id : this.referencedMessage
|
|
2002
|
+
};
|
|
2003
|
+
}
|
|
1081
2004
|
}
|
|
1082
2005
|
export {
|
|
2006
|
+
AuditLog,
|
|
2007
|
+
AuditLogEntry,
|
|
2008
|
+
AutoModerationRule,
|
|
1083
2009
|
AutocompleteInteraction,
|
|
1084
2010
|
BaseStructure,
|
|
1085
2011
|
Channel,
|
|
@@ -1087,18 +2013,28 @@ export {
|
|
|
1087
2013
|
CommandOptions,
|
|
1088
2014
|
ComponentInteraction,
|
|
1089
2015
|
Embed,
|
|
2016
|
+
Emoji,
|
|
1090
2017
|
Guild,
|
|
1091
2018
|
GuildMember,
|
|
1092
|
-
|
|
2019
|
+
GuildOnboarding2 as GuildOnboarding,
|
|
2020
|
+
GuildWelcomeScreen2 as GuildWelcomeScreen,
|
|
2021
|
+
Interaction2 as Interaction,
|
|
1093
2022
|
InteractionResponse,
|
|
1094
2023
|
InteractionResponseType,
|
|
1095
2024
|
InteractionType,
|
|
2025
|
+
Invite,
|
|
1096
2026
|
Message,
|
|
1097
2027
|
ModalSubmitInteraction,
|
|
2028
|
+
OnboardingPrompt,
|
|
2029
|
+
OnboardingPromptOption,
|
|
2030
|
+
PermissionsBitField,
|
|
1098
2031
|
Role,
|
|
1099
2032
|
TextChannel,
|
|
1100
2033
|
User,
|
|
2034
|
+
Webhook,
|
|
2035
|
+
WebhookType,
|
|
2036
|
+
WelcomeScreenChannel,
|
|
1101
2037
|
createInteraction
|
|
1102
2038
|
};
|
|
1103
2039
|
|
|
1104
|
-
//# debugId=
|
|
2040
|
+
//# debugId=889BE16B7674B4BA64756E2164756E21
|