@fluxerjs/core 3.2.0 → 3.3.0
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/{SubpathMessage-DW9TgPNl.d.mts → SubpathMessage-CNJlnR6y.d.mts} +2174 -1928
- package/dist/{SubpathMessage-DHo7ltTz.d.ts → SubpathMessage-DjLo6il5.d.ts} +2174 -1928
- package/dist/{Sudo-DwxTf-jj.d.mts → Sudo-mzPLv6YU.d.mts} +339 -3
- package/dist/{Sudo-DwxTf-jj.d.ts → Sudo-mzPLv6YU.d.ts} +339 -3
- package/dist/client.d.mts +2 -2
- package/dist/client.d.ts +2 -2
- package/dist/client.js +2376 -1413
- package/dist/client.mjs +2346 -1377
- package/dist/cluster.d.mts +2 -2
- package/dist/cluster.d.ts +2 -2
- package/dist/cluster.js +2376 -1413
- package/dist/cluster.mjs +2346 -1377
- package/dist/index.d.mts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +1219 -232
- package/dist/index.mjs +1122 -136
- package/dist/internal.d.mts +3 -2
- package/dist/internal.d.ts +3 -2
- package/dist/internal.js +52 -0
- package/dist/internal.mjs +54 -0
- package/dist/message.d.mts +2 -2
- package/dist/message.d.ts +2 -2
- package/dist/message.js +717 -34
- package/dist/message.mjs +708 -23
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -24,7 +24,7 @@ __export(src_exports, {
|
|
|
24
24
|
AnnouncementChannel: () => AnnouncementChannel,
|
|
25
25
|
AttachmentBuilder: () => import_builders5.AttachmentBuilder,
|
|
26
26
|
AttachmentMeta: () => import_builders5.AttachmentMeta,
|
|
27
|
-
AuditLogActionType: () =>
|
|
27
|
+
AuditLogActionType: () => import_types46.AuditLogActionType,
|
|
28
28
|
BETA_CLIENT_CLUSTER_WARNING: () => BETA_CLIENT_CLUSTER_WARNING,
|
|
29
29
|
Base: () => Base,
|
|
30
30
|
CDN_URL: () => CDN_URL,
|
|
@@ -32,12 +32,12 @@ __export(src_exports, {
|
|
|
32
32
|
CategoryChannel: () => CategoryChannel,
|
|
33
33
|
Channel: () => Channel,
|
|
34
34
|
ChannelManager: () => ChannelManager,
|
|
35
|
-
ChannelType: () =>
|
|
35
|
+
ChannelType: () => import_types46.ChannelType,
|
|
36
36
|
Client: () => Client,
|
|
37
37
|
ClientCluster: () => ClientCluster,
|
|
38
38
|
ClientClusterEvents: () => ClientClusterEvents,
|
|
39
39
|
ClientUser: () => ClientUser,
|
|
40
|
-
ContentWarningLevel: () =>
|
|
40
|
+
ContentWarningLevel: () => import_types46.ContentWarningLevel,
|
|
41
41
|
DEFAULT_CACHE_LIMITS: () => DEFAULT_CACHE_LIMITS,
|
|
42
42
|
DEFAULT_INSTANCE_ENDPOINTS: () => DEFAULT_INSTANCE_ENDPOINTS,
|
|
43
43
|
DMChannel: () => DMChannel,
|
|
@@ -45,7 +45,11 @@ __export(src_exports, {
|
|
|
45
45
|
ErrorCodes: () => import_util3.ErrorCodes,
|
|
46
46
|
Events: () => Events,
|
|
47
47
|
FluxerError: () => import_util4.FluxerError,
|
|
48
|
-
|
|
48
|
+
ForumChannel: () => ForumChannel,
|
|
49
|
+
ForumLayout: () => import_types46.ForumLayout,
|
|
50
|
+
ForumSortOrder: () => import_types46.ForumSortOrder,
|
|
51
|
+
ForumTagSetting: () => import_types46.ForumTagSetting,
|
|
52
|
+
GatewayOpcodes: () => import_types46.GatewayOpcodes,
|
|
49
53
|
Guild: () => Guild,
|
|
50
54
|
GuildBan: () => GuildBan,
|
|
51
55
|
GuildChannel: () => GuildChannel,
|
|
@@ -53,45 +57,52 @@ __export(src_exports, {
|
|
|
53
57
|
GuildManager: () => GuildManager,
|
|
54
58
|
GuildMember: () => GuildMember,
|
|
55
59
|
GuildMemberManager: () => GuildMemberManager,
|
|
56
|
-
GuildMemberProfileFlags: () =>
|
|
60
|
+
GuildMemberProfileFlags: () => import_types46.GuildMemberProfileFlags,
|
|
57
61
|
GuildMemberRoleManager: () => GuildMemberRoleManager,
|
|
58
|
-
GuildNSFWLevel: () =>
|
|
59
|
-
GuildOperations: () =>
|
|
62
|
+
GuildNSFWLevel: () => import_types46.GuildNSFWLevel,
|
|
63
|
+
GuildOperations: () => import_types46.GuildOperations,
|
|
60
64
|
GuildRoleManager: () => GuildRoleManager,
|
|
61
65
|
GuildSticker: () => GuildSticker,
|
|
62
66
|
INSTANCE_DISCOVERY_PATH: () => INSTANCE_DISCOVERY_PATH,
|
|
63
67
|
Invite: () => Invite,
|
|
64
|
-
InviteType: () =>
|
|
68
|
+
InviteType: () => import_types46.InviteType,
|
|
65
69
|
LinkChannel: () => LinkChannel,
|
|
70
|
+
MediaChannel: () => MediaChannel,
|
|
66
71
|
Message: () => Message,
|
|
67
|
-
MessageAttachmentFlags: () =>
|
|
72
|
+
MessageAttachmentFlags: () => import_types46.MessageAttachmentFlags,
|
|
68
73
|
MessageCollector: () => MessageCollector,
|
|
69
|
-
MessageFlags: () =>
|
|
74
|
+
MessageFlags: () => import_types46.MessageFlags,
|
|
70
75
|
MessageFlagsBitField: () => import_util27.MessageFlagsBitField,
|
|
71
76
|
MessageFlagsBits: () => import_util27.MessageFlagsBits,
|
|
72
77
|
MessageManager: () => MessageManager,
|
|
73
78
|
MessagePayload: () => import_builders5.MessagePayload,
|
|
74
79
|
MessageReaction: () => MessageReaction,
|
|
75
80
|
MessageReactionManager: () => MessageReactionManager,
|
|
76
|
-
MessageReferenceType: () =>
|
|
81
|
+
MessageReferenceType: () => import_types46.MessageReferenceType,
|
|
77
82
|
MessageSticker: () => MessageSticker,
|
|
78
|
-
MessageType: () =>
|
|
79
|
-
OverwriteType: () =>
|
|
83
|
+
MessageType: () => import_types46.MessageType,
|
|
84
|
+
OverwriteType: () => import_types46.OverwriteType,
|
|
80
85
|
PartialGuildMember: () => PartialGuildMember,
|
|
81
86
|
PartialMessage: () => PartialMessage,
|
|
82
87
|
PermissionFlags: () => import_util27.PermissionFlags,
|
|
83
88
|
PermissionOverwrite: () => PermissionOverwrite,
|
|
84
89
|
PermissionOverwriteManager: () => PermissionOverwriteManager,
|
|
85
90
|
PermissionsBitField: () => import_util27.PermissionsBitField,
|
|
86
|
-
PublicUserFlags: () =>
|
|
91
|
+
PublicUserFlags: () => import_types46.PublicUserFlags,
|
|
87
92
|
ReactionCollector: () => ReactionCollector,
|
|
88
|
-
RelationshipType: () =>
|
|
93
|
+
RelationshipType: () => import_types46.RelationshipType,
|
|
89
94
|
Role: () => Role,
|
|
90
|
-
Routes: () =>
|
|
95
|
+
Routes: () => import_types46.Routes,
|
|
91
96
|
STATIC_CDN_URL: () => STATIC_CDN_URL,
|
|
92
|
-
SplashCardAlignment: () =>
|
|
93
|
-
SystemChannelFlags: () =>
|
|
97
|
+
SplashCardAlignment: () => import_types46.SplashCardAlignment,
|
|
98
|
+
SystemChannelFlags: () => import_types46.SystemChannelFlags,
|
|
94
99
|
TextChannel: () => TextChannel,
|
|
100
|
+
ThreadAutoArchiveDuration: () => import_types46.ThreadAutoArchiveDuration,
|
|
101
|
+
ThreadChannel: () => ThreadChannel,
|
|
102
|
+
ThreadManager: () => ThreadManager,
|
|
103
|
+
ThreadMember: () => ThreadMember,
|
|
104
|
+
ThreadMemberFlags: () => import_types46.ThreadMemberFlags,
|
|
105
|
+
ThreadMemberManager: () => ThreadMemberManager,
|
|
95
106
|
User: () => User,
|
|
96
107
|
UserFlagsBitField: () => import_util27.UserFlagsBitField,
|
|
97
108
|
UserFlagsBits: () => import_util27.UserFlagsBits,
|
|
@@ -108,6 +119,7 @@ __export(src_exports, {
|
|
|
108
119
|
cdnMemberBannerURL: () => cdnMemberBannerURL,
|
|
109
120
|
cdnStickerURL: () => cdnStickerURL,
|
|
110
121
|
createLogger: () => import_util27.createLogger,
|
|
122
|
+
fetchActiveThreads: () => fetchActiveThreads,
|
|
111
123
|
instanceDiscoveryUrl: () => instanceDiscoveryUrl,
|
|
112
124
|
inviteUrl: () => inviteUrl,
|
|
113
125
|
normalizeApiOrigin: () => normalizeApiOrigin,
|
|
@@ -123,7 +135,7 @@ __export(src_exports, {
|
|
|
123
135
|
});
|
|
124
136
|
module.exports = __toCommonJS(src_exports);
|
|
125
137
|
var import_builders5 = require("@fluxerjs/builders");
|
|
126
|
-
var
|
|
138
|
+
var import_types46 = require("@fluxerjs/types");
|
|
127
139
|
var import_util27 = require("@fluxerjs/util");
|
|
128
140
|
|
|
129
141
|
// src/ClientCore/CacheController.ts
|
|
@@ -267,20 +279,20 @@ var CacheController = class {
|
|
|
267
279
|
|
|
268
280
|
// src/ClientCore/ChannelManager.ts
|
|
269
281
|
var import_collection8 = require("@fluxerjs/collection");
|
|
270
|
-
var
|
|
282
|
+
var import_types28 = require("@fluxerjs/types");
|
|
271
283
|
|
|
272
284
|
// src/Domain/Channel/Base.ts
|
|
273
|
-
var
|
|
285
|
+
var import_types10 = require("@fluxerjs/types");
|
|
274
286
|
var import_util8 = require("@fluxerjs/util");
|
|
275
287
|
|
|
276
288
|
// src/ClientCore/MessageManager.ts
|
|
277
289
|
var import_collection4 = require("@fluxerjs/collection");
|
|
278
|
-
var
|
|
290
|
+
var import_types8 = require("@fluxerjs/types");
|
|
279
291
|
|
|
280
292
|
// src/Domain/Message/Message.ts
|
|
281
293
|
var import_builders3 = require("@fluxerjs/builders");
|
|
282
294
|
var import_collection3 = require("@fluxerjs/collection");
|
|
283
|
-
var
|
|
295
|
+
var import_types7 = require("@fluxerjs/types");
|
|
284
296
|
var import_util6 = require("@fluxerjs/util");
|
|
285
297
|
|
|
286
298
|
// src/ClientCore/SdkOptions/Attachments.ts
|
|
@@ -348,7 +360,130 @@ function toAttachmentUploadPlanResponse(data) {
|
|
|
348
360
|
}
|
|
349
361
|
|
|
350
362
|
// src/ClientCore/SdkOptions/Channels.ts
|
|
363
|
+
var import_types2 = require("@fluxerjs/types");
|
|
351
364
|
var import_util = require("@fluxerjs/util");
|
|
365
|
+
|
|
366
|
+
// src/ClientCore/SdkOptions/Threads.ts
|
|
367
|
+
var import_types = require("@fluxerjs/types");
|
|
368
|
+
function toThreadEditBody(type, options) {
|
|
369
|
+
const body = {};
|
|
370
|
+
if (options.name !== void 0) body.name = options.name;
|
|
371
|
+
if (options.archived !== void 0) body.archived = options.archived;
|
|
372
|
+
if (options.autoArchiveDuration !== void 0) {
|
|
373
|
+
body.auto_archive_duration = options.autoArchiveDuration;
|
|
374
|
+
}
|
|
375
|
+
if (options.locked !== void 0) body.locked = options.locked;
|
|
376
|
+
if (options.rateLimitPerUser !== void 0) body.rate_limit_per_user = options.rateLimitPerUser;
|
|
377
|
+
if (options.flags !== void 0) body.flags = options.flags;
|
|
378
|
+
if (options.appliedTags !== void 0 && type !== import_types.ChannelType.PrivateThread) {
|
|
379
|
+
body.applied_tags = options.appliedTags;
|
|
380
|
+
}
|
|
381
|
+
if (options.invitable !== void 0 && type === import_types.ChannelType.PrivateThread) {
|
|
382
|
+
body.invitable = options.invitable;
|
|
383
|
+
}
|
|
384
|
+
return body;
|
|
385
|
+
}
|
|
386
|
+
function toThreadParentEditBody(options) {
|
|
387
|
+
const body = {};
|
|
388
|
+
if (options.autoArchiveDuration !== void 0) {
|
|
389
|
+
body.default_auto_archive_duration = options.autoArchiveDuration;
|
|
390
|
+
}
|
|
391
|
+
if (options.rateLimitPerUser !== void 0) {
|
|
392
|
+
body.default_thread_rate_limit_per_user = options.rateLimitPerUser;
|
|
393
|
+
}
|
|
394
|
+
return body;
|
|
395
|
+
}
|
|
396
|
+
function toStartThreadBody(channelType, options) {
|
|
397
|
+
const type = options.type ?? (channelType === import_types.ChannelType.GuildAnnouncement ? import_types.ChannelType.AnnouncementThread : import_types.ChannelType.PublicThread);
|
|
398
|
+
const body = { name: options.name, type };
|
|
399
|
+
if (options.autoArchiveDuration !== void 0) {
|
|
400
|
+
body.auto_archive_duration = options.autoArchiveDuration;
|
|
401
|
+
}
|
|
402
|
+
if (options.rateLimitPerUser !== void 0) body.rate_limit_per_user = options.rateLimitPerUser;
|
|
403
|
+
if (options.invitable !== void 0) body.invitable = options.invitable;
|
|
404
|
+
return body;
|
|
405
|
+
}
|
|
406
|
+
function toStartThreadFromMessageBody(options) {
|
|
407
|
+
const body = { name: options.name };
|
|
408
|
+
if (options.autoArchiveDuration !== void 0) {
|
|
409
|
+
body.auto_archive_duration = options.autoArchiveDuration;
|
|
410
|
+
}
|
|
411
|
+
if (options.rateLimitPerUser !== void 0) body.rate_limit_per_user = options.rateLimitPerUser;
|
|
412
|
+
return body;
|
|
413
|
+
}
|
|
414
|
+
function toForumThreadMessage(body) {
|
|
415
|
+
const message = {};
|
|
416
|
+
if (body.content !== void 0) message.content = body.content;
|
|
417
|
+
if (body.embeds !== void 0) message.embeds = body.embeds;
|
|
418
|
+
if (body.attachments !== void 0) message.attachments = body.attachments;
|
|
419
|
+
if (body.allowed_mentions !== void 0) message.allowed_mentions = body.allowed_mentions;
|
|
420
|
+
if (body.flags !== void 0) message.flags = body.flags;
|
|
421
|
+
if (body.sticker_ids !== void 0) message.sticker_ids = body.sticker_ids;
|
|
422
|
+
return message;
|
|
423
|
+
}
|
|
424
|
+
function toForumTagBody(options) {
|
|
425
|
+
const body = { name: options.name };
|
|
426
|
+
if ("id" in options && options.id !== void 0) body.id = options.id;
|
|
427
|
+
if (options.moderated !== void 0) body.moderated = options.moderated;
|
|
428
|
+
if (options.emojiId !== void 0) body.emoji_id = options.emojiId;
|
|
429
|
+
if (options.emojiName !== void 0) body.emoji_name = options.emojiName;
|
|
430
|
+
return body;
|
|
431
|
+
}
|
|
432
|
+
function forumParentWire(options, includeLayout) {
|
|
433
|
+
const body = {};
|
|
434
|
+
if (options.availableTags !== void 0) {
|
|
435
|
+
body.available_tags = options.availableTags.map((tag) => toForumTagBody(tag));
|
|
436
|
+
}
|
|
437
|
+
if (options.defaultReactionEmoji !== void 0) {
|
|
438
|
+
body.default_reaction_emoji = options.defaultReactionEmoji === null ? null : reactionEmojiWire(options.defaultReactionEmoji);
|
|
439
|
+
}
|
|
440
|
+
if (options.defaultSortOrder !== void 0) body.default_sort_order = options.defaultSortOrder;
|
|
441
|
+
if (options.defaultTagSetting !== void 0) body.default_tag_setting = options.defaultTagSetting;
|
|
442
|
+
if (options.flags !== void 0) body.flags = options.flags;
|
|
443
|
+
if (options.defaultAutoArchiveDuration !== void 0) {
|
|
444
|
+
body.default_auto_archive_duration = options.defaultAutoArchiveDuration;
|
|
445
|
+
}
|
|
446
|
+
if (options.defaultThreadRateLimitPerUser !== void 0) {
|
|
447
|
+
body.default_thread_rate_limit_per_user = options.defaultThreadRateLimitPerUser;
|
|
448
|
+
}
|
|
449
|
+
if (includeLayout && options.defaultForumLayout !== void 0) {
|
|
450
|
+
body.default_forum_layout = options.defaultForumLayout;
|
|
451
|
+
}
|
|
452
|
+
return body;
|
|
453
|
+
}
|
|
454
|
+
function reactionEmojiWire(emoji) {
|
|
455
|
+
const body = {};
|
|
456
|
+
if (emoji.emojiId !== void 0) body.emoji_id = emoji.emojiId;
|
|
457
|
+
if (emoji.emojiName !== void 0) body.emoji_name = emoji.emojiName;
|
|
458
|
+
return body;
|
|
459
|
+
}
|
|
460
|
+
function toThreadMemberSettingsBody(options) {
|
|
461
|
+
const body = {};
|
|
462
|
+
if (options.flags !== void 0) body.flags = options.flags;
|
|
463
|
+
if (options.muted !== void 0) body.muted = options.muted;
|
|
464
|
+
if (options.muteConfig !== void 0) {
|
|
465
|
+
body.mute_config = options.muteConfig === null ? null : {
|
|
466
|
+
...options.muteConfig.endTime !== void 0 ? { end_time: options.muteConfig.endTime } : {},
|
|
467
|
+
selected_time_window: options.muteConfig.selectedTimeWindow
|
|
468
|
+
};
|
|
469
|
+
}
|
|
470
|
+
return body;
|
|
471
|
+
}
|
|
472
|
+
function withQuery(path, params) {
|
|
473
|
+
const query = new URLSearchParams();
|
|
474
|
+
for (const [key, value] of Object.entries(params)) {
|
|
475
|
+
if (value === void 0) continue;
|
|
476
|
+
if (Array.isArray(value)) {
|
|
477
|
+
for (const item of value) query.append(key, item);
|
|
478
|
+
continue;
|
|
479
|
+
}
|
|
480
|
+
query.set(key, String(value));
|
|
481
|
+
}
|
|
482
|
+
const text = query.toString();
|
|
483
|
+
return text ? `${path}?${text}` : path;
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
// src/ClientCore/SdkOptions/Channels.ts
|
|
352
487
|
function toOverwriteWire(overwrite) {
|
|
353
488
|
return {
|
|
354
489
|
id: overwrite.id,
|
|
@@ -409,6 +544,16 @@ function toChannelCreateBody(options) {
|
|
|
409
544
|
body.content_warning_text = options.contentWarningText;
|
|
410
545
|
}
|
|
411
546
|
if (options.rateLimitPerUser !== void 0) body.rate_limit_per_user = options.rateLimitPerUser;
|
|
547
|
+
if (options.defaultAutoArchiveDuration !== void 0) {
|
|
548
|
+
body.default_auto_archive_duration = options.defaultAutoArchiveDuration;
|
|
549
|
+
}
|
|
550
|
+
if (options.defaultThreadRateLimitPerUser !== void 0) {
|
|
551
|
+
body.default_thread_rate_limit_per_user = options.defaultThreadRateLimitPerUser;
|
|
552
|
+
}
|
|
553
|
+
const forumParent = options.type === import_types2.ChannelType.GuildForum || options.type === import_types2.ChannelType.GuildMedia;
|
|
554
|
+
if (forumParent) {
|
|
555
|
+
Object.assign(body, forumParentWire(options, options.type === import_types2.ChannelType.GuildForum));
|
|
556
|
+
}
|
|
412
557
|
return body;
|
|
413
558
|
}
|
|
414
559
|
function toChannelInviteBody(options) {
|
|
@@ -704,7 +849,7 @@ function auditReasonHeaders(reason) {
|
|
|
704
849
|
|
|
705
850
|
// src/Helpers/MessageUtils/Body.ts
|
|
706
851
|
var import_builders = require("@fluxerjs/builders");
|
|
707
|
-
var
|
|
852
|
+
var import_types3 = require("@fluxerjs/types");
|
|
708
853
|
|
|
709
854
|
// src/LibErrors/ErrorCodes.ts
|
|
710
855
|
var import_util3 = require("@fluxerjs/util");
|
|
@@ -787,7 +932,7 @@ function normalizeSendFiles(files) {
|
|
|
787
932
|
id: i,
|
|
788
933
|
filename: file.filename,
|
|
789
934
|
...file.description != null ? { description: file.description } : {},
|
|
790
|
-
...file.spoiler ? { flags:
|
|
935
|
+
...file.spoiler ? { flags: import_types3.MessageAttachmentFlags.IS_SPOILER } : {}
|
|
791
936
|
};
|
|
792
937
|
if (file.description != null || file.spoiler) anyBuilderMeta = true;
|
|
793
938
|
metaFromBuilders.push(meta);
|
|
@@ -837,8 +982,8 @@ function toMessageReference(target, forceForward = false) {
|
|
|
837
982
|
message_id: target.messageId
|
|
838
983
|
};
|
|
839
984
|
if (target.guildId) ref.guild_id = target.guildId;
|
|
840
|
-
const type = forceForward ?
|
|
841
|
-
if (type !==
|
|
985
|
+
const type = forceForward ? import_types3.MessageReferenceType.Forward : target.type ?? import_types3.MessageReferenceType.Default;
|
|
986
|
+
if (type !== import_types3.MessageReferenceType.Default) ref.type = type;
|
|
842
987
|
if (target.attachmentIds?.length) ref.attachment_ids = target.attachmentIds;
|
|
843
988
|
if (target.embedIndices?.length) ref.embed_indices = target.embedIndices;
|
|
844
989
|
return ref;
|
|
@@ -934,7 +1079,7 @@ var import_node_events = require("events");
|
|
|
934
1079
|
var import_collection = require("@fluxerjs/collection");
|
|
935
1080
|
|
|
936
1081
|
// src/Domain/Message/MessageReaction.ts
|
|
937
|
-
var
|
|
1082
|
+
var import_types4 = require("@fluxerjs/types");
|
|
938
1083
|
|
|
939
1084
|
// src/Helpers/HttpErrors.ts
|
|
940
1085
|
var import_rest = require("@fluxerjs/rest");
|
|
@@ -1051,7 +1196,7 @@ var MessageReaction = class _MessageReaction extends Base {
|
|
|
1051
1196
|
if (cached) return cached;
|
|
1052
1197
|
try {
|
|
1053
1198
|
const data = await this.client.rest.get(
|
|
1054
|
-
|
|
1199
|
+
import_types4.Routes.channelMessage(this.channelId, this.messageId)
|
|
1055
1200
|
);
|
|
1056
1201
|
return new Message(this.client, data);
|
|
1057
1202
|
} catch (err) {
|
|
@@ -1100,6 +1245,14 @@ var Events = {
|
|
|
1100
1245
|
ChannelCreate: "channelCreate",
|
|
1101
1246
|
ChannelUpdate: "channelUpdate",
|
|
1102
1247
|
ChannelDelete: "channelDelete",
|
|
1248
|
+
ThreadCreate: "threadCreate",
|
|
1249
|
+
ThreadUpdate: "threadUpdate",
|
|
1250
|
+
ThreadDelete: "threadDelete",
|
|
1251
|
+
ThreadListSync: "threadListSync",
|
|
1252
|
+
ThreadMemberUpdate: "threadMemberUpdate",
|
|
1253
|
+
ThreadMembersUpdate: "threadMembersUpdate",
|
|
1254
|
+
ThreadMemberListUpdate: "threadMemberListUpdate",
|
|
1255
|
+
ForumUnreads: "forumUnreads",
|
|
1103
1256
|
ChannelPinsUpdate: "channelPinsUpdate",
|
|
1104
1257
|
ChannelRecipientAdd: "channelRecipientAdd",
|
|
1105
1258
|
ChannelRecipientRemove: "channelRecipientRemove",
|
|
@@ -1237,6 +1390,30 @@ var ReactionCollector = class _ReactionCollector extends import_node_events.Even
|
|
|
1237
1390
|
}
|
|
1238
1391
|
};
|
|
1239
1392
|
|
|
1393
|
+
// src/Domain/Channel/ThreadCache.ts
|
|
1394
|
+
function cacheThread(client, data) {
|
|
1395
|
+
const existing = client.channels.get(data.id);
|
|
1396
|
+
if (existing?.isThread() && existing.type === data.type) {
|
|
1397
|
+
existing._patch(data);
|
|
1398
|
+
placeThread(client, existing);
|
|
1399
|
+
return existing;
|
|
1400
|
+
}
|
|
1401
|
+
const created = Channel.from(client, data);
|
|
1402
|
+
if (!created.isThread()) {
|
|
1403
|
+
throw new import_util4.FluxerError(`Channel ${data.id} is not a thread`, {
|
|
1404
|
+
code: import_util3.ErrorCodes.InvalidChannelType
|
|
1405
|
+
});
|
|
1406
|
+
}
|
|
1407
|
+
placeThread(client, created);
|
|
1408
|
+
return created;
|
|
1409
|
+
}
|
|
1410
|
+
function placeThread(client, thread) {
|
|
1411
|
+
client.channels.set(thread.id, thread);
|
|
1412
|
+
if (!thread.guildId) return;
|
|
1413
|
+
const guild = client.guilds.get(thread.guildId);
|
|
1414
|
+
if (guild) guild.channels.set(thread.id, thread);
|
|
1415
|
+
}
|
|
1416
|
+
|
|
1240
1417
|
// src/Domain/Message/Attachment.ts
|
|
1241
1418
|
function toMessageAttachment(data) {
|
|
1242
1419
|
return {
|
|
@@ -1515,27 +1692,27 @@ var MessageSticker = class extends Base {
|
|
|
1515
1692
|
};
|
|
1516
1693
|
|
|
1517
1694
|
// src/Domain/Message/Reactions.ts
|
|
1518
|
-
var
|
|
1695
|
+
var import_types5 = require("@fluxerjs/types");
|
|
1519
1696
|
async function emojiPath(message, emoji) {
|
|
1520
1697
|
return message.client.resolveEmoji(emoji, message.guildId);
|
|
1521
1698
|
}
|
|
1522
1699
|
async function reactToMessage(message, emoji) {
|
|
1523
1700
|
const wire = await emojiPath(message, emoji);
|
|
1524
1701
|
await message.client.rest.put(
|
|
1525
|
-
|
|
1702
|
+
import_types5.Routes.channelMessageReactionMe(message.channelId, message.id, wire)
|
|
1526
1703
|
);
|
|
1527
1704
|
}
|
|
1528
1705
|
async function removeMessageReaction(message, emoji, userId) {
|
|
1529
1706
|
const e = await emojiPath(message, emoji);
|
|
1530
|
-
const route = userId ?
|
|
1707
|
+
const route = userId ? import_types5.Routes.channelMessageReactionUser(message.channelId, message.id, e, userId) : import_types5.Routes.channelMessageReactionMe(message.channelId, message.id, e);
|
|
1531
1708
|
await message.client.rest.delete(route);
|
|
1532
1709
|
}
|
|
1533
1710
|
async function removeAllMessageReactions(message) {
|
|
1534
|
-
await message.client.rest.delete(
|
|
1711
|
+
await message.client.rest.delete(import_types5.Routes.channelMessageReactions(message.channelId, message.id));
|
|
1535
1712
|
}
|
|
1536
1713
|
async function removeMessageReactionEmoji(message, emoji) {
|
|
1537
1714
|
const e = await emojiPath(message, emoji);
|
|
1538
|
-
await message.client.rest.delete(
|
|
1715
|
+
await message.client.rest.delete(import_types5.Routes.channelMessageReaction(message.channelId, message.id, e));
|
|
1539
1716
|
}
|
|
1540
1717
|
async function fetchMessageReactionUsers(message, emoji, options) {
|
|
1541
1718
|
return (await fetchMessageReactionUsersPage(message, emoji, options)).users;
|
|
@@ -1546,7 +1723,7 @@ async function fetchMessageReactionUsersPage(message, emoji, options) {
|
|
|
1546
1723
|
if (options?.limit != null) params.set("limit", String(options.limit));
|
|
1547
1724
|
if (options?.after) params.set("after", options.after);
|
|
1548
1725
|
const qs2 = params.toString();
|
|
1549
|
-
const route =
|
|
1726
|
+
const route = import_types5.Routes.channelMessageReactionUsers(message.channelId, message.id, e) + (qs2 ? `?${qs2}` : "");
|
|
1550
1727
|
const data = await message.client.rest.get(route);
|
|
1551
1728
|
if (Array.isArray(data)) {
|
|
1552
1729
|
return {
|
|
@@ -1565,7 +1742,7 @@ async function fetchMessageReactionUsersPage(message, emoji, options) {
|
|
|
1565
1742
|
|
|
1566
1743
|
// src/Domain/Message/Send.ts
|
|
1567
1744
|
var import_builders2 = require("@fluxerjs/builders");
|
|
1568
|
-
var
|
|
1745
|
+
var import_types6 = require("@fluxerjs/types");
|
|
1569
1746
|
function toReplyTarget(ref) {
|
|
1570
1747
|
return {
|
|
1571
1748
|
channelId: ref.channel_id,
|
|
@@ -1599,7 +1776,7 @@ function asReplyTarget(value) {
|
|
|
1599
1776
|
}
|
|
1600
1777
|
async function sendPrepared(message, payload) {
|
|
1601
1778
|
const data = await message.client.rest.post(
|
|
1602
|
-
|
|
1779
|
+
import_types6.Routes.channelMessages(message.channelId),
|
|
1603
1780
|
payload
|
|
1604
1781
|
);
|
|
1605
1782
|
message.client._addMessageToCache(message.channelId, data);
|
|
@@ -1708,6 +1885,8 @@ var Message = class _Message extends Base {
|
|
|
1708
1885
|
nonce;
|
|
1709
1886
|
/** IDs of custom emojis in the message classified as explicit. */
|
|
1710
1887
|
nsfwEmojis;
|
|
1888
|
+
/** Thread started from this message, when the payload included one. */
|
|
1889
|
+
thread;
|
|
1711
1890
|
/**
|
|
1712
1891
|
* Cached text-capable channel (guild text, guild voice, or DM), or null if uncached / not text-based.
|
|
1713
1892
|
* Narrowed type has {@link Channel.send} and {@link Channel.delete}.
|
|
@@ -1761,7 +1940,7 @@ var Message = class _Message extends Base {
|
|
|
1761
1940
|
this.pinned = data.pinned;
|
|
1762
1941
|
this.attachments = new import_collection3.Collection();
|
|
1763
1942
|
for (const a of data.attachments ?? []) this.attachments.set(a.id, toMessageAttachment(a));
|
|
1764
|
-
this.type = data.type ??
|
|
1943
|
+
this.type = data.type ?? import_types7.MessageType.Default;
|
|
1765
1944
|
this.flags = new import_util6.MessageFlagsBitField(BigInt(data.flags ?? 0));
|
|
1766
1945
|
this.mentionEveryone = data.mention_everyone ?? false;
|
|
1767
1946
|
this.tts = data.tts ?? false;
|
|
@@ -1783,6 +1962,7 @@ var Message = class _Message extends Base {
|
|
|
1783
1962
|
this.mentionRoles = data.mention_roles ?? [];
|
|
1784
1963
|
this.nonce = data.nonce ?? null;
|
|
1785
1964
|
this.nsfwEmojis = data.nsfw_emojis ?? [];
|
|
1965
|
+
this.thread = data.thread ? cacheThread(client, data.thread) : null;
|
|
1786
1966
|
}
|
|
1787
1967
|
/**
|
|
1788
1968
|
* Apply an API message payload in place (cache identity / MESSAGE_UPDATE).
|
|
@@ -1816,6 +1996,7 @@ var Message = class _Message extends Base {
|
|
|
1816
1996
|
this.mentionRoles = data.mention_roles ?? [];
|
|
1817
1997
|
this.nonce = data.nonce ?? null;
|
|
1818
1998
|
this.nsfwEmojis = data.nsfw_emojis ?? [];
|
|
1999
|
+
if (data.thread) this.thread = cacheThread(this.client, data.thread);
|
|
1819
2000
|
}
|
|
1820
2001
|
/**
|
|
1821
2002
|
* Send a standalone message in this channel (not a reply).
|
|
@@ -1876,7 +2057,7 @@ var Message = class _Message extends Base {
|
|
|
1876
2057
|
if (options.attachments !== void 0) {
|
|
1877
2058
|
body.attachments = toMessageAttachmentEditWire(options.attachments);
|
|
1878
2059
|
}
|
|
1879
|
-
const data = await this.client.rest.patch(
|
|
2060
|
+
const data = await this.client.rest.patch(import_types7.Routes.channelMessage(this.channelId, this.id), {
|
|
1880
2061
|
body
|
|
1881
2062
|
});
|
|
1882
2063
|
const updated = new _Message(this.client, data);
|
|
@@ -1894,13 +2075,30 @@ var Message = class _Message extends Base {
|
|
|
1894
2075
|
awaitReactions(options) {
|
|
1895
2076
|
return ReactionCollector.awaitReactions(this.client, this.id, this.channelId, options);
|
|
1896
2077
|
}
|
|
2078
|
+
/**
|
|
2079
|
+
* Start a thread from this message.
|
|
2080
|
+
* Fluxer chooses a public or announcement thread from the parent channel.
|
|
2081
|
+
*/
|
|
2082
|
+
async startThread(options) {
|
|
2083
|
+
const data = await this.client.rest.post(
|
|
2084
|
+
import_types7.Routes.channelMessageThreads(this.channelId, this.id),
|
|
2085
|
+
{
|
|
2086
|
+
body: toStartThreadFromMessageBody(options),
|
|
2087
|
+
auth: true,
|
|
2088
|
+
...auditReasonHeaders(options.reason)
|
|
2089
|
+
}
|
|
2090
|
+
);
|
|
2091
|
+
const thread = cacheThread(this.client, data);
|
|
2092
|
+
this.thread = thread;
|
|
2093
|
+
return thread;
|
|
2094
|
+
}
|
|
1897
2095
|
/** Fetch the latest version of this message from the API. */
|
|
1898
2096
|
async fetch() {
|
|
1899
2097
|
return this.client.channels.fetchMessage(this.channelId, this.id);
|
|
1900
2098
|
}
|
|
1901
2099
|
/** Delete this message. */
|
|
1902
2100
|
async delete(reason) {
|
|
1903
|
-
await this.client.rest.delete(
|
|
2101
|
+
await this.client.rest.delete(import_types7.Routes.channelMessage(this.channelId, this.id), {
|
|
1904
2102
|
...auditReasonHeaders(reason)
|
|
1905
2103
|
});
|
|
1906
2104
|
this.client._removeMessageFromCache(this.channelId, this.id);
|
|
@@ -1908,19 +2106,19 @@ var Message = class _Message extends Base {
|
|
|
1908
2106
|
/** Delete a specific attachment from this message. */
|
|
1909
2107
|
async deleteAttachment(attachmentId) {
|
|
1910
2108
|
await this.client.rest.delete(
|
|
1911
|
-
|
|
2109
|
+
import_types7.Routes.channelMessageAttachment(this.channelId, this.id, attachmentId),
|
|
1912
2110
|
{ auth: true }
|
|
1913
2111
|
);
|
|
1914
2112
|
this.attachments.delete(attachmentId);
|
|
1915
2113
|
}
|
|
1916
2114
|
/** Pin this message in the channel. */
|
|
1917
2115
|
async pin() {
|
|
1918
|
-
await this.client.rest.put(
|
|
2116
|
+
await this.client.rest.put(import_types7.Routes.channelPinMessage(this.channelId, this.id));
|
|
1919
2117
|
this.pinned = true;
|
|
1920
2118
|
}
|
|
1921
2119
|
/** Unpin this message from the channel. */
|
|
1922
2120
|
async unpin() {
|
|
1923
|
-
await this.client.rest.delete(
|
|
2121
|
+
await this.client.rest.delete(import_types7.Routes.channelPinMessage(this.channelId, this.id));
|
|
1924
2122
|
this.pinned = false;
|
|
1925
2123
|
}
|
|
1926
2124
|
/** React to this message with an emoji. */
|
|
@@ -2073,7 +2271,7 @@ var MessageManager = class {
|
|
|
2073
2271
|
async fetchOne(messageId) {
|
|
2074
2272
|
try {
|
|
2075
2273
|
const data = await this.client.rest.get(
|
|
2076
|
-
|
|
2274
|
+
import_types8.Routes.channelMessage(this.channelId, messageId)
|
|
2077
2275
|
);
|
|
2078
2276
|
return this.wrap(data);
|
|
2079
2277
|
} catch (err) {
|
|
@@ -2098,7 +2296,7 @@ var MessageManager = class {
|
|
|
2098
2296
|
const value = options[key];
|
|
2099
2297
|
if (value != null && value !== "") qs2.set(key, String(value));
|
|
2100
2298
|
}
|
|
2101
|
-
const base =
|
|
2299
|
+
const base = import_types8.Routes.channelMessages(this.channelId);
|
|
2102
2300
|
const data = await this.client.rest.get(qs2.size > 0 ? `${base}?${qs2}` : base);
|
|
2103
2301
|
const collection = new import_collection4.Collection();
|
|
2104
2302
|
for (const msg of data) collection.set(msg.id, this.wrap(msg));
|
|
@@ -2205,7 +2403,7 @@ var MessageCollector = class _MessageCollector extends import_node_events2.Event
|
|
|
2205
2403
|
};
|
|
2206
2404
|
|
|
2207
2405
|
// src/Domain/Channel/Attachments.ts
|
|
2208
|
-
var
|
|
2406
|
+
var import_types9 = require("@fluxerjs/types");
|
|
2209
2407
|
var BOT_ATTACHMENT_MAX_BYTES = 50 * 1024 * 1024;
|
|
2210
2408
|
var ATTACHMENT_MULTIPART_THRESHOLD_BYTES = 10 * 1024 * 1024;
|
|
2211
2409
|
function instanceLimitOverridesSnapshot(client) {
|
|
@@ -2250,7 +2448,7 @@ async function putBlob(url, body, contentType) {
|
|
|
2250
2448
|
async function uploadAttachmentsForSend(client, channelId, files) {
|
|
2251
2449
|
assertBotAttachmentLimits(client, files);
|
|
2252
2450
|
const plan = await client.rest.post(
|
|
2253
|
-
|
|
2451
|
+
import_types9.Routes.channelAttachments(channelId),
|
|
2254
2452
|
{
|
|
2255
2453
|
body: {
|
|
2256
2454
|
attachments: files.map((f) => ({
|
|
@@ -2296,7 +2494,7 @@ async function uploadAttachmentsForSend(client, channelId, files) {
|
|
|
2296
2494
|
});
|
|
2297
2495
|
}
|
|
2298
2496
|
if (multipart.length) {
|
|
2299
|
-
await client.rest.post(
|
|
2497
|
+
await client.rest.post(import_types9.Routes.channelAttachmentsComplete(channelId), {
|
|
2300
2498
|
body: { uploads: multipart },
|
|
2301
2499
|
auth: true
|
|
2302
2500
|
});
|
|
@@ -2361,43 +2559,56 @@ var Channel = class extends Base {
|
|
|
2361
2559
|
throw new Error("Channel.createDM not initialized");
|
|
2362
2560
|
}
|
|
2363
2561
|
/**
|
|
2364
|
-
* Whether this channel type can carry messages (text, announcement, voice, DM, group DM, notes).
|
|
2562
|
+
* Whether this channel type can carry messages (text, announcement, voice, threads, DM, group DM, notes).
|
|
2563
|
+
* Forum and media channels contain threads and do not accept `send`.
|
|
2365
2564
|
* Checks {@link ChannelType}, not whether `send` exists on the instance.
|
|
2366
2565
|
*/
|
|
2367
2566
|
isTextBased() {
|
|
2368
|
-
return this.type ===
|
|
2567
|
+
return this.type === import_types10.ChannelType.GuildText || this.type === import_types10.ChannelType.GuildAnnouncement || this.type === import_types10.ChannelType.GuildVoice || this.type === import_types10.ChannelType.DM || this.type === import_types10.ChannelType.GroupDM || this.type === import_types10.ChannelType.DMPersonalNotes || this.type === import_types10.ChannelType.AnnouncementThread || this.type === import_types10.ChannelType.PublicThread || this.type === import_types10.ChannelType.PrivateThread;
|
|
2369
2568
|
}
|
|
2370
|
-
/** Check if this is a guild channel
|
|
2569
|
+
/** Check if this is a guild channel, including threads, forums, and media channels. */
|
|
2371
2570
|
isGuild() {
|
|
2372
|
-
return this.type ===
|
|
2571
|
+
return this.type === import_types10.ChannelType.GuildText || this.type === import_types10.ChannelType.GuildAnnouncement || this.type === import_types10.ChannelType.GuildVoice || this.type === import_types10.ChannelType.GuildCategory || this.type === import_types10.ChannelType.GuildLink || this.type === import_types10.ChannelType.AnnouncementThread || this.type === import_types10.ChannelType.PublicThread || this.type === import_types10.ChannelType.PrivateThread || this.type === import_types10.ChannelType.GuildForum || this.type === import_types10.ChannelType.GuildMedia;
|
|
2572
|
+
}
|
|
2573
|
+
/** Check if this is a thread (public, private, or announcement). */
|
|
2574
|
+
isThread() {
|
|
2575
|
+
return this.type === import_types10.ChannelType.AnnouncementThread || this.type === import_types10.ChannelType.PublicThread || this.type === import_types10.ChannelType.PrivateThread;
|
|
2576
|
+
}
|
|
2577
|
+
/** Check if this is a forum channel. */
|
|
2578
|
+
isForum() {
|
|
2579
|
+
return this.type === import_types10.ChannelType.GuildForum;
|
|
2580
|
+
}
|
|
2581
|
+
/** Check if this is a media channel. */
|
|
2582
|
+
isMedia() {
|
|
2583
|
+
return this.type === import_types10.ChannelType.GuildMedia;
|
|
2373
2584
|
}
|
|
2374
2585
|
/** Check if this is a guild text channel. */
|
|
2375
2586
|
isText() {
|
|
2376
|
-
return this.type ===
|
|
2587
|
+
return this.type === import_types10.ChannelType.GuildText;
|
|
2377
2588
|
}
|
|
2378
2589
|
/** Check if this is a guild announcement channel. */
|
|
2379
2590
|
isAnnouncement() {
|
|
2380
|
-
return this.type ===
|
|
2591
|
+
return this.type === import_types10.ChannelType.GuildAnnouncement;
|
|
2381
2592
|
}
|
|
2382
2593
|
/** Check if this is a category channel. */
|
|
2383
2594
|
isCategory() {
|
|
2384
|
-
return this.type ===
|
|
2595
|
+
return this.type === import_types10.ChannelType.GuildCategory;
|
|
2385
2596
|
}
|
|
2386
2597
|
/** Check if this is a DM, group DM, or personal notes channel. */
|
|
2387
2598
|
isDM() {
|
|
2388
|
-
return this.type ===
|
|
2599
|
+
return this.type === import_types10.ChannelType.DM || this.type === import_types10.ChannelType.GroupDM || this.type === import_types10.ChannelType.DMPersonalNotes;
|
|
2389
2600
|
}
|
|
2390
2601
|
/** Check if this is a personal notes channel. */
|
|
2391
2602
|
isPersonalNotes() {
|
|
2392
|
-
return this.type ===
|
|
2603
|
+
return this.type === import_types10.ChannelType.DMPersonalNotes;
|
|
2393
2604
|
}
|
|
2394
2605
|
/** Check if this is a voice channel. */
|
|
2395
2606
|
isVoice() {
|
|
2396
|
-
return this.type ===
|
|
2607
|
+
return this.type === import_types10.ChannelType.GuildVoice;
|
|
2397
2608
|
}
|
|
2398
2609
|
/** Check if this is a link channel. */
|
|
2399
2610
|
isLink() {
|
|
2400
|
-
return this.type ===
|
|
2611
|
+
return this.type === import_types10.ChannelType.GuildLink;
|
|
2401
2612
|
}
|
|
2402
2613
|
/**
|
|
2403
2614
|
* Delete recent messages or an explicit ID list.
|
|
@@ -2420,7 +2631,7 @@ var Channel = class extends Base {
|
|
|
2420
2631
|
}
|
|
2421
2632
|
if (ids.length === 0) return [];
|
|
2422
2633
|
if (ids.length === 1) {
|
|
2423
|
-
await this.client.rest.delete(
|
|
2634
|
+
await this.client.rest.delete(import_types10.Routes.channelMessage(this.id, ids[0]), { auth: true });
|
|
2424
2635
|
this.client._removeMessageFromCache(this.id, ids[0]);
|
|
2425
2636
|
return ids;
|
|
2426
2637
|
}
|
|
@@ -2429,7 +2640,7 @@ var Channel = class extends Base {
|
|
|
2429
2640
|
code: import_util3.ErrorCodes.InvalidBulkDelete
|
|
2430
2641
|
});
|
|
2431
2642
|
}
|
|
2432
|
-
await this.client.rest.post(
|
|
2643
|
+
await this.client.rest.post(import_types10.Routes.channelBulkDelete(this.id), {
|
|
2433
2644
|
body: { message_ids: ids },
|
|
2434
2645
|
auth: true
|
|
2435
2646
|
});
|
|
@@ -2439,7 +2650,7 @@ var Channel = class extends Base {
|
|
|
2439
2650
|
/** Delete all messages sent by the bot in this channel. Sudo auto-passes for bots. */
|
|
2440
2651
|
async bulkDeleteMyMessages(options) {
|
|
2441
2652
|
const body = options ? toSudoBody(options) : void 0;
|
|
2442
|
-
await this.client.rest.post(
|
|
2653
|
+
await this.client.rest.post(import_types10.Routes.channelBulkDeleteMine(this.id), {
|
|
2443
2654
|
body: body && Object.keys(body).length ? body : void 0,
|
|
2444
2655
|
auth: true
|
|
2445
2656
|
});
|
|
@@ -2449,19 +2660,19 @@ var Channel = class extends Base {
|
|
|
2449
2660
|
* Session-token helper; bots usually skip this.
|
|
2450
2661
|
*/
|
|
2451
2662
|
async acknowledgePins() {
|
|
2452
|
-
await this.client.rest.post(
|
|
2663
|
+
await this.client.rest.post(import_types10.Routes.channelPinsAck(this.id), { auth: true });
|
|
2453
2664
|
}
|
|
2454
2665
|
/**
|
|
2455
2666
|
* Clear the read state for this channel.
|
|
2456
2667
|
* Session-token helper; bots usually skip this.
|
|
2457
2668
|
*/
|
|
2458
2669
|
async clearReadState() {
|
|
2459
|
-
await this.client.rest.delete(
|
|
2670
|
+
await this.client.rest.delete(import_types10.Routes.channelMessagesAck(this.id), { auth: true });
|
|
2460
2671
|
}
|
|
2461
2672
|
/** Request upload URLs for attachments before sending a message. */
|
|
2462
2673
|
async requestAttachmentUploads(attachments) {
|
|
2463
2674
|
const data = await this.client.rest.post(
|
|
2464
|
-
|
|
2675
|
+
import_types10.Routes.channelAttachments(this.id),
|
|
2465
2676
|
{
|
|
2466
2677
|
body: toAttachmentUploadPlanBody(attachments),
|
|
2467
2678
|
auth: true
|
|
@@ -2472,7 +2683,7 @@ var Channel = class extends Base {
|
|
|
2472
2683
|
/** Complete the attachment upload flow after uploading to the CDN. */
|
|
2473
2684
|
async completeAttachmentUploads(uploads) {
|
|
2474
2685
|
const data = await this.client.rest.post(
|
|
2475
|
-
|
|
2686
|
+
import_types10.Routes.channelAttachmentsComplete(this.id),
|
|
2476
2687
|
{
|
|
2477
2688
|
body: toAttachmentUploadCompleteBody(uploads),
|
|
2478
2689
|
auth: true
|
|
@@ -2488,7 +2699,7 @@ var Channel = class extends Base {
|
|
|
2488
2699
|
}
|
|
2489
2700
|
/** Trigger the typing indicator in this channel. */
|
|
2490
2701
|
async sendTyping() {
|
|
2491
|
-
await this.client.rest.post(
|
|
2702
|
+
await this.client.rest.post(import_types10.Routes.channelTyping(this.id), { auth: true });
|
|
2492
2703
|
}
|
|
2493
2704
|
/**
|
|
2494
2705
|
* Fetch available RTC regions for voice channels.
|
|
@@ -2496,7 +2707,7 @@ var Channel = class extends Base {
|
|
|
2496
2707
|
* Bots should skip this and join voice with `@fluxerjs/voice` instead.
|
|
2497
2708
|
*/
|
|
2498
2709
|
async fetchRtcRegions() {
|
|
2499
|
-
const data = await this.client.rest.get(
|
|
2710
|
+
const data = await this.client.rest.get(import_types10.Routes.channelRtcRegions(this.id), {
|
|
2500
2711
|
auth: true
|
|
2501
2712
|
});
|
|
2502
2713
|
return data.map((r) => ({ id: r.id, name: r.name, emoji: r.emoji }));
|
|
@@ -2504,7 +2715,7 @@ var Channel = class extends Base {
|
|
|
2504
2715
|
/** Fetch slowmode state for this channel. */
|
|
2505
2716
|
async fetchSlowmode() {
|
|
2506
2717
|
const data = await this.client.rest.get(
|
|
2507
|
-
|
|
2718
|
+
import_types10.Routes.channelSlowmode(this.id),
|
|
2508
2719
|
{ auth: true }
|
|
2509
2720
|
);
|
|
2510
2721
|
return {
|
|
@@ -2551,7 +2762,7 @@ var Channel = class extends Base {
|
|
|
2551
2762
|
const qs2 = params.toString();
|
|
2552
2763
|
const { silent: _s, deleteMessages: _d, reason: _reason, ...sudo } = options ?? {};
|
|
2553
2764
|
const body = Object.keys(sudo).length ? toSudoBody(sudo) : void 0;
|
|
2554
|
-
await this.client.rest.delete(
|
|
2765
|
+
await this.client.rest.delete(import_types10.Routes.channel(this.id) + (qs2 ? `?${qs2}` : ""), {
|
|
2555
2766
|
body,
|
|
2556
2767
|
auth: true,
|
|
2557
2768
|
...auditReasonHeaders(_reason)
|
|
@@ -2569,17 +2780,17 @@ var Channel = class extends Base {
|
|
|
2569
2780
|
};
|
|
2570
2781
|
|
|
2571
2782
|
// src/Domain/Channel/Dm.ts
|
|
2572
|
-
var
|
|
2783
|
+
var import_types12 = require("@fluxerjs/types");
|
|
2573
2784
|
|
|
2574
2785
|
// src/Domain/Channel/TextCapable.ts
|
|
2575
|
-
var
|
|
2786
|
+
var import_types11 = require("@fluxerjs/types");
|
|
2576
2787
|
async function fetchPinnedMessagesPageFor(client, channelId, options) {
|
|
2577
2788
|
const params = new URLSearchParams();
|
|
2578
2789
|
if (options?.limit != null) params.set("limit", String(options.limit));
|
|
2579
2790
|
if (options?.before) params.set("before", options.before);
|
|
2580
2791
|
const qs2 = params.toString();
|
|
2581
2792
|
const data = await client.rest.get(
|
|
2582
|
-
|
|
2793
|
+
import_types11.Routes.channelPins(channelId) + (qs2 ? `?${qs2}` : "")
|
|
2583
2794
|
);
|
|
2584
2795
|
const items = data.items ?? [];
|
|
2585
2796
|
return {
|
|
@@ -2649,7 +2860,7 @@ var DMChannel = class extends TextCapable(Channel) {
|
|
|
2649
2860
|
* Transferring ownership to a bot fails (`CannotTransferOwnershipToBotError`).
|
|
2650
2861
|
*/
|
|
2651
2862
|
async edit(options) {
|
|
2652
|
-
const data = await this.client.rest.patch(
|
|
2863
|
+
const data = await this.client.rest.patch(import_types12.Routes.channel(this.id), {
|
|
2653
2864
|
body: toGroupDmEditBody(options),
|
|
2654
2865
|
auth: true
|
|
2655
2866
|
});
|
|
@@ -2661,13 +2872,13 @@ var DMChannel = class extends TextCapable(Channel) {
|
|
|
2661
2872
|
* Notes-only; bots usually skip this.
|
|
2662
2873
|
*/
|
|
2663
2874
|
async purgeMessages() {
|
|
2664
|
-
if (this.type !==
|
|
2875
|
+
if (this.type !== import_types12.ChannelType.DMPersonalNotes) {
|
|
2665
2876
|
throw new import_util4.FluxerError("purgeMessages is only available on personal notes channels", {
|
|
2666
2877
|
code: import_util3.ErrorCodes.InvalidChannelType
|
|
2667
2878
|
});
|
|
2668
2879
|
}
|
|
2669
2880
|
const data = await this.client.rest.post(
|
|
2670
|
-
|
|
2881
|
+
import_types12.Routes.channelMessagesPurge(this.id),
|
|
2671
2882
|
{ auth: true }
|
|
2672
2883
|
);
|
|
2673
2884
|
return data.deleted_count;
|
|
@@ -2677,39 +2888,42 @@ var DMChannel = class extends TextCapable(Channel) {
|
|
|
2677
2888
|
* Session-token helper; bots usually skip this.
|
|
2678
2889
|
*/
|
|
2679
2890
|
async pinInList() {
|
|
2680
|
-
await this.client.rest.put(
|
|
2891
|
+
await this.client.rest.put(import_types12.Routes.userMeChannelPin(this.id), { auth: true });
|
|
2681
2892
|
}
|
|
2682
2893
|
/**
|
|
2683
2894
|
* Unpin this DM channel from the DM list.
|
|
2684
2895
|
* Session-token helper; bots usually skip this.
|
|
2685
2896
|
*/
|
|
2686
2897
|
async unpinFromList() {
|
|
2687
|
-
await this.client.rest.delete(
|
|
2898
|
+
await this.client.rest.delete(import_types12.Routes.userMeChannelPin(this.id), { auth: true });
|
|
2688
2899
|
}
|
|
2689
2900
|
/**
|
|
2690
2901
|
* Add a user to this group DM.
|
|
2691
2902
|
* Captcha-gated when captcha is enabled; bots are not exempt (`CaptchaRequiredError`).
|
|
2692
2903
|
*/
|
|
2693
2904
|
async addRecipient(userId) {
|
|
2694
|
-
await this.client.rest.put(
|
|
2905
|
+
await this.client.rest.put(import_types12.Routes.channelRecipient(this.id, userId), { auth: true });
|
|
2695
2906
|
const user = this.client.users.get(userId) ?? await this.client.users.fetch(userId);
|
|
2696
2907
|
if (user) this.recipients.push(user);
|
|
2697
2908
|
}
|
|
2698
2909
|
/** Remove a user from this group DM. */
|
|
2699
2910
|
async removeRecipient(userId, options) {
|
|
2700
|
-
const url =
|
|
2911
|
+
const url = import_types12.Routes.channelRecipient(this.id, userId) + (options?.silent ? "?silent=true" : "");
|
|
2701
2912
|
await this.client.rest.delete(url, { auth: true });
|
|
2702
2913
|
const idx = this.recipients.findIndex((u) => u.id === userId);
|
|
2703
2914
|
if (idx >= 0) this.recipients.splice(idx, 1);
|
|
2704
2915
|
}
|
|
2705
2916
|
};
|
|
2706
2917
|
|
|
2918
|
+
// src/Domain/Channel/Forum.ts
|
|
2919
|
+
var import_types19 = require("@fluxerjs/types");
|
|
2920
|
+
|
|
2707
2921
|
// src/Domain/Channel/Guild.ts
|
|
2708
|
-
var
|
|
2922
|
+
var import_types16 = require("@fluxerjs/types");
|
|
2709
2923
|
var import_util13 = require("@fluxerjs/util");
|
|
2710
2924
|
|
|
2711
2925
|
// src/Domain/Invite.ts
|
|
2712
|
-
var
|
|
2926
|
+
var import_types13 = require("@fluxerjs/types");
|
|
2713
2927
|
|
|
2714
2928
|
// src/Helpers/Instance.ts
|
|
2715
2929
|
var import_util9 = require("@fluxerjs/util");
|
|
@@ -2958,11 +3172,11 @@ var Invite = class _Invite extends Base {
|
|
|
2958
3172
|
this.client = client;
|
|
2959
3173
|
this.code = data.code;
|
|
2960
3174
|
this.type = data.type;
|
|
2961
|
-
this.guildSnapshot = (0,
|
|
2962
|
-
this.channelSnapshot = (0,
|
|
3175
|
+
this.guildSnapshot = (0, import_types13.isGuildInvite)(data) ? toInviteGuild(data.guild) : null;
|
|
3176
|
+
this.channelSnapshot = (0, import_types13.isGuildInvite)(data) || (0, import_types13.isGroupDmInvite)(data) ? toInviteChannel(data.channel) : null;
|
|
2963
3177
|
this.inviter = data.inviter ? client.getOrCreateUser(data.inviter) : null;
|
|
2964
3178
|
this.memberCount = data.member_count ?? null;
|
|
2965
|
-
this.presenceCount = (0,
|
|
3179
|
+
this.presenceCount = (0, import_types13.isGuildInvite)(data) ? data.presence_count ?? null : null;
|
|
2966
3180
|
this.expiresAt = parseOptionalDate(data.expires_at);
|
|
2967
3181
|
this.temporary = data.temporary ?? null;
|
|
2968
3182
|
this.createdAt = parseOptionalDate(data.created_at);
|
|
@@ -2971,10 +3185,10 @@ var Invite = class _Invite extends Base {
|
|
|
2971
3185
|
this.maxAge = data.max_age ?? null;
|
|
2972
3186
|
}
|
|
2973
3187
|
isGuild() {
|
|
2974
|
-
return this.type ===
|
|
3188
|
+
return this.type === import_types13.InviteType.Guild;
|
|
2975
3189
|
}
|
|
2976
3190
|
isGroupDM() {
|
|
2977
|
-
return this.type ===
|
|
3191
|
+
return this.type === import_types13.InviteType.GroupDM;
|
|
2978
3192
|
}
|
|
2979
3193
|
/** Full invite URL (uses this client's instance invite base). */
|
|
2980
3194
|
get url() {
|
|
@@ -2998,18 +3212,18 @@ var Invite = class _Invite extends Base {
|
|
|
2998
3212
|
}
|
|
2999
3213
|
/** Fetch invite metadata by code or URL (does not join). */
|
|
3000
3214
|
static async fetch(client, codeOrUrl) {
|
|
3001
|
-
const data = await client.rest.get(
|
|
3215
|
+
const data = await client.rest.get(import_types13.Routes.invite(parseInviteCode(codeOrUrl)));
|
|
3002
3216
|
return new _Invite(client, data);
|
|
3003
3217
|
}
|
|
3004
3218
|
/** Delete this invite. Requires Manage Guild or Create Instant Invite. */
|
|
3005
3219
|
async delete() {
|
|
3006
|
-
await this.client.rest.delete(
|
|
3220
|
+
await this.client.rest.delete(import_types13.Routes.invite(this.code), { auth: true });
|
|
3007
3221
|
}
|
|
3008
3222
|
};
|
|
3009
3223
|
|
|
3010
3224
|
// src/Domain/Webhook.ts
|
|
3011
3225
|
var import_builders4 = require("@fluxerjs/builders");
|
|
3012
|
-
var
|
|
3226
|
+
var import_types14 = require("@fluxerjs/types");
|
|
3013
3227
|
var import_util10 = require("@fluxerjs/util");
|
|
3014
3228
|
var Webhook = class _Webhook extends Base {
|
|
3015
3229
|
/** Parent client instance. */
|
|
@@ -3028,6 +3242,8 @@ var Webhook = class _Webhook extends Base {
|
|
|
3028
3242
|
token;
|
|
3029
3243
|
/** The user that created this webhook. */
|
|
3030
3244
|
user;
|
|
3245
|
+
/** Incoming or channel-follower webhook. */
|
|
3246
|
+
type;
|
|
3031
3247
|
constructor(client, data) {
|
|
3032
3248
|
super();
|
|
3033
3249
|
this.client = client;
|
|
@@ -3038,6 +3254,7 @@ var Webhook = class _Webhook extends Base {
|
|
|
3038
3254
|
this.avatar = data.avatar ?? null;
|
|
3039
3255
|
this.token = data.token ?? null;
|
|
3040
3256
|
this.user = client.getOrCreateUser(data.user);
|
|
3257
|
+
this.type = data.type ?? import_types14.WebhookType.Incoming;
|
|
3041
3258
|
}
|
|
3042
3259
|
avatarURL(options) {
|
|
3043
3260
|
return cdnAvatarURL(this.id, this.avatar, {
|
|
@@ -3056,10 +3273,10 @@ var Webhook = class _Webhook extends Base {
|
|
|
3056
3273
|
/** Delete this webhook (token auth when available, otherwise bot auth). */
|
|
3057
3274
|
async delete() {
|
|
3058
3275
|
if (this.token) {
|
|
3059
|
-
await this.client.rest.delete(
|
|
3276
|
+
await this.client.rest.delete(import_types14.Routes.webhookExecute(this.id, this.token), { auth: false });
|
|
3060
3277
|
return;
|
|
3061
3278
|
}
|
|
3062
|
-
await this.client.rest.delete(
|
|
3279
|
+
await this.client.rest.delete(import_types14.Routes.webhook(this.id), { auth: true });
|
|
3063
3280
|
}
|
|
3064
3281
|
/**
|
|
3065
3282
|
* Edit name/avatar. With bot auth (no token), `channelId` may also be set.
|
|
@@ -3071,10 +3288,10 @@ var Webhook = class _Webhook extends Base {
|
|
|
3071
3288
|
if (!this.token && options.channelId !== void 0) {
|
|
3072
3289
|
body.channel_id = options.channelId;
|
|
3073
3290
|
}
|
|
3074
|
-
const data = this.token ? await this.client.rest.patch(
|
|
3291
|
+
const data = this.token ? await this.client.rest.patch(import_types14.Routes.webhookExecute(this.id, this.token), {
|
|
3075
3292
|
body,
|
|
3076
3293
|
auth: false
|
|
3077
|
-
}) : await this.client.rest.patch(
|
|
3294
|
+
}) : await this.client.rest.patch(import_types14.Routes.webhook(this.id), { body, auth: true });
|
|
3078
3295
|
this.name = data.name ?? this.name;
|
|
3079
3296
|
this.avatar = data.avatar ?? null;
|
|
3080
3297
|
if (!this.token) this.channelId = data.channel_id ?? this.channelId;
|
|
@@ -3095,7 +3312,7 @@ var Webhook = class _Webhook extends Base {
|
|
|
3095
3312
|
if (overrides.avatarUrl !== void 0) {
|
|
3096
3313
|
body.avatar_url = overrides.avatarUrl;
|
|
3097
3314
|
}
|
|
3098
|
-
const route = `${
|
|
3315
|
+
const route = `${import_types14.Routes.webhookExecute(this.id, token)}${wait ? "?wait=true" : ""}`;
|
|
3099
3316
|
const data = await this.client.rest.post(route, {
|
|
3100
3317
|
body,
|
|
3101
3318
|
...files?.length ? { files } : {},
|
|
@@ -3136,7 +3353,7 @@ var Webhook = class _Webhook extends Base {
|
|
|
3136
3353
|
}
|
|
3137
3354
|
/** Fetch a webhook by ID (bot auth; no token). */
|
|
3138
3355
|
static async fetch(client, webhookId) {
|
|
3139
|
-
const data = await client.rest.get(
|
|
3356
|
+
const data = await client.rest.get(import_types14.Routes.webhook(webhookId));
|
|
3140
3357
|
return new _Webhook(client, data);
|
|
3141
3358
|
}
|
|
3142
3359
|
/** Build a webhook from a stored id + token (e.g. webhook URL). */
|
|
@@ -3148,6 +3365,7 @@ var Webhook = class _Webhook extends Base {
|
|
|
3148
3365
|
name: options?.name ?? "Webhook",
|
|
3149
3366
|
avatar: null,
|
|
3150
3367
|
token,
|
|
3368
|
+
type: import_types14.WebhookType.Incoming,
|
|
3151
3369
|
user: {
|
|
3152
3370
|
id: "",
|
|
3153
3371
|
username: "webhook",
|
|
@@ -3169,13 +3387,13 @@ var Webhook = class _Webhook extends Base {
|
|
|
3169
3387
|
return this.token;
|
|
3170
3388
|
}
|
|
3171
3389
|
messageRoute(messageId) {
|
|
3172
|
-
return
|
|
3390
|
+
return import_types14.Routes.webhookMessage(this.id, this.requireToken(), messageId);
|
|
3173
3391
|
}
|
|
3174
3392
|
};
|
|
3175
3393
|
|
|
3176
3394
|
// src/Domain/Channel/PermissionOverwriteManager.ts
|
|
3177
3395
|
var import_collection6 = require("@fluxerjs/collection");
|
|
3178
|
-
var
|
|
3396
|
+
var import_types15 = require("@fluxerjs/types");
|
|
3179
3397
|
var import_util12 = require("@fluxerjs/util");
|
|
3180
3398
|
|
|
3181
3399
|
// src/Domain/Channel/PermissionOverwrite.ts
|
|
@@ -3237,7 +3455,7 @@ var PermissionOverwriteManager = class {
|
|
|
3237
3455
|
async edit(overwriteId, options) {
|
|
3238
3456
|
const allow = options.allow !== void 0 ? (0, import_util12.resolvePermissionsToBitfield)(options.allow) : "0";
|
|
3239
3457
|
const deny = options.deny !== void 0 ? (0, import_util12.resolvePermissionsToBitfield)(options.deny) : "0";
|
|
3240
|
-
await this.channel.client.rest.put(
|
|
3458
|
+
await this.channel.client.rest.put(import_types15.Routes.channelPermission(this.channel.id, overwriteId), {
|
|
3241
3459
|
body: { type: options.type, allow, deny },
|
|
3242
3460
|
auth: true
|
|
3243
3461
|
});
|
|
@@ -3253,7 +3471,7 @@ var PermissionOverwriteManager = class {
|
|
|
3253
3471
|
}
|
|
3254
3472
|
/** Delete a permission overwrite. */
|
|
3255
3473
|
async delete(overwriteId) {
|
|
3256
|
-
await this.channel.client.rest.delete(
|
|
3474
|
+
await this.channel.client.rest.delete(import_types15.Routes.channelPermission(this.channel.id, overwriteId), {
|
|
3257
3475
|
auth: true
|
|
3258
3476
|
});
|
|
3259
3477
|
this._cache.delete(overwriteId);
|
|
@@ -3267,6 +3485,23 @@ var PermissionOverwriteManager = class {
|
|
|
3267
3485
|
}
|
|
3268
3486
|
};
|
|
3269
3487
|
|
|
3488
|
+
// src/Domain/Channel/ThreadBind.ts
|
|
3489
|
+
var factory;
|
|
3490
|
+
var managers = /* @__PURE__ */ new WeakMap();
|
|
3491
|
+
function bindThreadManager(next) {
|
|
3492
|
+
factory = next;
|
|
3493
|
+
}
|
|
3494
|
+
function threadManagerFor(channel) {
|
|
3495
|
+
const existing = managers.get(channel);
|
|
3496
|
+
if (existing) return existing;
|
|
3497
|
+
if (!factory) {
|
|
3498
|
+
throw new Error("ThreadManager is not initialized");
|
|
3499
|
+
}
|
|
3500
|
+
const created = factory(channel);
|
|
3501
|
+
managers.set(channel, created);
|
|
3502
|
+
return created;
|
|
3503
|
+
}
|
|
3504
|
+
|
|
3270
3505
|
// src/Domain/Channel/Guild.ts
|
|
3271
3506
|
var GuildChannel = class extends Channel {
|
|
3272
3507
|
/** Guild ID this channel belongs to, or null if missing from the payload. */
|
|
@@ -3304,7 +3539,7 @@ var GuildChannel = class extends Channel {
|
|
|
3304
3539
|
}
|
|
3305
3540
|
/** Create a webhook for this channel. Requires Manage Webhooks. */
|
|
3306
3541
|
async createWebhook(options) {
|
|
3307
|
-
const data = await this.client.rest.post(
|
|
3542
|
+
const data = await this.client.rest.post(import_types16.Routes.channelWebhooks(this.id), {
|
|
3308
3543
|
body: options,
|
|
3309
3544
|
auth: true
|
|
3310
3545
|
});
|
|
@@ -3312,13 +3547,13 @@ var GuildChannel = class extends Channel {
|
|
|
3312
3547
|
}
|
|
3313
3548
|
/** Fetch all webhooks in this channel. Requires Manage Webhooks. */
|
|
3314
3549
|
async fetchWebhooks() {
|
|
3315
|
-
const data = await this.client.rest.get(
|
|
3550
|
+
const data = await this.client.rest.get(import_types16.Routes.channelWebhooks(this.id));
|
|
3316
3551
|
return data.map((w) => new Webhook(this.client, w));
|
|
3317
3552
|
}
|
|
3318
3553
|
/** Create an invite for this channel. Requires Create Instant Invite. */
|
|
3319
3554
|
async createInvite(options) {
|
|
3320
3555
|
const body = options ? toChannelInviteBody(options) : {};
|
|
3321
|
-
const data = await this.client.rest.post(
|
|
3556
|
+
const data = await this.client.rest.post(import_types16.Routes.channelInvites(this.id), {
|
|
3322
3557
|
body: Object.keys(body).length ? body : void 0,
|
|
3323
3558
|
auth: true
|
|
3324
3559
|
});
|
|
@@ -3326,7 +3561,7 @@ var GuildChannel = class extends Channel {
|
|
|
3326
3561
|
}
|
|
3327
3562
|
/** Fetch all invites for this channel. Requires Manage Channels. */
|
|
3328
3563
|
async fetchInvites() {
|
|
3329
|
-
const data = await this.client.rest.get(
|
|
3564
|
+
const data = await this.client.rest.get(import_types16.Routes.channelInvites(this.id));
|
|
3330
3565
|
return data.map((i) => new Invite(this.client, i));
|
|
3331
3566
|
}
|
|
3332
3567
|
/** Check if the bot can send messages in this channel (cache-only; needs `members.me`). */
|
|
@@ -3356,7 +3591,7 @@ var GuildChannel = class extends Channel {
|
|
|
3356
3591
|
}
|
|
3357
3592
|
/** Edit this channel's settings. Requires Manage Channels. */
|
|
3358
3593
|
async edit(options) {
|
|
3359
|
-
const data = await this.client.rest.patch(
|
|
3594
|
+
const data = await this.client.rest.patch(import_types16.Routes.channel(this.id), {
|
|
3360
3595
|
body: toChannelEditBody(options),
|
|
3361
3596
|
auth: true,
|
|
3362
3597
|
...auditReasonHeaders(options.reason)
|
|
@@ -3387,6 +3622,10 @@ var TextChannel = class extends TextCapable(GuildChannel) {
|
|
|
3387
3622
|
contentWarningLevel;
|
|
3388
3623
|
/** Custom content warning text. */
|
|
3389
3624
|
contentWarningText;
|
|
3625
|
+
/** Default auto-archive duration in minutes for new threads. */
|
|
3626
|
+
defaultAutoArchiveDuration;
|
|
3627
|
+
/** Slowmode in seconds copied onto new threads. */
|
|
3628
|
+
defaultThreadRateLimitPerUser;
|
|
3390
3629
|
constructor(client, data) {
|
|
3391
3630
|
super(client, data);
|
|
3392
3631
|
this.topic = data.topic ?? null;
|
|
@@ -3396,6 +3635,12 @@ var TextChannel = class extends TextCapable(GuildChannel) {
|
|
|
3396
3635
|
this.lastMessageId = data.last_message_id ?? null;
|
|
3397
3636
|
this.contentWarningLevel = data.content_warning_level ?? null;
|
|
3398
3637
|
this.contentWarningText = data.content_warning_text ?? null;
|
|
3638
|
+
this.defaultAutoArchiveDuration = data.default_auto_archive_duration ?? null;
|
|
3639
|
+
this.defaultThreadRateLimitPerUser = data.default_thread_rate_limit_per_user ?? null;
|
|
3640
|
+
}
|
|
3641
|
+
/** Create, list, and search threads in this channel. */
|
|
3642
|
+
get threads() {
|
|
3643
|
+
return threadManagerFor(this);
|
|
3399
3644
|
}
|
|
3400
3645
|
/**
|
|
3401
3646
|
* Set slowmode (seconds between messages). Pass `0` to disable.
|
|
@@ -3416,6 +3661,25 @@ var TextChannel = class extends TextCapable(GuildChannel) {
|
|
|
3416
3661
|
if ("content_warning_text" in data) {
|
|
3417
3662
|
this.contentWarningText = data.content_warning_text ?? null;
|
|
3418
3663
|
}
|
|
3664
|
+
if ("default_auto_archive_duration" in data) {
|
|
3665
|
+
this.defaultAutoArchiveDuration = data.default_auto_archive_duration ?? null;
|
|
3666
|
+
}
|
|
3667
|
+
if ("default_thread_rate_limit_per_user" in data) {
|
|
3668
|
+
this.defaultThreadRateLimitPerUser = data.default_thread_rate_limit_per_user ?? null;
|
|
3669
|
+
}
|
|
3670
|
+
}
|
|
3671
|
+
/**
|
|
3672
|
+
* Set the auto-archive and slowmode defaults copied onto new threads.
|
|
3673
|
+
* Sends only those fields. The thread-parent update body does not accept a channel rename.
|
|
3674
|
+
*/
|
|
3675
|
+
async editThreadDefaults(options) {
|
|
3676
|
+
const data = await this.client.rest.patch(import_types16.Routes.channel(this.id), {
|
|
3677
|
+
body: toThreadParentEditBody(options),
|
|
3678
|
+
auth: true,
|
|
3679
|
+
...auditReasonHeaders(options.reason)
|
|
3680
|
+
});
|
|
3681
|
+
this._patch(data);
|
|
3682
|
+
return this;
|
|
3419
3683
|
}
|
|
3420
3684
|
};
|
|
3421
3685
|
var AnnouncementChannel = class extends TextChannel {
|
|
@@ -3498,26 +3762,522 @@ var LinkChannel = class extends GuildChannel {
|
|
|
3498
3762
|
}
|
|
3499
3763
|
};
|
|
3500
3764
|
|
|
3765
|
+
// src/Domain/Channel/ThreadManager.ts
|
|
3766
|
+
var import_types18 = require("@fluxerjs/types");
|
|
3767
|
+
|
|
3768
|
+
// src/Domain/Channel/ThreadChannel.ts
|
|
3769
|
+
var import_types17 = require("@fluxerjs/types");
|
|
3770
|
+
var ThreadMember = class {
|
|
3771
|
+
/** Thread ID. */
|
|
3772
|
+
id;
|
|
3773
|
+
/** User ID. */
|
|
3774
|
+
userId;
|
|
3775
|
+
/** When the user last joined the thread. */
|
|
3776
|
+
joinedAt;
|
|
3777
|
+
/** Thread member flags bitfield. */
|
|
3778
|
+
flags;
|
|
3779
|
+
/** Whether the current user has muted the thread. */
|
|
3780
|
+
muted;
|
|
3781
|
+
/** ISO-8601 timestamp when the mute expires, if set. */
|
|
3782
|
+
muteEndTime;
|
|
3783
|
+
/** Selected mute duration in seconds, if set. */
|
|
3784
|
+
muteWindow;
|
|
3785
|
+
constructor(data) {
|
|
3786
|
+
this.id = data.id ?? null;
|
|
3787
|
+
this.userId = data.user_id ?? data.member?.user?.id ?? null;
|
|
3788
|
+
this.joinedAt = new Date(data.join_timestamp);
|
|
3789
|
+
this.flags = data.flags;
|
|
3790
|
+
this.muted = data.muted ?? null;
|
|
3791
|
+
this.muteEndTime = data.mute_config?.end_time ?? null;
|
|
3792
|
+
this.muteWindow = data.mute_config?.selected_time_window ?? null;
|
|
3793
|
+
}
|
|
3794
|
+
};
|
|
3795
|
+
function threadEditFields(options) {
|
|
3796
|
+
const source = options;
|
|
3797
|
+
return {
|
|
3798
|
+
name: typeof source.name === "string" ? source.name : void 0,
|
|
3799
|
+
archived: source.archived,
|
|
3800
|
+
autoArchiveDuration: source.autoArchiveDuration,
|
|
3801
|
+
locked: source.locked,
|
|
3802
|
+
rateLimitPerUser: source.rateLimitPerUser,
|
|
3803
|
+
flags: source.flags,
|
|
3804
|
+
appliedTags: source.appliedTags,
|
|
3805
|
+
invitable: source.invitable,
|
|
3806
|
+
reason: source.reason
|
|
3807
|
+
};
|
|
3808
|
+
}
|
|
3809
|
+
function readMetadata(data) {
|
|
3810
|
+
return {
|
|
3811
|
+
archived: data?.archived ?? false,
|
|
3812
|
+
autoArchiveDuration: data?.auto_archive_duration ?? 0,
|
|
3813
|
+
archiveTimestamp: data?.archive_timestamp ?? null,
|
|
3814
|
+
locked: data?.locked ?? false,
|
|
3815
|
+
invitable: data?.invitable ?? null
|
|
3816
|
+
};
|
|
3817
|
+
}
|
|
3818
|
+
var ThreadChannel = class extends TextCapable(GuildChannel) {
|
|
3819
|
+
/** User who created the thread. */
|
|
3820
|
+
ownerId;
|
|
3821
|
+
/** Whether the thread is archived. */
|
|
3822
|
+
archived;
|
|
3823
|
+
/** Minutes of inactivity before the thread archives. */
|
|
3824
|
+
autoArchiveDuration;
|
|
3825
|
+
/** ISO-8601 timestamp when the archive status last changed. */
|
|
3826
|
+
archiveTimestamp;
|
|
3827
|
+
/** Whether only moderators can unarchive the thread. */
|
|
3828
|
+
locked;
|
|
3829
|
+
/** Whether non-moderators can add other non-moderators. Private threads only. */
|
|
3830
|
+
invitable;
|
|
3831
|
+
/** Slowmode in seconds. */
|
|
3832
|
+
rateLimitPerUser;
|
|
3833
|
+
/** ID of the last message sent in this thread. */
|
|
3834
|
+
lastMessageId;
|
|
3835
|
+
/** Messages in the thread, excluding the starter and deleted messages. */
|
|
3836
|
+
messageCount;
|
|
3837
|
+
/** Messages ever sent in the thread. This count is never decremented. */
|
|
3838
|
+
totalMessageSent;
|
|
3839
|
+
/** Approximate member count, capped at 50. */
|
|
3840
|
+
memberCount;
|
|
3841
|
+
/** Tag IDs applied to a forum or media post. */
|
|
3842
|
+
appliedTags;
|
|
3843
|
+
/** Channel flags bitfield. */
|
|
3844
|
+
flags;
|
|
3845
|
+
/** The current user's membership, when the payload included it. */
|
|
3846
|
+
member;
|
|
3847
|
+
/** Add, remove, and list members of this thread. */
|
|
3848
|
+
members;
|
|
3849
|
+
constructor(client, data) {
|
|
3850
|
+
super(client, data);
|
|
3851
|
+
const metadata = readMetadata(data.thread_metadata);
|
|
3852
|
+
this.ownerId = data.owner_id ?? null;
|
|
3853
|
+
this.archived = metadata.archived;
|
|
3854
|
+
this.autoArchiveDuration = metadata.autoArchiveDuration;
|
|
3855
|
+
this.archiveTimestamp = metadata.archiveTimestamp;
|
|
3856
|
+
this.locked = metadata.locked;
|
|
3857
|
+
this.invitable = metadata.invitable;
|
|
3858
|
+
this.rateLimitPerUser = data.rate_limit_per_user ?? 0;
|
|
3859
|
+
this.lastMessageId = data.last_message_id ?? null;
|
|
3860
|
+
this.messageCount = data.message_count ?? 0;
|
|
3861
|
+
this.totalMessageSent = data.total_message_sent ?? 0;
|
|
3862
|
+
this.memberCount = data.member_count ?? 0;
|
|
3863
|
+
this.appliedTags = data.applied_tags ?? [];
|
|
3864
|
+
this.flags = data.flags ?? 0;
|
|
3865
|
+
this.member = data.member ? new ThreadMember(data.member) : null;
|
|
3866
|
+
this.members = new ThreadMemberManager(this);
|
|
3867
|
+
}
|
|
3868
|
+
/** @internal */
|
|
3869
|
+
_patch(data) {
|
|
3870
|
+
super._patch(data);
|
|
3871
|
+
if (data.owner_id !== void 0) this.ownerId = data.owner_id ?? null;
|
|
3872
|
+
if (data.thread_metadata) {
|
|
3873
|
+
const metadata = readMetadata(data.thread_metadata);
|
|
3874
|
+
this.archived = metadata.archived;
|
|
3875
|
+
this.autoArchiveDuration = metadata.autoArchiveDuration;
|
|
3876
|
+
this.archiveTimestamp = metadata.archiveTimestamp;
|
|
3877
|
+
this.locked = metadata.locked;
|
|
3878
|
+
this.invitable = metadata.invitable;
|
|
3879
|
+
}
|
|
3880
|
+
if ("rate_limit_per_user" in data && data.rate_limit_per_user !== void 0) {
|
|
3881
|
+
this.rateLimitPerUser = data.rate_limit_per_user ?? 0;
|
|
3882
|
+
}
|
|
3883
|
+
if ("last_message_id" in data) this.lastMessageId = data.last_message_id ?? null;
|
|
3884
|
+
if (data.message_count !== void 0) this.messageCount = data.message_count;
|
|
3885
|
+
if (data.total_message_sent !== void 0) this.totalMessageSent = data.total_message_sent;
|
|
3886
|
+
if (data.member_count !== void 0) this.memberCount = data.member_count;
|
|
3887
|
+
if (data.applied_tags !== void 0) this.appliedTags = data.applied_tags ?? [];
|
|
3888
|
+
if (data.flags !== void 0) this.flags = data.flags;
|
|
3889
|
+
if (data.member !== void 0) this.member = data.member ? new ThreadMember(data.member) : null;
|
|
3890
|
+
}
|
|
3891
|
+
/**
|
|
3892
|
+
* Edit this thread. Requires Manage Threads on public threads, or ownership on private ones.
|
|
3893
|
+
* `appliedTags` is sent for public and announcement threads. `invitable` is sent for private threads.
|
|
3894
|
+
*/
|
|
3895
|
+
async edit(options) {
|
|
3896
|
+
const data = await this.client.rest.patch(import_types17.Routes.channel(this.id), {
|
|
3897
|
+
body: toThreadEditBody(this.type, threadEditFields(options)),
|
|
3898
|
+
auth: true,
|
|
3899
|
+
...auditReasonHeaders(options.reason)
|
|
3900
|
+
});
|
|
3901
|
+
this._patch(data);
|
|
3902
|
+
return this;
|
|
3903
|
+
}
|
|
3904
|
+
/** Archive or unarchive this thread. */
|
|
3905
|
+
async setArchived(archived, reason) {
|
|
3906
|
+
return this.edit({ archived, reason });
|
|
3907
|
+
}
|
|
3908
|
+
/** Lock or unlock this thread. Locked threads can only be unarchived by moderators. */
|
|
3909
|
+
async setLocked(locked, reason) {
|
|
3910
|
+
return this.edit({ locked, reason });
|
|
3911
|
+
}
|
|
3912
|
+
/** Join this thread. */
|
|
3913
|
+
async join() {
|
|
3914
|
+
await this.client.rest.put(import_types17.Routes.channelThreadMemberMe(this.id), { auth: true });
|
|
3915
|
+
}
|
|
3916
|
+
/** Leave this thread. */
|
|
3917
|
+
async leave() {
|
|
3918
|
+
await this.client.rest.delete(import_types17.Routes.channelThreadMemberMe(this.id), { auth: true });
|
|
3919
|
+
}
|
|
3920
|
+
/** Update the current user's notification settings for this thread. */
|
|
3921
|
+
async editSelf(options) {
|
|
3922
|
+
const data = await this.client.rest.patch(
|
|
3923
|
+
import_types17.Routes.channelThreadMemberMeSettings(this.id),
|
|
3924
|
+
{ body: toThreadMemberSettingsBody(options), auth: true }
|
|
3925
|
+
);
|
|
3926
|
+
this.member = data ? new ThreadMember(data) : null;
|
|
3927
|
+
return this.member;
|
|
3928
|
+
}
|
|
3929
|
+
};
|
|
3930
|
+
var ThreadMemberManager = class {
|
|
3931
|
+
constructor(thread) {
|
|
3932
|
+
this.thread = thread;
|
|
3933
|
+
}
|
|
3934
|
+
/** List members of this thread. */
|
|
3935
|
+
async fetch(options) {
|
|
3936
|
+
const data = await this.thread.client.rest.get(
|
|
3937
|
+
withQuery(import_types17.Routes.channelThreadMembers(this.thread.id), {
|
|
3938
|
+
with_member: options?.withMember === void 0 ? void 0 : String(options.withMember),
|
|
3939
|
+
after: options?.after,
|
|
3940
|
+
limit: options?.limit
|
|
3941
|
+
})
|
|
3942
|
+
);
|
|
3943
|
+
return data.map((member) => new ThreadMember(member));
|
|
3944
|
+
}
|
|
3945
|
+
/** Fetch one member of this thread. */
|
|
3946
|
+
async fetchOne(userId, options) {
|
|
3947
|
+
const data = await this.thread.client.rest.get(
|
|
3948
|
+
withQuery(import_types17.Routes.channelThreadMember(this.thread.id, userId), {
|
|
3949
|
+
with_member: options?.withMember === void 0 ? void 0 : String(options.withMember)
|
|
3950
|
+
})
|
|
3951
|
+
);
|
|
3952
|
+
return new ThreadMember(data);
|
|
3953
|
+
}
|
|
3954
|
+
/** Add a user to this thread. Private threads only, unless the caller can manage the parent. */
|
|
3955
|
+
async add(userId) {
|
|
3956
|
+
await this.thread.client.rest.put(import_types17.Routes.channelThreadMember(this.thread.id, userId), {
|
|
3957
|
+
auth: true
|
|
3958
|
+
});
|
|
3959
|
+
}
|
|
3960
|
+
/** Remove a user from this thread. */
|
|
3961
|
+
async remove(userId) {
|
|
3962
|
+
await this.thread.client.rest.delete(import_types17.Routes.channelThreadMember(this.thread.id, userId), {
|
|
3963
|
+
auth: true
|
|
3964
|
+
});
|
|
3965
|
+
}
|
|
3966
|
+
};
|
|
3967
|
+
function isThreadType(type) {
|
|
3968
|
+
return type === import_types17.ChannelType.AnnouncementThread || type === import_types17.ChannelType.PublicThread || type === import_types17.ChannelType.PrivateThread;
|
|
3969
|
+
}
|
|
3970
|
+
|
|
3971
|
+
// src/Domain/Channel/ThreadManager.ts
|
|
3972
|
+
var ThreadManager = class {
|
|
3973
|
+
constructor(channel) {
|
|
3974
|
+
this.channel = channel;
|
|
3975
|
+
}
|
|
3976
|
+
/**
|
|
3977
|
+
* Start a thread in a text or announcement channel.
|
|
3978
|
+
* Forum and media channels must use {@link createPost}.
|
|
3979
|
+
*/
|
|
3980
|
+
async create(options) {
|
|
3981
|
+
if (this.channel.type === import_types18.ChannelType.GuildForum || this.channel.type === import_types18.ChannelType.GuildMedia) {
|
|
3982
|
+
throw new import_util4.FluxerError("Forum and media channels start posts with createPost", {
|
|
3983
|
+
code: import_util3.ErrorCodes.InvalidChannelType
|
|
3984
|
+
});
|
|
3985
|
+
}
|
|
3986
|
+
const data = await this.channel.client.rest.post(
|
|
3987
|
+
import_types18.Routes.channelThreads(this.channel.id),
|
|
3988
|
+
{
|
|
3989
|
+
body: toStartThreadBody(this.channel.type, options),
|
|
3990
|
+
auth: true,
|
|
3991
|
+
...auditReasonHeaders(options.reason)
|
|
3992
|
+
}
|
|
3993
|
+
);
|
|
3994
|
+
return cacheThread(this.channel.client, data);
|
|
3995
|
+
}
|
|
3996
|
+
/**
|
|
3997
|
+
* Start a post in a forum or media channel.
|
|
3998
|
+
* The post is a public thread. `message` is its first message.
|
|
3999
|
+
*/
|
|
4000
|
+
async createPost(options) {
|
|
4001
|
+
if (this.channel.type !== import_types18.ChannelType.GuildForum && this.channel.type !== import_types18.ChannelType.GuildMedia) {
|
|
4002
|
+
throw new import_util4.FluxerError("createPost is for forum and media channels", {
|
|
4003
|
+
code: import_util3.ErrorCodes.InvalidChannelType
|
|
4004
|
+
});
|
|
4005
|
+
}
|
|
4006
|
+
const prepared = await prepareMessagePostPayload(options.message, {
|
|
4007
|
+
defaultAllowedMentions: this.channel.client.options.defaultAllowedMentions
|
|
4008
|
+
});
|
|
4009
|
+
const body = {
|
|
4010
|
+
name: options.name,
|
|
4011
|
+
type: import_types18.ChannelType.PublicThread,
|
|
4012
|
+
message: toForumThreadMessage(prepared.body)
|
|
4013
|
+
};
|
|
4014
|
+
if (options.autoArchiveDuration !== void 0) {
|
|
4015
|
+
body.auto_archive_duration = options.autoArchiveDuration;
|
|
4016
|
+
}
|
|
4017
|
+
if (options.rateLimitPerUser !== void 0) body.rate_limit_per_user = options.rateLimitPerUser;
|
|
4018
|
+
if (options.appliedTags !== void 0) body.applied_tags = options.appliedTags;
|
|
4019
|
+
const data = await this.channel.client.rest.post(
|
|
4020
|
+
import_types18.Routes.channelThreads(this.channel.id),
|
|
4021
|
+
{
|
|
4022
|
+
body,
|
|
4023
|
+
files: prepared.files,
|
|
4024
|
+
auth: true,
|
|
4025
|
+
...auditReasonHeaders(options.reason)
|
|
4026
|
+
}
|
|
4027
|
+
);
|
|
4028
|
+
const thread = cacheThread(this.channel.client, data);
|
|
4029
|
+
if (data.message) {
|
|
4030
|
+
this.channel.client._addMessageToCache(data.message.channel_id, data.message);
|
|
4031
|
+
}
|
|
4032
|
+
return thread;
|
|
4033
|
+
}
|
|
4034
|
+
/**
|
|
4035
|
+
* List archived threads in this channel.
|
|
4036
|
+
* `before` is an ISO-8601 archive timestamp.
|
|
4037
|
+
*/
|
|
4038
|
+
async fetchArchived(options) {
|
|
4039
|
+
const path = options.type === "private" ? import_types18.Routes.channelThreadsArchivedPrivate(this.channel.id) : import_types18.Routes.channelThreadsArchivedPublic(this.channel.id);
|
|
4040
|
+
const data = await this.channel.client.rest.get(
|
|
4041
|
+
withQuery(path, { before: options.before, limit: options.limit })
|
|
4042
|
+
);
|
|
4043
|
+
return fetchedThreadsFrom(this.channel.client, data);
|
|
4044
|
+
}
|
|
4045
|
+
/**
|
|
4046
|
+
* List private archived threads in this channel that the current user has joined.
|
|
4047
|
+
* `before` is a thread snowflake.
|
|
4048
|
+
*/
|
|
4049
|
+
async fetchJoinedPrivateArchived(options) {
|
|
4050
|
+
const data = await this.channel.client.rest.get(
|
|
4051
|
+
withQuery(import_types18.Routes.channelJoinedArchivedPrivateThreads(this.channel.id), {
|
|
4052
|
+
before: options?.before,
|
|
4053
|
+
limit: options?.limit
|
|
4054
|
+
})
|
|
4055
|
+
);
|
|
4056
|
+
return fetchedThreadsFrom(this.channel.client, data);
|
|
4057
|
+
}
|
|
4058
|
+
/**
|
|
4059
|
+
* Search threads in this channel.
|
|
4060
|
+
* Returns `{ indexing: true }` while the search index is still building.
|
|
4061
|
+
*/
|
|
4062
|
+
async search(options) {
|
|
4063
|
+
const data = await this.channel.client.rest.get(
|
|
4064
|
+
withQuery(import_types18.Routes.channelThreadSearch(this.channel.id), {
|
|
4065
|
+
name: options?.name,
|
|
4066
|
+
tag: options?.tag,
|
|
4067
|
+
tag_setting: options?.tagSetting,
|
|
4068
|
+
archived: options?.archived === void 0 ? void 0 : String(options.archived),
|
|
4069
|
+
sort_by: options?.sortBy,
|
|
4070
|
+
sort_order: options?.sortOrder,
|
|
4071
|
+
limit: options?.limit,
|
|
4072
|
+
offset: options?.offset,
|
|
4073
|
+
max_id: options?.maxId,
|
|
4074
|
+
min_id: options?.minId
|
|
4075
|
+
})
|
|
4076
|
+
);
|
|
4077
|
+
if (isSearchNotReady(data)) {
|
|
4078
|
+
return { indexing: true, retryAfter: data.retry_after, message: data.message };
|
|
4079
|
+
}
|
|
4080
|
+
const page = fetchedThreadsFrom(this.channel.client, data);
|
|
4081
|
+
return {
|
|
4082
|
+
...page,
|
|
4083
|
+
hasMore: data.has_more,
|
|
4084
|
+
totalResults: data.total_results,
|
|
4085
|
+
firstMessages: (data.first_messages ?? []).map(
|
|
4086
|
+
(message) => new Message(this.channel.client, message)
|
|
4087
|
+
)
|
|
4088
|
+
};
|
|
4089
|
+
}
|
|
4090
|
+
/** Set the auto-archive and slowmode defaults copied onto new threads. */
|
|
4091
|
+
async editDefaults(options) {
|
|
4092
|
+
return this.channel.client.rest.patch(import_types18.Routes.channel(this.channel.id), {
|
|
4093
|
+
body: toThreadParentEditBody(options),
|
|
4094
|
+
auth: true,
|
|
4095
|
+
...auditReasonHeaders(options.reason)
|
|
4096
|
+
});
|
|
4097
|
+
}
|
|
4098
|
+
};
|
|
4099
|
+
function fetchedThreadsFrom(client, data) {
|
|
4100
|
+
return {
|
|
4101
|
+
threads: (data.threads ?? []).map((thread) => cacheThread(client, thread)),
|
|
4102
|
+
members: (data.members ?? []).map((member) => new ThreadMember(member)),
|
|
4103
|
+
hasMore: data.has_more ?? false
|
|
4104
|
+
};
|
|
4105
|
+
}
|
|
4106
|
+
function isSearchNotReady(data) {
|
|
4107
|
+
return "code" in data && data.code === "SEARCH_INDEX_NOT_READY";
|
|
4108
|
+
}
|
|
4109
|
+
async function fetchActiveThreads(client, guildId) {
|
|
4110
|
+
const data = await client.rest.get(import_types18.Routes.guildActiveThreads(guildId));
|
|
4111
|
+
return fetchedThreadsFrom(client, data);
|
|
4112
|
+
}
|
|
4113
|
+
|
|
4114
|
+
// src/Domain/Channel/Forum.ts
|
|
4115
|
+
function tagsFrom(data) {
|
|
4116
|
+
return data ?? [];
|
|
4117
|
+
}
|
|
4118
|
+
var ThreadOnlyChannel = class extends GuildChannel {
|
|
4119
|
+
/** Tags that can be applied to posts. */
|
|
4120
|
+
availableTags;
|
|
4121
|
+
/** Default reaction for new posts. */
|
|
4122
|
+
defaultReactionEmoji;
|
|
4123
|
+
/** Default sort order for posts. */
|
|
4124
|
+
defaultSortOrder;
|
|
4125
|
+
/** How posts are filtered when searching by several tags. */
|
|
4126
|
+
defaultTagSetting;
|
|
4127
|
+
/** Default auto-archive duration in minutes for new posts. */
|
|
4128
|
+
defaultAutoArchiveDuration;
|
|
4129
|
+
/** Slowmode in seconds copied onto new posts. */
|
|
4130
|
+
defaultThreadRateLimitPerUser;
|
|
4131
|
+
/** Channel flags bitfield. */
|
|
4132
|
+
flags;
|
|
4133
|
+
/** Create, list, and search posts in this channel. */
|
|
4134
|
+
threads;
|
|
4135
|
+
constructor(client, data) {
|
|
4136
|
+
super(client, data);
|
|
4137
|
+
this.availableTags = tagsFrom(data.available_tags);
|
|
4138
|
+
this.defaultReactionEmoji = data.default_reaction_emoji ?? null;
|
|
4139
|
+
this.defaultSortOrder = data.default_sort_order ?? null;
|
|
4140
|
+
this.defaultTagSetting = data.default_tag_setting ?? null;
|
|
4141
|
+
this.defaultAutoArchiveDuration = data.default_auto_archive_duration ?? null;
|
|
4142
|
+
this.defaultThreadRateLimitPerUser = data.default_thread_rate_limit_per_user ?? null;
|
|
4143
|
+
this.flags = data.flags ?? 0;
|
|
4144
|
+
this.threads = new ThreadManager(this);
|
|
4145
|
+
}
|
|
4146
|
+
/** @internal */
|
|
4147
|
+
_patch(data) {
|
|
4148
|
+
super._patch(data);
|
|
4149
|
+
if (data.available_tags !== void 0) this.availableTags = tagsFrom(data.available_tags);
|
|
4150
|
+
if ("default_reaction_emoji" in data) {
|
|
4151
|
+
this.defaultReactionEmoji = data.default_reaction_emoji ?? null;
|
|
4152
|
+
}
|
|
4153
|
+
if ("default_sort_order" in data) this.defaultSortOrder = data.default_sort_order ?? null;
|
|
4154
|
+
if ("default_tag_setting" in data) this.defaultTagSetting = data.default_tag_setting ?? null;
|
|
4155
|
+
if ("default_auto_archive_duration" in data) {
|
|
4156
|
+
this.defaultAutoArchiveDuration = data.default_auto_archive_duration ?? null;
|
|
4157
|
+
}
|
|
4158
|
+
if ("default_thread_rate_limit_per_user" in data) {
|
|
4159
|
+
this.defaultThreadRateLimitPerUser = data.default_thread_rate_limit_per_user ?? null;
|
|
4160
|
+
}
|
|
4161
|
+
if (data.flags !== void 0) this.flags = data.flags;
|
|
4162
|
+
}
|
|
4163
|
+
/**
|
|
4164
|
+
* Edit this channel.
|
|
4165
|
+
* Tag, sort, reaction, and thread-default fields are sent with the usual channel fields.
|
|
4166
|
+
* `defaultForumLayout` is sent only for forum channels.
|
|
4167
|
+
*/
|
|
4168
|
+
async edit(options) {
|
|
4169
|
+
const data = await this.client.rest.patch(import_types19.Routes.channel(this.id), {
|
|
4170
|
+
body: {
|
|
4171
|
+
...toChannelEditBody(options),
|
|
4172
|
+
...forumParentWire(options, this.type === import_types19.ChannelType.GuildForum)
|
|
4173
|
+
},
|
|
4174
|
+
auth: true,
|
|
4175
|
+
...auditReasonHeaders(options.reason)
|
|
4176
|
+
});
|
|
4177
|
+
this._patch(data);
|
|
4178
|
+
return this;
|
|
4179
|
+
}
|
|
4180
|
+
/** Replace the tags that can be applied to posts (max 20). */
|
|
4181
|
+
async setAvailableTags(tags, reason) {
|
|
4182
|
+
return this.edit({ availableTags: tags, reason });
|
|
4183
|
+
}
|
|
4184
|
+
/** Set or clear the default reaction on new posts. */
|
|
4185
|
+
async setDefaultReactionEmoji(emoji, reason) {
|
|
4186
|
+
return this.edit({ defaultReactionEmoji: emoji, reason });
|
|
4187
|
+
}
|
|
4188
|
+
/** Set or clear the default post sort order. */
|
|
4189
|
+
async setDefaultSortOrder(order, reason) {
|
|
4190
|
+
return this.edit({ defaultSortOrder: order, reason });
|
|
4191
|
+
}
|
|
4192
|
+
/** Set or clear how posts match when several tags are selected. */
|
|
4193
|
+
async setDefaultTagSetting(setting, reason) {
|
|
4194
|
+
return this.edit({ defaultTagSetting: setting, reason });
|
|
4195
|
+
}
|
|
4196
|
+
/** Set the auto-archive and slowmode defaults copied onto new posts. */
|
|
4197
|
+
async editThreadDefaults(options) {
|
|
4198
|
+
const data = await this.client.rest.patch(import_types19.Routes.channel(this.id), {
|
|
4199
|
+
body: toThreadParentEditBody(options),
|
|
4200
|
+
auth: true,
|
|
4201
|
+
...auditReasonHeaders(options.reason)
|
|
4202
|
+
});
|
|
4203
|
+
this._patch(data);
|
|
4204
|
+
return this;
|
|
4205
|
+
}
|
|
4206
|
+
/** Create a tag. The response replaces {@link availableTags}. */
|
|
4207
|
+
async createTag(options) {
|
|
4208
|
+
const data = await this.client.rest.post(import_types19.Routes.channelTags(this.id), {
|
|
4209
|
+
body: toForumTagBody(options),
|
|
4210
|
+
auth: true,
|
|
4211
|
+
...auditReasonHeaders(options.reason)
|
|
4212
|
+
});
|
|
4213
|
+
this._patch(data);
|
|
4214
|
+
return this;
|
|
4215
|
+
}
|
|
4216
|
+
/** Replace a tag. The response replaces {@link availableTags}. */
|
|
4217
|
+
async editTag(tagId, options) {
|
|
4218
|
+
const data = await this.client.rest.put(import_types19.Routes.channelTag(this.id, tagId), {
|
|
4219
|
+
body: toForumTagBody(options),
|
|
4220
|
+
auth: true,
|
|
4221
|
+
...auditReasonHeaders(options.reason)
|
|
4222
|
+
});
|
|
4223
|
+
this._patch(data);
|
|
4224
|
+
return this;
|
|
4225
|
+
}
|
|
4226
|
+
/** Delete a tag. The response replaces {@link availableTags}. */
|
|
4227
|
+
async deleteTag(tagId, reason) {
|
|
4228
|
+
const data = await this.client.rest.delete(import_types19.Routes.channelTag(this.id, tagId), {
|
|
4229
|
+
auth: true,
|
|
4230
|
+
...auditReasonHeaders(reason)
|
|
4231
|
+
});
|
|
4232
|
+
this._patch(data);
|
|
4233
|
+
return this;
|
|
4234
|
+
}
|
|
4235
|
+
};
|
|
4236
|
+
var ForumChannel = class extends ThreadOnlyChannel {
|
|
4237
|
+
/** Default layout for posts. */
|
|
4238
|
+
defaultForumLayout;
|
|
4239
|
+
/** Set or clear the default post layout. */
|
|
4240
|
+
async setDefaultForumLayout(layout, reason) {
|
|
4241
|
+
return this.edit({ defaultForumLayout: layout, reason });
|
|
4242
|
+
}
|
|
4243
|
+
constructor(client, data) {
|
|
4244
|
+
super(client, data);
|
|
4245
|
+
this.defaultForumLayout = data.default_forum_layout ?? null;
|
|
4246
|
+
}
|
|
4247
|
+
/** @internal */
|
|
4248
|
+
_patch(data) {
|
|
4249
|
+
super._patch(data);
|
|
4250
|
+
if ("default_forum_layout" in data) this.defaultForumLayout = data.default_forum_layout ?? null;
|
|
4251
|
+
}
|
|
4252
|
+
};
|
|
4253
|
+
var MediaChannel = class extends ThreadOnlyChannel {
|
|
4254
|
+
};
|
|
4255
|
+
|
|
3501
4256
|
// src/Domain/Channel/Factory.ts
|
|
3502
|
-
var
|
|
4257
|
+
var import_types20 = require("@fluxerjs/types");
|
|
3503
4258
|
var GUILD_FACTORIES = {
|
|
3504
|
-
[
|
|
3505
|
-
[
|
|
3506
|
-
[
|
|
3507
|
-
[
|
|
3508
|
-
[
|
|
4259
|
+
[import_types20.ChannelType.GuildText]: (c, d) => new TextChannel(c, d),
|
|
4260
|
+
[import_types20.ChannelType.GuildAnnouncement]: (c, d) => new AnnouncementChannel(c, d),
|
|
4261
|
+
[import_types20.ChannelType.GuildCategory]: (c, d) => new CategoryChannel(c, d),
|
|
4262
|
+
[import_types20.ChannelType.GuildVoice]: (c, d) => new VoiceChannel(c, d),
|
|
4263
|
+
[import_types20.ChannelType.GuildLink]: (c, d) => new LinkChannel(c, d),
|
|
4264
|
+
[import_types20.ChannelType.AnnouncementThread]: (c, d) => new ThreadChannel(c, d),
|
|
4265
|
+
[import_types20.ChannelType.PublicThread]: (c, d) => new ThreadChannel(c, d),
|
|
4266
|
+
[import_types20.ChannelType.PrivateThread]: (c, d) => new ThreadChannel(c, d),
|
|
4267
|
+
[import_types20.ChannelType.GuildForum]: (c, d) => new ForumChannel(c, d),
|
|
4268
|
+
[import_types20.ChannelType.GuildMedia]: (c, d) => new MediaChannel(c, d)
|
|
3509
4269
|
};
|
|
3510
4270
|
var DM_TYPES = /* @__PURE__ */ new Set([
|
|
3511
|
-
|
|
3512
|
-
|
|
3513
|
-
|
|
4271
|
+
import_types20.ChannelType.DM,
|
|
4272
|
+
import_types20.ChannelType.GroupDM,
|
|
4273
|
+
import_types20.ChannelType.DMPersonalNotes
|
|
3514
4274
|
]);
|
|
3515
4275
|
function createDM(client, data) {
|
|
3516
4276
|
return new DMChannel(client, data);
|
|
3517
4277
|
}
|
|
3518
4278
|
function channelFrom(client, data) {
|
|
3519
|
-
const
|
|
3520
|
-
return
|
|
4279
|
+
const factory2 = GUILD_FACTORIES[data.type ?? 0];
|
|
4280
|
+
return factory2 ? factory2(client, data) : new GuildChannel(client, data);
|
|
3521
4281
|
}
|
|
3522
4282
|
function channelFromOrCreate(client, data) {
|
|
3523
4283
|
return DM_TYPES.has(data.type ?? 0) ? createDM(client, data) : channelFrom(client, data);
|
|
@@ -3527,9 +4287,13 @@ function channelFromOrCreate(client, data) {
|
|
|
3527
4287
|
Channel.from = channelFrom;
|
|
3528
4288
|
Channel.fromOrCreate = channelFromOrCreate;
|
|
3529
4289
|
Channel.createDM = createDM;
|
|
4290
|
+
bindThreadManager((channel) => new ThreadManager(channel));
|
|
4291
|
+
|
|
4292
|
+
// src/Domain/Guild/Cache.ts
|
|
4293
|
+
var import_types27 = require("@fluxerjs/types");
|
|
3530
4294
|
|
|
3531
4295
|
// src/Domain/Guild/GuildEmoji.ts
|
|
3532
|
-
var
|
|
4296
|
+
var import_types21 = require("@fluxerjs/types");
|
|
3533
4297
|
var import_util14 = require("@fluxerjs/util");
|
|
3534
4298
|
var GuildEmoji = class extends Base {
|
|
3535
4299
|
client;
|
|
@@ -3578,7 +4342,7 @@ var GuildEmoji = class extends Base {
|
|
|
3578
4342
|
}
|
|
3579
4343
|
/** Delete this emoji. Requires Manage Emojis and Stickers permission. */
|
|
3580
4344
|
async delete(reason) {
|
|
3581
|
-
await this.client.rest.delete(
|
|
4345
|
+
await this.client.rest.delete(import_types21.Routes.guildEmoji(this.guildId, this.id), {
|
|
3582
4346
|
auth: true,
|
|
3583
4347
|
...auditReasonHeaders(reason)
|
|
3584
4348
|
});
|
|
@@ -3591,7 +4355,7 @@ var GuildEmoji = class extends Base {
|
|
|
3591
4355
|
*/
|
|
3592
4356
|
async edit(options) {
|
|
3593
4357
|
const { reason, name } = options;
|
|
3594
|
-
const data = await this.client.rest.patch(
|
|
4358
|
+
const data = await this.client.rest.patch(import_types21.Routes.guildEmoji(this.guildId, this.id), {
|
|
3595
4359
|
body: { name },
|
|
3596
4360
|
auth: true,
|
|
3597
4361
|
...auditReasonHeaders(reason)
|
|
@@ -3602,11 +4366,11 @@ var GuildEmoji = class extends Base {
|
|
|
3602
4366
|
};
|
|
3603
4367
|
|
|
3604
4368
|
// src/Domain/Guild/GuildMember.ts
|
|
3605
|
-
var
|
|
4369
|
+
var import_types24 = require("@fluxerjs/types");
|
|
3606
4370
|
var import_util16 = require("@fluxerjs/util");
|
|
3607
4371
|
|
|
3608
4372
|
// src/Helpers/Permissions.ts
|
|
3609
|
-
var
|
|
4373
|
+
var import_types22 = require("@fluxerjs/types");
|
|
3610
4374
|
var import_util15 = require("@fluxerjs/util");
|
|
3611
4375
|
function computePermissions(basePermissions, overwrites, memberRoles, memberId, isOwner) {
|
|
3612
4376
|
if (isOwner) return import_util15.ALL_PERMISSIONS_BIGINT;
|
|
@@ -3615,7 +4379,7 @@ function computePermissions(basePermissions, overwrites, memberRoles, memberId,
|
|
|
3615
4379
|
}
|
|
3616
4380
|
let perms = basePermissions;
|
|
3617
4381
|
for (const overwrite of overwrites ?? []) {
|
|
3618
|
-
const applies = overwrite.type ===
|
|
4382
|
+
const applies = overwrite.type === import_types22.OverwriteType.Role && memberRoles.includes(overwrite.id) || overwrite.type === import_types22.OverwriteType.Member && overwrite.id === memberId;
|
|
3619
4383
|
if (!applies) continue;
|
|
3620
4384
|
const allow = BigInt(overwrite.allow || "0");
|
|
3621
4385
|
const deny = BigInt(overwrite.deny || "0");
|
|
@@ -3626,7 +4390,7 @@ function computePermissions(basePermissions, overwrites, memberRoles, memberId,
|
|
|
3626
4390
|
|
|
3627
4391
|
// src/Domain/Guild/GuildMemberRoleManager.ts
|
|
3628
4392
|
var import_collection7 = require("@fluxerjs/collection");
|
|
3629
|
-
var
|
|
4393
|
+
var import_types23 = require("@fluxerjs/types");
|
|
3630
4394
|
function roleId(roleOrId) {
|
|
3631
4395
|
return typeof roleOrId === "string" ? roleOrId : roleOrId.id;
|
|
3632
4396
|
}
|
|
@@ -3655,7 +4419,7 @@ var GuildMemberRoleManager = class {
|
|
|
3655
4419
|
const id = roleId(roleOrId);
|
|
3656
4420
|
if (this.ids.includes(id)) return;
|
|
3657
4421
|
await this.member.client.rest.put(
|
|
3658
|
-
|
|
4422
|
+
import_types23.Routes.guildMemberRole(this.member.guild.id, this.member.id, id)
|
|
3659
4423
|
);
|
|
3660
4424
|
this.ids.push(id);
|
|
3661
4425
|
}
|
|
@@ -3664,13 +4428,13 @@ var GuildMemberRoleManager = class {
|
|
|
3664
4428
|
const idx = this.ids.indexOf(id);
|
|
3665
4429
|
if (idx === -1) return;
|
|
3666
4430
|
await this.member.client.rest.delete(
|
|
3667
|
-
|
|
4431
|
+
import_types23.Routes.guildMemberRole(this.member.guild.id, this.member.id, id)
|
|
3668
4432
|
);
|
|
3669
4433
|
this.ids.splice(idx, 1);
|
|
3670
4434
|
}
|
|
3671
4435
|
async set(roleIds) {
|
|
3672
4436
|
const data = await this.member.client.rest.patch(
|
|
3673
|
-
|
|
4437
|
+
import_types23.Routes.guildMember(this.member.guild.id, this.member.id),
|
|
3674
4438
|
{ body: { roles: roleIds }, auth: true }
|
|
3675
4439
|
);
|
|
3676
4440
|
this.ids = data.roles ? [...data.roles] : [];
|
|
@@ -3824,7 +4588,7 @@ var GuildMember = class _GuildMember extends Base {
|
|
|
3824
4588
|
*/
|
|
3825
4589
|
async edit(options) {
|
|
3826
4590
|
const isMe = this.client.user?.id === this.id;
|
|
3827
|
-
const route = isMe ?
|
|
4591
|
+
const route = isMe ? import_types24.Routes.guildMemberMe(this.guild.id) : import_types24.Routes.guildMember(this.guild.id, this.id);
|
|
3828
4592
|
const data = await this.client.rest.patch(route, {
|
|
3829
4593
|
body: toMemberEditBody(options),
|
|
3830
4594
|
auth: true,
|
|
@@ -3937,7 +4701,7 @@ var GuildMember = class _GuildMember extends Base {
|
|
|
3937
4701
|
};
|
|
3938
4702
|
|
|
3939
4703
|
// src/Domain/Guild/GuildSticker.ts
|
|
3940
|
-
var
|
|
4704
|
+
var import_types25 = require("@fluxerjs/types");
|
|
3941
4705
|
var import_util17 = require("@fluxerjs/util");
|
|
3942
4706
|
var GuildSticker = class extends Base {
|
|
3943
4707
|
client;
|
|
@@ -3988,7 +4752,7 @@ var GuildSticker = class extends Base {
|
|
|
3988
4752
|
}
|
|
3989
4753
|
/** Delete this sticker. Requires Manage Emojis and Stickers permission. */
|
|
3990
4754
|
async delete(reason) {
|
|
3991
|
-
await this.client.rest.delete(
|
|
4755
|
+
await this.client.rest.delete(import_types25.Routes.guildSticker(this.guildId, this.id), {
|
|
3992
4756
|
auth: true,
|
|
3993
4757
|
...auditReasonHeaders(reason)
|
|
3994
4758
|
});
|
|
@@ -4001,7 +4765,7 @@ var GuildSticker = class extends Base {
|
|
|
4001
4765
|
*/
|
|
4002
4766
|
async edit(options) {
|
|
4003
4767
|
const { reason, ...body } = options;
|
|
4004
|
-
const data = await this.client.rest.patch(
|
|
4768
|
+
const data = await this.client.rest.patch(import_types25.Routes.guildSticker(this.guildId, this.id), {
|
|
4005
4769
|
body,
|
|
4006
4770
|
auth: true,
|
|
4007
4771
|
...auditReasonHeaders(reason)
|
|
@@ -4014,7 +4778,7 @@ var GuildSticker = class extends Base {
|
|
|
4014
4778
|
};
|
|
4015
4779
|
|
|
4016
4780
|
// src/Domain/Guild/Role.ts
|
|
4017
|
-
var
|
|
4781
|
+
var import_types26 = require("@fluxerjs/types");
|
|
4018
4782
|
var import_util18 = require("@fluxerjs/util");
|
|
4019
4783
|
var Role = class _Role extends Base {
|
|
4020
4784
|
/** Parent client instance. */
|
|
@@ -4124,7 +4888,7 @@ var Role = class _Role extends Base {
|
|
|
4124
4888
|
*/
|
|
4125
4889
|
async edit(options) {
|
|
4126
4890
|
const body = toRoleEditBody(options);
|
|
4127
|
-
const data = await this.client.rest.patch(
|
|
4891
|
+
const data = await this.client.rest.patch(import_types26.Routes.guildRole(this.guildId, this.id), {
|
|
4128
4892
|
body: Object.keys(body).length ? body : void 0,
|
|
4129
4893
|
auth: true,
|
|
4130
4894
|
...auditReasonHeaders(options.reason)
|
|
@@ -4137,7 +4901,7 @@ var Role = class _Role extends Base {
|
|
|
4137
4901
|
* @param reason - Audit log reason (`X-Audit-Log-Reason`)
|
|
4138
4902
|
*/
|
|
4139
4903
|
async delete(reason) {
|
|
4140
|
-
await this.client.rest.delete(
|
|
4904
|
+
await this.client.rest.delete(import_types26.Routes.guildRole(this.guildId, this.id), {
|
|
4141
4905
|
auth: true,
|
|
4142
4906
|
...auditReasonHeaders(reason)
|
|
4143
4907
|
});
|
|
@@ -4232,11 +4996,30 @@ function syncChannels(guild, channels) {
|
|
|
4232
4996
|
const keep = new Set(channels.map((c) => c.id));
|
|
4233
4997
|
for (const data of channels) cacheChannel(guild, data);
|
|
4234
4998
|
for (const [id, channel] of [...guild.channels.entries()]) {
|
|
4235
|
-
if (keep.has(id)) continue;
|
|
4999
|
+
if (keep.has(id) || channel.isThread()) continue;
|
|
4236
5000
|
Map.prototype.delete.call(guild.channels, id);
|
|
4237
5001
|
guild.client.cache.cascadeChannel(channel, "guild");
|
|
4238
5002
|
}
|
|
4239
5003
|
}
|
|
5004
|
+
function isThreadChannelType(type) {
|
|
5005
|
+
return type === import_types27.ChannelType.AnnouncementThread || type === import_types27.ChannelType.PublicThread || type === import_types27.ChannelType.PrivateThread;
|
|
5006
|
+
}
|
|
5007
|
+
function syncThreads(guild, threads, alsoKeep = /* @__PURE__ */ new Set()) {
|
|
5008
|
+
const keep = new Set(alsoKeep);
|
|
5009
|
+
for (const data of threads) {
|
|
5010
|
+
if (!isThreadChannelType(data.type)) continue;
|
|
5011
|
+
const withGuild = data.guild_id ? data : { ...data, guild_id: guild.id };
|
|
5012
|
+
cacheThread(guild.client, withGuild);
|
|
5013
|
+
keep.add(data.id);
|
|
5014
|
+
}
|
|
5015
|
+
const seen = /* @__PURE__ */ new Set();
|
|
5016
|
+
for (const channel of [...guild.channels.values(), ...guild.client.channels.values()]) {
|
|
5017
|
+
if (seen.has(channel.id)) continue;
|
|
5018
|
+
seen.add(channel.id);
|
|
5019
|
+
if (!channel.isThread() || channel.guildId !== guild.id || keep.has(channel.id)) continue;
|
|
5020
|
+
guild.client.cache.cascadeChannel(channel);
|
|
5021
|
+
}
|
|
5022
|
+
}
|
|
4240
5023
|
function mergeMembers(guild, members) {
|
|
4241
5024
|
for (const m of members) {
|
|
4242
5025
|
if (!m.user?.id) continue;
|
|
@@ -4300,7 +5083,7 @@ var ChannelManager = class extends import_collection8.LimitedCollection {
|
|
|
4300
5083
|
const cached = this.get(channelId);
|
|
4301
5084
|
if (cached && !options?.force) return cached;
|
|
4302
5085
|
try {
|
|
4303
|
-
const data = await this.client.rest.get(
|
|
5086
|
+
const data = await this.client.rest.get(import_types28.Routes.channel(channelId));
|
|
4304
5087
|
const guildId = "guild_id" in data ? data.guild_id : void 0;
|
|
4305
5088
|
if (guildId) {
|
|
4306
5089
|
const guild = this.client.guilds.get(guildId);
|
|
@@ -4345,7 +5128,7 @@ var ChannelManager = class extends import_collection8.LimitedCollection {
|
|
|
4345
5128
|
defaultAllowedMentions: this.client.options.defaultAllowedMentions
|
|
4346
5129
|
});
|
|
4347
5130
|
const data = await this.client.rest.post(
|
|
4348
|
-
|
|
5131
|
+
import_types28.Routes.channelMessages(channelId),
|
|
4349
5132
|
postPayload
|
|
4350
5133
|
);
|
|
4351
5134
|
this.client._addMessageToCache(channelId, data);
|
|
@@ -4356,11 +5139,11 @@ var ChannelManager = class extends import_collection8.LimitedCollection {
|
|
|
4356
5139
|
// src/ClientCore/Client.ts
|
|
4357
5140
|
var import_node_events3 = require("events");
|
|
4358
5141
|
var import_rest3 = require("@fluxerjs/rest");
|
|
4359
|
-
var
|
|
5142
|
+
var import_types45 = require("@fluxerjs/types");
|
|
4360
5143
|
var import_util26 = require("@fluxerjs/util");
|
|
4361
5144
|
|
|
4362
5145
|
// src/Domain/User.ts
|
|
4363
|
-
var
|
|
5146
|
+
var import_types29 = require("@fluxerjs/types");
|
|
4364
5147
|
var import_util19 = require("@fluxerjs/util");
|
|
4365
5148
|
var User = class extends Base {
|
|
4366
5149
|
/** Parent client instance. */
|
|
@@ -4459,7 +5242,7 @@ var User = class extends Base {
|
|
|
4459
5242
|
* @returns DM channel instance (cached if already open)
|
|
4460
5243
|
*/
|
|
4461
5244
|
async createDM() {
|
|
4462
|
-
const data = await this.client.rest.post(
|
|
5245
|
+
const data = await this.client.rest.post(import_types29.Routes.userMeChannels(), {
|
|
4463
5246
|
body: { recipient_id: this.id },
|
|
4464
5247
|
auth: true
|
|
4465
5248
|
});
|
|
@@ -4537,7 +5320,7 @@ function resolveCacheLimits(input) {
|
|
|
4537
5320
|
|
|
4538
5321
|
// src/ClientCore/ClientEmoji.ts
|
|
4539
5322
|
var import_collection9 = require("@fluxerjs/collection");
|
|
4540
|
-
var
|
|
5323
|
+
var import_types30 = require("@fluxerjs/types");
|
|
4541
5324
|
var import_util20 = require("@fluxerjs/util");
|
|
4542
5325
|
async function resolveClientEmoji(client, emoji, guildId) {
|
|
4543
5326
|
if (typeof emoji === "object" && emoji.id) {
|
|
@@ -4556,7 +5339,7 @@ async function resolveClientEmoji(client, emoji, guildId) {
|
|
|
4556
5339
|
const unicodeFromShortcode = (0, import_util20.getUnicodeFromShortcode)(parsed.name);
|
|
4557
5340
|
if (unicodeFromShortcode) return unicodeFromShortcode;
|
|
4558
5341
|
if (guildId) {
|
|
4559
|
-
const emojis = await client.rest.get(
|
|
5342
|
+
const emojis = await client.rest.get(import_types30.Routes.guildEmojis(guildId));
|
|
4560
5343
|
const found = emojis.find((e) => e.name && e.name.toLowerCase() === parsed.name.toLowerCase());
|
|
4561
5344
|
if (found) return (0, import_util20.formatEmoji)({ ...parsed, id: found.id, animated: found.animated });
|
|
4562
5345
|
throw new import_util4.FluxerError(
|
|
@@ -4573,26 +5356,26 @@ async function resolveClientEmoji(client, emoji, guildId) {
|
|
|
4573
5356
|
return parsed.name;
|
|
4574
5357
|
}
|
|
4575
5358
|
async function fetchInstance(client) {
|
|
4576
|
-
const raw = await client.rest.get(
|
|
5359
|
+
const raw = await client.rest.get(import_types30.Routes.instanceDiscovery(), {
|
|
4577
5360
|
auth: false,
|
|
4578
5361
|
unversioned: true
|
|
4579
5362
|
});
|
|
4580
5363
|
return parseInstanceDiscovery(raw);
|
|
4581
5364
|
}
|
|
4582
5365
|
function fetchGatewayInfo(client) {
|
|
4583
|
-
return client.rest.get(
|
|
5366
|
+
return client.rest.get(import_types30.Routes.gatewayBot());
|
|
4584
5367
|
}
|
|
4585
5368
|
function fetchEmojiMetadata(client, emojiId) {
|
|
4586
|
-
return client.rest.get(
|
|
5369
|
+
return client.rest.get(import_types30.Routes.emojiMetadata(emojiId), { auth: true });
|
|
4587
5370
|
}
|
|
4588
5371
|
function fetchStickerMetadata(client, stickerId) {
|
|
4589
|
-
return client.rest.get(
|
|
5372
|
+
return client.rest.get(import_types30.Routes.stickerMetadata(stickerId), { auth: true });
|
|
4590
5373
|
}
|
|
4591
5374
|
function fetchApplication(client) {
|
|
4592
|
-
return client.rest.get(
|
|
5375
|
+
return client.rest.get(import_types30.Routes.applicationsMe(), { auth: true });
|
|
4593
5376
|
}
|
|
4594
5377
|
async function fetchOAuthApplications(client) {
|
|
4595
|
-
const data = await client.rest.get(
|
|
5378
|
+
const data = await client.rest.get(import_types30.Routes.oauth2ApplicationsMe(), { auth: true });
|
|
4596
5379
|
if (Array.isArray(data)) return data;
|
|
4597
5380
|
if (data && typeof data === "object" && "applications" in data && Array.isArray(data.applications)) {
|
|
4598
5381
|
return data.applications;
|
|
@@ -4611,14 +5394,14 @@ function assertChannelIdBatch(name, channelIds) {
|
|
|
4611
5394
|
}
|
|
4612
5395
|
function preloadMessages(client, channelIds) {
|
|
4613
5396
|
assertChannelIdBatch("preloadMessages", channelIds);
|
|
4614
|
-
return client.rest.post(
|
|
5397
|
+
return client.rest.post(import_types30.Routes.preloadMessages(), {
|
|
4615
5398
|
body: { channels: channelIds },
|
|
4616
5399
|
auth: true
|
|
4617
5400
|
});
|
|
4618
5401
|
}
|
|
4619
5402
|
function preloadMessagesAlt(client, channelIds) {
|
|
4620
5403
|
assertChannelIdBatch("preloadMessagesAlt", channelIds);
|
|
4621
|
-
return client.rest.post(
|
|
5404
|
+
return client.rest.post(import_types30.Routes.preloadMessagesAlt(), {
|
|
4622
5405
|
body: { channels: channelIds },
|
|
4623
5406
|
auth: true
|
|
4624
5407
|
});
|
|
@@ -4626,7 +5409,7 @@ function preloadMessagesAlt(client, channelIds) {
|
|
|
4626
5409
|
async function bulkFetchMessages(client, requests, options = {}) {
|
|
4627
5410
|
validateBulkMessageFetchRequests(requests);
|
|
4628
5411
|
const wire = toBulkFetchWire(requests);
|
|
4629
|
-
const data = await client.rest.post(
|
|
5412
|
+
const data = await client.rest.post(import_types30.Routes.channelsMessagesBulk(), {
|
|
4630
5413
|
body: { requests: wire },
|
|
4631
5414
|
auth: true
|
|
4632
5415
|
});
|
|
@@ -4643,7 +5426,7 @@ async function bulkFetchMessages(client, requests, options = {}) {
|
|
|
4643
5426
|
};
|
|
4644
5427
|
}
|
|
4645
5428
|
async function searchMessages(client, options = {}) {
|
|
4646
|
-
const data = await client.rest.post(
|
|
5429
|
+
const data = await client.rest.post(import_types30.Routes.searchMessages(), {
|
|
4647
5430
|
body: toMessageSearchBody(options),
|
|
4648
5431
|
auth: true
|
|
4649
5432
|
});
|
|
@@ -4668,12 +5451,12 @@ var import_ws = require("@fluxerjs/ws");
|
|
|
4668
5451
|
|
|
4669
5452
|
// src/Domain/Guild/Guild.ts
|
|
4670
5453
|
var import_collection12 = require("@fluxerjs/collection");
|
|
4671
|
-
var
|
|
5454
|
+
var import_types40 = require("@fluxerjs/types");
|
|
4672
5455
|
var import_util22 = require("@fluxerjs/util");
|
|
4673
5456
|
|
|
4674
5457
|
// src/ClientCore/GuildMemberManager.ts
|
|
4675
5458
|
var import_collection10 = require("@fluxerjs/collection");
|
|
4676
|
-
var
|
|
5459
|
+
var import_types31 = require("@fluxerjs/types");
|
|
4677
5460
|
var GuildMemberManager = class extends import_collection10.LimitedCollection {
|
|
4678
5461
|
constructor(guild) {
|
|
4679
5462
|
super({ maxSize: guild.client.cache.limits.members });
|
|
@@ -4730,7 +5513,7 @@ var GuildMemberManager = class extends import_collection10.LimitedCollection {
|
|
|
4730
5513
|
if (options?.limit != null) params.set("limit", String(options.limit));
|
|
4731
5514
|
if (options?.after) params.set("after", options.after);
|
|
4732
5515
|
const qs2 = params.toString();
|
|
4733
|
-
const url =
|
|
5516
|
+
const url = import_types31.Routes.guildMembers(this.guild.id) + (qs2 ? `?${qs2}` : "");
|
|
4734
5517
|
const data = await this.guild.client.rest.get(url, { auth: true });
|
|
4735
5518
|
const members = [];
|
|
4736
5519
|
for (const m of data) {
|
|
@@ -4753,7 +5536,7 @@ var GuildMemberManager = class extends import_collection10.LimitedCollection {
|
|
|
4753
5536
|
*/
|
|
4754
5537
|
async search(options = {}) {
|
|
4755
5538
|
const data = await this.guild.client.rest.post(
|
|
4756
|
-
|
|
5539
|
+
import_types31.Routes.guildMembersSearch(this.guild.id),
|
|
4757
5540
|
{ body: toMemberSearchBody(options), auth: true }
|
|
4758
5541
|
);
|
|
4759
5542
|
const offset = options.offset ?? 0;
|
|
@@ -4779,7 +5562,7 @@ var GuildMemberManager = class extends import_collection10.LimitedCollection {
|
|
|
4779
5562
|
};
|
|
4780
5563
|
|
|
4781
5564
|
// src/Domain/Guild/Admin.ts
|
|
4782
|
-
var
|
|
5565
|
+
var import_types32 = require("@fluxerjs/types");
|
|
4783
5566
|
function toAuditLogEntryPayload(entry, guildId) {
|
|
4784
5567
|
return {
|
|
4785
5568
|
id: entry.id,
|
|
@@ -4800,7 +5583,7 @@ function toVanityPayload(data) {
|
|
|
4800
5583
|
return { code: data.code ?? null, uses: data.uses };
|
|
4801
5584
|
}
|
|
4802
5585
|
async function fetchAuditLogs(guild, options) {
|
|
4803
|
-
const url =
|
|
5586
|
+
const url = import_types32.Routes.guildAuditLogs(guild.id) + qs({
|
|
4804
5587
|
limit: options?.limit,
|
|
4805
5588
|
before: options?.before,
|
|
4806
5589
|
after: options?.after,
|
|
@@ -4824,7 +5607,7 @@ async function fetchAuditLogs(guild, options) {
|
|
|
4824
5607
|
};
|
|
4825
5608
|
}
|
|
4826
5609
|
async function editGuild(guild, options) {
|
|
4827
|
-
const data = await guild.client.rest.patch(
|
|
5610
|
+
const data = await guild.client.rest.patch(import_types32.Routes.guild(guild.id), {
|
|
4828
5611
|
body: toGuildEditBody(options),
|
|
4829
5612
|
auth: true
|
|
4830
5613
|
});
|
|
@@ -4832,13 +5615,13 @@ async function editGuild(guild, options) {
|
|
|
4832
5615
|
return guild;
|
|
4833
5616
|
}
|
|
4834
5617
|
async function fetchVanityURL(guild) {
|
|
4835
|
-
const data = await guild.client.rest.get(
|
|
5618
|
+
const data = await guild.client.rest.get(import_types32.Routes.guildVanityUrl(guild.id), {
|
|
4836
5619
|
auth: true
|
|
4837
5620
|
});
|
|
4838
5621
|
return toVanityPayload(data);
|
|
4839
5622
|
}
|
|
4840
5623
|
async function editVanityURL(guild, code) {
|
|
4841
|
-
const data = await guild.client.rest.patch(
|
|
5624
|
+
const data = await guild.client.rest.patch(import_types32.Routes.guildVanityUrl(guild.id), {
|
|
4842
5625
|
body: { code },
|
|
4843
5626
|
auth: true
|
|
4844
5627
|
});
|
|
@@ -4846,14 +5629,14 @@ async function editVanityURL(guild, code) {
|
|
|
4846
5629
|
return toVanityPayload(data);
|
|
4847
5630
|
}
|
|
4848
5631
|
async function fetchDiscoveryStatus(guild) {
|
|
4849
|
-
const data = await guild.client.rest.get(
|
|
5632
|
+
const data = await guild.client.rest.get(import_types32.Routes.guildDiscovery(guild.id), {
|
|
4850
5633
|
auth: true
|
|
4851
5634
|
});
|
|
4852
5635
|
return toDiscoveryStatusPayload(data);
|
|
4853
5636
|
}
|
|
4854
5637
|
async function applyForDiscovery(guild, options) {
|
|
4855
5638
|
const data = await guild.client.rest.post(
|
|
4856
|
-
|
|
5639
|
+
import_types32.Routes.guildDiscovery(guild.id),
|
|
4857
5640
|
{
|
|
4858
5641
|
body: toDiscoveryBody(options),
|
|
4859
5642
|
auth: true
|
|
@@ -4863,7 +5646,7 @@ async function applyForDiscovery(guild, options) {
|
|
|
4863
5646
|
}
|
|
4864
5647
|
async function editDiscoveryApplication(guild, options) {
|
|
4865
5648
|
const data = await guild.client.rest.patch(
|
|
4866
|
-
|
|
5649
|
+
import_types32.Routes.guildDiscovery(guild.id),
|
|
4867
5650
|
{
|
|
4868
5651
|
body: toDiscoveryBody(options),
|
|
4869
5652
|
auth: true
|
|
@@ -4872,34 +5655,34 @@ async function editDiscoveryApplication(guild, options) {
|
|
|
4872
5655
|
return toDiscoveryApplicationPayload(data);
|
|
4873
5656
|
}
|
|
4874
5657
|
async function withdrawDiscoveryApplication(guild) {
|
|
4875
|
-
await guild.client.rest.delete(
|
|
5658
|
+
await guild.client.rest.delete(import_types32.Routes.guildDiscovery(guild.id), { auth: true });
|
|
4876
5659
|
}
|
|
4877
5660
|
async function deleteGuild(guild, options) {
|
|
4878
5661
|
const body = options ? toSudoBody(options) : {};
|
|
4879
|
-
await guild.client.rest.post(
|
|
5662
|
+
await guild.client.rest.post(import_types32.Routes.guildDelete(guild.id), {
|
|
4880
5663
|
body,
|
|
4881
5664
|
auth: true
|
|
4882
5665
|
});
|
|
4883
5666
|
guild.client.guilds.delete(guild.id);
|
|
4884
5667
|
}
|
|
4885
5668
|
async function transferOwnership(guild, newOwnerId, password) {
|
|
4886
|
-
await guild.client.rest.post(
|
|
5669
|
+
await guild.client.rest.post(import_types32.Routes.guildTransferOwnership(guild.id), {
|
|
4887
5670
|
body: { new_owner_id: newOwnerId, ...password != null && { password } },
|
|
4888
5671
|
auth: true
|
|
4889
5672
|
});
|
|
4890
5673
|
}
|
|
4891
5674
|
|
|
4892
5675
|
// src/Domain/Guild/Channels.ts
|
|
4893
|
-
var
|
|
5676
|
+
var import_types33 = require("@fluxerjs/types");
|
|
4894
5677
|
async function createChannel(guild, options) {
|
|
4895
|
-
const created = await guild.client.rest.post(
|
|
5678
|
+
const created = await guild.client.rest.post(import_types33.Routes.guildChannels(guild.id), {
|
|
4896
5679
|
body: toChannelCreateBody(options),
|
|
4897
5680
|
auth: true
|
|
4898
5681
|
});
|
|
4899
5682
|
return cacheChannel(guild, created);
|
|
4900
5683
|
}
|
|
4901
5684
|
async function fetchChannels(guild) {
|
|
4902
|
-
const data = await guild.client.rest.get(
|
|
5685
|
+
const data = await guild.client.rest.get(import_types33.Routes.guildChannels(guild.id));
|
|
4903
5686
|
const channels = [];
|
|
4904
5687
|
for (const ch of data) {
|
|
4905
5688
|
const channel = cacheChannel(guild, ch);
|
|
@@ -4908,17 +5691,17 @@ async function fetchChannels(guild) {
|
|
|
4908
5691
|
return channels;
|
|
4909
5692
|
}
|
|
4910
5693
|
async function setChannelPositions(guild, updates) {
|
|
4911
|
-
await guild.client.rest.patch(
|
|
5694
|
+
await guild.client.rest.patch(import_types33.Routes.guildChannels(guild.id), {
|
|
4912
5695
|
body: toChannelPositionBody(updates),
|
|
4913
5696
|
auth: true
|
|
4914
5697
|
});
|
|
4915
5698
|
}
|
|
4916
5699
|
async function fetchWebhooks(guild) {
|
|
4917
|
-
const data = await guild.client.rest.get(
|
|
5700
|
+
const data = await guild.client.rest.get(import_types33.Routes.guildWebhooks(guild.id));
|
|
4918
5701
|
return data.map((w) => new Webhook(guild.client, w));
|
|
4919
5702
|
}
|
|
4920
5703
|
async function fetchInvites(guild) {
|
|
4921
|
-
const data = await guild.client.rest.get(
|
|
5704
|
+
const data = await guild.client.rest.get(import_types33.Routes.guildInvites(guild.id));
|
|
4922
5705
|
return data.map((invite) => new Invite(guild.client, invite));
|
|
4923
5706
|
}
|
|
4924
5707
|
async function fetchInvite(guild, codeOrUrl) {
|
|
@@ -4938,14 +5721,14 @@ function resolveGuildOnlineCount(data) {
|
|
|
4938
5721
|
}
|
|
4939
5722
|
|
|
4940
5723
|
// src/Domain/Guild/Emojis.ts
|
|
4941
|
-
var
|
|
5724
|
+
var import_types34 = require("@fluxerjs/types");
|
|
4942
5725
|
async function fetchEmojis(guild) {
|
|
4943
|
-
const data = await guild.client.rest.get(
|
|
5726
|
+
const data = await guild.client.rest.get(import_types34.Routes.guildEmojis(guild.id));
|
|
4944
5727
|
return data.map((e) => cacheEmoji(guild, e));
|
|
4945
5728
|
}
|
|
4946
5729
|
async function fetchEmoji(guild, emojiId) {
|
|
4947
5730
|
try {
|
|
4948
|
-
const data = await guild.client.rest.get(
|
|
5731
|
+
const data = await guild.client.rest.get(import_types34.Routes.guildEmoji(guild.id, emojiId));
|
|
4949
5732
|
return cacheEmoji(guild, data);
|
|
4950
5733
|
} catch (err) {
|
|
4951
5734
|
rethrowMapped(err, {
|
|
@@ -4956,7 +5739,7 @@ async function fetchEmoji(guild, emojiId) {
|
|
|
4956
5739
|
}
|
|
4957
5740
|
async function createEmoji(guild, options) {
|
|
4958
5741
|
const { reason, ...body } = options;
|
|
4959
|
-
const data = await guild.client.rest.post(
|
|
5742
|
+
const data = await guild.client.rest.post(import_types34.Routes.guildEmojis(guild.id), {
|
|
4960
5743
|
body,
|
|
4961
5744
|
auth: true,
|
|
4962
5745
|
...auditReasonHeaders(reason)
|
|
@@ -4964,7 +5747,7 @@ async function createEmoji(guild, options) {
|
|
|
4964
5747
|
return cacheEmoji(guild, data);
|
|
4965
5748
|
}
|
|
4966
5749
|
async function cloneEmoji(guild, sourceEmojiId) {
|
|
4967
|
-
const data = await guild.client.rest.post(
|
|
5750
|
+
const data = await guild.client.rest.post(import_types34.Routes.guildEmojisClone(guild.id), {
|
|
4968
5751
|
body: { source_emoji_id: sourceEmojiId },
|
|
4969
5752
|
auth: true
|
|
4970
5753
|
});
|
|
@@ -4972,7 +5755,7 @@ async function cloneEmoji(guild, sourceEmojiId) {
|
|
|
4972
5755
|
}
|
|
4973
5756
|
async function createEmojisBulk(guild, emojis) {
|
|
4974
5757
|
const data = await guild.client.rest.post(
|
|
4975
|
-
|
|
5758
|
+
import_types34.Routes.guildEmojisBulk(guild.id),
|
|
4976
5759
|
{ body: { emojis }, auth: true }
|
|
4977
5760
|
);
|
|
4978
5761
|
return { success: data.success.map((e) => cacheEmoji(guild, e)), failed: data.failed };
|
|
@@ -4992,11 +5775,11 @@ var GuildRoleManager = class extends import_collection11.LimitedCollection {
|
|
|
4992
5775
|
};
|
|
4993
5776
|
|
|
4994
5777
|
// src/Domain/Guild/MemberHttp.ts
|
|
4995
|
-
var
|
|
5778
|
+
var import_types35 = require("@fluxerjs/types");
|
|
4996
5779
|
async function fetchMember(guild, userId) {
|
|
4997
5780
|
try {
|
|
4998
5781
|
const data = await guild.client.rest.get(
|
|
4999
|
-
|
|
5782
|
+
import_types35.Routes.guildMember(guild.id, userId)
|
|
5000
5783
|
);
|
|
5001
5784
|
return cacheMember(guild, data);
|
|
5002
5785
|
} catch (err) {
|
|
@@ -5011,17 +5794,17 @@ async function fetchMember(guild, userId) {
|
|
|
5011
5794
|
}
|
|
5012
5795
|
async function fetchMe(guild) {
|
|
5013
5796
|
const data = await guild.client.rest.get(
|
|
5014
|
-
|
|
5797
|
+
import_types35.Routes.guildMemberMe(guild.id),
|
|
5015
5798
|
{ auth: true }
|
|
5016
5799
|
);
|
|
5017
5800
|
return cacheMember(guild, data);
|
|
5018
5801
|
}
|
|
5019
5802
|
|
|
5020
5803
|
// src/Domain/Guild/Moderation.ts
|
|
5021
|
-
var
|
|
5804
|
+
var import_types37 = require("@fluxerjs/types");
|
|
5022
5805
|
|
|
5023
5806
|
// src/Domain/Guild/GuildBan.ts
|
|
5024
|
-
var
|
|
5807
|
+
var import_types36 = require("@fluxerjs/types");
|
|
5025
5808
|
function parseOptionalDate2(value) {
|
|
5026
5809
|
if (value == null || value === "") return null;
|
|
5027
5810
|
const date = new Date(value);
|
|
@@ -5048,7 +5831,7 @@ var GuildBan = class extends Base {
|
|
|
5048
5831
|
* Requires Ban Members permission.
|
|
5049
5832
|
*/
|
|
5050
5833
|
async unban(reason) {
|
|
5051
|
-
await this.client.rest.delete(
|
|
5834
|
+
await this.client.rest.delete(import_types36.Routes.guildBan(this.guildId, this.user.id), {
|
|
5052
5835
|
auth: true,
|
|
5053
5836
|
...auditReasonHeaders(reason)
|
|
5054
5837
|
});
|
|
@@ -5058,35 +5841,35 @@ var GuildBan = class extends Base {
|
|
|
5058
5841
|
// src/Domain/Guild/Moderation.ts
|
|
5059
5842
|
async function ban(guild, userId, options) {
|
|
5060
5843
|
const body = options ? toGuildBanBody(options) : {};
|
|
5061
|
-
await guild.client.rest.put(
|
|
5844
|
+
await guild.client.rest.put(import_types37.Routes.guildBan(guild.id, userId), {
|
|
5062
5845
|
body: Object.keys(body).length ? body : void 0,
|
|
5063
5846
|
auth: true,
|
|
5064
5847
|
...auditReasonHeaders(options?.reason)
|
|
5065
5848
|
});
|
|
5066
5849
|
}
|
|
5067
5850
|
async function fetchBans(guild) {
|
|
5068
|
-
const data = await guild.client.rest.get(
|
|
5851
|
+
const data = await guild.client.rest.get(import_types37.Routes.guildBans(guild.id));
|
|
5069
5852
|
return data.map((b) => new GuildBan(guild.client, { ...b, guild_id: guild.id }, guild.id));
|
|
5070
5853
|
}
|
|
5071
5854
|
async function unban(guild, userId, reason) {
|
|
5072
|
-
await guild.client.rest.delete(
|
|
5855
|
+
await guild.client.rest.delete(import_types37.Routes.guildBan(guild.id, userId), {
|
|
5073
5856
|
auth: true,
|
|
5074
5857
|
...auditReasonHeaders(reason)
|
|
5075
5858
|
});
|
|
5076
5859
|
}
|
|
5077
5860
|
async function kick(guild, userId, reason) {
|
|
5078
|
-
await guild.client.rest.delete(
|
|
5861
|
+
await guild.client.rest.delete(import_types37.Routes.guildMember(guild.id, userId), {
|
|
5079
5862
|
auth: true,
|
|
5080
5863
|
...auditReasonHeaders(reason)
|
|
5081
5864
|
});
|
|
5082
5865
|
}
|
|
5083
5866
|
|
|
5084
5867
|
// src/Domain/Guild/Roles.ts
|
|
5085
|
-
var
|
|
5868
|
+
var import_types38 = require("@fluxerjs/types");
|
|
5086
5869
|
var import_util21 = require("@fluxerjs/util");
|
|
5087
5870
|
async function createRole(guild, options = {}) {
|
|
5088
5871
|
const body = toRoleCreateBody(options);
|
|
5089
|
-
const data = await guild.client.rest.post(
|
|
5872
|
+
const data = await guild.client.rest.post(import_types38.Routes.guildRoles(guild.id), {
|
|
5090
5873
|
body: Object.keys(body).length ? body : void 0,
|
|
5091
5874
|
auth: true,
|
|
5092
5875
|
...auditReasonHeaders(options.reason)
|
|
@@ -5094,12 +5877,12 @@ async function createRole(guild, options = {}) {
|
|
|
5094
5877
|
return cacheRole(guild, data);
|
|
5095
5878
|
}
|
|
5096
5879
|
async function fetchRoles(guild) {
|
|
5097
|
-
const data = await guild.client.rest.get(
|
|
5880
|
+
const data = await guild.client.rest.get(import_types38.Routes.guildRoles(guild.id));
|
|
5098
5881
|
return data.map((r) => cacheRole(guild, r));
|
|
5099
5882
|
}
|
|
5100
5883
|
async function fetchRole(guild, roleId2) {
|
|
5101
5884
|
try {
|
|
5102
|
-
const data = await guild.client.rest.get(
|
|
5885
|
+
const data = await guild.client.rest.get(import_types38.Routes.guildRole(guild.id, roleId2));
|
|
5103
5886
|
return cacheRole(guild, data);
|
|
5104
5887
|
} catch (err) {
|
|
5105
5888
|
rethrowMapped(err, {
|
|
@@ -5116,7 +5899,7 @@ async function resolveRoleId(guild, arg) {
|
|
|
5116
5899
|
const needle = trimmed.toLowerCase();
|
|
5117
5900
|
const cached = guild.roles.find((r) => r.name?.toLowerCase() === needle);
|
|
5118
5901
|
if (cached) return cached.id;
|
|
5119
|
-
const roles = await guild.client.rest.get(
|
|
5902
|
+
const roles = await guild.client.rest.get(import_types38.Routes.guildRoles(guild.id));
|
|
5120
5903
|
const role = roles.find((r) => r.name?.toLowerCase() === needle);
|
|
5121
5904
|
if (!role) return null;
|
|
5122
5905
|
cacheRole(guild, role);
|
|
@@ -5125,7 +5908,7 @@ async function resolveRoleId(guild, arg) {
|
|
|
5125
5908
|
async function setRolePositions(guild, updates) {
|
|
5126
5909
|
return replaceRoles(
|
|
5127
5910
|
guild,
|
|
5128
|
-
await guild.client.rest.patch(
|
|
5911
|
+
await guild.client.rest.patch(import_types38.Routes.guildRoles(guild.id), {
|
|
5129
5912
|
body: updates,
|
|
5130
5913
|
auth: true
|
|
5131
5914
|
})
|
|
@@ -5134,7 +5917,7 @@ async function setRolePositions(guild, updates) {
|
|
|
5134
5917
|
async function setRoleHoistPositions(guild, updates) {
|
|
5135
5918
|
return replaceRoles(
|
|
5136
5919
|
guild,
|
|
5137
|
-
await guild.client.rest.patch(
|
|
5920
|
+
await guild.client.rest.patch(import_types38.Routes.guildRolesHoistPositions(guild.id), {
|
|
5138
5921
|
body: updates.map((u) => ({
|
|
5139
5922
|
id: u.id,
|
|
5140
5923
|
...u.hoistPosition !== void 0 ? { hoist_position: u.hoistPosition } : {}
|
|
@@ -5146,17 +5929,17 @@ async function setRoleHoistPositions(guild, updates) {
|
|
|
5146
5929
|
async function resetRoleHoistPositions(guild) {
|
|
5147
5930
|
return replaceRoles(
|
|
5148
5931
|
guild,
|
|
5149
|
-
await guild.client.rest.delete(
|
|
5932
|
+
await guild.client.rest.delete(import_types38.Routes.guildRolesHoistPositions(guild.id), {
|
|
5150
5933
|
auth: true
|
|
5151
5934
|
})
|
|
5152
5935
|
);
|
|
5153
5936
|
}
|
|
5154
5937
|
|
|
5155
5938
|
// src/Domain/Guild/Stickers.ts
|
|
5156
|
-
var
|
|
5939
|
+
var import_types39 = require("@fluxerjs/types");
|
|
5157
5940
|
async function createSticker(guild, options) {
|
|
5158
5941
|
const { reason, ...body } = options;
|
|
5159
|
-
const data = await guild.client.rest.post(
|
|
5942
|
+
const data = await guild.client.rest.post(import_types39.Routes.guildStickers(guild.id), {
|
|
5160
5943
|
body,
|
|
5161
5944
|
auth: true,
|
|
5162
5945
|
...auditReasonHeaders(reason)
|
|
@@ -5164,7 +5947,7 @@ async function createSticker(guild, options) {
|
|
|
5164
5947
|
return cacheSticker(guild, data);
|
|
5165
5948
|
}
|
|
5166
5949
|
async function cloneSticker(guild, sourceStickerId) {
|
|
5167
|
-
const data = await guild.client.rest.post(
|
|
5950
|
+
const data = await guild.client.rest.post(import_types39.Routes.guildStickersClone(guild.id), {
|
|
5168
5951
|
body: { source_sticker_id: sourceStickerId },
|
|
5169
5952
|
auth: true
|
|
5170
5953
|
});
|
|
@@ -5172,17 +5955,17 @@ async function cloneSticker(guild, sourceStickerId) {
|
|
|
5172
5955
|
}
|
|
5173
5956
|
async function createStickersBulk(guild, stickers) {
|
|
5174
5957
|
const data = await guild.client.rest.post(
|
|
5175
|
-
|
|
5958
|
+
import_types39.Routes.guildStickersBulk(guild.id),
|
|
5176
5959
|
{ body: { stickers }, auth: true }
|
|
5177
5960
|
);
|
|
5178
5961
|
return { success: data.success.map((s) => cacheSticker(guild, s)), failed: data.failed };
|
|
5179
5962
|
}
|
|
5180
5963
|
async function fetchStickers(guild) {
|
|
5181
|
-
const data = await guild.client.rest.get(
|
|
5964
|
+
const data = await guild.client.rest.get(import_types39.Routes.guildStickers(guild.id));
|
|
5182
5965
|
return data.map((s) => cacheSticker(guild, s));
|
|
5183
5966
|
}
|
|
5184
5967
|
async function fetchSticker(guild, stickerId) {
|
|
5185
|
-
const data = await guild.client.rest.get(
|
|
5968
|
+
const data = await guild.client.rest.get(import_types39.Routes.guildSticker(guild.id, stickerId));
|
|
5186
5969
|
return cacheSticker(guild, data);
|
|
5187
5970
|
}
|
|
5188
5971
|
|
|
@@ -5299,7 +6082,7 @@ var Guild = class extends Base {
|
|
|
5299
6082
|
this.systemChannelFlags = data.system_channel_flags ?? 0;
|
|
5300
6083
|
this.splashCardAlignment = data.splash_card_alignment ?? 0;
|
|
5301
6084
|
this.embedSplash = data.embed_splash ?? null;
|
|
5302
|
-
this.nsfwLevel = data.nsfw_level ??
|
|
6085
|
+
this.nsfwLevel = data.nsfw_level ?? import_types40.GuildNSFWLevel.Safe;
|
|
5303
6086
|
this.nsfw = data.nsfw ?? false;
|
|
5304
6087
|
this.contentWarningLevel = data.content_warning_level ?? 0;
|
|
5305
6088
|
this.contentWarningText = data.content_warning_text ?? null;
|
|
@@ -5347,7 +6130,7 @@ var Guild = class extends Base {
|
|
|
5347
6130
|
this.splashCardAlignment = data.splash_card_alignment ?? 0;
|
|
5348
6131
|
}
|
|
5349
6132
|
if (data.embed_splash !== void 0) this.embedSplash = data.embed_splash ?? null;
|
|
5350
|
-
if (data.nsfw_level !== void 0) this.nsfwLevel = data.nsfw_level ??
|
|
6133
|
+
if (data.nsfw_level !== void 0) this.nsfwLevel = data.nsfw_level ?? import_types40.GuildNSFWLevel.Safe;
|
|
5351
6134
|
if (data.nsfw !== void 0) this.nsfw = data.nsfw ?? false;
|
|
5352
6135
|
if (data.content_warning_level !== void 0) {
|
|
5353
6136
|
this.contentWarningLevel = data.content_warning_level ?? 0;
|
|
@@ -5414,7 +6197,7 @@ var Guild = class extends Base {
|
|
|
5414
6197
|
});
|
|
5415
6198
|
}
|
|
5416
6199
|
/**
|
|
5417
|
-
* Create a channel. `type`: 0=text, 2=voice, 4=category, 998=link (set `url`).
|
|
6200
|
+
* Create a channel. `type`: 0=text, 2=voice, 4=category, 5=announcement, 15=forum, 16=media, 998=link (set `url`).
|
|
5418
6201
|
* Requires Manage Channels.
|
|
5419
6202
|
*/
|
|
5420
6203
|
createChannel(options) {
|
|
@@ -5424,6 +6207,10 @@ var Guild = class extends Base {
|
|
|
5424
6207
|
fetchChannels() {
|
|
5425
6208
|
return fetchChannels(this);
|
|
5426
6209
|
}
|
|
6210
|
+
/** Fetch active threads in this guild. */
|
|
6211
|
+
fetchActiveThreads() {
|
|
6212
|
+
return fetchActiveThreads(this.client, this.id);
|
|
6213
|
+
}
|
|
5427
6214
|
/** Update channel positions (reordering). */
|
|
5428
6215
|
setChannelPositions(updates) {
|
|
5429
6216
|
return setChannelPositions(this, updates);
|
|
@@ -5654,6 +6441,13 @@ function upsertGuildFromSnapshot(client, guildData, resources = {}) {
|
|
|
5654
6441
|
client.guilds.set(guild.id, guild);
|
|
5655
6442
|
if (resources.roles !== void 0) syncRoles(guild, resources.roles);
|
|
5656
6443
|
if (resources.channels !== void 0) syncChannels(guild, resources.channels);
|
|
6444
|
+
if (resources.threads !== void 0) {
|
|
6445
|
+
syncThreads(
|
|
6446
|
+
guild,
|
|
6447
|
+
resources.threads,
|
|
6448
|
+
new Set((resources.channels ?? []).map((channel) => channel.id))
|
|
6449
|
+
);
|
|
6450
|
+
}
|
|
5657
6451
|
if (resources.members !== void 0) mergeMembers(guild, resources.members);
|
|
5658
6452
|
if (resources.emojis !== void 0) syncEmojis(guild, resources.emojis);
|
|
5659
6453
|
if (resources.stickers !== void 0) syncStickers(guild, resources.stickers);
|
|
@@ -5668,7 +6462,9 @@ function applyGuildSnapshotFromGateway(client, raw) {
|
|
|
5668
6462
|
channels: g.channels,
|
|
5669
6463
|
members: g.members,
|
|
5670
6464
|
emojis: g.emojis,
|
|
5671
|
-
stickers: g.stickers
|
|
6465
|
+
stickers: g.stickers,
|
|
6466
|
+
// A channel list without `threads` means this session has no viewable threads.
|
|
6467
|
+
threads: g.channels !== void 0 ? g.threads ?? [] : g.threads
|
|
5672
6468
|
});
|
|
5673
6469
|
if (g.voice_states?.length) {
|
|
5674
6470
|
client.emit(Events.VoiceStatesSync, {
|
|
@@ -5680,23 +6476,23 @@ function applyGuildSnapshotFromGateway(client, raw) {
|
|
|
5680
6476
|
}
|
|
5681
6477
|
|
|
5682
6478
|
// src/ClientCore/ClientUser.ts
|
|
5683
|
-
var
|
|
6479
|
+
var import_types41 = require("@fluxerjs/types");
|
|
5684
6480
|
var ClientUser = class extends User {
|
|
5685
6481
|
/** Broadcast presence (gateway opcode 3) on all shards. */
|
|
5686
6482
|
setPresence(presence) {
|
|
5687
6483
|
this.client.options.presence = presence;
|
|
5688
6484
|
const wire = toPresenceWire(presence);
|
|
5689
|
-
this.client._sendToAllShards({ op:
|
|
6485
|
+
this.client._sendToAllShards({ op: import_types41.GatewayOpcodes.PresenceUpdate, d: wire });
|
|
5690
6486
|
}
|
|
5691
6487
|
/** GET /users/@me — refresh the logged-in user from REST and patch this instance. */
|
|
5692
6488
|
async fetch() {
|
|
5693
|
-
const data = await this.client.rest.get(
|
|
6489
|
+
const data = await this.client.rest.get(import_types41.Routes.currentUser(), { auth: true });
|
|
5694
6490
|
this._patch(data);
|
|
5695
6491
|
return this;
|
|
5696
6492
|
}
|
|
5697
6493
|
/** GET /users/@me/guilds — returns camelCase partial guilds. */
|
|
5698
6494
|
async fetchGuilds(options) {
|
|
5699
|
-
const path =
|
|
6495
|
+
const path = import_types41.Routes.currentUserGuilds() + (options?.withCounts ? "?with_counts=true" : "");
|
|
5700
6496
|
const data = await this.client.rest.get(path, { auth: true });
|
|
5701
6497
|
return data.map((g) => ({
|
|
5702
6498
|
id: g.id,
|
|
@@ -5720,7 +6516,7 @@ var ClientUser = class extends User {
|
|
|
5720
6516
|
*/
|
|
5721
6517
|
async leaveGuild(guildId, options) {
|
|
5722
6518
|
const body = options ? toSudoBody(options) : void 0;
|
|
5723
|
-
await this.client.rest.delete(
|
|
6519
|
+
await this.client.rest.delete(import_types41.Routes.leaveGuild(guildId), {
|
|
5724
6520
|
body: body && Object.keys(body).length ? body : void 0,
|
|
5725
6521
|
auth: true
|
|
5726
6522
|
});
|
|
@@ -5728,7 +6524,7 @@ var ClientUser = class extends User {
|
|
|
5728
6524
|
/** Delete every message authored by the caller across a guild (sudo). */
|
|
5729
6525
|
async bulkDeleteMyMessagesInGuild(guildId, options) {
|
|
5730
6526
|
const body = options ? toSudoBody(options) : void 0;
|
|
5731
|
-
await this.client.rest.post(
|
|
6527
|
+
await this.client.rest.post(import_types41.Routes.guildBulkDeleteMine(guildId), {
|
|
5732
6528
|
body: body && Object.keys(body).length ? body : void 0,
|
|
5733
6529
|
auth: true
|
|
5734
6530
|
});
|
|
@@ -5763,6 +6559,7 @@ var channelHandlers = {
|
|
|
5763
6559
|
if (!ch) return;
|
|
5764
6560
|
indexChannel(client, ch);
|
|
5765
6561
|
client.emit(Events.ChannelCreate, ch);
|
|
6562
|
+
if (ch.isThread()) client.emit(Events.ThreadCreate, ch);
|
|
5766
6563
|
},
|
|
5767
6564
|
CHANNEL_UPDATE(client, d) {
|
|
5768
6565
|
const data = d;
|
|
@@ -5775,12 +6572,14 @@ var channelHandlers = {
|
|
|
5775
6572
|
existing._patch(data);
|
|
5776
6573
|
indexChannel(client, existing);
|
|
5777
6574
|
client.emit(Events.ChannelUpdate, oldCh, existing);
|
|
6575
|
+
if (existing.isThread()) client.emit(Events.ThreadUpdate, oldCh, existing);
|
|
5778
6576
|
return;
|
|
5779
6577
|
}
|
|
5780
6578
|
const newCh = Channel.from(client, data);
|
|
5781
6579
|
if (!newCh) return;
|
|
5782
6580
|
indexChannel(client, newCh);
|
|
5783
6581
|
client.emit(Events.ChannelUpdate, existing ?? newCh, newCh);
|
|
6582
|
+
if (newCh.isThread()) client.emit(Events.ThreadUpdate, existing ?? newCh, newCh);
|
|
5784
6583
|
},
|
|
5785
6584
|
CHANNEL_UPDATE_BULK(client, d) {
|
|
5786
6585
|
const data = d;
|
|
@@ -5802,7 +6601,11 @@ var channelHandlers = {
|
|
|
5802
6601
|
}
|
|
5803
6602
|
if (!channel) return;
|
|
5804
6603
|
client.channels.delete(id);
|
|
6604
|
+
if (channel.isGuild() && channel.guildId) {
|
|
6605
|
+
client.guilds.get(channel.guildId)?.channels.delete(id);
|
|
6606
|
+
}
|
|
5805
6607
|
client.emit(Events.ChannelDelete, channel);
|
|
6608
|
+
if (channel.isThread()) client.emit(Events.ThreadDelete, channel);
|
|
5806
6609
|
},
|
|
5807
6610
|
CHANNEL_PINS_UPDATE(client, d) {
|
|
5808
6611
|
const data = d;
|
|
@@ -5992,6 +6795,10 @@ var guildHandlers = {
|
|
|
5992
6795
|
}
|
|
5993
6796
|
client._onGuildReceived(guild.id);
|
|
5994
6797
|
},
|
|
6798
|
+
/** Same snapshot as Guild Create, including `threads`. Cache only: this is not a join. */
|
|
6799
|
+
GUILD_SYNC(client, d) {
|
|
6800
|
+
applyGuildSnapshotFromGateway(client, d);
|
|
6801
|
+
},
|
|
5995
6802
|
GUILD_UPDATE(client, d) {
|
|
5996
6803
|
const guildData = normalizeGuildUpdatePayload(d);
|
|
5997
6804
|
if (!guildData) return;
|
|
@@ -6040,13 +6847,13 @@ var guildHandlers = {
|
|
|
6040
6847
|
};
|
|
6041
6848
|
|
|
6042
6849
|
// src/ClientCore/EventHandlers/Invites.ts
|
|
6043
|
-
var
|
|
6850
|
+
var import_types42 = require("@fluxerjs/types");
|
|
6044
6851
|
function normalizeInviteCreate(client, payload) {
|
|
6045
6852
|
const raw = (0, import_util24.asRecord)(payload);
|
|
6046
6853
|
const code = (0, import_util24.str)(raw?.code);
|
|
6047
6854
|
if (!raw || !code) return null;
|
|
6048
6855
|
const typeNum = (0, import_util24.num)(raw.type);
|
|
6049
|
-
const type = typeNum ===
|
|
6856
|
+
const type = typeNum === import_types42.InviteType.GroupDM ? import_types42.InviteType.GroupDM : import_types42.InviteType.Guild;
|
|
6050
6857
|
const shared = {
|
|
6051
6858
|
code,
|
|
6052
6859
|
inviter: raw.inviter ?? null,
|
|
@@ -6063,17 +6870,17 @@ function normalizeInviteCreate(client, payload) {
|
|
|
6063
6870
|
const guildId = (0, import_util24.str)(guildObj?.id) ?? (0, import_util24.str)(raw.guild_id) ?? "0";
|
|
6064
6871
|
const channelId = (0, import_util24.str)(channelObj?.id) ?? (0, import_util24.str)(raw.channel_id) ?? "0";
|
|
6065
6872
|
const cachedGuild = guildId !== "0" ? client.guilds.get(guildId) : null;
|
|
6066
|
-
const
|
|
6873
|
+
const cachedChannel2 = channelId !== "0" ? client.channels.get(channelId) : null;
|
|
6067
6874
|
const channel = {
|
|
6068
6875
|
id: channelId,
|
|
6069
|
-
type: (0, import_util24.num)(channelObj?.type) ??
|
|
6070
|
-
name: (0, import_util24.str)(channelObj?.name) ??
|
|
6876
|
+
type: (0, import_util24.num)(channelObj?.type) ?? cachedChannel2?.type ?? import_types42.ChannelType.GuildText,
|
|
6877
|
+
name: (0, import_util24.str)(channelObj?.name) ?? cachedChannel2?.name ?? null,
|
|
6071
6878
|
icon: channelObj?.icon ?? null
|
|
6072
6879
|
};
|
|
6073
|
-
if (type ===
|
|
6880
|
+
if (type === import_types42.InviteType.GroupDM) return { ...shared, type, channel };
|
|
6074
6881
|
return {
|
|
6075
6882
|
...shared,
|
|
6076
|
-
type:
|
|
6883
|
+
type: import_types42.InviteType.Guild,
|
|
6077
6884
|
guild: {
|
|
6078
6885
|
id: guildId,
|
|
6079
6886
|
name: (0, import_util24.str)(guildObj?.name) ?? cachedGuild?.name ?? "Unknown Guild",
|
|
@@ -6471,6 +7278,107 @@ var passthroughHandlers = {
|
|
|
6471
7278
|
WEBAUTHN_CREDENTIALS_UPDATE: pass(Events.WebAuthnCredentialsUpdate)
|
|
6472
7279
|
};
|
|
6473
7280
|
|
|
7281
|
+
// src/ClientCore/EventHandlers/Threads.ts
|
|
7282
|
+
function cachedChannel(client, id) {
|
|
7283
|
+
const direct = client.channels.get(id);
|
|
7284
|
+
if (direct) return direct;
|
|
7285
|
+
for (const guild of client.guilds.values()) {
|
|
7286
|
+
const nested = guild.channels.get(id);
|
|
7287
|
+
if (nested) return nested;
|
|
7288
|
+
}
|
|
7289
|
+
return null;
|
|
7290
|
+
}
|
|
7291
|
+
var threadHandlers = {
|
|
7292
|
+
THREAD_CREATE(client, d) {
|
|
7293
|
+
channelHandlers.CHANNEL_CREATE(client, d);
|
|
7294
|
+
},
|
|
7295
|
+
THREAD_UPDATE(client, d) {
|
|
7296
|
+
channelHandlers.CHANNEL_UPDATE(client, d);
|
|
7297
|
+
},
|
|
7298
|
+
THREAD_DELETE(client, d) {
|
|
7299
|
+
const data = d;
|
|
7300
|
+
const existing = data.id ? cachedChannel(client, data.id) : null;
|
|
7301
|
+
if (existing?.isThread()) {
|
|
7302
|
+
channelHandlers.CHANNEL_DELETE(client, data);
|
|
7303
|
+
return;
|
|
7304
|
+
}
|
|
7305
|
+
if (!data.id || !isThreadType(data.type)) return;
|
|
7306
|
+
const thread = Channel.from(client, {
|
|
7307
|
+
id: data.id,
|
|
7308
|
+
type: data.type,
|
|
7309
|
+
guild_id: data.guild_id,
|
|
7310
|
+
parent_id: data.parent_id
|
|
7311
|
+
});
|
|
7312
|
+
if (!thread.isThread()) return;
|
|
7313
|
+
client.emit(Events.ChannelDelete, thread);
|
|
7314
|
+
client.emit(Events.ThreadDelete, thread);
|
|
7315
|
+
},
|
|
7316
|
+
THREAD_LIST_SYNC(client, d) {
|
|
7317
|
+
const data = d;
|
|
7318
|
+
const { threads } = fetchedThreadsFrom(client, {
|
|
7319
|
+
threads: data.threads ?? [],
|
|
7320
|
+
members: data.members ?? []
|
|
7321
|
+
});
|
|
7322
|
+
const payload = {
|
|
7323
|
+
guildId: data.guild_id,
|
|
7324
|
+
channelIds: data.channel_ids ?? [],
|
|
7325
|
+
threads
|
|
7326
|
+
};
|
|
7327
|
+
client.emit(Events.ThreadListSync, payload);
|
|
7328
|
+
},
|
|
7329
|
+
THREAD_MEMBER_UPDATE(client, d) {
|
|
7330
|
+
const data = d;
|
|
7331
|
+
const member = new ThreadMember(data);
|
|
7332
|
+
const thread = member.id ? client.channels.get(member.id) : void 0;
|
|
7333
|
+
if (thread?.isThread() && member.userId && member.userId === client.user?.id) {
|
|
7334
|
+
thread.member = member;
|
|
7335
|
+
}
|
|
7336
|
+
client.emit(Events.ThreadMemberUpdate, member);
|
|
7337
|
+
},
|
|
7338
|
+
THREAD_MEMBERS_UPDATE(client, d) {
|
|
7339
|
+
const data = d;
|
|
7340
|
+
const thread = client.channels.get(data.id);
|
|
7341
|
+
if (thread?.isThread()) thread.memberCount = data.member_count;
|
|
7342
|
+
const payload = {
|
|
7343
|
+
id: data.id,
|
|
7344
|
+
guildId: data.guild_id,
|
|
7345
|
+
memberCount: data.member_count,
|
|
7346
|
+
addedMembers: (data.added_members ?? []).map((member) => new ThreadMember(member)),
|
|
7347
|
+
removedMemberIds: data.removed_member_ids ?? []
|
|
7348
|
+
};
|
|
7349
|
+
client.emit(Events.ThreadMembersUpdate, payload);
|
|
7350
|
+
},
|
|
7351
|
+
THREAD_MEMBER_LIST_UPDATE(client, d) {
|
|
7352
|
+
const data = d;
|
|
7353
|
+
const guild = data.guild_id ? client.guilds.get(data.guild_id) : void 0;
|
|
7354
|
+
const payload = {
|
|
7355
|
+
guildId: data.guild_id,
|
|
7356
|
+
threadId: data.thread_id,
|
|
7357
|
+
members: (data.members ?? []).map((entry) => ({
|
|
7358
|
+
userId: entry.user_id,
|
|
7359
|
+
joinTimestamp: entry.join_timestamp,
|
|
7360
|
+
flags: entry.flags,
|
|
7361
|
+
member: guild && entry.member?.user?.id ? cacheMember(guild, entry.member) : null,
|
|
7362
|
+
presence: entry.presence ? { status: entry.presence.status ?? null } : null
|
|
7363
|
+
}))
|
|
7364
|
+
};
|
|
7365
|
+
client.emit(Events.ThreadMemberListUpdate, payload);
|
|
7366
|
+
},
|
|
7367
|
+
FORUM_UNREADS(client, d) {
|
|
7368
|
+
const data = d;
|
|
7369
|
+
const payload = {
|
|
7370
|
+
guildId: data.guild_id,
|
|
7371
|
+
channelId: data.channel_id,
|
|
7372
|
+
threads: (data.threads ?? []).map((entry) => ({
|
|
7373
|
+
threadId: entry.thread_id,
|
|
7374
|
+
count: entry.count ?? null,
|
|
7375
|
+
missing: entry.missing === true
|
|
7376
|
+
}))
|
|
7377
|
+
};
|
|
7378
|
+
client.emit(Events.ForumUnreads, payload);
|
|
7379
|
+
}
|
|
7380
|
+
};
|
|
7381
|
+
|
|
6474
7382
|
// src/ClientCore/EventHandlers/index.ts
|
|
6475
7383
|
var eventHandlers = buildRegistry(
|
|
6476
7384
|
messageHandlers,
|
|
@@ -6479,7 +7387,8 @@ var eventHandlers = buildRegistry(
|
|
|
6479
7387
|
memberHandlers,
|
|
6480
7388
|
inviteHandlers,
|
|
6481
7389
|
guildResourceHandlers,
|
|
6482
|
-
passthroughHandlers
|
|
7390
|
+
passthroughHandlers,
|
|
7391
|
+
threadHandlers
|
|
6483
7392
|
);
|
|
6484
7393
|
|
|
6485
7394
|
// src/ClientCore/GatewayDispatch.ts
|
|
@@ -6705,7 +7614,7 @@ async function connectClientGateway(client, token, signal) {
|
|
|
6705
7614
|
|
|
6706
7615
|
// src/ClientCore/GuildManager.ts
|
|
6707
7616
|
var import_collection13 = require("@fluxerjs/collection");
|
|
6708
|
-
var
|
|
7617
|
+
var import_types43 = require("@fluxerjs/types");
|
|
6709
7618
|
var GuildManager = class extends import_collection13.LimitedCollection {
|
|
6710
7619
|
constructor(client) {
|
|
6711
7620
|
super({
|
|
@@ -6744,7 +7653,7 @@ var GuildManager = class extends import_collection13.LimitedCollection {
|
|
|
6744
7653
|
const cached = this.get(guildId);
|
|
6745
7654
|
if (cached && !options?.force) return cached;
|
|
6746
7655
|
try {
|
|
6747
|
-
const data = await this.client.rest.get(
|
|
7656
|
+
const data = await this.client.rest.get(import_types43.Routes.guild(guildId));
|
|
6748
7657
|
if (cached) {
|
|
6749
7658
|
cached._patch(data);
|
|
6750
7659
|
return cached;
|
|
@@ -6831,7 +7740,7 @@ var MessageCache = class {
|
|
|
6831
7740
|
|
|
6832
7741
|
// src/ClientCore/UserManager.ts
|
|
6833
7742
|
var import_collection14 = require("@fluxerjs/collection");
|
|
6834
|
-
var
|
|
7743
|
+
var import_types44 = require("@fluxerjs/types");
|
|
6835
7744
|
var soft = (p) => p.catch(() => null);
|
|
6836
7745
|
var UserManager = class extends import_collection14.LimitedCollection {
|
|
6837
7746
|
constructor(client) {
|
|
@@ -6855,7 +7764,7 @@ var UserManager = class extends import_collection14.LimitedCollection {
|
|
|
6855
7764
|
async fetch(userId, options) {
|
|
6856
7765
|
const cached = this.get(userId);
|
|
6857
7766
|
if (cached && !options?.force) return cached;
|
|
6858
|
-
const data = await this.client.rest.get(
|
|
7767
|
+
const data = await this.client.rest.get(import_types44.Routes.user(userId));
|
|
6859
7768
|
return this.client.getOrCreateUser(data);
|
|
6860
7769
|
}
|
|
6861
7770
|
/** Return a cached user, otherwise {@link fetch}. */
|
|
@@ -6873,10 +7782,10 @@ var UserManager = class extends import_collection14.LimitedCollection {
|
|
|
6873
7782
|
async fetchWithProfile(userId, options) {
|
|
6874
7783
|
const guildId = options?.guildId ?? void 0;
|
|
6875
7784
|
const [userData, globalProfileRaw, serverProfileRaw, memberData] = await Promise.all([
|
|
6876
|
-
this.client.rest.get(
|
|
6877
|
-
soft(this.client.rest.get(
|
|
6878
|
-
guildId ? soft(this.client.rest.get(
|
|
6879
|
-
guildId ? soft(this.client.rest.get(
|
|
7785
|
+
this.client.rest.get(import_types44.Routes.user(userId)),
|
|
7786
|
+
soft(this.client.rest.get(import_types44.Routes.userProfile(userId))),
|
|
7787
|
+
guildId ? soft(this.client.rest.get(import_types44.Routes.userProfile(userId, guildId))) : null,
|
|
7788
|
+
guildId ? soft(this.client.rest.get(import_types44.Routes.guildMember(guildId, userId))) : null
|
|
6880
7789
|
]);
|
|
6881
7790
|
const user = this.client.getOrCreateUser(userData);
|
|
6882
7791
|
let member = null;
|
|
@@ -7222,7 +8131,7 @@ var Client = class _Client extends import_node_events3.EventEmitter {
|
|
|
7222
8131
|
if (options.userIds !== void 0) data.user_ids = [...new Set(options.userIds)];
|
|
7223
8132
|
if (options.presences !== void 0) data.presences = options.presences;
|
|
7224
8133
|
if (options.nonce !== void 0) data.nonce = options.nonce;
|
|
7225
|
-
this._sendToAllShards({ op:
|
|
8134
|
+
this._sendToAllShards({ op: import_types45.GatewayOpcodes.RequestGuildMembers, d: data });
|
|
7226
8135
|
}
|
|
7227
8136
|
/**
|
|
7228
8137
|
* Request guild member/online counts via gateway opcode 15.
|
|
@@ -7237,7 +8146,7 @@ var Client = class _Client extends import_node_events3.EventEmitter {
|
|
|
7237
8146
|
}
|
|
7238
8147
|
const data = { guild_ids: guildIds };
|
|
7239
8148
|
if (options.nonce !== void 0) data.nonce = options.nonce;
|
|
7240
|
-
this._sendToAllShards({ op:
|
|
8149
|
+
this._sendToAllShards({ op: import_types45.GatewayOpcodes.RequestGuildCounts, d: data });
|
|
7241
8150
|
}
|
|
7242
8151
|
/**
|
|
7243
8152
|
* Request per-channel member counts via gateway opcode 16.
|
|
@@ -7253,7 +8162,73 @@ var Client = class _Client extends import_node_events3.EventEmitter {
|
|
|
7253
8162
|
if (options.channelId !== void 0) data.channel_id = options.channelId;
|
|
7254
8163
|
if (options.channelIds !== void 0) data.channel_ids = [...new Set(options.channelIds)];
|
|
7255
8164
|
if (options.nonce !== void 0) data.nonce = options.nonce;
|
|
7256
|
-
this._sendToAllShards({ op:
|
|
8165
|
+
this._sendToAllShards({ op: import_types45.GatewayOpcodes.RequestChannelMemberCounts, d: data });
|
|
8166
|
+
}
|
|
8167
|
+
/**
|
|
8168
|
+
* Request unread counts for posts in one forum or media channel (opcode 28).
|
|
8169
|
+
* Listen for `forumUnreads`. The gateway keeps at most 40 posts and ignores a channel the session cannot view.
|
|
8170
|
+
*/
|
|
8171
|
+
requestForumUnreads(options) {
|
|
8172
|
+
if (!options.guildId || !options.channelId) {
|
|
8173
|
+
throw new import_util4.FluxerError("requestForumUnreads requires guildId and channelId", {
|
|
8174
|
+
code: import_util3.ErrorCodes.InvalidGatewayRequest
|
|
8175
|
+
});
|
|
8176
|
+
}
|
|
8177
|
+
const threads = [];
|
|
8178
|
+
const seen = /* @__PURE__ */ new Set();
|
|
8179
|
+
for (const thread of options.threads) {
|
|
8180
|
+
if (!thread.threadId || seen.has(thread.threadId)) continue;
|
|
8181
|
+
seen.add(thread.threadId);
|
|
8182
|
+
const entry = { thread_id: thread.threadId };
|
|
8183
|
+
if (thread.ackMessageId !== void 0) entry.ack_message_id = thread.ackMessageId;
|
|
8184
|
+
threads.push(entry);
|
|
8185
|
+
}
|
|
8186
|
+
if (!threads.length) {
|
|
8187
|
+
throw new import_util4.FluxerError("requestForumUnreads requires at least one thread", {
|
|
8188
|
+
code: import_util3.ErrorCodes.InvalidGatewayRequest
|
|
8189
|
+
});
|
|
8190
|
+
}
|
|
8191
|
+
if (threads.length > 40) {
|
|
8192
|
+
throw new import_util4.FluxerError("requestForumUnreads accepts at most 40 threads", {
|
|
8193
|
+
code: import_util3.ErrorCodes.InvalidGatewayRequest
|
|
8194
|
+
});
|
|
8195
|
+
}
|
|
8196
|
+
const data = {
|
|
8197
|
+
guild_id: options.guildId,
|
|
8198
|
+
channel_id: options.channelId,
|
|
8199
|
+
threads
|
|
8200
|
+
};
|
|
8201
|
+
this._sendToAllShards({ op: import_types45.GatewayOpcodes.RequestForumUnreads, d: data });
|
|
8202
|
+
}
|
|
8203
|
+
/**
|
|
8204
|
+
* Subscribe to thread traffic in a guild (opcode 14).
|
|
8205
|
+
* `threads: true` receives every thread event in the guild.
|
|
8206
|
+
* `threadIds` (at most 10) subscribes to those member lists. Each one arrives as `threadMemberListUpdate`.
|
|
8207
|
+
*/
|
|
8208
|
+
subscribeThreads(options) {
|
|
8209
|
+
if (!options.guildId) {
|
|
8210
|
+
throw new import_util4.FluxerError("subscribeThreads requires guildId", {
|
|
8211
|
+
code: import_util3.ErrorCodes.InvalidGatewayRequest
|
|
8212
|
+
});
|
|
8213
|
+
}
|
|
8214
|
+
if (options.threads === void 0 && options.threadIds === void 0) {
|
|
8215
|
+
throw new import_util4.FluxerError("subscribeThreads requires threads or threadIds", {
|
|
8216
|
+
code: import_util3.ErrorCodes.InvalidGatewayRequest
|
|
8217
|
+
});
|
|
8218
|
+
}
|
|
8219
|
+
const subscription = {};
|
|
8220
|
+
if (options.threads !== void 0) subscription.threads = options.threads;
|
|
8221
|
+
if (options.threadIds !== void 0) {
|
|
8222
|
+
const threadIds = [...new Set(options.threadIds.filter(Boolean))];
|
|
8223
|
+
if (threadIds.length > 10) {
|
|
8224
|
+
throw new import_util4.FluxerError("subscribeThreads accepts at most 10 threadIds", {
|
|
8225
|
+
code: import_util3.ErrorCodes.InvalidGatewayRequest
|
|
8226
|
+
});
|
|
8227
|
+
}
|
|
8228
|
+
subscription.thread_member_lists = threadIds;
|
|
8229
|
+
}
|
|
8230
|
+
const data = { subscriptions: { [options.guildId]: subscription } };
|
|
8231
|
+
this._sendToAllShards({ op: import_types45.GatewayOpcodes.LazyRequest, d: data });
|
|
7257
8232
|
}
|
|
7258
8233
|
/**
|
|
7259
8234
|
* Broadcast a gateway payload to all shards.
|
|
@@ -7358,7 +8333,7 @@ var Client = class _Client extends import_node_events3.EventEmitter {
|
|
|
7358
8333
|
* @see {@link Routes}
|
|
7359
8334
|
*/
|
|
7360
8335
|
static get Routes() {
|
|
7361
|
-
return
|
|
8336
|
+
return import_types45.Routes;
|
|
7362
8337
|
}
|
|
7363
8338
|
};
|
|
7364
8339
|
|
|
@@ -7725,6 +8700,10 @@ var ClientCluster = class extends import_node_events4.EventEmitter {
|
|
|
7725
8700
|
ErrorCodes,
|
|
7726
8701
|
Events,
|
|
7727
8702
|
FluxerError,
|
|
8703
|
+
ForumChannel,
|
|
8704
|
+
ForumLayout,
|
|
8705
|
+
ForumSortOrder,
|
|
8706
|
+
ForumTagSetting,
|
|
7728
8707
|
GatewayOpcodes,
|
|
7729
8708
|
Guild,
|
|
7730
8709
|
GuildBan,
|
|
@@ -7743,6 +8722,7 @@ var ClientCluster = class extends import_node_events4.EventEmitter {
|
|
|
7743
8722
|
Invite,
|
|
7744
8723
|
InviteType,
|
|
7745
8724
|
LinkChannel,
|
|
8725
|
+
MediaChannel,
|
|
7746
8726
|
Message,
|
|
7747
8727
|
MessageAttachmentFlags,
|
|
7748
8728
|
MessageCollector,
|
|
@@ -7772,6 +8752,12 @@ var ClientCluster = class extends import_node_events4.EventEmitter {
|
|
|
7772
8752
|
SplashCardAlignment,
|
|
7773
8753
|
SystemChannelFlags,
|
|
7774
8754
|
TextChannel,
|
|
8755
|
+
ThreadAutoArchiveDuration,
|
|
8756
|
+
ThreadChannel,
|
|
8757
|
+
ThreadManager,
|
|
8758
|
+
ThreadMember,
|
|
8759
|
+
ThreadMemberFlags,
|
|
8760
|
+
ThreadMemberManager,
|
|
7775
8761
|
User,
|
|
7776
8762
|
UserFlagsBitField,
|
|
7777
8763
|
UserFlagsBits,
|
|
@@ -7788,6 +8774,7 @@ var ClientCluster = class extends import_node_events4.EventEmitter {
|
|
|
7788
8774
|
cdnMemberBannerURL,
|
|
7789
8775
|
cdnStickerURL,
|
|
7790
8776
|
createLogger,
|
|
8777
|
+
fetchActiveThreads,
|
|
7791
8778
|
instanceDiscoveryUrl,
|
|
7792
8779
|
inviteUrl,
|
|
7793
8780
|
normalizeApiOrigin,
|