@fluxerjs/core 2.2.0 → 3.1.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/README.md +21 -9
- package/dist/Expressions-Bdgo72qI.d.mts +34 -0
- package/dist/Expressions-Bdgo72qI.d.ts +34 -0
- package/dist/{SubpathMessage-D70lAT7N.d.mts → SubpathMessage-Cj_U0V19.d.mts} +1446 -1117
- package/dist/{SubpathMessage-D70lAT7N.d.ts → SubpathMessage-DaimQAd9.d.ts} +1446 -1117
- package/dist/Sudo-fOKSPbxN.d.mts +461 -0
- package/dist/Sudo-fOKSPbxN.d.ts +461 -0
- package/dist/client.d.mts +4 -3
- package/dist/client.d.ts +4 -3
- package/dist/client.js +2219 -1051
- package/dist/client.mjs +2103 -938
- package/dist/cluster.d.mts +5 -4
- package/dist/cluster.d.ts +5 -4
- package/dist/cluster.js +2134 -966
- package/dist/cluster.mjs +2097 -932
- package/dist/index.d.mts +6 -4
- package/dist/index.d.ts +6 -4
- package/dist/index.js +2199 -1053
- package/dist/index.mjs +2035 -877
- package/dist/internal.d.mts +12 -0
- package/dist/internal.d.ts +12 -0
- package/dist/internal.js +449 -0
- package/dist/internal.mjs +398 -0
- package/dist/message.d.mts +4 -3
- package/dist/message.d.ts +4 -3
- package/dist/message.js +528 -95
- package/dist/message.mjs +528 -96
- package/package.json +13 -9
package/dist/cluster.mjs
CHANGED
|
@@ -54,7 +54,13 @@ var Events = {
|
|
|
54
54
|
WebhooksUpdate: "webhooksUpdate",
|
|
55
55
|
Resumed: "resumed",
|
|
56
56
|
Error: "error",
|
|
57
|
-
Debug: "debug"
|
|
57
|
+
Debug: "debug",
|
|
58
|
+
ShardReady: "shardReady",
|
|
59
|
+
ShardResumed: "shardResumed",
|
|
60
|
+
ShardDisconnect: "shardDisconnect",
|
|
61
|
+
ShardReconnecting: "shardReconnecting",
|
|
62
|
+
ShardError: "shardError",
|
|
63
|
+
ShardingRequired: "shardingRequired"
|
|
58
64
|
};
|
|
59
65
|
|
|
60
66
|
// src/LibErrors/ErrorCodes.ts
|
|
@@ -69,91 +75,14 @@ import { REST } from "@fluxerjs/rest";
|
|
|
69
75
|
import { GatewayOpcodes as GatewayOpcodes2, Routes as Routes34 } from "@fluxerjs/types";
|
|
70
76
|
import { createLogger } from "@fluxerjs/util";
|
|
71
77
|
|
|
72
|
-
// src/Domain/User.ts
|
|
73
|
-
import { Routes as Routes13 } from "@fluxerjs/types";
|
|
74
|
-
import { SnowflakeUtil as SnowflakeUtil3 } from "@fluxerjs/util";
|
|
75
|
-
|
|
76
|
-
// src/Helpers/Constants.ts
|
|
77
|
-
import { DEFAULT_USER_AGENT } from "@fluxerjs/rest";
|
|
78
|
-
var CDN_URL = "https://fluxerusercontent.com";
|
|
79
|
-
var STATIC_CDN_URL = "https://fluxerstatic.com";
|
|
80
|
-
|
|
81
|
-
// src/Helpers/Cdn.ts
|
|
82
|
-
function mediaBase(options) {
|
|
83
|
-
return (options?.mediaBase ?? CDN_URL).replace(/\/+$/, "");
|
|
84
|
-
}
|
|
85
|
-
function staticBase(options) {
|
|
86
|
-
return (options?.staticCdnBase ?? STATIC_CDN_URL).replace(/\/+$/, "");
|
|
87
|
-
}
|
|
88
|
-
function getExtension(hash, options) {
|
|
89
|
-
const ext = options?.extension ?? "png";
|
|
90
|
-
if (hash?.startsWith("a_")) return "gif";
|
|
91
|
-
return ext;
|
|
92
|
-
}
|
|
93
|
-
function appendSize(options) {
|
|
94
|
-
return options?.size ? `?size=${options.size}` : "";
|
|
95
|
-
}
|
|
96
|
-
function cdnAvatarURL(userId, avatarHash, options) {
|
|
97
|
-
if (!avatarHash) return null;
|
|
98
|
-
const ext = getExtension(avatarHash, options);
|
|
99
|
-
const size = appendSize(options);
|
|
100
|
-
return `${mediaBase(options)}/avatars/${userId}/${avatarHash}.${ext}${size}`;
|
|
101
|
-
}
|
|
102
|
-
function cdnBannerURL(resourceId, bannerHash, options) {
|
|
103
|
-
if (!bannerHash) return null;
|
|
104
|
-
const ext = getExtension(bannerHash, options);
|
|
105
|
-
const size = appendSize(options);
|
|
106
|
-
return `${mediaBase(options)}/banners/${resourceId}/${bannerHash}.${ext}${size}`;
|
|
107
|
-
}
|
|
108
|
-
function cdnMemberAvatarURL(guildId, userId, avatarHash, options) {
|
|
109
|
-
if (!avatarHash) return null;
|
|
110
|
-
const ext = getExtension(avatarHash, options);
|
|
111
|
-
const size = appendSize(options);
|
|
112
|
-
return `${mediaBase(options)}/guilds/${guildId}/users/${userId}/avatars/${avatarHash}.${ext}${size}`;
|
|
113
|
-
}
|
|
114
|
-
function cdnMemberBannerURL(guildId, userId, bannerHash, options) {
|
|
115
|
-
if (!bannerHash) return null;
|
|
116
|
-
const ext = getExtension(bannerHash, options);
|
|
117
|
-
const size = appendSize(options);
|
|
118
|
-
return `${mediaBase(options)}/guilds/${guildId}/users/${userId}/banners/${bannerHash}.${ext}${size}`;
|
|
119
|
-
}
|
|
120
|
-
function cdnDefaultAvatarURL(userIdOrIndex, options) {
|
|
121
|
-
const index = typeof userIdOrIndex === "string" ? Number(BigInt(userIdOrIndex) % 6n) : Math.abs(Math.floor(userIdOrIndex) % 6);
|
|
122
|
-
return `${staticBase(options)}/avatars/${index}.png`;
|
|
123
|
-
}
|
|
124
|
-
function cdnGuildAssetURL(kind, id, hash, options) {
|
|
125
|
-
if (!hash) return null;
|
|
126
|
-
const size = options?.size ? `?size=${options.size}` : "";
|
|
127
|
-
return `${mediaBase(options)}/${kind}/${id}/${hash}.png${size}`;
|
|
128
|
-
}
|
|
129
|
-
function cdnEmojiURL(emojiId, animated, options) {
|
|
130
|
-
const ext = animated ? "gif" : "png";
|
|
131
|
-
return `${mediaBase(options)}/emojis/${emojiId}.${ext}`;
|
|
132
|
-
}
|
|
133
|
-
function cdnStickerURL(stickerId, animated, options) {
|
|
134
|
-
const ext = animated ? "gif" : "png";
|
|
135
|
-
return `${mediaBase(options)}/stickers/${stickerId}.${ext}`;
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
// src/Domain/Base.ts
|
|
139
|
-
var Base = class {
|
|
140
|
-
};
|
|
141
|
-
|
|
142
|
-
// src/Domain/Channel/Base.ts
|
|
143
|
-
import { ChannelType, Routes as Routes7 } from "@fluxerjs/types";
|
|
144
|
-
import { SnowflakeUtil } from "@fluxerjs/util";
|
|
145
|
-
|
|
146
|
-
// src/ClientCore/MessageManager.ts
|
|
147
|
-
import { Collection as Collection3 } from "@fluxerjs/collection";
|
|
148
|
-
import { Routes as Routes5 } from "@fluxerjs/types";
|
|
149
|
-
|
|
150
78
|
// src/Domain/Message/Message.ts
|
|
151
79
|
import { EmbedBuilder as EmbedBuilder2 } from "@fluxerjs/builders";
|
|
152
|
-
import { Collection as
|
|
80
|
+
import { Collection as Collection3 } from "@fluxerjs/collection";
|
|
153
81
|
import {
|
|
154
82
|
MessageType,
|
|
155
83
|
Routes as Routes4
|
|
156
84
|
} from "@fluxerjs/types";
|
|
85
|
+
import { MessageFlagsBitField } from "@fluxerjs/util";
|
|
157
86
|
|
|
158
87
|
// src/ClientCore/SdkOptions/Attachments.ts
|
|
159
88
|
function toMessageAttachmentEditWire(attachments) {
|
|
@@ -220,21 +149,66 @@ function toAttachmentUploadPlanResponse(data) {
|
|
|
220
149
|
}
|
|
221
150
|
|
|
222
151
|
// src/ClientCore/SdkOptions/Channels.ts
|
|
152
|
+
import { resolvePermissionsToBitfield } from "@fluxerjs/util";
|
|
153
|
+
function toOverwriteWire(overwrite) {
|
|
154
|
+
return {
|
|
155
|
+
id: overwrite.id,
|
|
156
|
+
type: overwrite.type,
|
|
157
|
+
allow: overwrite.allow !== void 0 ? resolvePermissionsToBitfield(overwrite.allow) : "0",
|
|
158
|
+
deny: overwrite.deny !== void 0 ? resolvePermissionsToBitfield(overwrite.deny) : "0"
|
|
159
|
+
};
|
|
160
|
+
}
|
|
223
161
|
function toChannelEditBody(options) {
|
|
224
162
|
const body = {};
|
|
225
163
|
if (options.name !== void 0) body.name = options.name;
|
|
226
164
|
if (options.topic !== void 0) body.topic = options.topic;
|
|
165
|
+
if (options.url !== void 0) body.url = options.url;
|
|
227
166
|
if (options.parentId !== void 0) body.parent_id = options.parentId;
|
|
228
167
|
if (options.bitrate !== void 0) body.bitrate = options.bitrate;
|
|
229
168
|
if (options.userLimit !== void 0) body.user_limit = options.userLimit;
|
|
169
|
+
if (options.voiceConnectionLimit !== void 0) {
|
|
170
|
+
body.voice_connection_limit = options.voiceConnectionLimit;
|
|
171
|
+
}
|
|
230
172
|
if (options.nsfw !== void 0) body.nsfw = options.nsfw;
|
|
173
|
+
if (options.nsfwOverride !== void 0) body.nsfw_override = options.nsfwOverride;
|
|
174
|
+
if (options.contentWarningLevel !== void 0) {
|
|
175
|
+
body.content_warning_level = options.contentWarningLevel;
|
|
176
|
+
}
|
|
177
|
+
if (options.contentWarningText !== void 0) {
|
|
178
|
+
body.content_warning_text = options.contentWarningText;
|
|
179
|
+
}
|
|
231
180
|
if (options.rateLimitPerUser !== void 0) {
|
|
232
181
|
body.rate_limit_per_user = options.rateLimitPerUser;
|
|
233
182
|
}
|
|
234
183
|
if (options.rtcRegion !== void 0) body.rtc_region = options.rtcRegion;
|
|
184
|
+
if (options.icon !== void 0) body.icon = options.icon;
|
|
185
|
+
if (options.permissionOverwrites !== void 0) {
|
|
186
|
+
body.permission_overwrites = options.permissionOverwrites.map(toOverwriteWire);
|
|
187
|
+
}
|
|
188
|
+
return body;
|
|
189
|
+
}
|
|
190
|
+
function toChannelCreateBody(options) {
|
|
191
|
+
const body = { name: options.name, type: options.type };
|
|
192
|
+
if (options.topic !== void 0) body.topic = options.topic;
|
|
193
|
+
if (options.url !== void 0) body.url = options.url;
|
|
194
|
+
if (options.parentId !== void 0) body.parent_id = options.parentId;
|
|
195
|
+
if (options.bitrate !== void 0) body.bitrate = options.bitrate;
|
|
196
|
+
if (options.userLimit !== void 0) body.user_limit = options.userLimit;
|
|
197
|
+
if (options.voiceConnectionLimit !== void 0) {
|
|
198
|
+
body.voice_connection_limit = options.voiceConnectionLimit;
|
|
199
|
+
}
|
|
235
200
|
if (options.permissionOverwrites !== void 0) {
|
|
236
|
-
body.permission_overwrites = options.permissionOverwrites;
|
|
201
|
+
body.permission_overwrites = options.permissionOverwrites.map(toOverwriteWire);
|
|
237
202
|
}
|
|
203
|
+
if (options.nsfw !== void 0) body.nsfw = options.nsfw;
|
|
204
|
+
if (options.nsfwOverride !== void 0) body.nsfw_override = options.nsfwOverride;
|
|
205
|
+
if (options.contentWarningLevel !== void 0) {
|
|
206
|
+
body.content_warning_level = options.contentWarningLevel;
|
|
207
|
+
}
|
|
208
|
+
if (options.contentWarningText !== void 0) {
|
|
209
|
+
body.content_warning_text = options.contentWarningText;
|
|
210
|
+
}
|
|
211
|
+
if (options.rateLimitPerUser !== void 0) body.rate_limit_per_user = options.rateLimitPerUser;
|
|
238
212
|
return body;
|
|
239
213
|
}
|
|
240
214
|
function toChannelInviteBody(options) {
|
|
@@ -245,6 +219,13 @@ function toChannelInviteBody(options) {
|
|
|
245
219
|
if (options.temporary !== void 0) body.temporary = options.temporary;
|
|
246
220
|
return body;
|
|
247
221
|
}
|
|
222
|
+
function toGroupDmEditBody(options) {
|
|
223
|
+
const body = { type: 3 };
|
|
224
|
+
if (options.name !== void 0) body.name = options.name;
|
|
225
|
+
if (options.icon !== void 0) body.icon = options.icon;
|
|
226
|
+
if (options.nicks !== void 0) body.nicks = options.nicks;
|
|
227
|
+
return body;
|
|
228
|
+
}
|
|
248
229
|
|
|
249
230
|
// src/ClientCore/SdkOptions/Discovery.ts
|
|
250
231
|
function toDiscoveryBody(options) {
|
|
@@ -280,32 +261,8 @@ function toDiscoveryStatusPayload(data) {
|
|
|
280
261
|
};
|
|
281
262
|
}
|
|
282
263
|
|
|
283
|
-
// src/ClientCore/SdkOptions/Expressions.ts
|
|
284
|
-
function toEmojiCreateBody(options) {
|
|
285
|
-
return { name: options.name, image: options.image };
|
|
286
|
-
}
|
|
287
|
-
function toEmojiEditBody(options) {
|
|
288
|
-
return { name: options.name };
|
|
289
|
-
}
|
|
290
|
-
function toStickerCreateBody(options) {
|
|
291
|
-
const body = {
|
|
292
|
-
name: options.name,
|
|
293
|
-
image: options.file
|
|
294
|
-
};
|
|
295
|
-
if (options.description !== void 0) body.description = options.description;
|
|
296
|
-
if (options.tags !== void 0) body.tags = options.tags;
|
|
297
|
-
return body;
|
|
298
|
-
}
|
|
299
|
-
function toStickerEditBody(options) {
|
|
300
|
-
const body = {};
|
|
301
|
-
if (options.name !== void 0) body.name = options.name;
|
|
302
|
-
if (options.description !== void 0) body.description = options.description;
|
|
303
|
-
if (options.tags !== void 0) body.tags = options.tags;
|
|
304
|
-
return body;
|
|
305
|
-
}
|
|
306
|
-
|
|
307
264
|
// src/ClientCore/SdkOptions/Guild.ts
|
|
308
|
-
import { resolvePermissionsToBitfield } from "@fluxerjs/util";
|
|
265
|
+
import { resolvePermissionsToBitfield as resolvePermissionsToBitfield2 } from "@fluxerjs/util";
|
|
309
266
|
function toGuildEditBody(options) {
|
|
310
267
|
const body = {};
|
|
311
268
|
if (options.name !== void 0) body.name = options.name;
|
|
@@ -333,6 +290,16 @@ function toGuildEditBody(options) {
|
|
|
333
290
|
body.splash_card_alignment = options.splashCardAlignment;
|
|
334
291
|
}
|
|
335
292
|
if (options.nsfwLevel !== void 0) body.nsfw_level = options.nsfwLevel;
|
|
293
|
+
if (options.nsfw !== void 0) body.nsfw = options.nsfw;
|
|
294
|
+
if (options.contentWarningLevel !== void 0) {
|
|
295
|
+
body.content_warning_level = options.contentWarningLevel;
|
|
296
|
+
}
|
|
297
|
+
if (options.contentWarningText !== void 0) {
|
|
298
|
+
body.content_warning_text = options.contentWarningText;
|
|
299
|
+
}
|
|
300
|
+
if (options.messageHistoryCutoff !== void 0) {
|
|
301
|
+
body.message_history_cutoff = options.messageHistoryCutoff;
|
|
302
|
+
}
|
|
336
303
|
if (options.features !== void 0) body.features = options.features;
|
|
337
304
|
return body;
|
|
338
305
|
}
|
|
@@ -342,6 +309,9 @@ function toGuildBanBody(options) {
|
|
|
342
309
|
if (options.deleteMessageDays !== void 0) {
|
|
343
310
|
body.delete_message_days = options.deleteMessageDays;
|
|
344
311
|
}
|
|
312
|
+
if (options.deleteMessageSeconds !== void 0) {
|
|
313
|
+
body.delete_message_seconds = options.deleteMessageSeconds;
|
|
314
|
+
}
|
|
345
315
|
if (options.banDurationSeconds !== void 0) {
|
|
346
316
|
body.ban_duration_seconds = options.banDurationSeconds;
|
|
347
317
|
}
|
|
@@ -356,18 +326,26 @@ function toChannelPositionBody(updates) {
|
|
|
356
326
|
return row;
|
|
357
327
|
});
|
|
358
328
|
}
|
|
359
|
-
function
|
|
329
|
+
function toRolePermissionsBody(options) {
|
|
360
330
|
const body = {};
|
|
331
|
+
if (options.permissions !== void 0) {
|
|
332
|
+
body.permissions = typeof options.permissions === "string" ? options.permissions : resolvePermissionsToBitfield2(options.permissions);
|
|
333
|
+
}
|
|
334
|
+
return body;
|
|
335
|
+
}
|
|
336
|
+
function toRoleCreateBody(options) {
|
|
337
|
+
const body = { ...toRolePermissionsBody(options) };
|
|
338
|
+
if (options.name !== void 0) body.name = options.name;
|
|
339
|
+
if (options.color !== void 0) body.color = options.color;
|
|
340
|
+
return body;
|
|
341
|
+
}
|
|
342
|
+
function toRoleEditBody(options) {
|
|
343
|
+
const body = { ...toRolePermissionsBody(options) };
|
|
361
344
|
if (options.name !== void 0) body.name = options.name;
|
|
362
345
|
if (options.color !== void 0) body.color = options.color;
|
|
363
346
|
if (options.hoist !== void 0) body.hoist = options.hoist;
|
|
364
347
|
if (options.mentionable !== void 0) body.mentionable = options.mentionable;
|
|
365
|
-
if (options.unicodeEmoji !== void 0) body.unicode_emoji = options.unicodeEmoji;
|
|
366
|
-
if (options.position !== void 0) body.position = options.position;
|
|
367
348
|
if (options.hoistPosition !== void 0) body.hoist_position = options.hoistPosition;
|
|
368
|
-
if (options.permissions !== void 0) {
|
|
369
|
-
body.permissions = typeof options.permissions === "string" ? options.permissions : resolvePermissionsToBitfield(options.permissions);
|
|
370
|
-
}
|
|
371
349
|
return body;
|
|
372
350
|
}
|
|
373
351
|
|
|
@@ -385,6 +363,8 @@ function toMemberSearchBody(options) {
|
|
|
385
363
|
if (options.userCreatedAtLte !== void 0) body.user_created_at_lte = options.userCreatedAtLte;
|
|
386
364
|
if (options.sortBy !== void 0) body.sort_by = options.sortBy;
|
|
387
365
|
if (options.sortOrder !== void 0) body.sort_order = options.sortOrder;
|
|
366
|
+
if (options.joinSourceType !== void 0) body.join_source_type = options.joinSourceType;
|
|
367
|
+
if (options.sourceInviteCode !== void 0) body.source_invite_code = options.sourceInviteCode;
|
|
388
368
|
return body;
|
|
389
369
|
}
|
|
390
370
|
function toMemberEditBody(options) {
|
|
@@ -397,6 +377,7 @@ function toMemberEditBody(options) {
|
|
|
397
377
|
if (options.pronouns !== void 0) body.pronouns = options.pronouns;
|
|
398
378
|
if (options.accentColor !== void 0) body.accent_color = options.accentColor;
|
|
399
379
|
if (options.profileFlags !== void 0) body.profile_flags = options.profileFlags;
|
|
380
|
+
if (options.mentionFlags !== void 0) body.mention_flags = options.mentionFlags;
|
|
400
381
|
if (options.mute !== void 0) body.mute = options.mute;
|
|
401
382
|
if (options.deaf !== void 0) body.deaf = options.deaf;
|
|
402
383
|
if (options.communicationDisabledUntil !== void 0) {
|
|
@@ -418,15 +399,54 @@ function toBulkFetchWire(requests) {
|
|
|
418
399
|
...r.around !== void 0 ? { around: r.around } : {}
|
|
419
400
|
}));
|
|
420
401
|
}
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
if (options.
|
|
426
|
-
if (options.
|
|
427
|
-
|
|
402
|
+
function toMessageSearchBody(options = {}) {
|
|
403
|
+
const body = { scope: "current" };
|
|
404
|
+
if (options.content !== void 0) body.content = options.content;
|
|
405
|
+
if (options.contents !== void 0) body.contents = options.contents;
|
|
406
|
+
if (options.exactPhrases !== void 0) body.exact_phrases = options.exactPhrases;
|
|
407
|
+
if (options.channelIds !== void 0) {
|
|
408
|
+
body.channel_id = options.channelIds;
|
|
409
|
+
body.channel_ids = options.channelIds;
|
|
410
|
+
}
|
|
411
|
+
if (options.excludeChannelIds !== void 0) body.exclude_channel_id = options.excludeChannelIds;
|
|
412
|
+
if (options.contextGuildId !== void 0) body.context_guild_id = options.contextGuildId;
|
|
413
|
+
if (options.contextChannelId !== void 0) body.context_channel_id = options.contextChannelId;
|
|
414
|
+
if (options.hitsPerPage !== void 0) body.hits_per_page = options.hitsPerPage;
|
|
415
|
+
if (options.page !== void 0) body.page = options.page;
|
|
416
|
+
if (options.cursor !== void 0) body.cursor = options.cursor;
|
|
417
|
+
if (options.minId !== void 0) body.min_id = options.minId;
|
|
418
|
+
if (options.maxId !== void 0) body.max_id = options.maxId;
|
|
419
|
+
if (options.authorIds !== void 0) body.author_id = options.authorIds;
|
|
420
|
+
if (options.excludeAuthorIds !== void 0) body.exclude_author_id = options.excludeAuthorIds;
|
|
421
|
+
if (options.authorType !== void 0) body.author_type = options.authorType;
|
|
422
|
+
if (options.excludeAuthorType !== void 0) body.exclude_author_type = options.excludeAuthorType;
|
|
423
|
+
if (options.mentions !== void 0) body.mentions = options.mentions;
|
|
424
|
+
if (options.excludeMentions !== void 0) body.exclude_mentions = options.excludeMentions;
|
|
425
|
+
if (options.mentionEveryone !== void 0) body.mention_everyone = options.mentionEveryone;
|
|
426
|
+
if (options.pinned !== void 0) body.pinned = options.pinned;
|
|
427
|
+
if (options.includeNsfw !== void 0) body.include_nsfw = options.includeNsfw;
|
|
428
|
+
if (options.has !== void 0) body.has = options.has;
|
|
429
|
+
if (options.excludeHas !== void 0) body.exclude_has = options.excludeHas;
|
|
430
|
+
if (options.sortBy !== void 0) body.sort_by = options.sortBy;
|
|
431
|
+
if (options.sortOrder !== void 0) body.sort_order = options.sortOrder;
|
|
428
432
|
return body;
|
|
429
433
|
}
|
|
434
|
+
function isMessageSearchIndexing(data) {
|
|
435
|
+
return "indexing" in data && data.indexing === true;
|
|
436
|
+
}
|
|
437
|
+
function toMessageSearchResponse(data) {
|
|
438
|
+
if (isMessageSearchIndexing(data)) {
|
|
439
|
+
return { indexing: true };
|
|
440
|
+
}
|
|
441
|
+
return {
|
|
442
|
+
messages: data.messages,
|
|
443
|
+
channels: data.channels,
|
|
444
|
+
total: data.total,
|
|
445
|
+
hitsPerPage: data.hits_per_page,
|
|
446
|
+
page: data.page,
|
|
447
|
+
...data.cursor !== void 0 ? { cursor: data.cursor } : {}
|
|
448
|
+
};
|
|
449
|
+
}
|
|
430
450
|
|
|
431
451
|
// src/ClientCore/SdkOptions/Presence.ts
|
|
432
452
|
function toPresenceWire(options) {
|
|
@@ -475,9 +495,16 @@ function toSudoBody(options) {
|
|
|
475
495
|
return body;
|
|
476
496
|
}
|
|
477
497
|
|
|
498
|
+
// src/Helpers/AuditReason.ts
|
|
499
|
+
var AUDIT_LOG_REASON_HEADER = "X-Audit-Log-Reason";
|
|
500
|
+
function auditReasonHeaders(reason) {
|
|
501
|
+
if (reason == null || reason === "") return {};
|
|
502
|
+
return { headers: { [AUDIT_LOG_REASON_HEADER]: encodeURIComponent(reason) } };
|
|
503
|
+
}
|
|
504
|
+
|
|
478
505
|
// src/Helpers/MessageUtils/Body.ts
|
|
479
|
-
import { EmbedBuilder, MessagePayload } from "@fluxerjs/builders";
|
|
480
|
-
import { MessageReferenceType } from "@fluxerjs/types";
|
|
506
|
+
import { AttachmentBuilder, EmbedBuilder, MessagePayload } from "@fluxerjs/builders";
|
|
507
|
+
import { MessageAttachmentFlags, MessageReferenceType } from "@fluxerjs/types";
|
|
481
508
|
|
|
482
509
|
// src/Helpers/MessageUtils/Files.ts
|
|
483
510
|
var FILE_FETCH_TIMEOUT_MS = 3e4;
|
|
@@ -540,6 +567,37 @@ function applyReplyPingSuppression(body) {
|
|
|
540
567
|
function assignIfDefined(target, key, value) {
|
|
541
568
|
if (value !== void 0) target[key] = value;
|
|
542
569
|
}
|
|
570
|
+
function normalizeSendFiles(files) {
|
|
571
|
+
if (!files?.length) return void 0;
|
|
572
|
+
const normalized = [];
|
|
573
|
+
const metaFromBuilders = [];
|
|
574
|
+
let anyBuilderMeta = false;
|
|
575
|
+
for (let i = 0; i < files.length; i++) {
|
|
576
|
+
const file = files[i];
|
|
577
|
+
if (!file) continue;
|
|
578
|
+
if (file instanceof AttachmentBuilder) {
|
|
579
|
+
normalized.push(file.toFileData());
|
|
580
|
+
const meta = {
|
|
581
|
+
id: i,
|
|
582
|
+
filename: file.filename,
|
|
583
|
+
...file.description != null ? { description: file.description } : {},
|
|
584
|
+
...file.spoiler ? { flags: MessageAttachmentFlags.IS_SPOILER } : {}
|
|
585
|
+
};
|
|
586
|
+
if (file.description != null || file.spoiler) anyBuilderMeta = true;
|
|
587
|
+
metaFromBuilders.push(meta);
|
|
588
|
+
} else {
|
|
589
|
+
normalized.push(file);
|
|
590
|
+
metaFromBuilders.push({
|
|
591
|
+
id: i,
|
|
592
|
+
filename: file.filename ?? file.name
|
|
593
|
+
});
|
|
594
|
+
}
|
|
595
|
+
}
|
|
596
|
+
return {
|
|
597
|
+
files: normalized,
|
|
598
|
+
metaFromBuilders: anyBuilderMeta ? metaFromBuilders : []
|
|
599
|
+
};
|
|
600
|
+
}
|
|
543
601
|
function buildSendBody(options) {
|
|
544
602
|
const body = typeof options === "string" ? { content: options } : options;
|
|
545
603
|
const result = {};
|
|
@@ -547,16 +605,17 @@ function buildSendBody(options) {
|
|
|
547
605
|
if (body.embeds?.length) {
|
|
548
606
|
result.embeds = body.embeds.map((e) => e instanceof EmbedBuilder ? e.toJSON() : e);
|
|
549
607
|
}
|
|
608
|
+
const normalizedFiles = normalizeSendFiles(body.files);
|
|
550
609
|
if (body.uploadedAttachments?.length) {
|
|
551
610
|
result.attachments = body.uploadedAttachments;
|
|
552
|
-
} else if (
|
|
611
|
+
} else if (normalizedFiles?.files.length) {
|
|
553
612
|
result.attachments = body.attachments?.length ? body.attachments.map((a) => ({
|
|
554
613
|
id: a.id,
|
|
555
614
|
filename: a.filename,
|
|
556
615
|
...a.title != null && { title: a.title },
|
|
557
616
|
...a.description != null && { description: a.description },
|
|
558
617
|
...a.flags != null && { flags: a.flags }
|
|
559
|
-
})) :
|
|
618
|
+
})) : normalizedFiles.metaFromBuilders.length ? normalizedFiles.metaFromBuilders : normalizedFiles.files.map((f, i) => ({ id: i, filename: f.filename ?? f.name }));
|
|
560
619
|
}
|
|
561
620
|
if (body.allowedMentions) result.allowed_mentions = toAPIAllowedMentions(body.allowedMentions);
|
|
562
621
|
if (body.stickerIds?.length) result.sticker_ids = body.stickerIds;
|
|
@@ -650,9 +709,10 @@ async function prepareMessagePostPayload(options, defaults) {
|
|
|
650
709
|
} else if (allowedMentions?.repliedUser === false) {
|
|
651
710
|
applyReplyPingSuppression(body);
|
|
652
711
|
}
|
|
712
|
+
const resolvedFiles = normalizeSendFiles(files);
|
|
653
713
|
return {
|
|
654
714
|
body,
|
|
655
|
-
files: !uploadedAttachments?.length && files
|
|
715
|
+
files: !uploadedAttachments?.length && resolvedFiles?.files.length ? await resolveMessageFiles(resolvedFiles.files) : void 0
|
|
656
716
|
};
|
|
657
717
|
}
|
|
658
718
|
|
|
@@ -701,14 +761,22 @@ function qs(params) {
|
|
|
701
761
|
return out ? `?${out}` : "";
|
|
702
762
|
}
|
|
703
763
|
|
|
764
|
+
// src/Domain/Base.ts
|
|
765
|
+
var Base = class {
|
|
766
|
+
};
|
|
767
|
+
|
|
704
768
|
// src/Domain/Message/MessageReaction.ts
|
|
705
|
-
var MessageReaction = class extends Base {
|
|
769
|
+
var MessageReaction = class _MessageReaction extends Base {
|
|
706
770
|
client;
|
|
707
771
|
messageId;
|
|
708
772
|
channelId;
|
|
709
773
|
guildId;
|
|
710
774
|
emoji;
|
|
711
|
-
/**
|
|
775
|
+
/** Total count when hydrated from a message payload; `1` for gateway add events. */
|
|
776
|
+
count;
|
|
777
|
+
/** Whether the current user reacted (message payload); false for gateway remove. */
|
|
778
|
+
me;
|
|
779
|
+
/** Raw gateway payload for low-level access (null when built from a message aggregate). */
|
|
712
780
|
_data;
|
|
713
781
|
constructor(client, data) {
|
|
714
782
|
super();
|
|
@@ -722,6 +790,26 @@ var MessageReaction = class extends Base {
|
|
|
722
790
|
...data.emoji.id !== void 0 ? { id: data.emoji.id } : {},
|
|
723
791
|
...data.emoji.animated !== void 0 ? { animated: data.emoji.animated } : {}
|
|
724
792
|
};
|
|
793
|
+
this.count = 1;
|
|
794
|
+
this.me = false;
|
|
795
|
+
}
|
|
796
|
+
/** Build a reaction aggregate from a message's `reactions` array entry. */
|
|
797
|
+
static fromMessage(message, data) {
|
|
798
|
+
const reaction = new _MessageReaction(message.client, {
|
|
799
|
+
user_id: message.client.user?.id ?? "0",
|
|
800
|
+
message_id: message.id,
|
|
801
|
+
channel_id: message.channelId,
|
|
802
|
+
guild_id: message.guildId ?? void 0,
|
|
803
|
+
emoji: {
|
|
804
|
+
name: data.emoji.name,
|
|
805
|
+
id: data.emoji.id ?? void 0,
|
|
806
|
+
animated: data.emoji.animated ?? void 0
|
|
807
|
+
}
|
|
808
|
+
});
|
|
809
|
+
Object.defineProperty(reaction, "_data", { value: null });
|
|
810
|
+
reaction.count = data.count;
|
|
811
|
+
reaction.me = data.me ?? false;
|
|
812
|
+
return reaction;
|
|
725
813
|
}
|
|
726
814
|
/** Emoji as a string for reaction routes: unicode or `name:id` (`a:name:id` when animated). */
|
|
727
815
|
get emojiIdentifier() {
|
|
@@ -731,12 +819,23 @@ var MessageReaction = class extends Base {
|
|
|
731
819
|
get guild() {
|
|
732
820
|
return this.guildId ? this.client.guilds.get(this.guildId) ?? null : null;
|
|
733
821
|
}
|
|
822
|
+
/** Cached message this reaction belongs to, or null if the message was not cached. */
|
|
823
|
+
get message() {
|
|
824
|
+
const cached = this.client._getMessageCache(this.channelId)?.get(this.messageId);
|
|
825
|
+
return cached ? new Message(this.client, cached) : null;
|
|
826
|
+
}
|
|
827
|
+
/** Cached text-capable channel, or null if uncached / not text-based. */
|
|
828
|
+
get channel() {
|
|
829
|
+
const channel = this.client.channels.get(this.channelId);
|
|
830
|
+
return channel?.isTextBased() ? channel : null;
|
|
831
|
+
}
|
|
734
832
|
/**
|
|
735
|
-
* Fetch the message this reaction belongs to.
|
|
736
|
-
* Use when you need to edit, delete, or otherwise interact with the message.
|
|
833
|
+
* Fetch the message this reaction belongs to (cache first, then REST).
|
|
737
834
|
* @throws FluxerError with MESSAGE_NOT_FOUND if the message does not exist
|
|
738
835
|
*/
|
|
739
836
|
async fetchMessage() {
|
|
837
|
+
const cached = this.message;
|
|
838
|
+
if (cached) return cached;
|
|
740
839
|
try {
|
|
741
840
|
const data = await this.client.rest.get(
|
|
742
841
|
Routes.channelMessage(this.channelId, this.messageId)
|
|
@@ -755,7 +854,7 @@ var MessageReaction = class extends Base {
|
|
|
755
854
|
};
|
|
756
855
|
|
|
757
856
|
// src/Helpers/ReactionCollector.ts
|
|
758
|
-
var ReactionCollector = class extends EventEmitter {
|
|
857
|
+
var ReactionCollector = class _ReactionCollector extends EventEmitter {
|
|
759
858
|
client;
|
|
760
859
|
messageId;
|
|
761
860
|
channelId;
|
|
@@ -798,15 +897,17 @@ var ReactionCollector = class extends EventEmitter {
|
|
|
798
897
|
...entry.emoji.animated !== void 0 ? { animated: entry.emoji.animated } : {}
|
|
799
898
|
}
|
|
800
899
|
});
|
|
801
|
-
const
|
|
900
|
+
const cached = this.client.users.get(entry.userId);
|
|
901
|
+
const user = entry.member?.user ?? cached ?? // Ephemeral stub only; do not cache fake "Unknown" users as real Users.
|
|
902
|
+
{
|
|
802
903
|
id: entry.userId,
|
|
803
904
|
username: "Unknown",
|
|
804
905
|
discriminator: "0",
|
|
805
|
-
|
|
906
|
+
globalName: null,
|
|
806
907
|
avatar: null,
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
}
|
|
908
|
+
bot: false,
|
|
909
|
+
system: false
|
|
910
|
+
};
|
|
810
911
|
this._collect(reaction, user, entry.userId);
|
|
811
912
|
}
|
|
812
913
|
};
|
|
@@ -838,6 +939,21 @@ var ReactionCollector = class extends EventEmitter {
|
|
|
838
939
|
}
|
|
839
940
|
this.emit("end", this.collected, reason);
|
|
840
941
|
}
|
|
942
|
+
/**
|
|
943
|
+
* One-shot helper used by {@link Message.awaitReactions}.
|
|
944
|
+
* Resolves with the collected reactions when the collector ends.
|
|
945
|
+
* Rejects if `options.errors` includes the end reason.
|
|
946
|
+
*/
|
|
947
|
+
static awaitReactions(client, messageId, channelId, options) {
|
|
948
|
+
const errors = options?.errors ?? [];
|
|
949
|
+
return new Promise((resolve, reject) => {
|
|
950
|
+
const collector = new _ReactionCollector(client, messageId, channelId, options);
|
|
951
|
+
collector.on("end", (collected, reason) => {
|
|
952
|
+
if (errors.includes(reason)) reject(collected);
|
|
953
|
+
else resolve(collected);
|
|
954
|
+
});
|
|
955
|
+
});
|
|
956
|
+
}
|
|
841
957
|
on(event, listener) {
|
|
842
958
|
return super.on(event, listener);
|
|
843
959
|
}
|
|
@@ -846,146 +962,366 @@ var ReactionCollector = class extends EventEmitter {
|
|
|
846
962
|
}
|
|
847
963
|
};
|
|
848
964
|
|
|
849
|
-
// src/Domain/Message/
|
|
850
|
-
|
|
851
|
-
import { parseEmoji } from "@fluxerjs/util";
|
|
852
|
-
async function emojiPath(message, emoji) {
|
|
853
|
-
return message.client.resolveEmoji(emoji, message.guildId);
|
|
854
|
-
}
|
|
855
|
-
function toReactionEmoji(emoji) {
|
|
856
|
-
if (typeof emoji !== "string") {
|
|
857
|
-
return {
|
|
858
|
-
name: emoji.name,
|
|
859
|
-
...emoji.id !== void 0 ? { id: emoji.id } : {},
|
|
860
|
-
...emoji.animated !== void 0 ? { animated: emoji.animated } : {}
|
|
861
|
-
};
|
|
862
|
-
}
|
|
863
|
-
const animatedWire = /^a:(\w+):(\d+)$/.exec(emoji);
|
|
864
|
-
if (animatedWire) {
|
|
865
|
-
return { name: animatedWire[1], id: animatedWire[2], animated: true };
|
|
866
|
-
}
|
|
867
|
-
const parsed = parseEmoji(emoji);
|
|
868
|
-
if (parsed?.id) {
|
|
869
|
-
return {
|
|
870
|
-
name: parsed.name,
|
|
871
|
-
id: parsed.id,
|
|
872
|
-
...parsed.animated ? { animated: true } : {}
|
|
873
|
-
};
|
|
874
|
-
}
|
|
875
|
-
let name = emoji;
|
|
876
|
-
try {
|
|
877
|
-
name = decodeURIComponent(emoji);
|
|
878
|
-
} catch {
|
|
879
|
-
}
|
|
880
|
-
return { name: parsed?.name ?? name };
|
|
881
|
-
}
|
|
882
|
-
function emitOwnReactionAdd(message, wireOrInput) {
|
|
883
|
-
const user = message.client.user;
|
|
884
|
-
if (!user) return;
|
|
885
|
-
const emojiPayload = toReactionEmoji(wireOrInput);
|
|
886
|
-
const reaction = new MessageReaction(message.client, {
|
|
887
|
-
user_id: user.id,
|
|
888
|
-
channel_id: message.channelId,
|
|
889
|
-
message_id: message.id,
|
|
890
|
-
guild_id: message.guildId ?? void 0,
|
|
891
|
-
emoji: {
|
|
892
|
-
name: emojiPayload.name,
|
|
893
|
-
...emojiPayload.id !== void 0 ? { id: emojiPayload.id } : {},
|
|
894
|
-
...emojiPayload.animated !== void 0 ? { animated: emojiPayload.animated } : {}
|
|
895
|
-
}
|
|
896
|
-
});
|
|
897
|
-
const payload = {
|
|
898
|
-
reaction,
|
|
899
|
-
user,
|
|
900
|
-
messageId: message.id,
|
|
901
|
-
channelId: message.channelId,
|
|
902
|
-
emoji: emojiPayload,
|
|
903
|
-
userId: user.id
|
|
904
|
-
};
|
|
905
|
-
message.client.emit(Events.MessageReactionAdd, payload);
|
|
906
|
-
}
|
|
907
|
-
async function reactToMessage(message, emoji) {
|
|
908
|
-
const wire = await emojiPath(message, emoji);
|
|
909
|
-
await message.client.rest.put(
|
|
910
|
-
Routes2.channelMessageReactionMe(message.channelId, message.id, wire)
|
|
911
|
-
);
|
|
912
|
-
emitOwnReactionAdd(message, wire);
|
|
913
|
-
}
|
|
914
|
-
async function removeMessageReaction(message, emoji, userId) {
|
|
915
|
-
const e = await emojiPath(message, emoji);
|
|
916
|
-
const route = userId ? Routes2.channelMessageReactionUser(message.channelId, message.id, e, userId) : Routes2.channelMessageReactionMe(message.channelId, message.id, e);
|
|
917
|
-
await message.client.rest.delete(route);
|
|
918
|
-
}
|
|
919
|
-
async function removeAllMessageReactions(message) {
|
|
920
|
-
await message.client.rest.delete(Routes2.channelMessageReactions(message.channelId, message.id));
|
|
921
|
-
}
|
|
922
|
-
async function removeMessageReactionEmoji(message, emoji) {
|
|
923
|
-
const e = await emojiPath(message, emoji);
|
|
924
|
-
await message.client.rest.delete(Routes2.channelMessageReaction(message.channelId, message.id, e));
|
|
925
|
-
}
|
|
926
|
-
async function fetchMessageReactionUsers(message, emoji, options) {
|
|
927
|
-
return (await fetchMessageReactionUsersPage(message, emoji, options)).users;
|
|
928
|
-
}
|
|
929
|
-
async function fetchMessageReactionUsersPage(message, emoji, options) {
|
|
930
|
-
const e = await emojiPath(message, emoji);
|
|
931
|
-
const params = new URLSearchParams();
|
|
932
|
-
if (options?.limit != null) params.set("limit", String(options.limit));
|
|
933
|
-
if (options?.after) params.set("after", options.after);
|
|
934
|
-
const qs2 = params.toString();
|
|
935
|
-
const route = Routes2.channelMessageReactionUsers(message.channelId, message.id, e) + (qs2 ? `?${qs2}` : "");
|
|
936
|
-
const data = await message.client.rest.get(route);
|
|
937
|
-
if (Array.isArray(data)) {
|
|
938
|
-
return {
|
|
939
|
-
users: data.map((u) => message.client.getOrCreateUser(u)),
|
|
940
|
-
hasMore: false,
|
|
941
|
-
nextAfter: null
|
|
942
|
-
};
|
|
943
|
-
}
|
|
944
|
-
const list = data.items ?? data.users ?? [];
|
|
965
|
+
// src/Domain/Message/Attachment.ts
|
|
966
|
+
function toMessageAttachment(data) {
|
|
945
967
|
return {
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
968
|
+
id: data.id,
|
|
969
|
+
filename: data.filename,
|
|
970
|
+
title: data.title ?? null,
|
|
971
|
+
description: data.description ?? null,
|
|
972
|
+
contentType: data.content_type ?? null,
|
|
973
|
+
contentHash: data.content_hash ?? null,
|
|
974
|
+
size: data.size,
|
|
975
|
+
url: data.url ?? null,
|
|
976
|
+
proxyUrl: data.proxy_url ?? null,
|
|
977
|
+
width: data.width ?? null,
|
|
978
|
+
height: data.height ?? null,
|
|
979
|
+
placeholder: data.placeholder ?? null,
|
|
980
|
+
flags: data.flags ?? 0,
|
|
981
|
+
nsfw: data.nsfw ?? false,
|
|
982
|
+
duration: data.duration ?? null,
|
|
983
|
+
waveform: data.waveform ?? null,
|
|
984
|
+
expiresAt: data.expires_at ? new Date(data.expires_at) : null,
|
|
985
|
+
expired: data.expired ?? false
|
|
949
986
|
};
|
|
950
987
|
}
|
|
951
988
|
|
|
952
|
-
// src/Domain/Message/
|
|
953
|
-
|
|
954
|
-
import { Routes as Routes3 } from "@fluxerjs/types";
|
|
955
|
-
function toReplyTarget(ref) {
|
|
989
|
+
// src/Domain/Message/Embed.ts
|
|
990
|
+
function toMessageEmbedAuthor(data) {
|
|
956
991
|
return {
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
992
|
+
name: data.name ?? null,
|
|
993
|
+
url: data.url ?? null,
|
|
994
|
+
iconUrl: data.icon_url ?? null,
|
|
995
|
+
proxyIconUrl: data.proxy_icon_url ?? null
|
|
960
996
|
};
|
|
961
997
|
}
|
|
962
|
-
function
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
998
|
+
function toMessageEmbedFooter(data) {
|
|
999
|
+
return {
|
|
1000
|
+
text: data.text,
|
|
1001
|
+
iconUrl: data.icon_url ?? null,
|
|
1002
|
+
proxyIconUrl: data.proxy_icon_url ?? null
|
|
1003
|
+
};
|
|
966
1004
|
}
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
1005
|
+
function toMessageEmbedMedia(data) {
|
|
1006
|
+
return {
|
|
1007
|
+
url: data.url,
|
|
1008
|
+
proxyUrl: data.proxy_url ?? null,
|
|
1009
|
+
contentType: data.content_type ?? null,
|
|
1010
|
+
contentHash: data.content_hash ?? null,
|
|
1011
|
+
width: data.width ?? null,
|
|
1012
|
+
height: data.height ?? null,
|
|
1013
|
+
description: data.description ?? null,
|
|
1014
|
+
placeholder: data.placeholder ?? null,
|
|
1015
|
+
duration: data.duration ?? null,
|
|
1016
|
+
flags: data.flags ?? null
|
|
1017
|
+
};
|
|
977
1018
|
}
|
|
978
|
-
function
|
|
979
|
-
|
|
1019
|
+
function toMessageEmbed(data) {
|
|
1020
|
+
const full = data;
|
|
980
1021
|
return {
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
1022
|
+
type: data.type ?? "rich",
|
|
1023
|
+
url: data.url ?? null,
|
|
1024
|
+
title: data.title ?? null,
|
|
1025
|
+
color: data.color ?? null,
|
|
1026
|
+
timestamp: data.timestamp ? new Date(data.timestamp) : null,
|
|
1027
|
+
description: data.description ?? null,
|
|
1028
|
+
author: data.author ? toMessageEmbedAuthor(data.author) : null,
|
|
1029
|
+
image: data.image ? toMessageEmbedMedia(data.image) : null,
|
|
1030
|
+
thumbnail: data.thumbnail ? toMessageEmbedMedia(data.thumbnail) : null,
|
|
1031
|
+
footer: data.footer ? toMessageEmbedFooter(data.footer) : null,
|
|
1032
|
+
fields: (data.fields ?? []).map((f) => ({
|
|
1033
|
+
name: f.name,
|
|
1034
|
+
value: f.value,
|
|
1035
|
+
inline: f.inline ?? false
|
|
1036
|
+
})),
|
|
1037
|
+
provider: data.provider ? toMessageEmbedAuthor(data.provider) : null,
|
|
1038
|
+
video: data.video ? toMessageEmbedMedia(data.video) : null,
|
|
1039
|
+
audio: data.audio ? toMessageEmbedMedia(data.audio) : null,
|
|
1040
|
+
nsfw: data.nsfw ?? false,
|
|
1041
|
+
children: (full.children ?? []).map(toMessageEmbed),
|
|
1042
|
+
html: full.html ?? null,
|
|
1043
|
+
htmlWidth: full.html_width ?? null,
|
|
1044
|
+
htmlHeight: full.html_height ?? null
|
|
984
1045
|
};
|
|
985
1046
|
}
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
1047
|
+
|
|
1048
|
+
// src/Domain/Message/MessageReactionManager.ts
|
|
1049
|
+
import { Collection as Collection2 } from "@fluxerjs/collection";
|
|
1050
|
+
var MessageReactionManager = class {
|
|
1051
|
+
constructor(message) {
|
|
1052
|
+
this.message = message;
|
|
1053
|
+
}
|
|
1054
|
+
_cache = new Collection2();
|
|
1055
|
+
/** Reactions keyed by unicode name or `name:id`. */
|
|
1056
|
+
get cache() {
|
|
1057
|
+
return this._cache;
|
|
1058
|
+
}
|
|
1059
|
+
get size() {
|
|
1060
|
+
return this._cache.size;
|
|
1061
|
+
}
|
|
1062
|
+
[Symbol.iterator]() {
|
|
1063
|
+
return this._cache.values();
|
|
1064
|
+
}
|
|
1065
|
+
/** @internal Sync from an API message payload. */
|
|
1066
|
+
_patch(reactions) {
|
|
1067
|
+
this._cache.clear();
|
|
1068
|
+
for (const data of reactions ?? []) {
|
|
1069
|
+
const reaction = MessageReaction.fromMessage(this.message, data);
|
|
1070
|
+
this._cache.set(reaction.emojiIdentifier, reaction);
|
|
1071
|
+
}
|
|
1072
|
+
}
|
|
1073
|
+
};
|
|
1074
|
+
|
|
1075
|
+
// src/Domain/Message/MessageSticker.ts
|
|
1076
|
+
import { SnowflakeUtil } from "@fluxerjs/util";
|
|
1077
|
+
|
|
1078
|
+
// src/Helpers/Constants.ts
|
|
1079
|
+
import { DEFAULT_USER_AGENT } from "@fluxerjs/rest";
|
|
1080
|
+
var CDN_URL = "https://fluxerusercontent.com";
|
|
1081
|
+
var STATIC_CDN_URL = "https://fluxerstatic.com";
|
|
1082
|
+
|
|
1083
|
+
// src/Helpers/Cdn.ts
|
|
1084
|
+
var CDN_SIZE_LADDER = [
|
|
1085
|
+
16,
|
|
1086
|
+
20,
|
|
1087
|
+
22,
|
|
1088
|
+
24,
|
|
1089
|
+
28,
|
|
1090
|
+
32,
|
|
1091
|
+
40,
|
|
1092
|
+
44,
|
|
1093
|
+
48,
|
|
1094
|
+
56,
|
|
1095
|
+
60,
|
|
1096
|
+
64,
|
|
1097
|
+
80,
|
|
1098
|
+
96,
|
|
1099
|
+
100,
|
|
1100
|
+
128,
|
|
1101
|
+
160,
|
|
1102
|
+
240,
|
|
1103
|
+
256,
|
|
1104
|
+
300,
|
|
1105
|
+
320,
|
|
1106
|
+
480,
|
|
1107
|
+
512,
|
|
1108
|
+
600,
|
|
1109
|
+
640,
|
|
1110
|
+
1024,
|
|
1111
|
+
1280,
|
|
1112
|
+
1536,
|
|
1113
|
+
2048,
|
|
1114
|
+
3072,
|
|
1115
|
+
4096,
|
|
1116
|
+
8192,
|
|
1117
|
+
16384
|
|
1118
|
+
];
|
|
1119
|
+
var CDN_ASSET_CLASS_RANGE = {
|
|
1120
|
+
icon: { min: 128, max: 1024 },
|
|
1121
|
+
banner: { min: 480, max: 2400 },
|
|
1122
|
+
emoji: { min: 32, max: 512 },
|
|
1123
|
+
sticker: { min: 128, max: 512 }
|
|
1124
|
+
};
|
|
1125
|
+
function nearestSize(requested, candidates) {
|
|
1126
|
+
let best = candidates[0];
|
|
1127
|
+
let bestDist = Math.abs(requested - best);
|
|
1128
|
+
for (let i = 1; i < candidates.length; i++) {
|
|
1129
|
+
const step = candidates[i];
|
|
1130
|
+
const dist = Math.abs(requested - step);
|
|
1131
|
+
if (dist < bestDist || dist === bestDist && step > best) {
|
|
1132
|
+
best = step;
|
|
1133
|
+
bestDist = dist;
|
|
1134
|
+
}
|
|
1135
|
+
}
|
|
1136
|
+
return best;
|
|
1137
|
+
}
|
|
1138
|
+
function snapCdnSize(requested, assetClass) {
|
|
1139
|
+
const { min, max } = CDN_ASSET_CLASS_RANGE[assetClass];
|
|
1140
|
+
const snapped = nearestSize(requested, CDN_SIZE_LADDER);
|
|
1141
|
+
const clamped = Math.min(max, Math.max(min, snapped));
|
|
1142
|
+
const allowed = CDN_SIZE_LADDER.filter((step) => step >= min && step <= max);
|
|
1143
|
+
return nearestSize(clamped, allowed);
|
|
1144
|
+
}
|
|
1145
|
+
function mediaBase(options) {
|
|
1146
|
+
return (options?.mediaBase ?? CDN_URL).replace(/\/+$/, "");
|
|
1147
|
+
}
|
|
1148
|
+
function staticBase(options) {
|
|
1149
|
+
return (options?.staticCdnBase ?? STATIC_CDN_URL).replace(/\/+$/, "");
|
|
1150
|
+
}
|
|
1151
|
+
function getExtension(hash, options) {
|
|
1152
|
+
const ext = options?.extension ?? "png";
|
|
1153
|
+
if (hash?.startsWith("a_")) return "gif";
|
|
1154
|
+
return ext;
|
|
1155
|
+
}
|
|
1156
|
+
function appendSize(options, assetClass) {
|
|
1157
|
+
const size = options?.size;
|
|
1158
|
+
if (size == null || !Number.isFinite(size) || size <= 0) return "";
|
|
1159
|
+
return `?size=${snapCdnSize(size, assetClass)}`;
|
|
1160
|
+
}
|
|
1161
|
+
function cdnAvatarURL(userId, avatarHash, options) {
|
|
1162
|
+
if (!avatarHash) return null;
|
|
1163
|
+
const ext = getExtension(avatarHash, options);
|
|
1164
|
+
const size = appendSize(options, "icon");
|
|
1165
|
+
return `${mediaBase(options)}/avatars/${userId}/${avatarHash}.${ext}${size}`;
|
|
1166
|
+
}
|
|
1167
|
+
function cdnBannerURL(resourceId, bannerHash, options) {
|
|
1168
|
+
if (!bannerHash) return null;
|
|
1169
|
+
const ext = getExtension(bannerHash, options);
|
|
1170
|
+
const size = appendSize(options, "banner");
|
|
1171
|
+
return `${mediaBase(options)}/banners/${resourceId}/${bannerHash}.${ext}${size}`;
|
|
1172
|
+
}
|
|
1173
|
+
function cdnMemberAvatarURL(guildId, userId, avatarHash, options) {
|
|
1174
|
+
if (!avatarHash) return null;
|
|
1175
|
+
const ext = getExtension(avatarHash, options);
|
|
1176
|
+
const size = appendSize(options, "icon");
|
|
1177
|
+
return `${mediaBase(options)}/guilds/${guildId}/users/${userId}/avatars/${avatarHash}.${ext}${size}`;
|
|
1178
|
+
}
|
|
1179
|
+
function cdnMemberBannerURL(guildId, userId, bannerHash, options) {
|
|
1180
|
+
if (!bannerHash) return null;
|
|
1181
|
+
const ext = getExtension(bannerHash, options);
|
|
1182
|
+
const size = appendSize(options, "banner");
|
|
1183
|
+
return `${mediaBase(options)}/guilds/${guildId}/users/${userId}/banners/${bannerHash}.${ext}${size}`;
|
|
1184
|
+
}
|
|
1185
|
+
function cdnDefaultAvatarURL(userIdOrIndex, options) {
|
|
1186
|
+
const index = typeof userIdOrIndex === "string" ? Number(BigInt(userIdOrIndex) % 6n) : Math.abs(Math.floor(userIdOrIndex) % 6);
|
|
1187
|
+
return `${staticBase(options)}/avatars/${index}.png`;
|
|
1188
|
+
}
|
|
1189
|
+
function cdnGuildAssetURL(kind, id, hash, options) {
|
|
1190
|
+
if (!hash) return null;
|
|
1191
|
+
const assetClass = kind === "icons" ? "icon" : "banner";
|
|
1192
|
+
const size = appendSize(options, assetClass);
|
|
1193
|
+
return `${mediaBase(options)}/${kind}/${id}/${hash}.png${size}`;
|
|
1194
|
+
}
|
|
1195
|
+
function cdnEmojiURL(emojiId, animated, options) {
|
|
1196
|
+
const ext = animated ? "gif" : "png";
|
|
1197
|
+
const size = appendSize(options, "emoji");
|
|
1198
|
+
return `${mediaBase(options)}/emojis/${emojiId}.${ext}${size}`;
|
|
1199
|
+
}
|
|
1200
|
+
function cdnStickerURL(stickerId, animated, options) {
|
|
1201
|
+
const ext = animated ? "gif" : "png";
|
|
1202
|
+
const size = appendSize(options, "sticker");
|
|
1203
|
+
return `${mediaBase(options)}/stickers/${stickerId}.${ext}${size}`;
|
|
1204
|
+
}
|
|
1205
|
+
|
|
1206
|
+
// src/Domain/Message/MessageSticker.ts
|
|
1207
|
+
var MessageSticker = class extends Base {
|
|
1208
|
+
client;
|
|
1209
|
+
id;
|
|
1210
|
+
name;
|
|
1211
|
+
description;
|
|
1212
|
+
tags;
|
|
1213
|
+
animated;
|
|
1214
|
+
constructor(client, data) {
|
|
1215
|
+
super();
|
|
1216
|
+
this.client = client;
|
|
1217
|
+
this.id = data.id;
|
|
1218
|
+
this.name = data.name;
|
|
1219
|
+
this.description = data.description ?? "";
|
|
1220
|
+
this.tags = data.tags ?? [];
|
|
1221
|
+
this.animated = data.animated ?? false;
|
|
1222
|
+
}
|
|
1223
|
+
/** CDN URL for this sticker image. */
|
|
1224
|
+
get url() {
|
|
1225
|
+
return cdnStickerURL(this.id, this.animated, {
|
|
1226
|
+
mediaBase: this.client.instance.endpoints.media
|
|
1227
|
+
});
|
|
1228
|
+
}
|
|
1229
|
+
/** Unix timestamp (ms) when this sticker was created, derived from its snowflake ID. */
|
|
1230
|
+
get createdTimestamp() {
|
|
1231
|
+
return SnowflakeUtil.timestampFromSnowflake(this.id);
|
|
1232
|
+
}
|
|
1233
|
+
/** Date when this sticker was created, derived from its snowflake ID. */
|
|
1234
|
+
get createdAt() {
|
|
1235
|
+
return SnowflakeUtil.dateFromSnowflake(this.id);
|
|
1236
|
+
}
|
|
1237
|
+
};
|
|
1238
|
+
|
|
1239
|
+
// src/Domain/Message/Reactions.ts
|
|
1240
|
+
import { Routes as Routes2 } from "@fluxerjs/types";
|
|
1241
|
+
async function emojiPath(message, emoji) {
|
|
1242
|
+
return message.client.resolveEmoji(emoji, message.guildId);
|
|
1243
|
+
}
|
|
1244
|
+
async function reactToMessage(message, emoji) {
|
|
1245
|
+
const wire = await emojiPath(message, emoji);
|
|
1246
|
+
await message.client.rest.put(
|
|
1247
|
+
Routes2.channelMessageReactionMe(message.channelId, message.id, wire)
|
|
1248
|
+
);
|
|
1249
|
+
}
|
|
1250
|
+
async function removeMessageReaction(message, emoji, userId) {
|
|
1251
|
+
const e = await emojiPath(message, emoji);
|
|
1252
|
+
const route = userId ? Routes2.channelMessageReactionUser(message.channelId, message.id, e, userId) : Routes2.channelMessageReactionMe(message.channelId, message.id, e);
|
|
1253
|
+
await message.client.rest.delete(route);
|
|
1254
|
+
}
|
|
1255
|
+
async function removeAllMessageReactions(message) {
|
|
1256
|
+
await message.client.rest.delete(Routes2.channelMessageReactions(message.channelId, message.id));
|
|
1257
|
+
}
|
|
1258
|
+
async function removeMessageReactionEmoji(message, emoji) {
|
|
1259
|
+
const e = await emojiPath(message, emoji);
|
|
1260
|
+
await message.client.rest.delete(Routes2.channelMessageReaction(message.channelId, message.id, e));
|
|
1261
|
+
}
|
|
1262
|
+
async function fetchMessageReactionUsers(message, emoji, options) {
|
|
1263
|
+
return (await fetchMessageReactionUsersPage(message, emoji, options)).users;
|
|
1264
|
+
}
|
|
1265
|
+
async function fetchMessageReactionUsersPage(message, emoji, options) {
|
|
1266
|
+
const e = await emojiPath(message, emoji);
|
|
1267
|
+
const params = new URLSearchParams();
|
|
1268
|
+
if (options?.limit != null) params.set("limit", String(options.limit));
|
|
1269
|
+
if (options?.after) params.set("after", options.after);
|
|
1270
|
+
const qs2 = params.toString();
|
|
1271
|
+
const route = Routes2.channelMessageReactionUsers(message.channelId, message.id, e) + (qs2 ? `?${qs2}` : "");
|
|
1272
|
+
const data = await message.client.rest.get(route);
|
|
1273
|
+
if (Array.isArray(data)) {
|
|
1274
|
+
return {
|
|
1275
|
+
users: data.map((u) => message.client.getOrCreateUser(u)),
|
|
1276
|
+
hasMore: false,
|
|
1277
|
+
nextAfter: null
|
|
1278
|
+
};
|
|
1279
|
+
}
|
|
1280
|
+
const list = data.items ?? data.users ?? [];
|
|
1281
|
+
return {
|
|
1282
|
+
users: list.map((u) => message.client.getOrCreateUser(u)),
|
|
1283
|
+
hasMore: data.has_more ?? false,
|
|
1284
|
+
nextAfter: data.next_after ?? null
|
|
1285
|
+
};
|
|
1286
|
+
}
|
|
1287
|
+
|
|
1288
|
+
// src/Domain/Message/Send.ts
|
|
1289
|
+
import { MessagePayload as MessagePayloadBuilder } from "@fluxerjs/builders";
|
|
1290
|
+
import { Routes as Routes3 } from "@fluxerjs/types";
|
|
1291
|
+
function toReplyTarget(ref) {
|
|
1292
|
+
return {
|
|
1293
|
+
channelId: ref.channel_id,
|
|
1294
|
+
messageId: ref.message_id,
|
|
1295
|
+
...ref.guild_id != null ? { guildId: ref.guild_id } : {}
|
|
1296
|
+
};
|
|
1297
|
+
}
|
|
1298
|
+
function toSendOptions(content) {
|
|
1299
|
+
if (typeof content === "string") return { content };
|
|
1300
|
+
if (content instanceof MessagePayloadBuilder) return messagePayloadToSendOptions(content);
|
|
1301
|
+
return { ...content };
|
|
1302
|
+
}
|
|
1303
|
+
async function createMessageBody(content, referenced_message, ping) {
|
|
1304
|
+
if (typeof content === "string" && content.length === 0) {
|
|
1305
|
+
throw new FluxerError("Cannot send an empty message", { code: ErrorCodes.EmptyMessage });
|
|
1306
|
+
}
|
|
1307
|
+
const opts = toSendOptions(content);
|
|
1308
|
+
if (referenced_message) {
|
|
1309
|
+
opts.replyTo = toReplyTarget(referenced_message);
|
|
1310
|
+
if (ping !== void 0) opts.ping = ping;
|
|
1311
|
+
}
|
|
1312
|
+
return prepareMessagePostPayload(opts);
|
|
1313
|
+
}
|
|
1314
|
+
function asReplyTarget(value) {
|
|
1315
|
+
if ("messageId" in value) return value;
|
|
1316
|
+
return {
|
|
1317
|
+
channelId: value.channelId,
|
|
1318
|
+
messageId: value.id,
|
|
1319
|
+
guildId: value.guildId
|
|
1320
|
+
};
|
|
1321
|
+
}
|
|
1322
|
+
async function sendPrepared(message, payload) {
|
|
1323
|
+
const data = await message.client.rest.post(
|
|
1324
|
+
Routes3.channelMessages(message.channelId),
|
|
989
1325
|
payload
|
|
990
1326
|
);
|
|
991
1327
|
message.client._addMessageToCache(message.channelId, data);
|
|
@@ -1015,7 +1351,33 @@ async function replyToMessage(message, options, replyOptions) {
|
|
|
1015
1351
|
}
|
|
1016
1352
|
|
|
1017
1353
|
// src/Domain/Message/Message.ts
|
|
1354
|
+
function toMessageCall(data) {
|
|
1355
|
+
return {
|
|
1356
|
+
participants: data.participants,
|
|
1357
|
+
endedAt: data.ended_timestamp ? new Date(data.ended_timestamp) : null
|
|
1358
|
+
};
|
|
1359
|
+
}
|
|
1360
|
+
function toMessageSnapshot(client, data) {
|
|
1361
|
+
return {
|
|
1362
|
+
content: data.content ?? null,
|
|
1363
|
+
createdAt: new Date(data.timestamp),
|
|
1364
|
+
editedAt: data.edited_timestamp ? new Date(data.edited_timestamp) : null,
|
|
1365
|
+
mentionUserIds: data.mentions ?? [],
|
|
1366
|
+
mentionRoles: data.mention_roles ?? [],
|
|
1367
|
+
embeds: (data.embeds ?? []).map(toMessageEmbed),
|
|
1368
|
+
attachments: (data.attachments ?? []).map(toMessageAttachment),
|
|
1369
|
+
stickers: (data.stickers ?? []).map((s) => new MessageSticker(client, s)),
|
|
1370
|
+
...data.type !== void 0 ? { type: data.type } : {}
|
|
1371
|
+
};
|
|
1372
|
+
}
|
|
1373
|
+
function resolveMessageFlags(flags) {
|
|
1374
|
+
if (flags === void 0) return void 0;
|
|
1375
|
+
if (typeof flags === "number") return flags;
|
|
1376
|
+
return Number(MessageFlagsBitField.resolve(flags));
|
|
1377
|
+
}
|
|
1018
1378
|
var Message = class _Message extends Base {
|
|
1379
|
+
/** Discriminant vs {@link PartialMessage}: always `false` on a hydrated Message. */
|
|
1380
|
+
partial = false;
|
|
1019
1381
|
/** The {@link Client} that instantiated this message. */
|
|
1020
1382
|
client;
|
|
1021
1383
|
/** Snowflake ID of this message. */
|
|
@@ -1044,7 +1406,7 @@ var Message = class _Message extends Base {
|
|
|
1044
1406
|
mentionEveryone;
|
|
1045
1407
|
/** Whether this is a text-to-speech message. */
|
|
1046
1408
|
tts;
|
|
1047
|
-
/** Embedded content (
|
|
1409
|
+
/** Embedded content (camelCase read view; send with {@link EmbedBuilder}). */
|
|
1048
1410
|
embeds;
|
|
1049
1411
|
/** Stickers sent with the message. */
|
|
1050
1412
|
stickers;
|
|
@@ -1066,26 +1428,43 @@ var Message = class _Message extends Base {
|
|
|
1066
1428
|
mentionRoles;
|
|
1067
1429
|
/** Client-side nonce for deduplication. */
|
|
1068
1430
|
nonce;
|
|
1069
|
-
/**
|
|
1431
|
+
/** IDs of custom emojis in the message classified as explicit. */
|
|
1432
|
+
nsfwEmojis;
|
|
1433
|
+
/**
|
|
1434
|
+
* Cached text-capable channel (guild text, guild voice, or DM), or null if uncached / not text-based.
|
|
1435
|
+
* Narrowed type has {@link Channel.send} and {@link Channel.delete}.
|
|
1436
|
+
*/
|
|
1070
1437
|
get channel() {
|
|
1071
|
-
|
|
1438
|
+
const channel = this.client.channels.get(this.channelId) ?? null;
|
|
1439
|
+
return channel?.isTextBased() ? channel : null;
|
|
1072
1440
|
}
|
|
1073
1441
|
/** Cached guild, or null for DMs / uncached. */
|
|
1074
1442
|
get guild() {
|
|
1075
1443
|
return this.guildId ? this.client.guilds.get(this.guildId) ?? null : null;
|
|
1076
1444
|
}
|
|
1077
|
-
/**
|
|
1445
|
+
/** Cached guild member for the author, or null in DMs / if uncached. */
|
|
1446
|
+
get member() {
|
|
1447
|
+
return this.guild?.members.get(this.author.id) ?? null;
|
|
1448
|
+
}
|
|
1449
|
+
/**
|
|
1450
|
+
* Fetch this message's channel (cache first). The returned {@link Channel}
|
|
1451
|
+
* has {@link Channel.delete} and {@link Channel.send}.
|
|
1452
|
+
* @example
|
|
1453
|
+
* const channel = await message.resolveChannel();
|
|
1454
|
+
* await channel.delete();
|
|
1455
|
+
*/
|
|
1078
1456
|
async resolveChannel() {
|
|
1079
1457
|
return this.client.channels.resolve(this.channelId);
|
|
1080
1458
|
}
|
|
1081
|
-
/**
|
|
1459
|
+
/**
|
|
1460
|
+
* Fetch and resolve the guild, or null if a DM.
|
|
1461
|
+
* Propagates network/auth errors; only returns null when there is no guildId.
|
|
1462
|
+
* @example
|
|
1463
|
+
* const guild = await message.resolveGuild();
|
|
1464
|
+
*/
|
|
1082
1465
|
async resolveGuild() {
|
|
1083
1466
|
if (!this.guildId) return null;
|
|
1084
|
-
|
|
1085
|
-
return await this.client.guilds.resolve(this.guildId);
|
|
1086
|
-
} catch {
|
|
1087
|
-
return null;
|
|
1088
|
-
}
|
|
1467
|
+
return this.client.guilds.resolve(this.guildId);
|
|
1089
1468
|
}
|
|
1090
1469
|
/**
|
|
1091
1470
|
* Construct a message from API data.
|
|
@@ -1102,29 +1481,75 @@ var Message = class _Message extends Base {
|
|
|
1102
1481
|
this.createdAt = new Date(data.timestamp);
|
|
1103
1482
|
this.editedAt = data.edited_timestamp ? new Date(data.edited_timestamp) : null;
|
|
1104
1483
|
this.pinned = data.pinned;
|
|
1105
|
-
this.attachments = new
|
|
1106
|
-
for (const a of data.attachments ?? []) this.attachments.set(a.id, a);
|
|
1484
|
+
this.attachments = new Collection3();
|
|
1485
|
+
for (const a of data.attachments ?? []) this.attachments.set(a.id, toMessageAttachment(a));
|
|
1107
1486
|
this.type = data.type ?? MessageType.Default;
|
|
1108
|
-
this.flags = data.flags ?? 0;
|
|
1487
|
+
this.flags = new MessageFlagsBitField(BigInt(data.flags ?? 0));
|
|
1109
1488
|
this.mentionEveryone = data.mention_everyone ?? false;
|
|
1110
1489
|
this.tts = data.tts ?? false;
|
|
1111
|
-
this.embeds = data.embeds ?? [];
|
|
1112
|
-
this.stickers = data.stickers ?? [];
|
|
1113
|
-
this.reactions =
|
|
1114
|
-
this.
|
|
1115
|
-
this.
|
|
1116
|
-
|
|
1490
|
+
this.embeds = (data.embeds ?? []).map(toMessageEmbed);
|
|
1491
|
+
this.stickers = (data.stickers ?? []).map((s) => new MessageSticker(client, s));
|
|
1492
|
+
this.reactions = new MessageReactionManager(this);
|
|
1493
|
+
this.reactions._patch(data.reactions);
|
|
1494
|
+
this.messageReference = data.message_reference ? {
|
|
1495
|
+
channelId: data.message_reference.channel_id,
|
|
1496
|
+
messageId: data.message_reference.message_id,
|
|
1497
|
+
guildId: data.message_reference.guild_id ?? null,
|
|
1498
|
+
...data.message_reference.type !== void 0 ? { type: data.message_reference.type } : {}
|
|
1499
|
+
} : null;
|
|
1500
|
+
this.messageSnapshots = (data.message_snapshots ?? []).map((s) => toMessageSnapshot(client, s));
|
|
1501
|
+
this.call = data.call ? toMessageCall(data.call) : null;
|
|
1117
1502
|
this.referencedMessage = data.referenced_message ? new _Message(client, data.referenced_message) : null;
|
|
1118
1503
|
this.webhookId = data.webhook_id ?? null;
|
|
1119
1504
|
this.mentions = (data.mentions ?? []).map((u) => client.getOrCreateUser(u));
|
|
1120
1505
|
this.mentionRoles = data.mention_roles ?? [];
|
|
1121
1506
|
this.nonce = data.nonce ?? null;
|
|
1507
|
+
this.nsfwEmojis = data.nsfw_emojis ?? [];
|
|
1508
|
+
}
|
|
1509
|
+
/**
|
|
1510
|
+
* Apply an API message payload in place (cache identity / MESSAGE_UPDATE).
|
|
1511
|
+
* @internal
|
|
1512
|
+
*/
|
|
1513
|
+
_patch(data) {
|
|
1514
|
+
this.content = data.content;
|
|
1515
|
+
this.editedAt = data.edited_timestamp ? new Date(data.edited_timestamp) : null;
|
|
1516
|
+
this.pinned = data.pinned;
|
|
1517
|
+
this.attachments.clear();
|
|
1518
|
+
for (const a of data.attachments ?? []) this.attachments.set(a.id, toMessageAttachment(a));
|
|
1519
|
+
this.flags = new MessageFlagsBitField(BigInt(data.flags ?? 0));
|
|
1520
|
+
this.mentionEveryone = data.mention_everyone ?? false;
|
|
1521
|
+
this.tts = data.tts ?? false;
|
|
1522
|
+
this.embeds = (data.embeds ?? []).map(toMessageEmbed);
|
|
1523
|
+
this.stickers = (data.stickers ?? []).map((s) => new MessageSticker(this.client, s));
|
|
1524
|
+
this.reactions._patch(data.reactions);
|
|
1525
|
+
this.messageReference = data.message_reference ? {
|
|
1526
|
+
channelId: data.message_reference.channel_id,
|
|
1527
|
+
messageId: data.message_reference.message_id,
|
|
1528
|
+
guildId: data.message_reference.guild_id ?? null,
|
|
1529
|
+
...data.message_reference.type !== void 0 ? { type: data.message_reference.type } : {}
|
|
1530
|
+
} : null;
|
|
1531
|
+
this.messageSnapshots = (data.message_snapshots ?? []).map(
|
|
1532
|
+
(s) => toMessageSnapshot(this.client, s)
|
|
1533
|
+
);
|
|
1534
|
+
this.call = data.call ? toMessageCall(data.call) : null;
|
|
1535
|
+
this.referencedMessage = data.referenced_message ? new _Message(this.client, data.referenced_message) : null;
|
|
1536
|
+
this.webhookId = data.webhook_id ?? null;
|
|
1537
|
+
this.mentions = (data.mentions ?? []).map((u) => this.client.getOrCreateUser(u));
|
|
1538
|
+
this.mentionRoles = data.mention_roles ?? [];
|
|
1539
|
+
this.nonce = data.nonce ?? null;
|
|
1540
|
+
this.nsfwEmojis = data.nsfw_emojis ?? [];
|
|
1122
1541
|
}
|
|
1123
|
-
/**
|
|
1542
|
+
/**
|
|
1543
|
+
* Send a standalone message in this channel (not a reply).
|
|
1544
|
+
* Prefer {@link Channel.send} or {@link reply} when you already have the channel or are answering.
|
|
1545
|
+
*/
|
|
1124
1546
|
async send(options) {
|
|
1125
1547
|
return sendMessage(this, options);
|
|
1126
1548
|
}
|
|
1127
|
-
/**
|
|
1549
|
+
/**
|
|
1550
|
+
* Send a message to another channel by ID.
|
|
1551
|
+
* Prefer `client.channels.fetch(channelId)` then {@link Channel.send}.
|
|
1552
|
+
*/
|
|
1128
1553
|
async sendTo(channelId, options) {
|
|
1129
1554
|
return sendMessageTo(this, channelId, options);
|
|
1130
1555
|
}
|
|
@@ -1138,6 +1563,16 @@ var Message = class _Message extends Base {
|
|
|
1138
1563
|
async reply(options, replyOptions) {
|
|
1139
1564
|
return replyToMessage(this, options, replyOptions);
|
|
1140
1565
|
}
|
|
1566
|
+
/**
|
|
1567
|
+
* Hydrate a partial message, or return the message as-is.
|
|
1568
|
+
* @example
|
|
1569
|
+
* client.on(Events.MessageUpdate, async (_old, msg) => {
|
|
1570
|
+
* const message = await Message.resolve(msg);
|
|
1571
|
+
* });
|
|
1572
|
+
*/
|
|
1573
|
+
static async resolve(message) {
|
|
1574
|
+
return message.partial ? message.fetch() : message;
|
|
1575
|
+
}
|
|
1141
1576
|
/** Test helper — prefer {@link reply} / `prepareMessagePostPayload()`. */
|
|
1142
1577
|
static async _createMessageBody(content, referenced_message, ping) {
|
|
1143
1578
|
return createMessageBody(content, referenced_message, ping);
|
|
@@ -1150,7 +1585,7 @@ var Message = class _Message extends Base {
|
|
|
1150
1585
|
async edit(options) {
|
|
1151
1586
|
const body = {};
|
|
1152
1587
|
if (options.content !== void 0) body.content = options.content;
|
|
1153
|
-
if (options.embeds
|
|
1588
|
+
if (options.embeds !== void 0) {
|
|
1154
1589
|
body.embeds = options.embeds.map(
|
|
1155
1590
|
(e) => e instanceof EmbedBuilder2 ? e.toJSON() : e
|
|
1156
1591
|
);
|
|
@@ -1158,7 +1593,8 @@ var Message = class _Message extends Base {
|
|
|
1158
1593
|
if (options.allowedMentions) {
|
|
1159
1594
|
body.allowed_mentions = toAPIAllowedMentions(options.allowedMentions);
|
|
1160
1595
|
}
|
|
1161
|
-
|
|
1596
|
+
const flags = resolveMessageFlags(options.flags);
|
|
1597
|
+
if (flags !== void 0) body.flags = flags;
|
|
1162
1598
|
if (options.attachments !== void 0) {
|
|
1163
1599
|
body.attachments = toMessageAttachmentEditWire(options.attachments);
|
|
1164
1600
|
}
|
|
@@ -1173,13 +1609,22 @@ var Message = class _Message extends Base {
|
|
|
1173
1609
|
createReactionCollector(options) {
|
|
1174
1610
|
return new ReactionCollector(this.client, this.id, this.channelId, options);
|
|
1175
1611
|
}
|
|
1612
|
+
/**
|
|
1613
|
+
* Wait for reactions matching the filter, then resolve the collected set.
|
|
1614
|
+
* Pass `errors: ['time']` to reject when the timer fires instead of resolving.
|
|
1615
|
+
*/
|
|
1616
|
+
awaitReactions(options) {
|
|
1617
|
+
return ReactionCollector.awaitReactions(this.client, this.id, this.channelId, options);
|
|
1618
|
+
}
|
|
1176
1619
|
/** Fetch the latest version of this message from the API. */
|
|
1177
1620
|
async fetch() {
|
|
1178
1621
|
return this.client.channels.fetchMessage(this.channelId, this.id);
|
|
1179
1622
|
}
|
|
1180
1623
|
/** Delete this message. */
|
|
1181
|
-
async delete() {
|
|
1182
|
-
await this.client.rest.delete(Routes4.channelMessage(this.channelId, this.id)
|
|
1624
|
+
async delete(reason) {
|
|
1625
|
+
await this.client.rest.delete(Routes4.channelMessage(this.channelId, this.id), {
|
|
1626
|
+
...auditReasonHeaders(reason)
|
|
1627
|
+
});
|
|
1183
1628
|
this.client._removeMessageFromCache(this.channelId, this.id);
|
|
1184
1629
|
}
|
|
1185
1630
|
/** Delete a specific attachment from this message. */
|
|
@@ -1226,7 +1671,68 @@ var Message = class _Message extends Base {
|
|
|
1226
1671
|
}
|
|
1227
1672
|
};
|
|
1228
1673
|
|
|
1674
|
+
// src/Domain/Message/PartialMessage.ts
|
|
1675
|
+
import { SnowflakeUtil as SnowflakeUtil2 } from "@fluxerjs/util";
|
|
1676
|
+
var PartialMessage = class {
|
|
1677
|
+
partial = true;
|
|
1678
|
+
client;
|
|
1679
|
+
id;
|
|
1680
|
+
channelId;
|
|
1681
|
+
guildId;
|
|
1682
|
+
content;
|
|
1683
|
+
authorId;
|
|
1684
|
+
author;
|
|
1685
|
+
createdAt;
|
|
1686
|
+
constructor(client, data) {
|
|
1687
|
+
this.client = client;
|
|
1688
|
+
this.id = data.id;
|
|
1689
|
+
this.channelId = data.channelId;
|
|
1690
|
+
this.guildId = data.guildId ?? null;
|
|
1691
|
+
this.content = data.content ?? null;
|
|
1692
|
+
this.authorId = data.authorId ?? null;
|
|
1693
|
+
this.author = data.author ?? null;
|
|
1694
|
+
this.createdAt = data.createdAt ?? (SnowflakeUtil2.isValid(data.id) ? SnowflakeUtil2.dateFromSnowflake(data.id) : null);
|
|
1695
|
+
}
|
|
1696
|
+
/**
|
|
1697
|
+
* Live text-capable channel from cache, or null if uncached / not text-based.
|
|
1698
|
+
* Same contract as {@link Message.channel}.
|
|
1699
|
+
*/
|
|
1700
|
+
get channel() {
|
|
1701
|
+
const channel = this.client.channels.get(this.channelId) ?? null;
|
|
1702
|
+
return channel?.isTextBased() ? channel : null;
|
|
1703
|
+
}
|
|
1704
|
+
/**
|
|
1705
|
+
* Fetch this message's channel (cache first). The returned {@link Channel}
|
|
1706
|
+
* has {@link Channel.delete} and {@link Channel.send}.
|
|
1707
|
+
* @example
|
|
1708
|
+
* const channel = await message.resolveChannel();
|
|
1709
|
+
* await channel.delete();
|
|
1710
|
+
*/
|
|
1711
|
+
async resolveChannel() {
|
|
1712
|
+
return this.client.channels.resolve(this.channelId);
|
|
1713
|
+
}
|
|
1714
|
+
/**
|
|
1715
|
+
* Fetch the full message from the API.
|
|
1716
|
+
* @example
|
|
1717
|
+
* const message = await partial.fetch();
|
|
1718
|
+
* await message.reply('Pong!');
|
|
1719
|
+
*/
|
|
1720
|
+
async fetch() {
|
|
1721
|
+
return this.client.channels.fetchMessage(this.channelId, this.id);
|
|
1722
|
+
}
|
|
1723
|
+
};
|
|
1724
|
+
|
|
1725
|
+
// src/Domain/User.ts
|
|
1726
|
+
import { Routes as Routes14 } from "@fluxerjs/types";
|
|
1727
|
+
import { SnowflakeUtil as SnowflakeUtil5 } from "@fluxerjs/util";
|
|
1728
|
+
|
|
1729
|
+
// src/Domain/Channel/Base.ts
|
|
1730
|
+
import { ChannelType, Routes as Routes7 } from "@fluxerjs/types";
|
|
1731
|
+
import { SnowflakeUtil as SnowflakeUtil3 } from "@fluxerjs/util";
|
|
1732
|
+
|
|
1229
1733
|
// src/ClientCore/MessageManager.ts
|
|
1734
|
+
import { Collection as Collection4 } from "@fluxerjs/collection";
|
|
1735
|
+
import { Routes as Routes5 } from "@fluxerjs/types";
|
|
1230
1736
|
var BULK = {
|
|
1231
1737
|
requests: { min: 1, max: 25 },
|
|
1232
1738
|
limit: { min: 1, max: 25 },
|
|
@@ -1260,19 +1766,40 @@ var MessageManager = class {
|
|
|
1260
1766
|
this.client = client;
|
|
1261
1767
|
this.channelId = channelId;
|
|
1262
1768
|
}
|
|
1769
|
+
/** Structure cache keyed by message id (identity for {@link get}). */
|
|
1770
|
+
_structures = new Collection4();
|
|
1263
1771
|
/** Retrieve a cached message by ID, or `undefined` if missing / caching disabled. */
|
|
1264
1772
|
get(messageId) {
|
|
1265
1773
|
const data = this.client._getMessageCache(this.channelId)?.get(messageId);
|
|
1266
|
-
|
|
1774
|
+
if (!data) {
|
|
1775
|
+
this._structures.delete(messageId);
|
|
1776
|
+
return void 0;
|
|
1777
|
+
}
|
|
1778
|
+
const existing = this._structures.get(messageId);
|
|
1779
|
+
if (existing) return existing;
|
|
1780
|
+
const message = new Message(this.client, data);
|
|
1781
|
+
this._structures.set(messageId, message);
|
|
1782
|
+
return message;
|
|
1783
|
+
}
|
|
1784
|
+
/** Retrieve from cache, otherwise {@link fetch}. */
|
|
1785
|
+
async resolve(messageId) {
|
|
1786
|
+
return this.get(messageId) ?? this.fetch(messageId);
|
|
1267
1787
|
}
|
|
1268
1788
|
async fetch(idOrOptions) {
|
|
1269
1789
|
return typeof idOrOptions === "string" ? this.fetchOne(idOrOptions) : this.fetchMany(idOrOptions);
|
|
1270
1790
|
}
|
|
1271
|
-
/** Cache API data and return a {@link Message}
|
|
1791
|
+
/** Cache API data and return a {@link Message} (reusing identity when present). */
|
|
1272
1792
|
wrap(data) {
|
|
1273
1793
|
this.client._addMessageToCache(this.channelId, data);
|
|
1274
1794
|
const cached = this.client._getMessageCache(this.channelId)?.get(data.id) ?? data;
|
|
1275
|
-
|
|
1795
|
+
const existing = this._structures.get(data.id);
|
|
1796
|
+
if (existing) {
|
|
1797
|
+
existing._patch(cached);
|
|
1798
|
+
return existing;
|
|
1799
|
+
}
|
|
1800
|
+
const message = new Message(this.client, cached);
|
|
1801
|
+
this._structures.set(data.id, message);
|
|
1802
|
+
return message;
|
|
1276
1803
|
}
|
|
1277
1804
|
/** Fetch a single message from the API. */
|
|
1278
1805
|
async fetchOne(messageId) {
|
|
@@ -1305,14 +1832,135 @@ var MessageManager = class {
|
|
|
1305
1832
|
}
|
|
1306
1833
|
const base = Routes5.channelMessages(this.channelId);
|
|
1307
1834
|
const data = await this.client.rest.get(qs2.size > 0 ? `${base}?${qs2}` : base);
|
|
1308
|
-
const collection = new
|
|
1835
|
+
const collection = new Collection4();
|
|
1309
1836
|
for (const msg of data) collection.set(msg.id, this.wrap(msg));
|
|
1310
1837
|
return collection;
|
|
1311
1838
|
}
|
|
1312
1839
|
};
|
|
1313
1840
|
|
|
1841
|
+
// src/Helpers/MessageCollector.ts
|
|
1842
|
+
import { EventEmitter as EventEmitter2 } from "events";
|
|
1843
|
+
import { Collection as Collection5 } from "@fluxerjs/collection";
|
|
1844
|
+
function requireCollectorBounds(options) {
|
|
1845
|
+
const time = options.time ?? 0;
|
|
1846
|
+
const max = options.max ?? 0;
|
|
1847
|
+
if (time <= 0 && max <= 0) {
|
|
1848
|
+
throw new FluxerError("MessageCollector requires `time` and/or `max`", {
|
|
1849
|
+
code: ErrorCodes.CollectorOptionsRequired
|
|
1850
|
+
});
|
|
1851
|
+
}
|
|
1852
|
+
}
|
|
1853
|
+
var MessageCollector = class _MessageCollector extends EventEmitter2 {
|
|
1854
|
+
client;
|
|
1855
|
+
channelId;
|
|
1856
|
+
options;
|
|
1857
|
+
collected = new Collection5();
|
|
1858
|
+
_timeout = null;
|
|
1859
|
+
_ended = false;
|
|
1860
|
+
_listener;
|
|
1861
|
+
constructor(client, channelId, options = {}) {
|
|
1862
|
+
super();
|
|
1863
|
+
requireCollectorBounds(options);
|
|
1864
|
+
this.client = client;
|
|
1865
|
+
this.channelId = channelId;
|
|
1866
|
+
this.options = {
|
|
1867
|
+
filter: options.filter ?? (() => true),
|
|
1868
|
+
time: options.time ?? 0,
|
|
1869
|
+
max: options.max ?? 0
|
|
1870
|
+
};
|
|
1871
|
+
this._listener = (message) => {
|
|
1872
|
+
if (this._ended || message.channelId !== this.channelId) return;
|
|
1873
|
+
if (!this.options.filter(message)) return;
|
|
1874
|
+
this.collected.set(message.id, message);
|
|
1875
|
+
this.emit("collect", message);
|
|
1876
|
+
if (this.options.max > 0 && this.collected.size >= this.options.max) {
|
|
1877
|
+
this.stop("limit");
|
|
1878
|
+
}
|
|
1879
|
+
};
|
|
1880
|
+
this.client.on(Events.MessageCreate, this._listener);
|
|
1881
|
+
if (this.options.time > 0) {
|
|
1882
|
+
this._timeout = setTimeout(() => this.stop("time"), this.options.time);
|
|
1883
|
+
}
|
|
1884
|
+
}
|
|
1885
|
+
stop(reason = "user") {
|
|
1886
|
+
if (this._ended) return;
|
|
1887
|
+
this._ended = true;
|
|
1888
|
+
this.client.off(Events.MessageCreate, this._listener);
|
|
1889
|
+
if (this._timeout) {
|
|
1890
|
+
clearTimeout(this._timeout);
|
|
1891
|
+
this._timeout = null;
|
|
1892
|
+
}
|
|
1893
|
+
this.emit("end", this.collected, reason);
|
|
1894
|
+
}
|
|
1895
|
+
/**
|
|
1896
|
+
* One-shot helper used by {@link Channel.awaitMessages}.
|
|
1897
|
+
* Resolves with the collected messages when the collector ends for `user` (or when
|
|
1898
|
+
* the end reason is not listed in `errors`).
|
|
1899
|
+
* By default, `time` and `limit` reject with {@link FluxerError}
|
|
1900
|
+
* (`CollectorIdle` / `CollectorMax`).
|
|
1901
|
+
*/
|
|
1902
|
+
static awaitMessages(client, channelId, options) {
|
|
1903
|
+
const errors = options?.errors ?? ["time", "limit"];
|
|
1904
|
+
return new Promise((resolve, reject) => {
|
|
1905
|
+
const collector = new _MessageCollector(client, channelId, options);
|
|
1906
|
+
collector.on("end", (collected, reason) => {
|
|
1907
|
+
if (!errors.includes(reason)) {
|
|
1908
|
+
resolve(collected);
|
|
1909
|
+
return;
|
|
1910
|
+
}
|
|
1911
|
+
if (reason === "time") {
|
|
1912
|
+
reject(
|
|
1913
|
+
new FluxerError("Message collector timed out", {
|
|
1914
|
+
code: ErrorCodes.CollectorIdle
|
|
1915
|
+
})
|
|
1916
|
+
);
|
|
1917
|
+
return;
|
|
1918
|
+
}
|
|
1919
|
+
if (reason === "limit") {
|
|
1920
|
+
reject(
|
|
1921
|
+
new FluxerError("Message collector reached max", {
|
|
1922
|
+
code: ErrorCodes.CollectorMax
|
|
1923
|
+
})
|
|
1924
|
+
);
|
|
1925
|
+
return;
|
|
1926
|
+
}
|
|
1927
|
+
reject(collected);
|
|
1928
|
+
});
|
|
1929
|
+
});
|
|
1930
|
+
}
|
|
1931
|
+
on(event, listener) {
|
|
1932
|
+
return super.on(event, listener);
|
|
1933
|
+
}
|
|
1934
|
+
emit(event, ...args) {
|
|
1935
|
+
return super.emit(event, ...args);
|
|
1936
|
+
}
|
|
1937
|
+
};
|
|
1938
|
+
|
|
1314
1939
|
// src/Domain/Channel/Attachments.ts
|
|
1315
1940
|
import { Routes as Routes6 } from "@fluxerjs/types";
|
|
1941
|
+
var BOT_ATTACHMENT_MAX_BYTES = 50 * 1024 * 1024;
|
|
1942
|
+
var ATTACHMENT_MULTIPART_THRESHOLD_BYTES = 10 * 1024 * 1024;
|
|
1943
|
+
function instanceLimitOverridesSnapshot(client) {
|
|
1944
|
+
const rules = client.instance.discovery?.limits?.rules;
|
|
1945
|
+
if (!rules?.length) return null;
|
|
1946
|
+
const snapshot = {};
|
|
1947
|
+
for (const rule of rules) {
|
|
1948
|
+
Object.assign(snapshot, rule.overrides);
|
|
1949
|
+
}
|
|
1950
|
+
return Object.keys(snapshot).length ? snapshot : null;
|
|
1951
|
+
}
|
|
1952
|
+
function assertBotAttachmentLimits(client, files) {
|
|
1953
|
+
const snapshot = instanceLimitOverridesSnapshot(client);
|
|
1954
|
+
for (const file of files) {
|
|
1955
|
+
const size = file.data.byteLength;
|
|
1956
|
+
if (size <= BOT_ATTACHMENT_MAX_BYTES) continue;
|
|
1957
|
+
const snapshotNote = snapshot ? ` Instance limit overrides: ${JSON.stringify(snapshot)}.` : "";
|
|
1958
|
+
throw new FluxerError(
|
|
1959
|
+
`Bot attachments are limited to 50 MiB (${BOT_ATTACHMENT_MAX_BYTES} bytes); "${file.filename}" is ${size} bytes.${snapshotNote}`,
|
|
1960
|
+
{ code: ErrorCodes.AttachmentTooLarge }
|
|
1961
|
+
);
|
|
1962
|
+
}
|
|
1963
|
+
}
|
|
1316
1964
|
function asBytes(data) {
|
|
1317
1965
|
const src = data instanceof ArrayBuffer ? new Uint8Array(data) : new Uint8Array(data);
|
|
1318
1966
|
const out = new Uint8Array(src.byteLength);
|
|
@@ -1332,6 +1980,7 @@ async function putBlob(url, body, contentType) {
|
|
|
1332
1980
|
}
|
|
1333
1981
|
}
|
|
1334
1982
|
async function uploadAttachmentsForSend(client, channelId, files) {
|
|
1983
|
+
assertBotAttachmentLimits(client, files);
|
|
1335
1984
|
const plan = await client.rest.post(
|
|
1336
1985
|
Routes6.channelAttachments(channelId),
|
|
1337
1986
|
{
|
|
@@ -1389,6 +2038,7 @@ async function uploadAttachmentsForSend(client, channelId, files) {
|
|
|
1389
2038
|
|
|
1390
2039
|
// src/Domain/Channel/Base.ts
|
|
1391
2040
|
var Channel = class extends Base {
|
|
2041
|
+
#messages;
|
|
1392
2042
|
/** The {@link Client} that instantiated this channel. */
|
|
1393
2043
|
client;
|
|
1394
2044
|
/** Snowflake ID of this channel. */
|
|
@@ -1412,11 +2062,11 @@ var Channel = class extends Base {
|
|
|
1412
2062
|
}
|
|
1413
2063
|
/** Unix timestamp (ms) when this channel was created, derived from its snowflake ID. */
|
|
1414
2064
|
get createdTimestamp() {
|
|
1415
|
-
return
|
|
2065
|
+
return SnowflakeUtil3.timestampFromSnowflake(this.id);
|
|
1416
2066
|
}
|
|
1417
2067
|
/** Date when this channel was created, derived from its snowflake ID. */
|
|
1418
2068
|
get createdAt() {
|
|
1419
|
-
return
|
|
2069
|
+
return SnowflakeUtil3.dateFromSnowflake(this.id);
|
|
1420
2070
|
}
|
|
1421
2071
|
/**
|
|
1422
2072
|
* Apply shared channel fields in place (gateway CHANNEL_UPDATE when type is unchanged).
|
|
@@ -1430,19 +2080,36 @@ var Channel = class extends Base {
|
|
|
1430
2080
|
this.lastPinTimestamp = data.last_pin_timestamp ?? null;
|
|
1431
2081
|
}
|
|
1432
2082
|
}
|
|
1433
|
-
/**
|
|
2083
|
+
/** @internal Factory wired after subclasses load. */
|
|
1434
2084
|
static from(_c, _d) {
|
|
1435
2085
|
throw new Error("Channel.from not initialized");
|
|
1436
2086
|
}
|
|
2087
|
+
/** @internal Factory wired after subclasses load. */
|
|
1437
2088
|
static fromOrCreate(_c, _d) {
|
|
1438
2089
|
throw new Error("Channel.fromOrCreate not initialized");
|
|
1439
2090
|
}
|
|
2091
|
+
/** @internal Factory wired after subclasses load. */
|
|
1440
2092
|
static createDM(_c, _d) {
|
|
1441
2093
|
throw new Error("Channel.createDM not initialized");
|
|
1442
2094
|
}
|
|
1443
|
-
/**
|
|
2095
|
+
/**
|
|
2096
|
+
* Whether this channel type can carry messages (text, voice, DM, group DM, notes).
|
|
2097
|
+
* Checks {@link ChannelType}, not whether `send` exists on the instance.
|
|
2098
|
+
*/
|
|
1444
2099
|
isTextBased() {
|
|
1445
|
-
return
|
|
2100
|
+
return this.type === ChannelType.GuildText || this.type === ChannelType.GuildVoice || this.type === ChannelType.DM || this.type === ChannelType.GroupDM || this.type === ChannelType.DMPersonalNotes;
|
|
2101
|
+
}
|
|
2102
|
+
/** Check if this is a guild channel (text, voice, category, or link). */
|
|
2103
|
+
isGuild() {
|
|
2104
|
+
return this.type === ChannelType.GuildText || this.type === ChannelType.GuildVoice || this.type === ChannelType.GuildCategory || this.type === ChannelType.GuildLink;
|
|
2105
|
+
}
|
|
2106
|
+
/** Check if this is a guild text channel. */
|
|
2107
|
+
isText() {
|
|
2108
|
+
return this.type === ChannelType.GuildText;
|
|
2109
|
+
}
|
|
2110
|
+
/** Check if this is a category channel. */
|
|
2111
|
+
isCategory() {
|
|
2112
|
+
return this.type === ChannelType.GuildCategory;
|
|
1446
2113
|
}
|
|
1447
2114
|
/** Check if this is a DM, group DM, or personal notes channel. */
|
|
1448
2115
|
isDM() {
|
|
@@ -1454,11 +2121,11 @@ var Channel = class extends Base {
|
|
|
1454
2121
|
}
|
|
1455
2122
|
/** Check if this is a voice channel. */
|
|
1456
2123
|
isVoice() {
|
|
1457
|
-
return
|
|
2124
|
+
return this.type === ChannelType.GuildVoice;
|
|
1458
2125
|
}
|
|
1459
2126
|
/** Check if this is a link channel. */
|
|
1460
2127
|
isLink() {
|
|
1461
|
-
return
|
|
2128
|
+
return this.type === ChannelType.GuildLink;
|
|
1462
2129
|
}
|
|
1463
2130
|
/**
|
|
1464
2131
|
* Delete recent messages or an explicit ID list.
|
|
@@ -1497,7 +2164,7 @@ var Channel = class extends Base {
|
|
|
1497
2164
|
for (const id of ids) this.client._removeMessageFromCache(this.id, id);
|
|
1498
2165
|
return ids;
|
|
1499
2166
|
}
|
|
1500
|
-
/** Delete all messages sent by the bot in this channel
|
|
2167
|
+
/** Delete all messages sent by the bot in this channel. Sudo auto-passes for bots. */
|
|
1501
2168
|
async bulkDeleteMyMessages(options) {
|
|
1502
2169
|
const body = options ? toSudoBody(options) : void 0;
|
|
1503
2170
|
await this.client.rest.post(Routes7.channelBulkDeleteMine(this.id), {
|
|
@@ -1505,11 +2172,17 @@ var Channel = class extends Base {
|
|
|
1505
2172
|
auth: true
|
|
1506
2173
|
});
|
|
1507
2174
|
}
|
|
1508
|
-
/**
|
|
2175
|
+
/**
|
|
2176
|
+
* Mark all pinned messages as read in this channel.
|
|
2177
|
+
* Session-token helper; bots usually skip this.
|
|
2178
|
+
*/
|
|
1509
2179
|
async acknowledgePins() {
|
|
1510
2180
|
await this.client.rest.post(Routes7.channelPinsAck(this.id), { auth: true });
|
|
1511
2181
|
}
|
|
1512
|
-
/**
|
|
2182
|
+
/**
|
|
2183
|
+
* Clear the read state for this channel.
|
|
2184
|
+
* Session-token helper; bots usually skip this.
|
|
2185
|
+
*/
|
|
1513
2186
|
async clearReadState() {
|
|
1514
2187
|
await this.client.rest.delete(Routes7.channelMessagesAck(this.id), { auth: true });
|
|
1515
2188
|
}
|
|
@@ -1545,7 +2218,11 @@ var Channel = class extends Base {
|
|
|
1545
2218
|
async sendTyping() {
|
|
1546
2219
|
await this.client.rest.post(Routes7.channelTyping(this.id), { auth: true });
|
|
1547
2220
|
}
|
|
1548
|
-
/**
|
|
2221
|
+
/**
|
|
2222
|
+
* Fetch available RTC regions for voice channels.
|
|
2223
|
+
* User-account only (`DefaultUserOnly`); bots receive `AccessDeniedError`.
|
|
2224
|
+
* Bots should skip this and join voice with `@fluxerjs/voice` instead.
|
|
2225
|
+
*/
|
|
1549
2226
|
async fetchRtcRegions() {
|
|
1550
2227
|
const data = await this.client.rest.get(Routes7.channelRtcRegions(this.id), {
|
|
1551
2228
|
auth: true
|
|
@@ -1556,79 +2233,74 @@ var Channel = class extends Base {
|
|
|
1556
2233
|
async fetchSlowmode() {
|
|
1557
2234
|
const data = await this.client.rest.get(
|
|
1558
2235
|
Routes7.channelSlowmode(this.id),
|
|
1559
|
-
{ auth: true }
|
|
1560
|
-
);
|
|
1561
|
-
return {
|
|
1562
|
-
rateLimitPerUser: data.rate_limit_per_user,
|
|
1563
|
-
retryAfterMs: data.retry_after_ms,
|
|
1564
|
-
nextSendAllowedAt: data.next_send_allowed_at
|
|
1565
|
-
};
|
|
1566
|
-
}
|
|
1567
|
-
/** Check if the bot can send messages in this channel. */
|
|
1568
|
-
canSendMessage() {
|
|
1569
|
-
return this.isDM();
|
|
1570
|
-
}
|
|
1571
|
-
};
|
|
1572
|
-
|
|
1573
|
-
// src/Domain/Channel/Dm.ts
|
|
1574
|
-
import { ChannelType as ChannelType2, Routes as Routes9 } from "@fluxerjs/types";
|
|
1575
|
-
|
|
1576
|
-
// src/Domain/Channel/TextCapable.ts
|
|
1577
|
-
import { Routes as Routes8 } from "@fluxerjs/types";
|
|
1578
|
-
|
|
1579
|
-
// src/Helpers/MessageCollector.ts
|
|
1580
|
-
import { EventEmitter as EventEmitter2 } from "events";
|
|
1581
|
-
import { Collection as Collection4 } from "@fluxerjs/collection";
|
|
1582
|
-
var MessageCollector = class extends EventEmitter2 {
|
|
1583
|
-
client;
|
|
1584
|
-
channelId;
|
|
1585
|
-
options;
|
|
1586
|
-
collected = new Collection4();
|
|
1587
|
-
_timeout = null;
|
|
1588
|
-
_ended = false;
|
|
1589
|
-
_listener;
|
|
1590
|
-
constructor(client, channelId, options = {}) {
|
|
1591
|
-
super();
|
|
1592
|
-
this.client = client;
|
|
1593
|
-
this.channelId = channelId;
|
|
1594
|
-
this.options = {
|
|
1595
|
-
filter: options.filter ?? (() => true),
|
|
1596
|
-
time: options.time ?? 0,
|
|
1597
|
-
max: options.max ?? 0
|
|
1598
|
-
};
|
|
1599
|
-
this._listener = (message) => {
|
|
1600
|
-
if (this._ended || message.channelId !== this.channelId) return;
|
|
1601
|
-
if (!this.options.filter(message)) return;
|
|
1602
|
-
this.collected.set(message.id, message);
|
|
1603
|
-
this.emit("collect", message);
|
|
1604
|
-
if (this.options.max > 0 && this.collected.size >= this.options.max) {
|
|
1605
|
-
this.stop("limit");
|
|
1606
|
-
}
|
|
2236
|
+
{ auth: true }
|
|
2237
|
+
);
|
|
2238
|
+
return {
|
|
2239
|
+
rateLimitPerUser: data.rate_limit_per_user,
|
|
2240
|
+
retryAfterMs: data.retry_after_ms,
|
|
2241
|
+
nextSendAllowedAt: data.next_send_allowed_at
|
|
1607
2242
|
};
|
|
1608
|
-
this.client.on(Events.MessageCreate, this._listener);
|
|
1609
|
-
if (this.options.time > 0) {
|
|
1610
|
-
this._timeout = setTimeout(() => this.stop("time"), this.options.time);
|
|
1611
|
-
}
|
|
1612
2243
|
}
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
this.
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
2244
|
+
/** Whether this channel type can carry messages (does not check permissions). */
|
|
2245
|
+
canSendMessage() {
|
|
2246
|
+
return this.isTextBased();
|
|
2247
|
+
}
|
|
2248
|
+
/** Per-channel message cache + fetch. */
|
|
2249
|
+
get messages() {
|
|
2250
|
+
if (!this.#messages) {
|
|
2251
|
+
this.#messages = new MessageManager(this.client, this.id);
|
|
1620
2252
|
}
|
|
1621
|
-
|
|
2253
|
+
return this.#messages;
|
|
1622
2254
|
}
|
|
1623
|
-
|
|
1624
|
-
|
|
2255
|
+
/** Collect messages in this channel until time/max/stop. */
|
|
2256
|
+
createMessageCollector(options) {
|
|
2257
|
+
return new MessageCollector(this.client, this.id, options);
|
|
1625
2258
|
}
|
|
1626
|
-
|
|
1627
|
-
|
|
2259
|
+
/**
|
|
2260
|
+
* Wait for messages matching the filter, then resolve the collected set.
|
|
2261
|
+
* Pass `errors: ['time']` to reject when the timer fires instead of resolving.
|
|
2262
|
+
* @example
|
|
2263
|
+
* const collected = await channel.awaitMessages({ max: 1, time: 15_000 });
|
|
2264
|
+
*/
|
|
2265
|
+
awaitMessages(options) {
|
|
2266
|
+
return MessageCollector.awaitMessages(this.client, this.id, options);
|
|
2267
|
+
}
|
|
2268
|
+
/**
|
|
2269
|
+
* Delete this channel (or close it if it is a DM).
|
|
2270
|
+
* Guild channels require Manage Channels. `silent` / `deleteMessages` are Fluxer query params.
|
|
2271
|
+
* @example
|
|
2272
|
+
* const channel = await client.channels.fetch(channelId);
|
|
2273
|
+
* await channel.delete();
|
|
2274
|
+
*/
|
|
2275
|
+
async delete(options) {
|
|
2276
|
+
const params = new URLSearchParams();
|
|
2277
|
+
if (options?.silent) params.set("silent", "true");
|
|
2278
|
+
if (options?.deleteMessages) params.set("delete_messages", "true");
|
|
2279
|
+
const qs2 = params.toString();
|
|
2280
|
+
const { silent: _s, deleteMessages: _d, reason: _reason, ...sudo } = options ?? {};
|
|
2281
|
+
const body = Object.keys(sudo).length ? toSudoBody(sudo) : void 0;
|
|
2282
|
+
await this.client.rest.delete(Routes7.channel(this.id) + (qs2 ? `?${qs2}` : ""), {
|
|
2283
|
+
body,
|
|
2284
|
+
auth: true,
|
|
2285
|
+
...auditReasonHeaders(_reason)
|
|
2286
|
+
});
|
|
2287
|
+
this.client.channels.delete(this.id);
|
|
2288
|
+
this.client._clearMessageCache(this.id);
|
|
2289
|
+
if (this.isGuild() && this.guildId) {
|
|
2290
|
+
this.client.guilds.get(this.guildId)?.channels.delete(this.id);
|
|
2291
|
+
}
|
|
2292
|
+
}
|
|
2293
|
+
/** Channel mention (`<#id>`). */
|
|
2294
|
+
toString() {
|
|
2295
|
+
return `<#${this.id}>`;
|
|
1628
2296
|
}
|
|
1629
2297
|
};
|
|
1630
2298
|
|
|
2299
|
+
// src/Domain/Channel/Dm.ts
|
|
2300
|
+
import { ChannelType as ChannelType2, Routes as Routes9 } from "@fluxerjs/types";
|
|
2301
|
+
|
|
1631
2302
|
// src/Domain/Channel/TextCapable.ts
|
|
2303
|
+
import { Routes as Routes8 } from "@fluxerjs/types";
|
|
1632
2304
|
async function fetchPinnedMessagesPageFor(client, channelId, options) {
|
|
1633
2305
|
const params = new URLSearchParams();
|
|
1634
2306
|
if (options?.limit != null) params.set("limit", String(options.limit));
|
|
@@ -1646,27 +2318,19 @@ async function fetchPinnedMessagesPageFor(client, channelId, options) {
|
|
|
1646
2318
|
}
|
|
1647
2319
|
function TextCapable(Base2) {
|
|
1648
2320
|
class TextCapableChannel extends Base2 {
|
|
1649
|
-
|
|
2321
|
+
/**
|
|
2322
|
+
* Send a message in this channel.
|
|
2323
|
+
* @example
|
|
2324
|
+
* await channel.send('hi');
|
|
2325
|
+
*/
|
|
1650
2326
|
async send(options) {
|
|
1651
|
-
|
|
1652
|
-
defaultAllowedMentions: this.client.options.defaultAllowedMentions
|
|
1653
|
-
});
|
|
1654
|
-
const data = await this.client.rest.post(Routes8.channelMessages(this.id), payload);
|
|
1655
|
-
this.client._addMessageToCache(this.id, data);
|
|
1656
|
-
return new Message(this.client, data);
|
|
1657
|
-
}
|
|
1658
|
-
get messages() {
|
|
1659
|
-
if (!this.#messages) {
|
|
1660
|
-
this.#messages = new MessageManager(this.client, this.id);
|
|
1661
|
-
}
|
|
1662
|
-
return this.#messages;
|
|
1663
|
-
}
|
|
1664
|
-
createMessageCollector(options) {
|
|
1665
|
-
return new MessageCollector(this.client, this.id, options);
|
|
2327
|
+
return this.client.channels.send(this.id, options);
|
|
1666
2328
|
}
|
|
2329
|
+
/** Fetch pinned messages in this channel. */
|
|
1667
2330
|
async fetchPinnedMessages(options) {
|
|
1668
2331
|
return (await this.fetchPinnedMessagesPage(options)).messages;
|
|
1669
2332
|
}
|
|
2333
|
+
/** Fetch a page of pinned messages plus pagination metadata. */
|
|
1670
2334
|
async fetchPinnedMessagesPage(options) {
|
|
1671
2335
|
return fetchPinnedMessagesPageFor(this.client, this.id, options);
|
|
1672
2336
|
}
|
|
@@ -1692,7 +2356,38 @@ var DMChannel = class extends TextCapable(Channel) {
|
|
|
1692
2356
|
this.recipients = (full.recipients ?? []).map((u) => client.getOrCreateUser(u));
|
|
1693
2357
|
this.nicks = full.nicks ?? {};
|
|
1694
2358
|
}
|
|
1695
|
-
/**
|
|
2359
|
+
/**
|
|
2360
|
+
* Apply DM/group-DM fields in place.
|
|
2361
|
+
* @internal
|
|
2362
|
+
*/
|
|
2363
|
+
_patch(data) {
|
|
2364
|
+
super._patch(data);
|
|
2365
|
+
const full = data;
|
|
2366
|
+
if ("last_message_id" in full && full.last_message_id !== void 0) {
|
|
2367
|
+
this.lastMessageId = full.last_message_id ?? null;
|
|
2368
|
+
}
|
|
2369
|
+
if ("owner_id" in full && full.owner_id !== void 0) this.ownerId = full.owner_id ?? null;
|
|
2370
|
+
if ("recipients" in full && full.recipients !== void 0) {
|
|
2371
|
+
this.recipients = (full.recipients ?? []).map((u) => this.client.getOrCreateUser(u));
|
|
2372
|
+
}
|
|
2373
|
+
if ("nicks" in full && full.nicks !== void 0) this.nicks = full.nicks ?? {};
|
|
2374
|
+
}
|
|
2375
|
+
/**
|
|
2376
|
+
* Edit this group DM (name, icon, nicks).
|
|
2377
|
+
* Transferring ownership to a bot fails (`CannotTransferOwnershipToBotError`).
|
|
2378
|
+
*/
|
|
2379
|
+
async edit(options) {
|
|
2380
|
+
const data = await this.client.rest.patch(Routes9.channel(this.id), {
|
|
2381
|
+
body: toGroupDmEditBody(options),
|
|
2382
|
+
auth: true
|
|
2383
|
+
});
|
|
2384
|
+
this._patch(data);
|
|
2385
|
+
return this;
|
|
2386
|
+
}
|
|
2387
|
+
/**
|
|
2388
|
+
* Purge all messages from personal notes. Only works on personal notes channels.
|
|
2389
|
+
* Notes-only; bots usually skip this.
|
|
2390
|
+
*/
|
|
1696
2391
|
async purgeMessages() {
|
|
1697
2392
|
if (this.type !== ChannelType2.DMPersonalNotes) {
|
|
1698
2393
|
throw new FluxerError("purgeMessages is only available on personal notes channels", {
|
|
@@ -1705,15 +2400,24 @@ var DMChannel = class extends TextCapable(Channel) {
|
|
|
1705
2400
|
);
|
|
1706
2401
|
return data.deleted_count;
|
|
1707
2402
|
}
|
|
1708
|
-
/**
|
|
2403
|
+
/**
|
|
2404
|
+
* Pin this DM channel to the top of the DM list.
|
|
2405
|
+
* Session-token helper; bots usually skip this.
|
|
2406
|
+
*/
|
|
1709
2407
|
async pinInList() {
|
|
1710
2408
|
await this.client.rest.put(Routes9.userMeChannelPin(this.id), { auth: true });
|
|
1711
2409
|
}
|
|
1712
|
-
/**
|
|
2410
|
+
/**
|
|
2411
|
+
* Unpin this DM channel from the DM list.
|
|
2412
|
+
* Session-token helper; bots usually skip this.
|
|
2413
|
+
*/
|
|
1713
2414
|
async unpinFromList() {
|
|
1714
2415
|
await this.client.rest.delete(Routes9.userMeChannelPin(this.id), { auth: true });
|
|
1715
2416
|
}
|
|
1716
|
-
/**
|
|
2417
|
+
/**
|
|
2418
|
+
* Add a user to this group DM.
|
|
2419
|
+
* Captcha-gated when captcha is enabled; bots are not exempt (`CaptchaRequiredError`).
|
|
2420
|
+
*/
|
|
1717
2421
|
async addRecipient(userId) {
|
|
1718
2422
|
await this.client.rest.put(Routes9.channelRecipient(this.id, userId), { auth: true });
|
|
1719
2423
|
const user = this.client.users.get(userId) ?? await this.client.users.fetch(userId);
|
|
@@ -1729,7 +2433,7 @@ var DMChannel = class extends TextCapable(Channel) {
|
|
|
1729
2433
|
};
|
|
1730
2434
|
|
|
1731
2435
|
// src/Domain/Channel/Guild.ts
|
|
1732
|
-
import { Routes as
|
|
2436
|
+
import { Routes as Routes13 } from "@fluxerjs/types";
|
|
1733
2437
|
import { PermissionFlags } from "@fluxerjs/util";
|
|
1734
2438
|
|
|
1735
2439
|
// src/Domain/Invite.ts
|
|
@@ -1737,14 +2441,13 @@ import {
|
|
|
1737
2441
|
InviteType,
|
|
1738
2442
|
isGroupDmInvite,
|
|
1739
2443
|
isGuildInvite,
|
|
1740
|
-
isPackInvite,
|
|
1741
2444
|
Routes as Routes10
|
|
1742
2445
|
} from "@fluxerjs/types";
|
|
1743
2446
|
|
|
1744
2447
|
// src/Helpers/Instance.ts
|
|
1745
2448
|
import { isRecord } from "@fluxerjs/util";
|
|
1746
2449
|
var DEFAULT_INSTANCE_ENDPOINTS = Object.freeze({
|
|
1747
|
-
api: "https://
|
|
2450
|
+
api: "https://web.fluxer.app/api",
|
|
1748
2451
|
api_client: "https://web.fluxer.app/api",
|
|
1749
2452
|
api_public: "https://api.fluxer.app",
|
|
1750
2453
|
gateway: "wss://gateway.fluxer.app",
|
|
@@ -1778,6 +2481,10 @@ function requireString(obj, key, path) {
|
|
|
1778
2481
|
}
|
|
1779
2482
|
return value;
|
|
1780
2483
|
}
|
|
2484
|
+
var INSTANCE_DISCOVERY_PATH = "/.well-known/fluxer";
|
|
2485
|
+
function instanceDiscoveryUrl(origin) {
|
|
2486
|
+
return `${normalizeApiOrigin(origin)}${INSTANCE_DISCOVERY_PATH}`;
|
|
2487
|
+
}
|
|
1781
2488
|
function normalizeApiOrigin(api) {
|
|
1782
2489
|
const trimmed = api.trim().replace(/\/+$/, "");
|
|
1783
2490
|
return trimmed.replace(/\/v\d+$/i, "");
|
|
@@ -1806,6 +2513,8 @@ function parseInstanceDiscovery(raw) {
|
|
|
1806
2513
|
endpoints[key] = requireString(raw.endpoints, key, "endpoints");
|
|
1807
2514
|
}
|
|
1808
2515
|
endpoints.api = normalizeApiOrigin(endpoints.api);
|
|
2516
|
+
endpoints.api_client = normalizeApiOrigin(endpoints.api_client);
|
|
2517
|
+
endpoints.api_public = normalizeApiOrigin(endpoints.api_public);
|
|
1809
2518
|
endpoints.invite = normalizeInviteBase(endpoints.invite);
|
|
1810
2519
|
endpoints.media = endpoints.media.replace(/\/+$/, "");
|
|
1811
2520
|
endpoints.static_cdn = endpoints.static_cdn.replace(/\/+$/, "");
|
|
@@ -1883,6 +2592,11 @@ function resolveInstanceEndpoints(input) {
|
|
|
1883
2592
|
}
|
|
1884
2593
|
}
|
|
1885
2594
|
merged.api = normalizeApiOrigin(merged.api);
|
|
2595
|
+
merged.api_client = normalizeApiOrigin(merged.api_client);
|
|
2596
|
+
merged.api_public = normalizeApiOrigin(merged.api_public);
|
|
2597
|
+
if (typeof partial.api === "string" && partial.api.length > 0 && (typeof partial.api_public !== "string" || partial.api_public.length === 0)) {
|
|
2598
|
+
merged.api_public = merged.api;
|
|
2599
|
+
}
|
|
1886
2600
|
merged.invite = normalizeInviteBase(merged.invite);
|
|
1887
2601
|
merged.media = merged.media.replace(/\/+$/, "");
|
|
1888
2602
|
merged.static_cdn = merged.static_cdn.replace(/\/+$/, "");
|
|
@@ -1891,13 +2605,13 @@ function resolveInstanceEndpoints(input) {
|
|
|
1891
2605
|
discovery: null
|
|
1892
2606
|
});
|
|
1893
2607
|
}
|
|
1894
|
-
function resolveRestApi(
|
|
1895
|
-
const fromInstance = normalizeApiOrigin(
|
|
2608
|
+
function resolveRestApi(instanceApiPublic, restApi) {
|
|
2609
|
+
const fromInstance = normalizeApiOrigin(instanceApiPublic);
|
|
1896
2610
|
if (restApi === void 0) return fromInstance;
|
|
1897
2611
|
const fromRest = normalizeApiOrigin(restApi);
|
|
1898
2612
|
if (fromRest !== fromInstance) {
|
|
1899
2613
|
throw new FluxerError(
|
|
1900
|
-
`Conflicting API hosts: instance.
|
|
2614
|
+
`Conflicting API hosts: instance.api_public (${fromInstance}) vs rest.api (${fromRest}). Prefer ClientOptions.instance.`,
|
|
1901
2615
|
{ code: ErrorCodes.ConflictingInstanceConfig }
|
|
1902
2616
|
);
|
|
1903
2617
|
}
|
|
@@ -1933,13 +2647,36 @@ function parseInviteCode(codeOrUrl) {
|
|
|
1933
2647
|
}
|
|
1934
2648
|
return code;
|
|
1935
2649
|
}
|
|
2650
|
+
function parseOptionalDate(value) {
|
|
2651
|
+
if (value == null || value === "") return null;
|
|
2652
|
+
const date = new Date(value);
|
|
2653
|
+
return Number.isNaN(date.getTime()) ? null : date;
|
|
2654
|
+
}
|
|
2655
|
+
function toInviteGuild(data) {
|
|
2656
|
+
return {
|
|
2657
|
+
id: data.id,
|
|
2658
|
+
name: data.name,
|
|
2659
|
+
icon: data.icon ?? null,
|
|
2660
|
+
banner: data.banner ?? null,
|
|
2661
|
+
splash: data.splash ?? null,
|
|
2662
|
+
features: data.features ?? []
|
|
2663
|
+
};
|
|
2664
|
+
}
|
|
2665
|
+
function toInviteChannel(data) {
|
|
2666
|
+
return {
|
|
2667
|
+
id: data.id,
|
|
2668
|
+
name: data.name ?? null,
|
|
2669
|
+
type: data.type,
|
|
2670
|
+
icon: data.icon ?? null,
|
|
2671
|
+
parentId: data.parent_id ?? null
|
|
2672
|
+
};
|
|
2673
|
+
}
|
|
1936
2674
|
var Invite = class _Invite extends Base {
|
|
1937
2675
|
client;
|
|
1938
2676
|
code;
|
|
1939
2677
|
type;
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
pack;
|
|
2678
|
+
guildSnapshot;
|
|
2679
|
+
channelSnapshot;
|
|
1943
2680
|
inviter;
|
|
1944
2681
|
memberCount;
|
|
1945
2682
|
presenceCount;
|
|
@@ -1954,15 +2691,14 @@ var Invite = class _Invite extends Base {
|
|
|
1954
2691
|
this.client = client;
|
|
1955
2692
|
this.code = data.code;
|
|
1956
2693
|
this.type = data.type;
|
|
1957
|
-
this.
|
|
1958
|
-
this.
|
|
1959
|
-
this.pack = isPackInvite(data) ? data.pack : null;
|
|
2694
|
+
this.guildSnapshot = isGuildInvite(data) ? toInviteGuild(data.guild) : null;
|
|
2695
|
+
this.channelSnapshot = isGuildInvite(data) || isGroupDmInvite(data) ? toInviteChannel(data.channel) : null;
|
|
1960
2696
|
this.inviter = data.inviter ? client.getOrCreateUser(data.inviter) : null;
|
|
1961
|
-
this.memberCount =
|
|
2697
|
+
this.memberCount = data.member_count ?? null;
|
|
1962
2698
|
this.presenceCount = isGuildInvite(data) ? data.presence_count ?? null : null;
|
|
1963
|
-
this.expiresAt = data.expires_at
|
|
2699
|
+
this.expiresAt = parseOptionalDate(data.expires_at);
|
|
1964
2700
|
this.temporary = data.temporary ?? null;
|
|
1965
|
-
this.createdAt = data.created_at
|
|
2701
|
+
this.createdAt = parseOptionalDate(data.created_at);
|
|
1966
2702
|
this.uses = data.uses ?? null;
|
|
1967
2703
|
this.maxUses = data.max_uses ?? null;
|
|
1968
2704
|
this.maxAge = data.max_age ?? null;
|
|
@@ -1973,16 +2709,25 @@ var Invite = class _Invite extends Base {
|
|
|
1973
2709
|
isGroupDM() {
|
|
1974
2710
|
return this.type === InviteType.GroupDM;
|
|
1975
2711
|
}
|
|
1976
|
-
isPack() {
|
|
1977
|
-
return this.type === InviteType.EmojiPack || this.type === InviteType.StickerPack;
|
|
1978
|
-
}
|
|
1979
2712
|
/** Full invite URL (uses this client's instance invite base). */
|
|
1980
2713
|
get url() {
|
|
1981
2714
|
return inviteUrl(this.client.instance.endpoints.invite, this.code);
|
|
1982
2715
|
}
|
|
1983
|
-
/**
|
|
1984
|
-
|
|
1985
|
-
|
|
2716
|
+
/**
|
|
2717
|
+
* Resolve the cached/fetched {@link Guild} for this invite, or null.
|
|
2718
|
+
* `guildSnapshot` is metadata only.
|
|
2719
|
+
*/
|
|
2720
|
+
async resolveGuild() {
|
|
2721
|
+
if (!this.guildSnapshot?.id) return null;
|
|
2722
|
+
return this.client.guilds.resolve(this.guildSnapshot.id);
|
|
2723
|
+
}
|
|
2724
|
+
/**
|
|
2725
|
+
* Resolve the cached/fetched {@link Channel} for this invite, or null.
|
|
2726
|
+
* `channelSnapshot` is metadata only.
|
|
2727
|
+
*/
|
|
2728
|
+
async resolveChannel() {
|
|
2729
|
+
if (!this.channelSnapshot?.id) return null;
|
|
2730
|
+
return this.client.channels.resolve(this.channelSnapshot.id);
|
|
1986
2731
|
}
|
|
1987
2732
|
/** Fetch invite metadata by code or URL (does not join). */
|
|
1988
2733
|
static async fetch(client, codeOrUrl) {
|
|
@@ -2000,7 +2745,7 @@ import { EmbedBuilder as EmbedBuilder3 } from "@fluxerjs/builders";
|
|
|
2000
2745
|
import {
|
|
2001
2746
|
Routes as Routes11
|
|
2002
2747
|
} from "@fluxerjs/types";
|
|
2003
|
-
import { SnowflakeUtil as
|
|
2748
|
+
import { SnowflakeUtil as SnowflakeUtil4 } from "@fluxerjs/util";
|
|
2004
2749
|
var Webhook = class _Webhook extends Base {
|
|
2005
2750
|
/** Parent client instance. */
|
|
2006
2751
|
client;
|
|
@@ -2037,11 +2782,11 @@ var Webhook = class _Webhook extends Base {
|
|
|
2037
2782
|
}
|
|
2038
2783
|
/** Unix timestamp (ms) when this webhook was created, derived from its snowflake ID. */
|
|
2039
2784
|
get createdTimestamp() {
|
|
2040
|
-
return
|
|
2785
|
+
return SnowflakeUtil4.timestampFromSnowflake(this.id);
|
|
2041
2786
|
}
|
|
2042
2787
|
/** Date when this webhook was created, derived from its snowflake ID. */
|
|
2043
2788
|
get createdAt() {
|
|
2044
|
-
return
|
|
2789
|
+
return SnowflakeUtil4.dateFromSnowflake(this.id);
|
|
2045
2790
|
}
|
|
2046
2791
|
/** Delete this webhook (token auth when available, otherwise bot auth). */
|
|
2047
2792
|
async delete() {
|
|
@@ -2163,9 +2908,103 @@ var Webhook = class _Webhook extends Base {
|
|
|
2163
2908
|
}
|
|
2164
2909
|
};
|
|
2165
2910
|
|
|
2911
|
+
// src/Domain/Channel/PermissionOverwriteManager.ts
|
|
2912
|
+
import { Collection as Collection6 } from "@fluxerjs/collection";
|
|
2913
|
+
import { Routes as Routes12 } from "@fluxerjs/types";
|
|
2914
|
+
import { resolvePermissionsToBitfield as resolvePermissionsToBitfield3 } from "@fluxerjs/util";
|
|
2915
|
+
|
|
2916
|
+
// src/Domain/Channel/PermissionOverwrite.ts
|
|
2917
|
+
import { PermissionsBitField } from "@fluxerjs/util";
|
|
2918
|
+
var PermissionOverwrite = class {
|
|
2919
|
+
id;
|
|
2920
|
+
type;
|
|
2921
|
+
/** @internal Raw allow bitfield string. */
|
|
2922
|
+
_allow;
|
|
2923
|
+
/** @internal Raw deny bitfield string. */
|
|
2924
|
+
_deny;
|
|
2925
|
+
constructor(data) {
|
|
2926
|
+
this.id = data.id;
|
|
2927
|
+
this.type = data.type;
|
|
2928
|
+
this._allow = data.allow ?? "0";
|
|
2929
|
+
this._deny = data.deny ?? "0";
|
|
2930
|
+
}
|
|
2931
|
+
/** Allowed permissions for this overwrite. */
|
|
2932
|
+
get allow() {
|
|
2933
|
+
return new PermissionsBitField(BigInt(this._allow || "0"));
|
|
2934
|
+
}
|
|
2935
|
+
/** Denied permissions for this overwrite. */
|
|
2936
|
+
get deny() {
|
|
2937
|
+
return new PermissionsBitField(BigInt(this._deny || "0"));
|
|
2938
|
+
}
|
|
2939
|
+
/** Wire shape for permission computation / REST. */
|
|
2940
|
+
toJSON() {
|
|
2941
|
+
return {
|
|
2942
|
+
id: this.id,
|
|
2943
|
+
type: this.type,
|
|
2944
|
+
allow: this._allow,
|
|
2945
|
+
deny: this._deny
|
|
2946
|
+
};
|
|
2947
|
+
}
|
|
2948
|
+
};
|
|
2949
|
+
|
|
2950
|
+
// src/Domain/Channel/PermissionOverwriteManager.ts
|
|
2951
|
+
var PermissionOverwriteManager = class {
|
|
2952
|
+
constructor(channel, initial = []) {
|
|
2953
|
+
this.channel = channel;
|
|
2954
|
+
this._patch(initial);
|
|
2955
|
+
}
|
|
2956
|
+
_cache = new Collection6();
|
|
2957
|
+
/** Cached overwrites keyed by role/member ID. */
|
|
2958
|
+
get cache() {
|
|
2959
|
+
return this._cache;
|
|
2960
|
+
}
|
|
2961
|
+
get size() {
|
|
2962
|
+
return this._cache.size;
|
|
2963
|
+
}
|
|
2964
|
+
[Symbol.iterator]() {
|
|
2965
|
+
return this._cache.values();
|
|
2966
|
+
}
|
|
2967
|
+
/** Wire-shaped overwrites for permission computation. */
|
|
2968
|
+
toJSON() {
|
|
2969
|
+
return [...this._cache.values()].map((o) => o.toJSON());
|
|
2970
|
+
}
|
|
2971
|
+
/** Edit or create a permission overwrite. */
|
|
2972
|
+
async edit(overwriteId, options) {
|
|
2973
|
+
const allow = options.allow !== void 0 ? resolvePermissionsToBitfield3(options.allow) : "0";
|
|
2974
|
+
const deny = options.deny !== void 0 ? resolvePermissionsToBitfield3(options.deny) : "0";
|
|
2975
|
+
await this.channel.client.rest.put(Routes12.channelPermission(this.channel.id, overwriteId), {
|
|
2976
|
+
body: { type: options.type, allow, deny },
|
|
2977
|
+
auth: true
|
|
2978
|
+
});
|
|
2979
|
+
this._cache.set(
|
|
2980
|
+
overwriteId,
|
|
2981
|
+
new PermissionOverwrite({
|
|
2982
|
+
id: overwriteId,
|
|
2983
|
+
type: options.type,
|
|
2984
|
+
allow,
|
|
2985
|
+
deny
|
|
2986
|
+
})
|
|
2987
|
+
);
|
|
2988
|
+
}
|
|
2989
|
+
/** Delete a permission overwrite. */
|
|
2990
|
+
async delete(overwriteId) {
|
|
2991
|
+
await this.channel.client.rest.delete(Routes12.channelPermission(this.channel.id, overwriteId), {
|
|
2992
|
+
auth: true
|
|
2993
|
+
});
|
|
2994
|
+
this._cache.delete(overwriteId);
|
|
2995
|
+
}
|
|
2996
|
+
/** @internal Sync from an API channel payload. */
|
|
2997
|
+
_patch(overwrites) {
|
|
2998
|
+
this._cache.clear();
|
|
2999
|
+
for (const entry of overwrites ?? []) {
|
|
3000
|
+
this._cache.set(entry.id, new PermissionOverwrite(entry));
|
|
3001
|
+
}
|
|
3002
|
+
}
|
|
3003
|
+
};
|
|
3004
|
+
|
|
2166
3005
|
// src/Domain/Channel/Guild.ts
|
|
2167
3006
|
var GuildChannel = class extends Channel {
|
|
2168
|
-
/** Guild ID this channel belongs to. */
|
|
3007
|
+
/** Guild ID this channel belongs to, or null if missing from the payload. */
|
|
2169
3008
|
guildId;
|
|
2170
3009
|
/** Position in the channel list. */
|
|
2171
3010
|
position;
|
|
@@ -2175,11 +3014,14 @@ var GuildChannel = class extends Channel {
|
|
|
2175
3014
|
permissionOverwrites;
|
|
2176
3015
|
constructor(client, data) {
|
|
2177
3016
|
super(client, data);
|
|
2178
|
-
this.guildId = data.guild_id ??
|
|
3017
|
+
this.guildId = data.guild_id ?? null;
|
|
2179
3018
|
this.name = data.name ?? null;
|
|
2180
3019
|
this.position = data.position;
|
|
2181
3020
|
this.parentId = data.parent_id ?? null;
|
|
2182
|
-
this.permissionOverwrites =
|
|
3021
|
+
this.permissionOverwrites = new PermissionOverwriteManager(
|
|
3022
|
+
this,
|
|
3023
|
+
data.permission_overwrites ?? []
|
|
3024
|
+
);
|
|
2183
3025
|
}
|
|
2184
3026
|
/**
|
|
2185
3027
|
* Apply guild-channel fields in place.
|
|
@@ -2191,13 +3033,13 @@ var GuildChannel = class extends Channel {
|
|
|
2191
3033
|
if (data.position !== void 0) this.position = data.position;
|
|
2192
3034
|
if (data.parent_id !== void 0) this.parentId = data.parent_id ?? null;
|
|
2193
3035
|
if (data.permission_overwrites !== void 0) {
|
|
2194
|
-
this.permissionOverwrites
|
|
3036
|
+
this.permissionOverwrites._patch(data.permission_overwrites ?? []);
|
|
2195
3037
|
}
|
|
2196
3038
|
this.applyEditPatch(data);
|
|
2197
3039
|
}
|
|
2198
3040
|
/** Create a webhook for this channel. Requires Manage Webhooks. */
|
|
2199
3041
|
async createWebhook(options) {
|
|
2200
|
-
const data = await this.client.rest.post(
|
|
3042
|
+
const data = await this.client.rest.post(Routes13.channelWebhooks(this.id), {
|
|
2201
3043
|
body: options,
|
|
2202
3044
|
auth: true
|
|
2203
3045
|
});
|
|
@@ -2205,13 +3047,13 @@ var GuildChannel = class extends Channel {
|
|
|
2205
3047
|
}
|
|
2206
3048
|
/** Fetch all webhooks in this channel. Requires Manage Webhooks. */
|
|
2207
3049
|
async fetchWebhooks() {
|
|
2208
|
-
const data = await this.client.rest.get(
|
|
3050
|
+
const data = await this.client.rest.get(Routes13.channelWebhooks(this.id));
|
|
2209
3051
|
return data.map((w) => new Webhook(this.client, w));
|
|
2210
3052
|
}
|
|
2211
3053
|
/** Create an invite for this channel. Requires Create Instant Invite. */
|
|
2212
3054
|
async createInvite(options) {
|
|
2213
3055
|
const body = options ? toChannelInviteBody(options) : {};
|
|
2214
|
-
const data = await this.client.rest.post(
|
|
3056
|
+
const data = await this.client.rest.post(Routes13.channelInvites(this.id), {
|
|
2215
3057
|
body: Object.keys(body).length ? body : void 0,
|
|
2216
3058
|
auth: true
|
|
2217
3059
|
});
|
|
@@ -2219,109 +3061,161 @@ var GuildChannel = class extends Channel {
|
|
|
2219
3061
|
}
|
|
2220
3062
|
/** Fetch all invites for this channel. Requires Manage Channels. */
|
|
2221
3063
|
async fetchInvites() {
|
|
2222
|
-
const data = await this.client.rest.get(
|
|
3064
|
+
const data = await this.client.rest.get(Routes13.channelInvites(this.id));
|
|
2223
3065
|
return data.map((i) => new Invite(this.client, i));
|
|
2224
3066
|
}
|
|
2225
|
-
/**
|
|
2226
|
-
async editPermission(overwriteId, options) {
|
|
2227
|
-
await this.client.rest.put(Routes12.channelPermission(this.id, overwriteId), {
|
|
2228
|
-
body: options,
|
|
2229
|
-
auth: true
|
|
2230
|
-
});
|
|
2231
|
-
const entry = {
|
|
2232
|
-
id: overwriteId,
|
|
2233
|
-
type: options.type,
|
|
2234
|
-
allow: options.allow ?? "0",
|
|
2235
|
-
deny: options.deny ?? "0"
|
|
2236
|
-
};
|
|
2237
|
-
const idx = this.permissionOverwrites.findIndex((o) => o.id === overwriteId);
|
|
2238
|
-
if (idx >= 0) this.permissionOverwrites[idx] = entry;
|
|
2239
|
-
else this.permissionOverwrites.push(entry);
|
|
2240
|
-
}
|
|
2241
|
-
/** Delete a permission overwrite. Requires Manage Roles. */
|
|
2242
|
-
async deletePermission(overwriteId) {
|
|
2243
|
-
await this.client.rest.delete(Routes12.channelPermission(this.id, overwriteId), { auth: true });
|
|
2244
|
-
const idx = this.permissionOverwrites.findIndex((o) => o.id === overwriteId);
|
|
2245
|
-
if (idx >= 0) this.permissionOverwrites.splice(idx, 1);
|
|
2246
|
-
}
|
|
2247
|
-
/** Check if the bot can send messages in this channel (with permissions). */
|
|
3067
|
+
/** Check if the bot can send messages in this channel (cache-only; needs `members.me`). */
|
|
2248
3068
|
canSendMessage() {
|
|
3069
|
+
if (!this.guildId) return false;
|
|
2249
3070
|
const me = this.client.guilds.get(this.guildId)?.members.me;
|
|
2250
3071
|
if (!me) return false;
|
|
2251
3072
|
const perms = me.permissionsIn(this);
|
|
2252
3073
|
return perms.has(PermissionFlags.ViewChannel) && perms.has(PermissionFlags.SendMessages);
|
|
2253
3074
|
}
|
|
3075
|
+
/**
|
|
3076
|
+
* Like {@link canSendMessage}, but hydrates `members.me` via REST when missing.
|
|
3077
|
+
* Returns false when the channel has no guildId.
|
|
3078
|
+
*/
|
|
3079
|
+
async canSend() {
|
|
3080
|
+
if (!this.guildId) return false;
|
|
3081
|
+
const guild = this.client.guilds.get(this.guildId);
|
|
3082
|
+
if (!guild) return false;
|
|
3083
|
+
if (!guild.members.me) {
|
|
3084
|
+
try {
|
|
3085
|
+
await guild.members.fetchMe();
|
|
3086
|
+
} catch {
|
|
3087
|
+
return false;
|
|
3088
|
+
}
|
|
3089
|
+
}
|
|
3090
|
+
return this.canSendMessage();
|
|
3091
|
+
}
|
|
2254
3092
|
/** Edit this channel's settings. Requires Manage Channels. */
|
|
2255
3093
|
async edit(options) {
|
|
2256
|
-
const data = await this.client.rest.patch(
|
|
3094
|
+
const data = await this.client.rest.patch(Routes13.channel(this.id), {
|
|
2257
3095
|
body: toChannelEditBody(options),
|
|
2258
|
-
auth: true
|
|
3096
|
+
auth: true,
|
|
3097
|
+
...auditReasonHeaders(options.reason)
|
|
2259
3098
|
});
|
|
2260
3099
|
this.name = data.name ?? this.name;
|
|
2261
3100
|
this.parentId = data.parent_id ?? this.parentId;
|
|
2262
|
-
|
|
3101
|
+
if (data.permission_overwrites !== void 0) {
|
|
3102
|
+
this.permissionOverwrites._patch(data.permission_overwrites);
|
|
3103
|
+
}
|
|
2263
3104
|
this.applyEditPatch(data);
|
|
2264
3105
|
return this;
|
|
2265
3106
|
}
|
|
2266
3107
|
applyEditPatch(_data) {
|
|
2267
3108
|
}
|
|
2268
|
-
/** Delete this channel. Requires Manage Channels or channel ownership. */
|
|
2269
|
-
async delete(options) {
|
|
2270
|
-
const params = new URLSearchParams();
|
|
2271
|
-
if (options?.silent) params.set("silent", "true");
|
|
2272
|
-
if (options?.deleteMessages) params.set("delete_messages", "true");
|
|
2273
|
-
const qs2 = params.toString();
|
|
2274
|
-
const { silent: _s, deleteMessages: _d, ...sudo } = options ?? {};
|
|
2275
|
-
const body = Object.keys(sudo).length ? toSudoBody(sudo) : void 0;
|
|
2276
|
-
await this.client.rest.delete(Routes12.channel(this.id) + (qs2 ? `?${qs2}` : ""), {
|
|
2277
|
-
body,
|
|
2278
|
-
auth: true
|
|
2279
|
-
});
|
|
2280
|
-
this.client.channels.delete(this.id);
|
|
2281
|
-
this.client._clearMessageCache(this.id);
|
|
2282
|
-
this.client.guilds.get(this.guildId)?.channels.delete(this.id);
|
|
2283
|
-
}
|
|
2284
3109
|
};
|
|
2285
3110
|
var TextChannel = class extends TextCapable(GuildChannel) {
|
|
2286
3111
|
/** Channel topic. */
|
|
2287
3112
|
topic;
|
|
2288
3113
|
/** Whether this channel is marked as NSFW. */
|
|
2289
3114
|
nsfw;
|
|
3115
|
+
/** Per-channel NSFW override (`null` inherits). */
|
|
3116
|
+
nsfwOverride;
|
|
2290
3117
|
/** Slowmode rate limit in seconds. */
|
|
2291
3118
|
rateLimitPerUser;
|
|
2292
3119
|
/** ID of the last message sent in this channel. */
|
|
2293
3120
|
lastMessageId;
|
|
3121
|
+
/** Content warning level. */
|
|
3122
|
+
contentWarningLevel;
|
|
3123
|
+
/** Custom content warning text. */
|
|
3124
|
+
contentWarningText;
|
|
2294
3125
|
constructor(client, data) {
|
|
2295
3126
|
super(client, data);
|
|
2296
3127
|
this.topic = data.topic ?? null;
|
|
2297
3128
|
this.nsfw = data.nsfw ?? false;
|
|
3129
|
+
this.nsfwOverride = data.nsfw_override ?? null;
|
|
2298
3130
|
this.rateLimitPerUser = data.rate_limit_per_user ?? 0;
|
|
2299
3131
|
this.lastMessageId = data.last_message_id ?? null;
|
|
3132
|
+
this.contentWarningLevel = data.content_warning_level ?? null;
|
|
3133
|
+
this.contentWarningText = data.content_warning_text ?? null;
|
|
3134
|
+
}
|
|
3135
|
+
/**
|
|
3136
|
+
* Set slowmode (seconds between messages). Pass `0` to disable.
|
|
3137
|
+
* Requires Manage Channels. Calls {@link GuildChannel.edit} with `rateLimitPerUser`.
|
|
3138
|
+
*/
|
|
3139
|
+
async setSlowmode(seconds) {
|
|
3140
|
+
return this.edit({ rateLimitPerUser: seconds });
|
|
2300
3141
|
}
|
|
2301
3142
|
applyEditPatch(data) {
|
|
2302
3143
|
if ("topic" in data) this.topic = data.topic ?? null;
|
|
2303
3144
|
if ("nsfw" in data) this.nsfw = data.nsfw ?? false;
|
|
3145
|
+
if ("nsfw_override" in data) this.nsfwOverride = data.nsfw_override ?? null;
|
|
2304
3146
|
if ("rate_limit_per_user" in data) this.rateLimitPerUser = data.rate_limit_per_user ?? 0;
|
|
3147
|
+
if ("last_message_id" in data) this.lastMessageId = data.last_message_id ?? null;
|
|
3148
|
+
if ("content_warning_level" in data) {
|
|
3149
|
+
this.contentWarningLevel = data.content_warning_level ?? null;
|
|
3150
|
+
}
|
|
3151
|
+
if ("content_warning_text" in data) {
|
|
3152
|
+
this.contentWarningText = data.content_warning_text ?? null;
|
|
3153
|
+
}
|
|
2305
3154
|
}
|
|
2306
3155
|
};
|
|
2307
3156
|
var CategoryChannel = class extends GuildChannel {
|
|
2308
3157
|
};
|
|
2309
|
-
var VoiceChannel = class extends GuildChannel {
|
|
3158
|
+
var VoiceChannel = class extends TextCapable(GuildChannel) {
|
|
3159
|
+
/** Channel topic. */
|
|
3160
|
+
topic;
|
|
3161
|
+
/** Whether this channel is marked as NSFW. */
|
|
3162
|
+
nsfw;
|
|
3163
|
+
/** Per-channel NSFW override (`null` inherits). */
|
|
3164
|
+
nsfwOverride;
|
|
3165
|
+
/** Slowmode rate limit in seconds. */
|
|
3166
|
+
rateLimitPerUser;
|
|
3167
|
+
/** ID of the last message sent in this channel. */
|
|
3168
|
+
lastMessageId;
|
|
3169
|
+
/** Content warning level. */
|
|
3170
|
+
contentWarningLevel;
|
|
3171
|
+
/** Custom content warning text. */
|
|
3172
|
+
contentWarningText;
|
|
2310
3173
|
/** Voice bitrate. */
|
|
2311
3174
|
bitrate;
|
|
2312
3175
|
/** Maximum number of users allowed. */
|
|
2313
3176
|
userLimit;
|
|
3177
|
+
/** Max active voice connections per user. */
|
|
3178
|
+
voiceConnectionLimit;
|
|
2314
3179
|
/** RTC region override for this channel. */
|
|
2315
3180
|
rtcRegion;
|
|
2316
3181
|
constructor(client, data) {
|
|
2317
3182
|
super(client, data);
|
|
3183
|
+
this.topic = data.topic ?? null;
|
|
3184
|
+
this.nsfw = data.nsfw ?? false;
|
|
3185
|
+
this.nsfwOverride = data.nsfw_override ?? null;
|
|
3186
|
+
this.rateLimitPerUser = data.rate_limit_per_user ?? 0;
|
|
3187
|
+
this.lastMessageId = data.last_message_id ?? null;
|
|
3188
|
+
this.contentWarningLevel = data.content_warning_level ?? null;
|
|
3189
|
+
this.contentWarningText = data.content_warning_text ?? null;
|
|
2318
3190
|
this.bitrate = data.bitrate ?? null;
|
|
2319
3191
|
this.userLimit = data.user_limit ?? null;
|
|
3192
|
+
this.voiceConnectionLimit = data.voice_connection_limit ?? null;
|
|
2320
3193
|
this.rtcRegion = data.rtc_region ?? null;
|
|
2321
3194
|
}
|
|
3195
|
+
/**
|
|
3196
|
+
* Set slowmode (seconds between messages). Pass `0` to disable.
|
|
3197
|
+
* Requires Manage Channels. Calls {@link GuildChannel.edit} with `rateLimitPerUser`.
|
|
3198
|
+
*/
|
|
3199
|
+
async setSlowmode(seconds) {
|
|
3200
|
+
return this.edit({ rateLimitPerUser: seconds });
|
|
3201
|
+
}
|
|
2322
3202
|
applyEditPatch(data) {
|
|
3203
|
+
if ("topic" in data) this.topic = data.topic ?? null;
|
|
3204
|
+
if ("nsfw" in data) this.nsfw = data.nsfw ?? false;
|
|
3205
|
+
if ("nsfw_override" in data) this.nsfwOverride = data.nsfw_override ?? null;
|
|
3206
|
+
if ("rate_limit_per_user" in data) this.rateLimitPerUser = data.rate_limit_per_user ?? 0;
|
|
3207
|
+
if ("last_message_id" in data) this.lastMessageId = data.last_message_id ?? null;
|
|
3208
|
+
if ("content_warning_level" in data) {
|
|
3209
|
+
this.contentWarningLevel = data.content_warning_level ?? null;
|
|
3210
|
+
}
|
|
3211
|
+
if ("content_warning_text" in data) {
|
|
3212
|
+
this.contentWarningText = data.content_warning_text ?? null;
|
|
3213
|
+
}
|
|
2323
3214
|
if ("bitrate" in data) this.bitrate = data.bitrate ?? null;
|
|
2324
3215
|
if ("user_limit" in data) this.userLimit = data.user_limit ?? null;
|
|
3216
|
+
if ("voice_connection_limit" in data) {
|
|
3217
|
+
this.voiceConnectionLimit = data.voice_connection_limit ?? null;
|
|
3218
|
+
}
|
|
2325
3219
|
if ("rtc_region" in data) this.rtcRegion = data.rtc_region ?? null;
|
|
2326
3220
|
}
|
|
2327
3221
|
};
|
|
@@ -2332,6 +3226,9 @@ var LinkChannel = class extends GuildChannel {
|
|
|
2332
3226
|
super(client, data);
|
|
2333
3227
|
this.url = data.url ?? null;
|
|
2334
3228
|
}
|
|
3229
|
+
applyEditPatch(data) {
|
|
3230
|
+
if ("url" in data) this.url = data.url ?? null;
|
|
3231
|
+
}
|
|
2335
3232
|
};
|
|
2336
3233
|
|
|
2337
3234
|
// src/Domain/Channel/Factory.ts
|
|
@@ -2447,11 +3344,11 @@ var User = class extends Base {
|
|
|
2447
3344
|
*/
|
|
2448
3345
|
/** Unix timestamp (ms) when this account was created, derived from its snowflake ID. */
|
|
2449
3346
|
get createdTimestamp() {
|
|
2450
|
-
return
|
|
3347
|
+
return SnowflakeUtil5.timestampFromSnowflake(this.id);
|
|
2451
3348
|
}
|
|
2452
3349
|
/** Date when this account was created, derived from its snowflake ID. */
|
|
2453
3350
|
get createdAt() {
|
|
2454
|
-
return
|
|
3351
|
+
return SnowflakeUtil5.dateFromSnowflake(this.id);
|
|
2455
3352
|
}
|
|
2456
3353
|
toString() {
|
|
2457
3354
|
return `<@${this.id}>`;
|
|
@@ -2461,7 +3358,7 @@ var User = class extends Base {
|
|
|
2461
3358
|
* @returns DM channel instance (cached if already open)
|
|
2462
3359
|
*/
|
|
2463
3360
|
async createDM() {
|
|
2464
|
-
const data = await this.client.rest.post(
|
|
3361
|
+
const data = await this.client.rest.post(Routes14.userMeChannels(), {
|
|
2465
3362
|
body: { recipient_id: this.id },
|
|
2466
3363
|
auth: true
|
|
2467
3364
|
});
|
|
@@ -2576,6 +3473,9 @@ var CacheController = class {
|
|
|
2576
3473
|
stickers
|
|
2577
3474
|
};
|
|
2578
3475
|
}
|
|
3476
|
+
/**
|
|
3477
|
+
* Sweep cached messages. Filter receives a hydrated {@link Message} (`createdAt`).
|
|
3478
|
+
*/
|
|
2579
3479
|
sweepMessages(filter, channelId) {
|
|
2580
3480
|
return this.client.sweepMessages(filter, channelId);
|
|
2581
3481
|
}
|
|
@@ -2644,7 +3544,7 @@ var CacheController = class {
|
|
|
2644
3544
|
* @internal
|
|
2645
3545
|
*/
|
|
2646
3546
|
cascadeChannel(channel, from = "both") {
|
|
2647
|
-
const guildId =
|
|
3547
|
+
const guildId = typeof channel.isGuild === "function" && channel.isGuild() ? channel.guildId : void 0;
|
|
2648
3548
|
const dropFromGuild = () => {
|
|
2649
3549
|
if (!guildId) return;
|
|
2650
3550
|
const guildChannels = this.client.guilds.get(guildId)?.channels;
|
|
@@ -2675,11 +3575,11 @@ var CacheController = class {
|
|
|
2675
3575
|
|
|
2676
3576
|
// src/ClientCore/ChannelManager.ts
|
|
2677
3577
|
import { LimitedCollection } from "@fluxerjs/collection";
|
|
2678
|
-
import { Routes as
|
|
3578
|
+
import { Routes as Routes20 } from "@fluxerjs/types";
|
|
2679
3579
|
|
|
2680
3580
|
// src/Domain/Guild/GuildEmoji.ts
|
|
2681
|
-
import { Routes as
|
|
2682
|
-
import { SnowflakeUtil as
|
|
3581
|
+
import { Routes as Routes15 } from "@fluxerjs/types";
|
|
3582
|
+
import { SnowflakeUtil as SnowflakeUtil6 } from "@fluxerjs/util";
|
|
2683
3583
|
var GuildEmoji = class extends Base {
|
|
2684
3584
|
client;
|
|
2685
3585
|
id;
|
|
@@ -2715,20 +3615,21 @@ var GuildEmoji = class extends Base {
|
|
|
2715
3615
|
}
|
|
2716
3616
|
/** Unix timestamp (ms) when this emoji was created, derived from its snowflake ID. */
|
|
2717
3617
|
get createdTimestamp() {
|
|
2718
|
-
return
|
|
3618
|
+
return SnowflakeUtil6.timestampFromSnowflake(this.id);
|
|
2719
3619
|
}
|
|
2720
3620
|
/** Date when this emoji was created, derived from its snowflake ID. */
|
|
2721
3621
|
get createdAt() {
|
|
2722
|
-
return
|
|
3622
|
+
return SnowflakeUtil6.dateFromSnowflake(this.id);
|
|
2723
3623
|
}
|
|
2724
3624
|
/** Renders this emoji for use in message content: `<:name:id>` (or `<a:name:id>` when animated). */
|
|
2725
3625
|
toString() {
|
|
2726
3626
|
return `<${this.animated ? "a" : ""}:${this.name}:${this.id}>`;
|
|
2727
3627
|
}
|
|
2728
3628
|
/** Delete this emoji. Requires Manage Emojis and Stickers permission. */
|
|
2729
|
-
async delete() {
|
|
2730
|
-
await this.client.rest.delete(
|
|
2731
|
-
auth: true
|
|
3629
|
+
async delete(reason) {
|
|
3630
|
+
await this.client.rest.delete(Routes15.guildEmoji(this.guildId, this.id), {
|
|
3631
|
+
auth: true,
|
|
3632
|
+
...auditReasonHeaders(reason)
|
|
2732
3633
|
});
|
|
2733
3634
|
const guild = this.client.guilds.get(this.guildId);
|
|
2734
3635
|
if (guild) guild.emojis.delete(this.id);
|
|
@@ -2738,9 +3639,11 @@ var GuildEmoji = class extends Base {
|
|
|
2738
3639
|
* Requires Manage Emojis and Stickers permission.
|
|
2739
3640
|
*/
|
|
2740
3641
|
async edit(options) {
|
|
2741
|
-
const
|
|
2742
|
-
|
|
2743
|
-
|
|
3642
|
+
const { reason, name } = options;
|
|
3643
|
+
const data = await this.client.rest.patch(Routes15.guildEmoji(this.guildId, this.id), {
|
|
3644
|
+
body: { name },
|
|
3645
|
+
auth: true,
|
|
3646
|
+
...auditReasonHeaders(reason)
|
|
2744
3647
|
});
|
|
2745
3648
|
this.name = data.name;
|
|
2746
3649
|
return this;
|
|
@@ -2748,14 +3651,17 @@ var GuildEmoji = class extends Base {
|
|
|
2748
3651
|
};
|
|
2749
3652
|
|
|
2750
3653
|
// src/Domain/Guild/GuildMember.ts
|
|
2751
|
-
import { Routes as
|
|
2752
|
-
import { PermissionsBitField } from "@fluxerjs/util";
|
|
3654
|
+
import { Routes as Routes17 } from "@fluxerjs/types";
|
|
3655
|
+
import { PermissionFlags as PermissionFlags3, PermissionsBitField as PermissionsBitField2 } from "@fluxerjs/util";
|
|
2753
3656
|
|
|
2754
3657
|
// src/Helpers/Permissions.ts
|
|
2755
3658
|
import { OverwriteType } from "@fluxerjs/types";
|
|
2756
3659
|
import { ALL_PERMISSIONS_BIGINT, PermissionFlags as PermissionFlags2 } from "@fluxerjs/util";
|
|
2757
3660
|
function computePermissions(basePermissions, overwrites, memberRoles, memberId, isOwner) {
|
|
2758
3661
|
if (isOwner) return ALL_PERMISSIONS_BIGINT;
|
|
3662
|
+
if ((basePermissions & PermissionFlags2.Administrator) !== 0n) {
|
|
3663
|
+
return ALL_PERMISSIONS_BIGINT;
|
|
3664
|
+
}
|
|
2759
3665
|
let perms = basePermissions;
|
|
2760
3666
|
for (const overwrite of overwrites ?? []) {
|
|
2761
3667
|
const applies = overwrite.type === OverwriteType.Role && memberRoles.includes(overwrite.id) || overwrite.type === OverwriteType.Member && overwrite.id === memberId;
|
|
@@ -2764,12 +3670,12 @@ function computePermissions(basePermissions, overwrites, memberRoles, memberId,
|
|
|
2764
3670
|
const deny = BigInt(overwrite.deny || "0");
|
|
2765
3671
|
perms = perms & ~deny | allow;
|
|
2766
3672
|
}
|
|
2767
|
-
return
|
|
3673
|
+
return perms;
|
|
2768
3674
|
}
|
|
2769
3675
|
|
|
2770
3676
|
// src/Domain/Guild/GuildMemberRoleManager.ts
|
|
2771
|
-
import { Collection as
|
|
2772
|
-
import { Routes as
|
|
3677
|
+
import { Collection as Collection7 } from "@fluxerjs/collection";
|
|
3678
|
+
import { Routes as Routes16 } from "@fluxerjs/types";
|
|
2773
3679
|
function roleId(roleOrId) {
|
|
2774
3680
|
return typeof roleOrId === "string" ? roleOrId : roleOrId.id;
|
|
2775
3681
|
}
|
|
@@ -2787,7 +3693,7 @@ var GuildMemberRoleManager = class {
|
|
|
2787
3693
|
}
|
|
2788
3694
|
/** Live Role objects from `guild.roles` for this member's role IDs. */
|
|
2789
3695
|
get cache() {
|
|
2790
|
-
const out = new
|
|
3696
|
+
const out = new Collection7();
|
|
2791
3697
|
for (const id of this.ids) {
|
|
2792
3698
|
const role = this.member.guild.roles.get(id);
|
|
2793
3699
|
if (role) out.set(id, role);
|
|
@@ -2798,7 +3704,7 @@ var GuildMemberRoleManager = class {
|
|
|
2798
3704
|
const id = roleId(roleOrId);
|
|
2799
3705
|
if (this.ids.includes(id)) return;
|
|
2800
3706
|
await this.member.client.rest.put(
|
|
2801
|
-
|
|
3707
|
+
Routes16.guildMemberRole(this.member.guild.id, this.member.id, id)
|
|
2802
3708
|
);
|
|
2803
3709
|
this.ids.push(id);
|
|
2804
3710
|
}
|
|
@@ -2807,13 +3713,13 @@ var GuildMemberRoleManager = class {
|
|
|
2807
3713
|
const idx = this.ids.indexOf(id);
|
|
2808
3714
|
if (idx === -1) return;
|
|
2809
3715
|
await this.member.client.rest.delete(
|
|
2810
|
-
|
|
3716
|
+
Routes16.guildMemberRole(this.member.guild.id, this.member.id, id)
|
|
2811
3717
|
);
|
|
2812
3718
|
this.ids.splice(idx, 1);
|
|
2813
3719
|
}
|
|
2814
3720
|
async set(roleIds) {
|
|
2815
3721
|
const data = await this.member.client.rest.patch(
|
|
2816
|
-
|
|
3722
|
+
Routes16.guildMember(this.member.guild.id, this.member.id),
|
|
2817
3723
|
{ body: { roles: roleIds }, auth: true }
|
|
2818
3724
|
);
|
|
2819
3725
|
this.ids = data.roles ? [...data.roles] : [];
|
|
@@ -2826,6 +3732,8 @@ var GuildMemberRoleManager = class {
|
|
|
2826
3732
|
|
|
2827
3733
|
// src/Domain/Guild/GuildMember.ts
|
|
2828
3734
|
var GuildMember = class _GuildMember extends Base {
|
|
3735
|
+
/** Discriminant vs {@link PartialGuildMember}: always `false` on a hydrated member. */
|
|
3736
|
+
partial = false;
|
|
2829
3737
|
/** Parent client instance. */
|
|
2830
3738
|
client;
|
|
2831
3739
|
/** User ID (same as `user.id`). */
|
|
@@ -2854,6 +3762,12 @@ var GuildMember = class _GuildMember extends Base {
|
|
|
2854
3762
|
accentColor;
|
|
2855
3763
|
/** Guild-specific profile flags. */
|
|
2856
3764
|
profileFlags;
|
|
3765
|
+
/** Per-guild reply mention preference override. */
|
|
3766
|
+
mentionFlags;
|
|
3767
|
+
/** Guild-specific bio (set from member edit; not always on GET member). */
|
|
3768
|
+
bio;
|
|
3769
|
+
/** Guild-specific pronouns (set from member edit; not always on GET member). */
|
|
3770
|
+
pronouns;
|
|
2857
3771
|
constructor(client, data, guild) {
|
|
2858
3772
|
super();
|
|
2859
3773
|
this.client = client;
|
|
@@ -2870,6 +3784,9 @@ var GuildMember = class _GuildMember extends Base {
|
|
|
2870
3784
|
this.banner = data.banner ?? null;
|
|
2871
3785
|
this.accentColor = data.accent_color ?? null;
|
|
2872
3786
|
this.profileFlags = data.profile_flags ?? null;
|
|
3787
|
+
this.mentionFlags = data.mention_flags ?? null;
|
|
3788
|
+
this.bio = data.bio ?? null;
|
|
3789
|
+
this.pronouns = data.pronouns ?? null;
|
|
2873
3790
|
}
|
|
2874
3791
|
/**
|
|
2875
3792
|
* Apply an API member payload in place (gateway GUILD_MEMBER_UPDATE / REST edit).
|
|
@@ -2888,6 +3805,9 @@ var GuildMember = class _GuildMember extends Base {
|
|
|
2888
3805
|
if (data.banner !== void 0) this.banner = data.banner ?? null;
|
|
2889
3806
|
if (data.accent_color !== void 0) this.accentColor = data.accent_color ?? null;
|
|
2890
3807
|
if (data.profile_flags !== void 0) this.profileFlags = data.profile_flags ?? null;
|
|
3808
|
+
if (data.mention_flags !== void 0) this.mentionFlags = data.mention_flags ?? null;
|
|
3809
|
+
if (data.bio !== void 0) this.bio = data.bio ?? null;
|
|
3810
|
+
if (data.pronouns !== void 0) this.pronouns = data.pronouns ?? null;
|
|
2891
3811
|
}
|
|
2892
3812
|
/**
|
|
2893
3813
|
* Snapshot for `guildMemberUpdate` old-member arg (before in-place patch).
|
|
@@ -2916,7 +3836,10 @@ var GuildMember = class _GuildMember extends Base {
|
|
|
2916
3836
|
avatar: this.avatar,
|
|
2917
3837
|
banner: this.banner,
|
|
2918
3838
|
accent_color: this.accentColor,
|
|
2919
|
-
profile_flags: this.profileFlags ?? void 0
|
|
3839
|
+
profile_flags: this.profileFlags ?? void 0,
|
|
3840
|
+
mention_flags: this.mentionFlags,
|
|
3841
|
+
bio: this.bio,
|
|
3842
|
+
pronouns: this.pronouns
|
|
2920
3843
|
},
|
|
2921
3844
|
this.guild
|
|
2922
3845
|
);
|
|
@@ -2943,15 +3866,23 @@ var GuildMember = class _GuildMember extends Base {
|
|
|
2943
3866
|
mediaBase: this.client.instance.endpoints.media
|
|
2944
3867
|
});
|
|
2945
3868
|
}
|
|
2946
|
-
/**
|
|
3869
|
+
/**
|
|
3870
|
+
* PATCH member (`/members/@me` when editing the bot).
|
|
3871
|
+
* @example
|
|
3872
|
+
* await member.edit({ nick: 'Ada' });
|
|
3873
|
+
*/
|
|
2947
3874
|
async edit(options) {
|
|
2948
3875
|
const isMe = this.client.user?.id === this.id;
|
|
2949
|
-
const route = isMe ?
|
|
3876
|
+
const route = isMe ? Routes17.guildMemberMe(this.guild.id) : Routes17.guildMember(this.guild.id, this.id);
|
|
2950
3877
|
const data = await this.client.rest.patch(route, {
|
|
2951
3878
|
body: toMemberEditBody(options),
|
|
2952
|
-
auth: true
|
|
3879
|
+
auth: true,
|
|
3880
|
+
...auditReasonHeaders(options.reason ?? options.timeoutReason)
|
|
2953
3881
|
});
|
|
2954
3882
|
this._patch(data);
|
|
3883
|
+
if (options.bio !== void 0) this.bio = options.bio;
|
|
3884
|
+
if (options.pronouns !== void 0) this.pronouns = options.pronouns;
|
|
3885
|
+
if (options.mentionFlags !== void 0) this.mentionFlags = options.mentionFlags;
|
|
2955
3886
|
return this;
|
|
2956
3887
|
}
|
|
2957
3888
|
/**
|
|
@@ -2959,7 +3890,7 @@ var GuildMember = class _GuildMember extends Base {
|
|
|
2959
3890
|
* @see {@link permissionsIn} for channel-specific permissions
|
|
2960
3891
|
*/
|
|
2961
3892
|
get permissions() {
|
|
2962
|
-
return new
|
|
3893
|
+
return new PermissionsBitField2(this._effectivePermissions([], []));
|
|
2963
3894
|
}
|
|
2964
3895
|
/**
|
|
2965
3896
|
* Effective permissions in a channel (roles + overwrites).
|
|
@@ -2967,8 +3898,8 @@ var GuildMember = class _GuildMember extends Base {
|
|
|
2967
3898
|
* @returns Computed permissions bitfield
|
|
2968
3899
|
*/
|
|
2969
3900
|
permissionsIn(channel) {
|
|
2970
|
-
return new
|
|
2971
|
-
this._effectivePermissions(channel.permissionOverwrites, [...this.roles.roleIds])
|
|
3901
|
+
return new PermissionsBitField2(
|
|
3902
|
+
this._effectivePermissions(channel.permissionOverwrites.toJSON(), [...this.roles.roleIds])
|
|
2972
3903
|
);
|
|
2973
3904
|
}
|
|
2974
3905
|
/**
|
|
@@ -2979,6 +3910,63 @@ var GuildMember = class _GuildMember extends Base {
|
|
|
2979
3910
|
async move(channelId, connectionId) {
|
|
2980
3911
|
await this.edit({ channelId, connectionId });
|
|
2981
3912
|
}
|
|
3913
|
+
/** Kick this member. Requires Kick Members. */
|
|
3914
|
+
async kick(reason) {
|
|
3915
|
+
await this.guild.kick(this.id, reason);
|
|
3916
|
+
}
|
|
3917
|
+
/** Ban this member. Requires Ban Members. */
|
|
3918
|
+
async ban(options) {
|
|
3919
|
+
await this.guild.ban(this.id, options);
|
|
3920
|
+
}
|
|
3921
|
+
/**
|
|
3922
|
+
* Whether the bot can kick this member (cache-only; needs `members.me`).
|
|
3923
|
+
* False for the guild owner, self, or when the bot lacks Kick Members / role hierarchy.
|
|
3924
|
+
*/
|
|
3925
|
+
get kickable() {
|
|
3926
|
+
return this._moderatableWith(PermissionFlags3.KickMembers);
|
|
3927
|
+
}
|
|
3928
|
+
/**
|
|
3929
|
+
* Whether the bot can ban this member (cache-only; needs `members.me`).
|
|
3930
|
+
*/
|
|
3931
|
+
get bannable() {
|
|
3932
|
+
return this._moderatableWith(PermissionFlags3.BanMembers);
|
|
3933
|
+
}
|
|
3934
|
+
/**
|
|
3935
|
+
* Whether the bot can timeout this member (cache-only; needs `members.me`).
|
|
3936
|
+
*/
|
|
3937
|
+
get moderatable() {
|
|
3938
|
+
return this._moderatableWith(PermissionFlags3.ModerateMembers);
|
|
3939
|
+
}
|
|
3940
|
+
_moderatableWith(flag) {
|
|
3941
|
+
const me = this.guild.members.me;
|
|
3942
|
+
if (!me) return false;
|
|
3943
|
+
if (this.id === me.id) return false;
|
|
3944
|
+
if (this.guild.ownerId != null && String(this.guild.ownerId) === String(this.id)) return false;
|
|
3945
|
+
if (!me.permissions.has(flag)) return false;
|
|
3946
|
+
return this._compareRolePosition(me) < 0;
|
|
3947
|
+
}
|
|
3948
|
+
/** Negative when this member's highest role is below `other`'s. */
|
|
3949
|
+
_compareRolePosition(other) {
|
|
3950
|
+
const highest = (m) => {
|
|
3951
|
+
let pos = -1;
|
|
3952
|
+
for (const role of m.roles.cache.values()) {
|
|
3953
|
+
if (role.position > pos) pos = role.position;
|
|
3954
|
+
}
|
|
3955
|
+
return pos;
|
|
3956
|
+
};
|
|
3957
|
+
return highest(this) - highest(other);
|
|
3958
|
+
}
|
|
3959
|
+
/**
|
|
3960
|
+
* Timeout this member for `durationMs` milliseconds, or pass `null` to clear.
|
|
3961
|
+
* Requires Moderate Members.
|
|
3962
|
+
*/
|
|
3963
|
+
async timeout(durationMs, reason) {
|
|
3964
|
+
const communicationDisabledUntil = durationMs == null || durationMs <= 0 ? null : new Date(Date.now() + durationMs).toISOString();
|
|
3965
|
+
return this.edit({
|
|
3966
|
+
communicationDisabledUntil,
|
|
3967
|
+
...reason !== void 0 ? { timeoutReason: reason } : {}
|
|
3968
|
+
});
|
|
3969
|
+
}
|
|
2982
3970
|
_effectivePermissions(overwrites, roleIds) {
|
|
2983
3971
|
const ownerId = this.guild.ownerId;
|
|
2984
3972
|
const isOwner = ownerId != null && ownerId !== "" && String(ownerId) === String(this.id);
|
|
@@ -2998,8 +3986,8 @@ var GuildMember = class _GuildMember extends Base {
|
|
|
2998
3986
|
};
|
|
2999
3987
|
|
|
3000
3988
|
// src/Domain/Guild/GuildSticker.ts
|
|
3001
|
-
import { Routes as
|
|
3002
|
-
import { SnowflakeUtil as
|
|
3989
|
+
import { Routes as Routes18 } from "@fluxerjs/types";
|
|
3990
|
+
import { SnowflakeUtil as SnowflakeUtil7 } from "@fluxerjs/util";
|
|
3003
3991
|
var GuildSticker = class extends Base {
|
|
3004
3992
|
client;
|
|
3005
3993
|
id;
|
|
@@ -3041,16 +4029,17 @@ var GuildSticker = class extends Base {
|
|
|
3041
4029
|
}
|
|
3042
4030
|
/** Unix timestamp (ms) when this sticker was created, derived from its snowflake ID. */
|
|
3043
4031
|
get createdTimestamp() {
|
|
3044
|
-
return
|
|
4032
|
+
return SnowflakeUtil7.timestampFromSnowflake(this.id);
|
|
3045
4033
|
}
|
|
3046
4034
|
/** Date when this sticker was created, derived from its snowflake ID. */
|
|
3047
4035
|
get createdAt() {
|
|
3048
|
-
return
|
|
4036
|
+
return SnowflakeUtil7.dateFromSnowflake(this.id);
|
|
3049
4037
|
}
|
|
3050
4038
|
/** Delete this sticker. Requires Manage Emojis and Stickers permission. */
|
|
3051
|
-
async delete() {
|
|
3052
|
-
await this.client.rest.delete(
|
|
3053
|
-
auth: true
|
|
4039
|
+
async delete(reason) {
|
|
4040
|
+
await this.client.rest.delete(Routes18.guildSticker(this.guildId, this.id), {
|
|
4041
|
+
auth: true,
|
|
4042
|
+
...auditReasonHeaders(reason)
|
|
3054
4043
|
});
|
|
3055
4044
|
const guild = this.client.guilds.get(this.guildId);
|
|
3056
4045
|
if (guild) guild.stickers.delete(this.id);
|
|
@@ -3060,9 +4049,11 @@ var GuildSticker = class extends Base {
|
|
|
3060
4049
|
* Requires Manage Emojis and Stickers permission.
|
|
3061
4050
|
*/
|
|
3062
4051
|
async edit(options) {
|
|
3063
|
-
const
|
|
3064
|
-
|
|
3065
|
-
|
|
4052
|
+
const { reason, ...body } = options;
|
|
4053
|
+
const data = await this.client.rest.patch(Routes18.guildSticker(this.guildId, this.id), {
|
|
4054
|
+
body,
|
|
4055
|
+
auth: true,
|
|
4056
|
+
...auditReasonHeaders(reason)
|
|
3066
4057
|
});
|
|
3067
4058
|
const s = data;
|
|
3068
4059
|
this.name = s.name;
|
|
@@ -3072,12 +4063,12 @@ var GuildSticker = class extends Base {
|
|
|
3072
4063
|
};
|
|
3073
4064
|
|
|
3074
4065
|
// src/Domain/Guild/Role.ts
|
|
3075
|
-
import { Routes as
|
|
4066
|
+
import { Routes as Routes19 } from "@fluxerjs/types";
|
|
3076
4067
|
import {
|
|
3077
4068
|
ALL_PERMISSIONS_BIGINT as ALL_PERMISSIONS_BIGINT2,
|
|
3078
|
-
PermissionFlags as
|
|
3079
|
-
PermissionsBitField as
|
|
3080
|
-
SnowflakeUtil as
|
|
4069
|
+
PermissionFlags as PermissionFlags4,
|
|
4070
|
+
PermissionsBitField as PermissionsBitField3,
|
|
4071
|
+
SnowflakeUtil as SnowflakeUtil8
|
|
3081
4072
|
} from "@fluxerjs/util";
|
|
3082
4073
|
var Role = class _Role extends Base {
|
|
3083
4074
|
/** Parent client instance. */
|
|
@@ -3121,21 +4112,29 @@ var Role = class _Role extends Base {
|
|
|
3121
4112
|
*/
|
|
3122
4113
|
get permissions() {
|
|
3123
4114
|
const bits = BigInt(this._permissions);
|
|
3124
|
-
return new
|
|
3125
|
-
(bits &
|
|
4115
|
+
return new PermissionsBitField3(
|
|
4116
|
+
(bits & PermissionFlags4.Administrator) !== 0n ? ALL_PERMISSIONS_BIGINT2 : bits
|
|
3126
4117
|
);
|
|
3127
4118
|
}
|
|
4119
|
+
/**
|
|
4120
|
+
* Alias of {@link permissions}.has for discord.js-style checks.
|
|
4121
|
+
* @example
|
|
4122
|
+
* if (role.has(PermissionFlags.BanMembers)) { ... }
|
|
4123
|
+
*/
|
|
4124
|
+
has(permission) {
|
|
4125
|
+
return this.permissions.has(permission);
|
|
4126
|
+
}
|
|
3128
4127
|
/**
|
|
3129
4128
|
* Format as a mention string (`<@&id>`).
|
|
3130
4129
|
* @returns Mention syntax
|
|
3131
4130
|
*/
|
|
3132
4131
|
/** Unix timestamp (ms) when this role was created, derived from its snowflake ID. */
|
|
3133
4132
|
get createdTimestamp() {
|
|
3134
|
-
return
|
|
4133
|
+
return SnowflakeUtil8.timestampFromSnowflake(this.id);
|
|
3135
4134
|
}
|
|
3136
4135
|
/** Date when this role was created, derived from its snowflake ID. */
|
|
3137
4136
|
get createdAt() {
|
|
3138
|
-
return
|
|
4137
|
+
return SnowflakeUtil8.dateFromSnowflake(this.id);
|
|
3139
4138
|
}
|
|
3140
4139
|
toString() {
|
|
3141
4140
|
return `<@&${this.id}>`;
|
|
@@ -3178,19 +4177,24 @@ var Role = class _Role extends Base {
|
|
|
3178
4177
|
* @returns This role instance (updated in-place)
|
|
3179
4178
|
*/
|
|
3180
4179
|
async edit(options) {
|
|
3181
|
-
const body =
|
|
3182
|
-
const data = await this.client.rest.patch(
|
|
4180
|
+
const body = toRoleEditBody(options);
|
|
4181
|
+
const data = await this.client.rest.patch(Routes19.guildRole(this.guildId, this.id), {
|
|
3183
4182
|
body: Object.keys(body).length ? body : void 0,
|
|
3184
|
-
auth: true
|
|
4183
|
+
auth: true,
|
|
4184
|
+
...auditReasonHeaders(options.reason)
|
|
3185
4185
|
});
|
|
3186
4186
|
this._patch(data);
|
|
3187
4187
|
return this;
|
|
3188
4188
|
}
|
|
3189
4189
|
/**
|
|
3190
4190
|
* DELETE role. Requires Manage Roles.
|
|
4191
|
+
* @param reason - Audit log reason (`X-Audit-Log-Reason`)
|
|
3191
4192
|
*/
|
|
3192
|
-
async delete() {
|
|
3193
|
-
await this.client.rest.delete(
|
|
4193
|
+
async delete(reason) {
|
|
4194
|
+
await this.client.rest.delete(Routes19.guildRole(this.guildId, this.id), {
|
|
4195
|
+
auth: true,
|
|
4196
|
+
...auditReasonHeaders(reason)
|
|
4197
|
+
});
|
|
3194
4198
|
this.client.guilds.get(this.guildId)?.roles.delete(this.id);
|
|
3195
4199
|
}
|
|
3196
4200
|
};
|
|
@@ -3198,17 +4202,15 @@ var Role = class _Role extends Base {
|
|
|
3198
4202
|
// src/Domain/Guild/Cache.ts
|
|
3199
4203
|
function putChannel(client, channel, guild) {
|
|
3200
4204
|
client.channels.set(channel.id, channel);
|
|
3201
|
-
|
|
3202
|
-
|
|
3203
|
-
return guildId ? client.guilds.get(guildId) : void 0;
|
|
3204
|
-
})();
|
|
4205
|
+
if (!channel.isGuild()) return;
|
|
4206
|
+
const resolvedGuild = guild ?? (channel.guildId ? client.guilds.get(channel.guildId) : void 0);
|
|
3205
4207
|
if (resolvedGuild) {
|
|
3206
4208
|
resolvedGuild.channels.set(channel.id, channel);
|
|
3207
4209
|
}
|
|
3208
4210
|
}
|
|
3209
4211
|
function cacheChannel(guild, data) {
|
|
3210
4212
|
const existing = guild.channels.get(data.id) ?? guild.client.channels.get(data.id);
|
|
3211
|
-
if (existing &&
|
|
4213
|
+
if (existing?.isGuild() && existing.type === data.type) {
|
|
3212
4214
|
existing._patch(data);
|
|
3213
4215
|
putChannel(guild.client, existing, guild);
|
|
3214
4216
|
return existing;
|
|
@@ -3322,6 +4324,10 @@ var ChannelManager = class extends LimitedCollection {
|
|
|
3322
4324
|
});
|
|
3323
4325
|
this.client = client;
|
|
3324
4326
|
}
|
|
4327
|
+
/**
|
|
4328
|
+
* Remove a channel from cache. Does not delete it on the API.
|
|
4329
|
+
* Use {@link Channel.delete} after {@link fetch} to delete the channel.
|
|
4330
|
+
*/
|
|
3325
4331
|
delete(key) {
|
|
3326
4332
|
const channel = this.get(key);
|
|
3327
4333
|
const deleted = super.delete(key);
|
|
@@ -3335,15 +4341,20 @@ var ChannelManager = class extends LimitedCollection {
|
|
|
3335
4341
|
return this.get(channelId) ?? this.fetch(channelId);
|
|
3336
4342
|
}
|
|
3337
4343
|
/**
|
|
3338
|
-
* Fetch a channel by ID.
|
|
3339
|
-
*
|
|
4344
|
+
* Fetch a channel by ID. The returned {@link Channel} has {@link Channel.delete}
|
|
4345
|
+
* and {@link Channel.send} (send throws if the type is not text-based).
|
|
4346
|
+
* Returns the cached channel unless `force` is set.
|
|
4347
|
+
* @example
|
|
4348
|
+
* const channel = await client.channels.fetch(channelId);
|
|
4349
|
+
* await channel.delete();
|
|
4350
|
+
* await channel.send('hi');
|
|
3340
4351
|
* @throws {@link FluxerError} with CHANNEL_NOT_FOUND if missing
|
|
3341
4352
|
*/
|
|
3342
4353
|
async fetch(channelId, options) {
|
|
3343
4354
|
const cached = this.get(channelId);
|
|
3344
4355
|
if (cached && !options?.force) return cached;
|
|
3345
4356
|
try {
|
|
3346
|
-
const data = await this.client.rest.get(
|
|
4357
|
+
const data = await this.client.rest.get(Routes20.channel(channelId));
|
|
3347
4358
|
const guildId = "guild_id" in data ? data.guild_id : void 0;
|
|
3348
4359
|
if (guildId) {
|
|
3349
4360
|
const guild = this.client.guilds.get(guildId);
|
|
@@ -3379,6 +4390,7 @@ var ChannelManager = class extends LimitedCollection {
|
|
|
3379
4390
|
}
|
|
3380
4391
|
/**
|
|
3381
4392
|
* Send to a channel by ID without resolving it first.
|
|
4393
|
+
* Prefer {@link Channel.send} after {@link fetch} when you want the channel object.
|
|
3382
4394
|
* @example
|
|
3383
4395
|
* await client.channels.send(logChannelId, 'User joined!');
|
|
3384
4396
|
*/
|
|
@@ -3387,7 +4399,7 @@ var ChannelManager = class extends LimitedCollection {
|
|
|
3387
4399
|
defaultAllowedMentions: this.client.options.defaultAllowedMentions
|
|
3388
4400
|
});
|
|
3389
4401
|
const data = await this.client.rest.post(
|
|
3390
|
-
|
|
4402
|
+
Routes20.channelMessages(channelId),
|
|
3391
4403
|
postPayload
|
|
3392
4404
|
);
|
|
3393
4405
|
this.client._addMessageToCache(channelId, data);
|
|
@@ -3396,14 +4408,14 @@ var ChannelManager = class extends LimitedCollection {
|
|
|
3396
4408
|
};
|
|
3397
4409
|
|
|
3398
4410
|
// src/ClientCore/ClientEmoji.ts
|
|
3399
|
-
import { Collection as
|
|
3400
|
-
import { Routes as
|
|
3401
|
-
import { formatEmoji, getUnicodeFromShortcode, parseEmoji
|
|
4411
|
+
import { Collection as Collection8 } from "@fluxerjs/collection";
|
|
4412
|
+
import { Routes as Routes21 } from "@fluxerjs/types";
|
|
4413
|
+
import { formatEmoji, getUnicodeFromShortcode, parseEmoji } from "@fluxerjs/util";
|
|
3402
4414
|
async function resolveClientEmoji(client, emoji, guildId) {
|
|
3403
4415
|
if (typeof emoji === "object" && emoji.id) {
|
|
3404
4416
|
return formatEmoji({ name: emoji.name, id: emoji.id, animated: emoji.animated });
|
|
3405
4417
|
}
|
|
3406
|
-
const parsed =
|
|
4418
|
+
const parsed = parseEmoji(
|
|
3407
4419
|
typeof emoji === "string" ? emoji : emoji.id ? `:${emoji.name}:` : emoji.name
|
|
3408
4420
|
);
|
|
3409
4421
|
if (!parsed) {
|
|
@@ -3416,7 +4428,7 @@ async function resolveClientEmoji(client, emoji, guildId) {
|
|
|
3416
4428
|
const unicodeFromShortcode = getUnicodeFromShortcode(parsed.name);
|
|
3417
4429
|
if (unicodeFromShortcode) return unicodeFromShortcode;
|
|
3418
4430
|
if (guildId) {
|
|
3419
|
-
const emojis = await client.rest.get(
|
|
4431
|
+
const emojis = await client.rest.get(Routes21.guildEmojis(guildId));
|
|
3420
4432
|
const found = emojis.find((e) => e.name && e.name.toLowerCase() === parsed.name.toLowerCase());
|
|
3421
4433
|
if (found) return formatEmoji({ ...parsed, id: found.id, animated: found.animated });
|
|
3422
4434
|
throw new FluxerError(
|
|
@@ -3433,28 +4445,34 @@ async function resolveClientEmoji(client, emoji, guildId) {
|
|
|
3433
4445
|
return parsed.name;
|
|
3434
4446
|
}
|
|
3435
4447
|
async function fetchInstance(client) {
|
|
3436
|
-
const raw = await client.rest.get(
|
|
4448
|
+
const raw = await client.rest.get(Routes21.instanceDiscovery(), {
|
|
4449
|
+
auth: false,
|
|
4450
|
+
unversioned: true
|
|
4451
|
+
});
|
|
3437
4452
|
return parseInstanceDiscovery(raw);
|
|
3438
4453
|
}
|
|
3439
4454
|
function fetchGatewayInfo(client) {
|
|
3440
|
-
return client.rest.get(
|
|
4455
|
+
return client.rest.get(Routes21.gatewayBot());
|
|
3441
4456
|
}
|
|
3442
4457
|
function fetchEmojiMetadata(client, emojiId) {
|
|
3443
|
-
return client.rest.get(
|
|
4458
|
+
return client.rest.get(Routes21.emojiMetadata(emojiId), { auth: true });
|
|
3444
4459
|
}
|
|
3445
4460
|
function fetchStickerMetadata(client, stickerId) {
|
|
3446
|
-
return client.rest.get(
|
|
4461
|
+
return client.rest.get(Routes21.stickerMetadata(stickerId), { auth: true });
|
|
3447
4462
|
}
|
|
3448
4463
|
function fetchApplication(client) {
|
|
3449
|
-
return client.rest.get(
|
|
4464
|
+
return client.rest.get(Routes21.applicationsMe(), { auth: true });
|
|
3450
4465
|
}
|
|
3451
4466
|
async function fetchOAuthApplications(client) {
|
|
3452
|
-
const data = await client.rest.get(
|
|
3453
|
-
|
|
3454
|
-
|
|
3455
|
-
|
|
3456
|
-
|
|
3457
|
-
|
|
4467
|
+
const data = await client.rest.get(Routes21.oauth2ApplicationsMe(), { auth: true });
|
|
4468
|
+
if (Array.isArray(data)) return data;
|
|
4469
|
+
if (data && typeof data === "object" && "applications" in data && Array.isArray(data.applications)) {
|
|
4470
|
+
return data.applications;
|
|
4471
|
+
}
|
|
4472
|
+
if (data && typeof data === "object" && "id" in data && typeof data.id === "string") {
|
|
4473
|
+
return [data];
|
|
4474
|
+
}
|
|
4475
|
+
return [];
|
|
3458
4476
|
}
|
|
3459
4477
|
function assertChannelIdBatch(name, channelIds) {
|
|
3460
4478
|
if (channelIds.length < 1 || channelIds.length > 100) {
|
|
@@ -3465,14 +4483,14 @@ function assertChannelIdBatch(name, channelIds) {
|
|
|
3465
4483
|
}
|
|
3466
4484
|
function preloadMessages(client, channelIds) {
|
|
3467
4485
|
assertChannelIdBatch("preloadMessages", channelIds);
|
|
3468
|
-
return client.rest.post(
|
|
4486
|
+
return client.rest.post(Routes21.preloadMessages(), {
|
|
3469
4487
|
body: { channels: channelIds },
|
|
3470
4488
|
auth: true
|
|
3471
4489
|
});
|
|
3472
4490
|
}
|
|
3473
4491
|
function preloadMessagesAlt(client, channelIds) {
|
|
3474
4492
|
assertChannelIdBatch("preloadMessagesAlt", channelIds);
|
|
3475
|
-
return client.rest.post(
|
|
4493
|
+
return client.rest.post(Routes21.preloadMessagesAlt(), {
|
|
3476
4494
|
body: { channels: channelIds },
|
|
3477
4495
|
auth: true
|
|
3478
4496
|
});
|
|
@@ -3480,14 +4498,14 @@ function preloadMessagesAlt(client, channelIds) {
|
|
|
3480
4498
|
async function bulkFetchMessages(client, requests, options = {}) {
|
|
3481
4499
|
validateBulkMessageFetchRequests(requests);
|
|
3482
4500
|
const wire = toBulkFetchWire(requests);
|
|
3483
|
-
const data = await client.rest.post(
|
|
4501
|
+
const data = await client.rest.post(Routes21.channelsMessagesBulk(), {
|
|
3484
4502
|
body: { requests: wire },
|
|
3485
4503
|
auth: true
|
|
3486
4504
|
});
|
|
3487
4505
|
if (options.hydrate === false) return data;
|
|
3488
4506
|
return {
|
|
3489
4507
|
channels: data.channels.map((entry) => {
|
|
3490
|
-
const collection = new
|
|
4508
|
+
const collection = new Collection8();
|
|
3491
4509
|
for (const msg of entry.messages) {
|
|
3492
4510
|
client._addMessageToCache(entry.channel_id, msg);
|
|
3493
4511
|
collection.set(msg.id, new Message(client, msg));
|
|
@@ -3496,6 +4514,13 @@ async function bulkFetchMessages(client, requests, options = {}) {
|
|
|
3496
4514
|
})
|
|
3497
4515
|
};
|
|
3498
4516
|
}
|
|
4517
|
+
async function searchMessages(client, options = {}) {
|
|
4518
|
+
const data = await client.rest.post(Routes21.searchMessages(), {
|
|
4519
|
+
body: toMessageSearchBody(options),
|
|
4520
|
+
auth: true
|
|
4521
|
+
});
|
|
4522
|
+
return toMessageSearchResponse(data);
|
|
4523
|
+
}
|
|
3499
4524
|
|
|
3500
4525
|
// src/ClientCore/ClientEvents.ts
|
|
3501
4526
|
function createEventMethods(client) {
|
|
@@ -3511,16 +4536,16 @@ function createEventMethods(client) {
|
|
|
3511
4536
|
}
|
|
3512
4537
|
|
|
3513
4538
|
// src/ClientCore/GatewayReady.ts
|
|
3514
|
-
import { WebSocketManager } from "@fluxerjs/ws";
|
|
4539
|
+
import { GatewayCloseCodes, WebSocketManager } from "@fluxerjs/ws";
|
|
3515
4540
|
|
|
3516
4541
|
// src/Domain/Guild/Guild.ts
|
|
3517
|
-
import { LimitedCollection as
|
|
4542
|
+
import { LimitedCollection as LimitedCollection4 } from "@fluxerjs/collection";
|
|
3518
4543
|
import { GuildNSFWLevel } from "@fluxerjs/types";
|
|
3519
|
-
import { SnowflakeUtil as
|
|
4544
|
+
import { SnowflakeUtil as SnowflakeUtil9 } from "@fluxerjs/util";
|
|
3520
4545
|
|
|
3521
4546
|
// src/ClientCore/GuildMemberManager.ts
|
|
3522
4547
|
import { LimitedCollection as LimitedCollection2 } from "@fluxerjs/collection";
|
|
3523
|
-
import { Routes as
|
|
4548
|
+
import { Routes as Routes22 } from "@fluxerjs/types";
|
|
3524
4549
|
var GuildMemberManager = class extends LimitedCollection2 {
|
|
3525
4550
|
constructor(guild) {
|
|
3526
4551
|
super({ maxSize: guild.client.cache.limits.members });
|
|
@@ -3537,7 +4562,7 @@ var GuildMemberManager = class extends LimitedCollection2 {
|
|
|
3537
4562
|
* console.log(member.displayName);
|
|
3538
4563
|
*/
|
|
3539
4564
|
async resolve(userId) {
|
|
3540
|
-
return this.get(userId) ?? this.
|
|
4565
|
+
return this.get(userId) ?? this.fetch(userId);
|
|
3541
4566
|
}
|
|
3542
4567
|
/**
|
|
3543
4568
|
* The current bot user as a GuildMember in this guild.
|
|
@@ -3564,17 +4589,20 @@ var GuildMemberManager = class extends LimitedCollection2 {
|
|
|
3564
4589
|
async fetchMe() {
|
|
3565
4590
|
return this.guild.fetchMe();
|
|
3566
4591
|
}
|
|
3567
|
-
|
|
3568
|
-
|
|
3569
|
-
|
|
3570
|
-
|
|
3571
|
-
|
|
3572
|
-
|
|
4592
|
+
async fetch(userIdOrOptions, options) {
|
|
4593
|
+
if (typeof userIdOrOptions === "string") {
|
|
4594
|
+
const cached = this.get(userIdOrOptions);
|
|
4595
|
+
if (cached && !options?.force) return cached;
|
|
4596
|
+
return this.guild.fetchMember(userIdOrOptions);
|
|
4597
|
+
}
|
|
4598
|
+
return this.fetchMany(userIdOrOptions);
|
|
4599
|
+
}
|
|
4600
|
+
async fetchMany(options) {
|
|
3573
4601
|
const params = new URLSearchParams();
|
|
3574
4602
|
if (options?.limit != null) params.set("limit", String(options.limit));
|
|
3575
4603
|
if (options?.after) params.set("after", options.after);
|
|
3576
4604
|
const qs2 = params.toString();
|
|
3577
|
-
const url =
|
|
4605
|
+
const url = Routes22.guildMembers(this.guild.id) + (qs2 ? `?${qs2}` : "");
|
|
3578
4606
|
const data = await this.guild.client.rest.get(url, { auth: true });
|
|
3579
4607
|
const members = [];
|
|
3580
4608
|
for (const m of data) {
|
|
@@ -3597,7 +4625,7 @@ var GuildMemberManager = class extends LimitedCollection2 {
|
|
|
3597
4625
|
*/
|
|
3598
4626
|
async search(options = {}) {
|
|
3599
4627
|
const data = await this.guild.client.rest.post(
|
|
3600
|
-
|
|
4628
|
+
Routes22.guildMembersSearch(this.guild.id),
|
|
3601
4629
|
{ body: toMemberSearchBody(options), auth: true }
|
|
3602
4630
|
);
|
|
3603
4631
|
const offset = options.offset ?? 0;
|
|
@@ -3623,7 +4651,7 @@ var GuildMemberManager = class extends LimitedCollection2 {
|
|
|
3623
4651
|
};
|
|
3624
4652
|
|
|
3625
4653
|
// src/Domain/Guild/Admin.ts
|
|
3626
|
-
import { Routes as
|
|
4654
|
+
import { Routes as Routes23 } from "@fluxerjs/types";
|
|
3627
4655
|
function toAuditLogEntryPayload(entry, guildId) {
|
|
3628
4656
|
return {
|
|
3629
4657
|
id: entry.id,
|
|
@@ -3644,7 +4672,7 @@ function toVanityPayload(data) {
|
|
|
3644
4672
|
return { code: data.code ?? null, uses: data.uses };
|
|
3645
4673
|
}
|
|
3646
4674
|
async function fetchAuditLogs(guild, options) {
|
|
3647
|
-
const url =
|
|
4675
|
+
const url = Routes23.guildAuditLogs(guild.id) + qs({
|
|
3648
4676
|
limit: options?.limit,
|
|
3649
4677
|
before: options?.before,
|
|
3650
4678
|
after: options?.after,
|
|
@@ -3668,7 +4696,7 @@ async function fetchAuditLogs(guild, options) {
|
|
|
3668
4696
|
};
|
|
3669
4697
|
}
|
|
3670
4698
|
async function editGuild(guild, options) {
|
|
3671
|
-
const data = await guild.client.rest.patch(
|
|
4699
|
+
const data = await guild.client.rest.patch(Routes23.guild(guild.id), {
|
|
3672
4700
|
body: toGuildEditBody(options),
|
|
3673
4701
|
auth: true
|
|
3674
4702
|
});
|
|
@@ -3676,13 +4704,13 @@ async function editGuild(guild, options) {
|
|
|
3676
4704
|
return guild;
|
|
3677
4705
|
}
|
|
3678
4706
|
async function fetchVanityURL(guild) {
|
|
3679
|
-
const data = await guild.client.rest.get(
|
|
4707
|
+
const data = await guild.client.rest.get(Routes23.guildVanityUrl(guild.id), {
|
|
3680
4708
|
auth: true
|
|
3681
4709
|
});
|
|
3682
4710
|
return toVanityPayload(data);
|
|
3683
4711
|
}
|
|
3684
4712
|
async function editVanityURL(guild, code) {
|
|
3685
|
-
const data = await guild.client.rest.patch(
|
|
4713
|
+
const data = await guild.client.rest.patch(Routes23.guildVanityUrl(guild.id), {
|
|
3686
4714
|
body: { code },
|
|
3687
4715
|
auth: true
|
|
3688
4716
|
});
|
|
@@ -3690,14 +4718,14 @@ async function editVanityURL(guild, code) {
|
|
|
3690
4718
|
return toVanityPayload(data);
|
|
3691
4719
|
}
|
|
3692
4720
|
async function fetchDiscoveryStatus(guild) {
|
|
3693
|
-
const data = await guild.client.rest.get(
|
|
4721
|
+
const data = await guild.client.rest.get(Routes23.guildDiscovery(guild.id), {
|
|
3694
4722
|
auth: true
|
|
3695
4723
|
});
|
|
3696
4724
|
return toDiscoveryStatusPayload(data);
|
|
3697
4725
|
}
|
|
3698
4726
|
async function applyForDiscovery(guild, options) {
|
|
3699
4727
|
const data = await guild.client.rest.post(
|
|
3700
|
-
|
|
4728
|
+
Routes23.guildDiscovery(guild.id),
|
|
3701
4729
|
{
|
|
3702
4730
|
body: toDiscoveryBody(options),
|
|
3703
4731
|
auth: true
|
|
@@ -3707,7 +4735,7 @@ async function applyForDiscovery(guild, options) {
|
|
|
3707
4735
|
}
|
|
3708
4736
|
async function editDiscoveryApplication(guild, options) {
|
|
3709
4737
|
const data = await guild.client.rest.patch(
|
|
3710
|
-
|
|
4738
|
+
Routes23.guildDiscovery(guild.id),
|
|
3711
4739
|
{
|
|
3712
4740
|
body: toDiscoveryBody(options),
|
|
3713
4741
|
auth: true
|
|
@@ -3716,34 +4744,34 @@ async function editDiscoveryApplication(guild, options) {
|
|
|
3716
4744
|
return toDiscoveryApplicationPayload(data);
|
|
3717
4745
|
}
|
|
3718
4746
|
async function withdrawDiscoveryApplication(guild) {
|
|
3719
|
-
await guild.client.rest.delete(
|
|
4747
|
+
await guild.client.rest.delete(Routes23.guildDiscovery(guild.id), { auth: true });
|
|
3720
4748
|
}
|
|
3721
4749
|
async function deleteGuild(guild, options) {
|
|
3722
4750
|
const body = options ? toSudoBody(options) : {};
|
|
3723
|
-
await guild.client.rest.post(
|
|
4751
|
+
await guild.client.rest.post(Routes23.guildDelete(guild.id), {
|
|
3724
4752
|
body,
|
|
3725
4753
|
auth: true
|
|
3726
4754
|
});
|
|
3727
4755
|
guild.client.guilds.delete(guild.id);
|
|
3728
4756
|
}
|
|
3729
4757
|
async function transferOwnership(guild, newOwnerId, password) {
|
|
3730
|
-
await guild.client.rest.post(
|
|
4758
|
+
await guild.client.rest.post(Routes23.guildTransferOwnership(guild.id), {
|
|
3731
4759
|
body: { new_owner_id: newOwnerId, ...password != null && { password } },
|
|
3732
4760
|
auth: true
|
|
3733
4761
|
});
|
|
3734
4762
|
}
|
|
3735
4763
|
|
|
3736
4764
|
// src/Domain/Guild/Channels.ts
|
|
3737
|
-
import { Routes as
|
|
3738
|
-
async function createChannel(guild,
|
|
3739
|
-
const created = await guild.client.rest.post(
|
|
3740
|
-
body:
|
|
4765
|
+
import { Routes as Routes24 } from "@fluxerjs/types";
|
|
4766
|
+
async function createChannel(guild, options) {
|
|
4767
|
+
const created = await guild.client.rest.post(Routes24.guildChannels(guild.id), {
|
|
4768
|
+
body: toChannelCreateBody(options),
|
|
3741
4769
|
auth: true
|
|
3742
4770
|
});
|
|
3743
4771
|
return cacheChannel(guild, created);
|
|
3744
4772
|
}
|
|
3745
4773
|
async function fetchChannels(guild) {
|
|
3746
|
-
const data = await guild.client.rest.get(
|
|
4774
|
+
const data = await guild.client.rest.get(Routes24.guildChannels(guild.id));
|
|
3747
4775
|
const channels = [];
|
|
3748
4776
|
for (const ch of data) {
|
|
3749
4777
|
const channel = cacheChannel(guild, ch);
|
|
@@ -3752,17 +4780,17 @@ async function fetchChannels(guild) {
|
|
|
3752
4780
|
return channels;
|
|
3753
4781
|
}
|
|
3754
4782
|
async function setChannelPositions(guild, updates) {
|
|
3755
|
-
await guild.client.rest.patch(
|
|
4783
|
+
await guild.client.rest.patch(Routes24.guildChannels(guild.id), {
|
|
3756
4784
|
body: toChannelPositionBody(updates),
|
|
3757
4785
|
auth: true
|
|
3758
4786
|
});
|
|
3759
4787
|
}
|
|
3760
4788
|
async function fetchWebhooks(guild) {
|
|
3761
|
-
const data = await guild.client.rest.get(
|
|
4789
|
+
const data = await guild.client.rest.get(Routes24.guildWebhooks(guild.id));
|
|
3762
4790
|
return data.map((w) => new Webhook(guild.client, w));
|
|
3763
4791
|
}
|
|
3764
4792
|
async function fetchInvites(guild) {
|
|
3765
|
-
const data = await guild.client.rest.get(
|
|
4793
|
+
const data = await guild.client.rest.get(Routes24.guildInvites(guild.id));
|
|
3766
4794
|
return data.map((invite) => new Invite(guild.client, invite));
|
|
3767
4795
|
}
|
|
3768
4796
|
async function fetchInvite(guild, codeOrUrl) {
|
|
@@ -3782,14 +4810,14 @@ function resolveGuildOnlineCount(data) {
|
|
|
3782
4810
|
}
|
|
3783
4811
|
|
|
3784
4812
|
// src/Domain/Guild/Emojis.ts
|
|
3785
|
-
import { Routes as
|
|
4813
|
+
import { Routes as Routes25 } from "@fluxerjs/types";
|
|
3786
4814
|
async function fetchEmojis(guild) {
|
|
3787
|
-
const data = await guild.client.rest.get(
|
|
4815
|
+
const data = await guild.client.rest.get(Routes25.guildEmojis(guild.id));
|
|
3788
4816
|
return data.map((e) => cacheEmoji(guild, e));
|
|
3789
4817
|
}
|
|
3790
4818
|
async function fetchEmoji(guild, emojiId) {
|
|
3791
4819
|
try {
|
|
3792
|
-
const data = await guild.client.rest.get(
|
|
4820
|
+
const data = await guild.client.rest.get(Routes25.guildEmoji(guild.id, emojiId));
|
|
3793
4821
|
return cacheEmoji(guild, data);
|
|
3794
4822
|
} catch (err) {
|
|
3795
4823
|
rethrowMapped(err, {
|
|
@@ -3799,14 +4827,16 @@ async function fetchEmoji(guild, emojiId) {
|
|
|
3799
4827
|
}
|
|
3800
4828
|
}
|
|
3801
4829
|
async function createEmoji(guild, options) {
|
|
3802
|
-
const
|
|
3803
|
-
|
|
3804
|
-
|
|
4830
|
+
const { reason, ...body } = options;
|
|
4831
|
+
const data = await guild.client.rest.post(Routes25.guildEmojis(guild.id), {
|
|
4832
|
+
body,
|
|
4833
|
+
auth: true,
|
|
4834
|
+
...auditReasonHeaders(reason)
|
|
3805
4835
|
});
|
|
3806
4836
|
return cacheEmoji(guild, data);
|
|
3807
4837
|
}
|
|
3808
4838
|
async function cloneEmoji(guild, sourceEmojiId) {
|
|
3809
|
-
const data = await guild.client.rest.post(
|
|
4839
|
+
const data = await guild.client.rest.post(Routes25.guildEmojisClone(guild.id), {
|
|
3810
4840
|
body: { source_emoji_id: sourceEmojiId },
|
|
3811
4841
|
auth: true
|
|
3812
4842
|
});
|
|
@@ -3814,18 +4844,31 @@ async function cloneEmoji(guild, sourceEmojiId) {
|
|
|
3814
4844
|
}
|
|
3815
4845
|
async function createEmojisBulk(guild, emojis) {
|
|
3816
4846
|
const data = await guild.client.rest.post(
|
|
3817
|
-
|
|
4847
|
+
Routes25.guildEmojisBulk(guild.id),
|
|
3818
4848
|
{ body: { emojis }, auth: true }
|
|
3819
4849
|
);
|
|
3820
4850
|
return { success: data.success.map((e) => cacheEmoji(guild, e)), failed: data.failed };
|
|
3821
4851
|
}
|
|
3822
4852
|
|
|
4853
|
+
// src/Domain/Guild/GuildRoleManager.ts
|
|
4854
|
+
import { LimitedCollection as LimitedCollection3 } from "@fluxerjs/collection";
|
|
4855
|
+
var GuildRoleManager = class extends LimitedCollection3 {
|
|
4856
|
+
constructor(guildId, options) {
|
|
4857
|
+
super(options);
|
|
4858
|
+
this.guildId = guildId;
|
|
4859
|
+
}
|
|
4860
|
+
/** The @everyone role (`id === guild.id`), or undefined if uncached. */
|
|
4861
|
+
get everyone() {
|
|
4862
|
+
return this.get(this.guildId);
|
|
4863
|
+
}
|
|
4864
|
+
};
|
|
4865
|
+
|
|
3823
4866
|
// src/Domain/Guild/MemberHttp.ts
|
|
3824
|
-
import { Routes as
|
|
4867
|
+
import { Routes as Routes26 } from "@fluxerjs/types";
|
|
3825
4868
|
async function fetchMember(guild, userId) {
|
|
3826
4869
|
try {
|
|
3827
4870
|
const data = await guild.client.rest.get(
|
|
3828
|
-
|
|
4871
|
+
Routes26.guildMember(guild.id, userId)
|
|
3829
4872
|
);
|
|
3830
4873
|
return cacheMember(guild, data);
|
|
3831
4874
|
} catch (err) {
|
|
@@ -3840,23 +4883,28 @@ async function fetchMember(guild, userId) {
|
|
|
3840
4883
|
}
|
|
3841
4884
|
async function fetchMe(guild) {
|
|
3842
4885
|
const data = await guild.client.rest.get(
|
|
3843
|
-
|
|
4886
|
+
Routes26.guildMemberMe(guild.id),
|
|
3844
4887
|
{ auth: true }
|
|
3845
4888
|
);
|
|
3846
4889
|
return cacheMember(guild, data);
|
|
3847
4890
|
}
|
|
3848
4891
|
|
|
3849
4892
|
// src/Domain/Guild/Moderation.ts
|
|
3850
|
-
import { Routes as
|
|
4893
|
+
import { Routes as Routes28 } from "@fluxerjs/types";
|
|
3851
4894
|
|
|
3852
4895
|
// src/Domain/Guild/GuildBan.ts
|
|
3853
|
-
import { Routes as
|
|
4896
|
+
import { Routes as Routes27 } from "@fluxerjs/types";
|
|
4897
|
+
function parseOptionalDate2(value) {
|
|
4898
|
+
if (value == null || value === "") return null;
|
|
4899
|
+
const date = new Date(value);
|
|
4900
|
+
return Number.isNaN(date.getTime()) ? null : date;
|
|
4901
|
+
}
|
|
3854
4902
|
var GuildBan = class extends Base {
|
|
3855
4903
|
client;
|
|
3856
4904
|
guildId;
|
|
3857
4905
|
user;
|
|
3858
4906
|
reason;
|
|
3859
|
-
/**
|
|
4907
|
+
/** When a temporary ban expires. Null for permanent bans. */
|
|
3860
4908
|
expiresAt;
|
|
3861
4909
|
/** @param data - API ban from GET /guilds/{id}/bans or gateway GUILD_BAN_ADD */
|
|
3862
4910
|
constructor(client, data, guildId) {
|
|
@@ -3865,15 +4913,16 @@ var GuildBan = class extends Base {
|
|
|
3865
4913
|
this.guildId = data.guild_id ?? guildId;
|
|
3866
4914
|
this.user = client.getOrCreateUser(data.user);
|
|
3867
4915
|
this.reason = data.reason ?? null;
|
|
3868
|
-
this.expiresAt = data.expires_at
|
|
4916
|
+
this.expiresAt = parseOptionalDate2(data.expires_at);
|
|
3869
4917
|
}
|
|
3870
4918
|
/**
|
|
3871
4919
|
* Remove this ban (unban the user).
|
|
3872
4920
|
* Requires Ban Members permission.
|
|
3873
4921
|
*/
|
|
3874
|
-
async unban() {
|
|
3875
|
-
await this.client.rest.delete(
|
|
3876
|
-
auth: true
|
|
4922
|
+
async unban(reason) {
|
|
4923
|
+
await this.client.rest.delete(Routes27.guildBan(this.guildId, this.user.id), {
|
|
4924
|
+
auth: true,
|
|
4925
|
+
...auditReasonHeaders(reason)
|
|
3877
4926
|
});
|
|
3878
4927
|
}
|
|
3879
4928
|
};
|
|
@@ -3881,40 +4930,48 @@ var GuildBan = class extends Base {
|
|
|
3881
4930
|
// src/Domain/Guild/Moderation.ts
|
|
3882
4931
|
async function ban(guild, userId, options) {
|
|
3883
4932
|
const body = options ? toGuildBanBody(options) : {};
|
|
3884
|
-
await guild.client.rest.put(
|
|
4933
|
+
await guild.client.rest.put(Routes28.guildBan(guild.id, userId), {
|
|
3885
4934
|
body: Object.keys(body).length ? body : void 0,
|
|
3886
|
-
auth: true
|
|
4935
|
+
auth: true,
|
|
4936
|
+
...auditReasonHeaders(options?.reason)
|
|
3887
4937
|
});
|
|
3888
4938
|
}
|
|
3889
4939
|
async function fetchBans(guild) {
|
|
3890
|
-
const data = await guild.client.rest.get(
|
|
4940
|
+
const data = await guild.client.rest.get(Routes28.guildBans(guild.id));
|
|
3891
4941
|
return data.map((b) => new GuildBan(guild.client, { ...b, guild_id: guild.id }, guild.id));
|
|
3892
4942
|
}
|
|
3893
|
-
async function unban(guild, userId) {
|
|
3894
|
-
await guild.client.rest.delete(
|
|
4943
|
+
async function unban(guild, userId, reason) {
|
|
4944
|
+
await guild.client.rest.delete(Routes28.guildBan(guild.id, userId), {
|
|
4945
|
+
auth: true,
|
|
4946
|
+
...auditReasonHeaders(reason)
|
|
4947
|
+
});
|
|
3895
4948
|
}
|
|
3896
|
-
async function kick(guild, userId) {
|
|
3897
|
-
await guild.client.rest.delete(
|
|
4949
|
+
async function kick(guild, userId, reason) {
|
|
4950
|
+
await guild.client.rest.delete(Routes28.guildMember(guild.id, userId), {
|
|
4951
|
+
auth: true,
|
|
4952
|
+
...auditReasonHeaders(reason)
|
|
4953
|
+
});
|
|
3898
4954
|
}
|
|
3899
4955
|
|
|
3900
4956
|
// src/Domain/Guild/Roles.ts
|
|
3901
|
-
import { Routes as
|
|
4957
|
+
import { Routes as Routes29 } from "@fluxerjs/types";
|
|
3902
4958
|
import { parseRoleMention } from "@fluxerjs/util";
|
|
3903
4959
|
async function createRole(guild, options = {}) {
|
|
3904
|
-
const body =
|
|
3905
|
-
const data = await guild.client.rest.post(
|
|
4960
|
+
const body = toRoleCreateBody(options);
|
|
4961
|
+
const data = await guild.client.rest.post(Routes29.guildRoles(guild.id), {
|
|
3906
4962
|
body: Object.keys(body).length ? body : void 0,
|
|
3907
|
-
auth: true
|
|
4963
|
+
auth: true,
|
|
4964
|
+
...auditReasonHeaders(options.reason)
|
|
3908
4965
|
});
|
|
3909
4966
|
return cacheRole(guild, data);
|
|
3910
4967
|
}
|
|
3911
4968
|
async function fetchRoles(guild) {
|
|
3912
|
-
const data = await guild.client.rest.get(
|
|
4969
|
+
const data = await guild.client.rest.get(Routes29.guildRoles(guild.id));
|
|
3913
4970
|
return data.map((r) => cacheRole(guild, r));
|
|
3914
4971
|
}
|
|
3915
4972
|
async function fetchRole(guild, roleId2) {
|
|
3916
4973
|
try {
|
|
3917
|
-
const data = await guild.client.rest.get(
|
|
4974
|
+
const data = await guild.client.rest.get(Routes29.guildRole(guild.id, roleId2));
|
|
3918
4975
|
return cacheRole(guild, data);
|
|
3919
4976
|
} catch (err) {
|
|
3920
4977
|
rethrowMapped(err, {
|
|
@@ -3931,7 +4988,7 @@ async function resolveRoleId(guild, arg) {
|
|
|
3931
4988
|
const needle = trimmed.toLowerCase();
|
|
3932
4989
|
const cached = guild.roles.find((r) => r.name?.toLowerCase() === needle);
|
|
3933
4990
|
if (cached) return cached.id;
|
|
3934
|
-
const roles = await guild.client.rest.get(
|
|
4991
|
+
const roles = await guild.client.rest.get(Routes29.guildRoles(guild.id));
|
|
3935
4992
|
const role = roles.find((r) => r.name?.toLowerCase() === needle);
|
|
3936
4993
|
if (!role) return null;
|
|
3937
4994
|
cacheRole(guild, role);
|
|
@@ -3940,7 +4997,7 @@ async function resolveRoleId(guild, arg) {
|
|
|
3940
4997
|
async function setRolePositions(guild, updates) {
|
|
3941
4998
|
return replaceRoles(
|
|
3942
4999
|
guild,
|
|
3943
|
-
await guild.client.rest.patch(
|
|
5000
|
+
await guild.client.rest.patch(Routes29.guildRoles(guild.id), {
|
|
3944
5001
|
body: updates,
|
|
3945
5002
|
auth: true
|
|
3946
5003
|
})
|
|
@@ -3949,7 +5006,7 @@ async function setRolePositions(guild, updates) {
|
|
|
3949
5006
|
async function setRoleHoistPositions(guild, updates) {
|
|
3950
5007
|
return replaceRoles(
|
|
3951
5008
|
guild,
|
|
3952
|
-
await guild.client.rest.patch(
|
|
5009
|
+
await guild.client.rest.patch(Routes29.guildRolesHoistPositions(guild.id), {
|
|
3953
5010
|
body: updates.map((u) => ({
|
|
3954
5011
|
id: u.id,
|
|
3955
5012
|
...u.hoistPosition !== void 0 ? { hoist_position: u.hoistPosition } : {}
|
|
@@ -3961,23 +5018,25 @@ async function setRoleHoistPositions(guild, updates) {
|
|
|
3961
5018
|
async function resetRoleHoistPositions(guild) {
|
|
3962
5019
|
return replaceRoles(
|
|
3963
5020
|
guild,
|
|
3964
|
-
await guild.client.rest.delete(
|
|
5021
|
+
await guild.client.rest.delete(Routes29.guildRolesHoistPositions(guild.id), {
|
|
3965
5022
|
auth: true
|
|
3966
5023
|
})
|
|
3967
5024
|
);
|
|
3968
5025
|
}
|
|
3969
5026
|
|
|
3970
5027
|
// src/Domain/Guild/Stickers.ts
|
|
3971
|
-
import { Routes as
|
|
5028
|
+
import { Routes as Routes30 } from "@fluxerjs/types";
|
|
3972
5029
|
async function createSticker(guild, options) {
|
|
3973
|
-
const
|
|
3974
|
-
|
|
3975
|
-
|
|
5030
|
+
const { reason, ...body } = options;
|
|
5031
|
+
const data = await guild.client.rest.post(Routes30.guildStickers(guild.id), {
|
|
5032
|
+
body,
|
|
5033
|
+
auth: true,
|
|
5034
|
+
...auditReasonHeaders(reason)
|
|
3976
5035
|
});
|
|
3977
5036
|
return cacheSticker(guild, data);
|
|
3978
5037
|
}
|
|
3979
5038
|
async function cloneSticker(guild, sourceStickerId) {
|
|
3980
|
-
const data = await guild.client.rest.post(
|
|
5039
|
+
const data = await guild.client.rest.post(Routes30.guildStickersClone(guild.id), {
|
|
3981
5040
|
body: { source_sticker_id: sourceStickerId },
|
|
3982
5041
|
auth: true
|
|
3983
5042
|
});
|
|
@@ -3985,17 +5044,17 @@ async function cloneSticker(guild, sourceStickerId) {
|
|
|
3985
5044
|
}
|
|
3986
5045
|
async function createStickersBulk(guild, stickers) {
|
|
3987
5046
|
const data = await guild.client.rest.post(
|
|
3988
|
-
|
|
5047
|
+
Routes30.guildStickersBulk(guild.id),
|
|
3989
5048
|
{ body: { stickers }, auth: true }
|
|
3990
5049
|
);
|
|
3991
5050
|
return { success: data.success.map((s) => cacheSticker(guild, s)), failed: data.failed };
|
|
3992
5051
|
}
|
|
3993
5052
|
async function fetchStickers(guild) {
|
|
3994
|
-
const data = await guild.client.rest.get(
|
|
5053
|
+
const data = await guild.client.rest.get(Routes30.guildStickers(guild.id));
|
|
3995
5054
|
return data.map((s) => cacheSticker(guild, s));
|
|
3996
5055
|
}
|
|
3997
5056
|
async function fetchSticker(guild, stickerId) {
|
|
3998
|
-
const data = await guild.client.rest.get(
|
|
5057
|
+
const data = await guild.client.rest.get(Routes30.guildSticker(guild.id, stickerId));
|
|
3999
5058
|
return cacheSticker(guild, data);
|
|
4000
5059
|
}
|
|
4001
5060
|
|
|
@@ -4035,8 +5094,26 @@ var Guild = class extends Base {
|
|
|
4035
5094
|
systemChannelId;
|
|
4036
5095
|
/** Rules channel ID (for Community guilds), or null if none. */
|
|
4037
5096
|
rulesChannelId;
|
|
5097
|
+
/** {@link SystemChannelFlags} bitfield. */
|
|
5098
|
+
systemChannelFlags;
|
|
5099
|
+
/** Splash card alignment. */
|
|
5100
|
+
splashCardAlignment;
|
|
5101
|
+
/** Embed splash hash. */
|
|
5102
|
+
embedSplash;
|
|
4038
5103
|
/** NSFW level for this guild. */
|
|
4039
5104
|
nsfwLevel;
|
|
5105
|
+
/** Whether the guild is marked as adult (18+) content. */
|
|
5106
|
+
nsfw;
|
|
5107
|
+
/** Content warning level. */
|
|
5108
|
+
contentWarningLevel;
|
|
5109
|
+
/** Custom guild-wide content warning text. */
|
|
5110
|
+
contentWarningText;
|
|
5111
|
+
/** {@link GuildOperations} bitfield of disabled operations. */
|
|
5112
|
+
disabledOperations;
|
|
5113
|
+
/** ISO-8601 timestamp before which message history is not available. */
|
|
5114
|
+
messageHistoryCutoff;
|
|
5115
|
+
/** Permissions for the current member in this guild (bitfield string). */
|
|
5116
|
+
permissions;
|
|
4040
5117
|
/** MFA level required for moderation actions. */
|
|
4041
5118
|
mfaLevel;
|
|
4042
5119
|
/** Banner width in pixels. */
|
|
@@ -4070,13 +5147,13 @@ var Guild = class extends Base {
|
|
|
4070
5147
|
this.client = client;
|
|
4071
5148
|
this.id = data.id;
|
|
4072
5149
|
this.members = new GuildMemberManager(this);
|
|
4073
|
-
this.channels = new
|
|
5150
|
+
this.channels = new LimitedCollection4({
|
|
4074
5151
|
maxSize: Number.POSITIVE_INFINITY,
|
|
4075
5152
|
onEvict: (_id, channel) => client.cache.cascadeChannel(channel, "guild")
|
|
4076
5153
|
});
|
|
4077
|
-
this.roles = new
|
|
4078
|
-
this.emojis = new
|
|
4079
|
-
this.stickers = new
|
|
5154
|
+
this.roles = new GuildRoleManager(this.id, { maxSize: client.cache.limits.roles });
|
|
5155
|
+
this.emojis = new LimitedCollection4({ maxSize: client.cache.limits.emojis });
|
|
5156
|
+
this.stickers = new LimitedCollection4({ maxSize: client.cache.limits.stickers });
|
|
4080
5157
|
this.name = data.name ?? "";
|
|
4081
5158
|
this.icon = data.icon ?? null;
|
|
4082
5159
|
this.banner = data.banner ?? null;
|
|
@@ -4091,7 +5168,16 @@ var Guild = class extends Base {
|
|
|
4091
5168
|
this.afkTimeout = data.afk_timeout ?? 0;
|
|
4092
5169
|
this.systemChannelId = data.system_channel_id ?? null;
|
|
4093
5170
|
this.rulesChannelId = data.rules_channel_id ?? null;
|
|
5171
|
+
this.systemChannelFlags = data.system_channel_flags ?? 0;
|
|
5172
|
+
this.splashCardAlignment = data.splash_card_alignment ?? 0;
|
|
5173
|
+
this.embedSplash = data.embed_splash ?? null;
|
|
4094
5174
|
this.nsfwLevel = data.nsfw_level ?? GuildNSFWLevel.Safe;
|
|
5175
|
+
this.nsfw = data.nsfw ?? false;
|
|
5176
|
+
this.contentWarningLevel = data.content_warning_level ?? 0;
|
|
5177
|
+
this.contentWarningText = data.content_warning_text ?? null;
|
|
5178
|
+
this.disabledOperations = data.disabled_operations ?? 0;
|
|
5179
|
+
this.messageHistoryCutoff = data.message_history_cutoff ?? null;
|
|
5180
|
+
this.permissions = data.permissions ?? null;
|
|
4095
5181
|
this.mfaLevel = data.mfa_level ?? 0;
|
|
4096
5182
|
this.bannerWidth = data.banner_width ?? null;
|
|
4097
5183
|
this.bannerHeight = data.banner_height ?? null;
|
|
@@ -4126,7 +5212,28 @@ var Guild = class extends Base {
|
|
|
4126
5212
|
if (data.afk_timeout !== void 0) this.afkTimeout = data.afk_timeout ?? 0;
|
|
4127
5213
|
if (data.system_channel_id !== void 0) this.systemChannelId = data.system_channel_id ?? null;
|
|
4128
5214
|
if (data.rules_channel_id !== void 0) this.rulesChannelId = data.rules_channel_id ?? null;
|
|
5215
|
+
if (data.system_channel_flags !== void 0) {
|
|
5216
|
+
this.systemChannelFlags = data.system_channel_flags ?? 0;
|
|
5217
|
+
}
|
|
5218
|
+
if (data.splash_card_alignment !== void 0) {
|
|
5219
|
+
this.splashCardAlignment = data.splash_card_alignment ?? 0;
|
|
5220
|
+
}
|
|
5221
|
+
if (data.embed_splash !== void 0) this.embedSplash = data.embed_splash ?? null;
|
|
4129
5222
|
if (data.nsfw_level !== void 0) this.nsfwLevel = data.nsfw_level ?? GuildNSFWLevel.Safe;
|
|
5223
|
+
if (data.nsfw !== void 0) this.nsfw = data.nsfw ?? false;
|
|
5224
|
+
if (data.content_warning_level !== void 0) {
|
|
5225
|
+
this.contentWarningLevel = data.content_warning_level ?? 0;
|
|
5226
|
+
}
|
|
5227
|
+
if (data.content_warning_text !== void 0) {
|
|
5228
|
+
this.contentWarningText = data.content_warning_text ?? null;
|
|
5229
|
+
}
|
|
5230
|
+
if (data.disabled_operations !== void 0) {
|
|
5231
|
+
this.disabledOperations = data.disabled_operations ?? 0;
|
|
5232
|
+
}
|
|
5233
|
+
if (data.message_history_cutoff !== void 0) {
|
|
5234
|
+
this.messageHistoryCutoff = data.message_history_cutoff ?? null;
|
|
5235
|
+
}
|
|
5236
|
+
if (data.permissions !== void 0) this.permissions = data.permissions ?? null;
|
|
4130
5237
|
if (data.mfa_level !== void 0) this.mfaLevel = data.mfa_level ?? 0;
|
|
4131
5238
|
if (data.banner_width !== void 0) this.bannerWidth = data.banner_width ?? null;
|
|
4132
5239
|
if (data.banner_height !== void 0) this.bannerHeight = data.banner_height ?? null;
|
|
@@ -4147,11 +5254,11 @@ var Guild = class extends Base {
|
|
|
4147
5254
|
}
|
|
4148
5255
|
/** Unix timestamp (ms) when this guild was created, derived from its snowflake ID. */
|
|
4149
5256
|
get createdTimestamp() {
|
|
4150
|
-
return
|
|
5257
|
+
return SnowflakeUtil9.timestampFromSnowflake(this.id);
|
|
4151
5258
|
}
|
|
4152
5259
|
/** Date when this guild was created, derived from its snowflake ID. */
|
|
4153
5260
|
get createdAt() {
|
|
4154
|
-
return
|
|
5261
|
+
return SnowflakeUtil9.dateFromSnowflake(this.id);
|
|
4155
5262
|
}
|
|
4156
5263
|
/** The guild's name. */
|
|
4157
5264
|
toString() {
|
|
@@ -4179,11 +5286,11 @@ var Guild = class extends Base {
|
|
|
4179
5286
|
});
|
|
4180
5287
|
}
|
|
4181
5288
|
/**
|
|
4182
|
-
* Create a channel. `
|
|
5289
|
+
* Create a channel. `type`: 0=text, 2=voice, 4=category, 998=link (set `url`).
|
|
4183
5290
|
* Requires Manage Channels.
|
|
4184
5291
|
*/
|
|
4185
|
-
createChannel(
|
|
4186
|
-
return createChannel(this,
|
|
5292
|
+
createChannel(options) {
|
|
5293
|
+
return createChannel(this, options);
|
|
4187
5294
|
}
|
|
4188
5295
|
/** Fetch all channels in this guild from the API. */
|
|
4189
5296
|
fetchChannels() {
|
|
@@ -4245,7 +5352,7 @@ var Guild = class extends Base {
|
|
|
4245
5352
|
resetRoleHoistPositions() {
|
|
4246
5353
|
return resetRoleHoistPositions(this);
|
|
4247
5354
|
}
|
|
4248
|
-
/** Ban a user from the guild. Requires Ban Members. `
|
|
5355
|
+
/** Ban a user from the guild. Requires Ban Members. `banDurationSeconds`: 0 = permanent. */
|
|
4249
5356
|
ban(userId, options) {
|
|
4250
5357
|
return ban(this, userId, options);
|
|
4251
5358
|
}
|
|
@@ -4254,12 +5361,12 @@ var Guild = class extends Base {
|
|
|
4254
5361
|
return fetchBans(this);
|
|
4255
5362
|
}
|
|
4256
5363
|
/** Unban a user from the guild. Requires Ban Members. */
|
|
4257
|
-
unban(userId) {
|
|
4258
|
-
return unban(this, userId);
|
|
5364
|
+
unban(userId, reason) {
|
|
5365
|
+
return unban(this, userId, reason);
|
|
4259
5366
|
}
|
|
4260
5367
|
/** Kick a user from the guild. Requires Kick Members. */
|
|
4261
|
-
kick(userId) {
|
|
4262
|
-
return kick(this, userId);
|
|
5368
|
+
kick(userId, reason) {
|
|
5369
|
+
return kick(this, userId, reason);
|
|
4263
5370
|
}
|
|
4264
5371
|
/** Fetch all emojis in this guild from the API. */
|
|
4265
5372
|
fetchEmojis() {
|
|
@@ -4445,23 +5552,23 @@ function applyGuildSnapshotFromGateway(client, raw) {
|
|
|
4445
5552
|
}
|
|
4446
5553
|
|
|
4447
5554
|
// src/ClientCore/ClientUser.ts
|
|
4448
|
-
import { GatewayOpcodes, Routes as
|
|
5555
|
+
import { GatewayOpcodes, Routes as Routes31 } from "@fluxerjs/types";
|
|
4449
5556
|
var ClientUser = class extends User {
|
|
4450
5557
|
/** Broadcast presence (gateway opcode 3) on all shards. */
|
|
4451
5558
|
setPresence(presence) {
|
|
5559
|
+
this.client.options.presence = presence;
|
|
4452
5560
|
const wire = toPresenceWire(presence);
|
|
4453
|
-
this.client.options.presence = wire;
|
|
4454
5561
|
this.client._sendToAllShards({ op: GatewayOpcodes.PresenceUpdate, d: wire });
|
|
4455
5562
|
}
|
|
4456
5563
|
/** GET /users/@me — refresh the logged-in user from REST and patch this instance. */
|
|
4457
5564
|
async fetch() {
|
|
4458
|
-
const data = await this.client.rest.get(
|
|
5565
|
+
const data = await this.client.rest.get(Routes31.currentUser(), { auth: true });
|
|
4459
5566
|
this._patch(data);
|
|
4460
5567
|
return this;
|
|
4461
5568
|
}
|
|
4462
5569
|
/** GET /users/@me/guilds — returns camelCase partial guilds. */
|
|
4463
5570
|
async fetchGuilds(options) {
|
|
4464
|
-
const path =
|
|
5571
|
+
const path = Routes31.currentUserGuilds() + (options?.withCounts ? "?with_counts=true" : "");
|
|
4465
5572
|
const data = await this.client.rest.get(path, { auth: true });
|
|
4466
5573
|
return data.map((g) => ({
|
|
4467
5574
|
id: g.id,
|
|
@@ -4474,10 +5581,18 @@ var ClientUser = class extends User {
|
|
|
4474
5581
|
...g.approximate_presence_count !== void 0 ? { approximatePresenceCount: g.approximate_presence_count } : {}
|
|
4475
5582
|
}));
|
|
4476
5583
|
}
|
|
4477
|
-
/**
|
|
5584
|
+
/**
|
|
5585
|
+
* Leave a guild (`client.user.leaveGuild`).
|
|
5586
|
+
* DELETE /users/@me/guilds/{guild_id}.
|
|
5587
|
+
*
|
|
5588
|
+
* @param guildId - Guild to leave
|
|
5589
|
+
* @param options - Optional sudo / MFA body for user accounts
|
|
5590
|
+
* @example
|
|
5591
|
+
* await client.user.leaveGuild(guildId);
|
|
5592
|
+
*/
|
|
4478
5593
|
async leaveGuild(guildId, options) {
|
|
4479
5594
|
const body = options ? toSudoBody(options) : void 0;
|
|
4480
|
-
await this.client.rest.delete(
|
|
5595
|
+
await this.client.rest.delete(Routes31.leaveGuild(guildId), {
|
|
4481
5596
|
body: body && Object.keys(body).length ? body : void 0,
|
|
4482
5597
|
auth: true
|
|
4483
5598
|
});
|
|
@@ -4485,7 +5600,7 @@ var ClientUser = class extends User {
|
|
|
4485
5600
|
/** Delete every message authored by the caller across a guild (sudo). */
|
|
4486
5601
|
async bulkDeleteMyMessagesInGuild(guildId, options) {
|
|
4487
5602
|
const body = options ? toSudoBody(options) : void 0;
|
|
4488
|
-
await this.client.rest.post(
|
|
5603
|
+
await this.client.rest.post(Routes31.guildBulkDeleteMine(guildId), {
|
|
4489
5604
|
body: body && Object.keys(body).length ? body : void 0,
|
|
4490
5605
|
auth: true
|
|
4491
5606
|
});
|
|
@@ -4652,7 +5767,7 @@ var guildResourceHandlers = {
|
|
|
4652
5767
|
role = new Role(client, data.role, data.guild_id);
|
|
4653
5768
|
guild?.roles.set(role.id, role);
|
|
4654
5769
|
}
|
|
4655
|
-
client.emit(Events.GuildRoleUpdate,
|
|
5770
|
+
client.emit(Events.GuildRoleUpdate, oldRole, role);
|
|
4656
5771
|
},
|
|
4657
5772
|
GUILD_ROLE_UPDATE_BULK(client, d) {
|
|
4658
5773
|
const data = d;
|
|
@@ -4668,11 +5783,7 @@ var guildResourceHandlers = {
|
|
|
4668
5783
|
const guild = client.guilds.get(data.guild_id);
|
|
4669
5784
|
const role = guild?.roles.get(data.role_id) ?? null;
|
|
4670
5785
|
guild?.roles.delete(data.role_id);
|
|
4671
|
-
client.emit(Events.GuildRoleDelete,
|
|
4672
|
-
roleId: data.role_id,
|
|
4673
|
-
guildId: data.guild_id,
|
|
4674
|
-
role
|
|
4675
|
-
});
|
|
5786
|
+
client.emit(Events.GuildRoleDelete, role, data.guild_id, data.role_id);
|
|
4676
5787
|
},
|
|
4677
5788
|
GUILD_BAN_ADD(client, d) {
|
|
4678
5789
|
const data = d;
|
|
@@ -4705,7 +5816,14 @@ function markGuildUnavailable(client, id) {
|
|
|
4705
5816
|
guild.available = false;
|
|
4706
5817
|
client.emit(Events.GuildUnavailable, guild);
|
|
4707
5818
|
}
|
|
5819
|
+
function isStartupGuildHydration(client) {
|
|
5820
|
+
return client._guildStreamSettleTimeout !== null;
|
|
5821
|
+
}
|
|
4708
5822
|
var guildHandlers = {
|
|
5823
|
+
/**
|
|
5824
|
+
* Available snapshots: {@link Events.GuildAvailable} for READY stubs / outage recovery,
|
|
5825
|
+
* {@link Events.GuildCreate} for real joins (unless {@link ClientOptions.emitGuildCreateOnStartup}).
|
|
5826
|
+
*/
|
|
4709
5827
|
GUILD_CREATE(client, d) {
|
|
4710
5828
|
const raw = d;
|
|
4711
5829
|
if (raw.unavailable === true) {
|
|
@@ -4718,11 +5836,32 @@ var guildHandlers = {
|
|
|
4718
5836
|
}
|
|
4719
5837
|
return;
|
|
4720
5838
|
}
|
|
5839
|
+
const startupHydration = isStartupGuildHydration(client);
|
|
5840
|
+
if (startupHydration) {
|
|
5841
|
+
resetGuildStreamSettle(client);
|
|
5842
|
+
}
|
|
4721
5843
|
const result = applyGuildSnapshotFromGateway(client, d);
|
|
4722
5844
|
if (!result) return;
|
|
4723
5845
|
const { guild, recovered } = result;
|
|
4724
|
-
|
|
4725
|
-
|
|
5846
|
+
const legacyStartup = client.options.emitGuildCreateOnStartup === true;
|
|
5847
|
+
const wasReadyStub = client._readyStubGuildIds.delete(guild.id);
|
|
5848
|
+
const isStartupBackfill = wasReadyStub || startupHydration;
|
|
5849
|
+
if (recovered) {
|
|
5850
|
+
guild.available = true;
|
|
5851
|
+
if (legacyStartup && isStartupBackfill) {
|
|
5852
|
+
client.emit(Events.GuildCreate, guild);
|
|
5853
|
+
} else {
|
|
5854
|
+
client.emit(Events.GuildAvailable, guild);
|
|
5855
|
+
}
|
|
5856
|
+
} else if (startupHydration) {
|
|
5857
|
+
if (legacyStartup) {
|
|
5858
|
+
client.emit(Events.GuildCreate, guild);
|
|
5859
|
+
} else {
|
|
5860
|
+
client.emit(Events.GuildAvailable, guild);
|
|
5861
|
+
}
|
|
5862
|
+
} else {
|
|
5863
|
+
client.emit(Events.GuildCreate, guild);
|
|
5864
|
+
}
|
|
4726
5865
|
client._onGuildReceived(guild.id);
|
|
4727
5866
|
},
|
|
4728
5867
|
GUILD_UPDATE(client, d) {
|
|
@@ -4761,6 +5900,7 @@ var guildHandlers = {
|
|
|
4761
5900
|
markGuildUnavailable(client, id);
|
|
4762
5901
|
return;
|
|
4763
5902
|
}
|
|
5903
|
+
client._readyStubGuildIds.delete(id);
|
|
4764
5904
|
const guild = client.guilds.get(id);
|
|
4765
5905
|
if (!guild) return;
|
|
4766
5906
|
client.guilds.delete(id);
|
|
@@ -4781,7 +5921,7 @@ function normalizeInviteCreate(client, payload) {
|
|
|
4781
5921
|
const code = str(raw?.code);
|
|
4782
5922
|
if (!raw || !code) return null;
|
|
4783
5923
|
const typeNum = num(raw.type);
|
|
4784
|
-
const type = typeNum === InviteType2.GroupDM
|
|
5924
|
+
const type = typeNum === InviteType2.GroupDM ? InviteType2.GroupDM : InviteType2.Guild;
|
|
4785
5925
|
const shared = {
|
|
4786
5926
|
code,
|
|
4787
5927
|
inviter: raw.inviter ?? null,
|
|
@@ -4793,11 +5933,6 @@ function normalizeInviteCreate(client, payload) {
|
|
|
4793
5933
|
max_uses: num(raw.max_uses),
|
|
4794
5934
|
max_age: num(raw.max_age)
|
|
4795
5935
|
};
|
|
4796
|
-
if (type === InviteType2.EmojiPack || type === InviteType2.StickerPack) {
|
|
4797
|
-
const pack = asRecord(raw.pack);
|
|
4798
|
-
if (!pack || !str(pack.id) || !str(pack.name)) return null;
|
|
4799
|
-
return { ...shared, type, pack };
|
|
4800
|
-
}
|
|
4801
5936
|
const guildObj = asRecord(raw.guild);
|
|
4802
5937
|
const channelObj = asRecord(raw.channel);
|
|
4803
5938
|
const guildId = str(guildObj?.id) ?? str(raw.guild_id) ?? "0";
|
|
@@ -4849,6 +5984,30 @@ var inviteHandlers = {
|
|
|
4849
5984
|
}
|
|
4850
5985
|
};
|
|
4851
5986
|
|
|
5987
|
+
// src/Domain/Guild/PartialGuildMember.ts
|
|
5988
|
+
var PartialGuildMember = class {
|
|
5989
|
+
partial = true;
|
|
5990
|
+
client;
|
|
5991
|
+
id;
|
|
5992
|
+
user;
|
|
5993
|
+
guildId;
|
|
5994
|
+
guild;
|
|
5995
|
+
constructor(data) {
|
|
5996
|
+
this.client = data.client;
|
|
5997
|
+
this.id = data.id;
|
|
5998
|
+
this.user = data.user;
|
|
5999
|
+
this.guild = data.guild;
|
|
6000
|
+
this.guildId = data.guild.id;
|
|
6001
|
+
}
|
|
6002
|
+
/**
|
|
6003
|
+
* Fetch the full {@link GuildMember} from the API (cache-aware via `guild.members.fetch`).
|
|
6004
|
+
* @throws FluxerError with MEMBER_NOT_FOUND if the user is not in the guild
|
|
6005
|
+
*/
|
|
6006
|
+
async fetch() {
|
|
6007
|
+
return this.guild.members.fetch(this.id);
|
|
6008
|
+
}
|
|
6009
|
+
};
|
|
6010
|
+
|
|
4852
6011
|
// src/ClientCore/EventHandlers/Members.ts
|
|
4853
6012
|
var memberHandlers = {
|
|
4854
6013
|
GUILD_MEMBER_ADD(client, d) {
|
|
@@ -4875,28 +6034,15 @@ var memberHandlers = {
|
|
|
4875
6034
|
const data = d;
|
|
4876
6035
|
const guild = client.guilds.get(data.guild_id);
|
|
4877
6036
|
if (!guild || !data.user?.id) return;
|
|
4878
|
-
|
|
4879
|
-
if (
|
|
4880
|
-
|
|
4881
|
-
|
|
4882
|
-
|
|
4883
|
-
|
|
4884
|
-
|
|
4885
|
-
|
|
4886
|
-
|
|
4887
|
-
...data.user,
|
|
4888
|
-
username: data.user.username ?? "Unknown",
|
|
4889
|
-
discriminator: data.user.discriminator ?? "0"
|
|
4890
|
-
},
|
|
4891
|
-
roles: [],
|
|
4892
|
-
joined_at: (/* @__PURE__ */ new Date(0)).toISOString(),
|
|
4893
|
-
nick: null,
|
|
4894
|
-
mute: false,
|
|
4895
|
-
deaf: false
|
|
4896
|
-
},
|
|
4897
|
-
guild
|
|
4898
|
-
);
|
|
4899
|
-
}
|
|
6037
|
+
const cached = guild.members.get(data.user.id);
|
|
6038
|
+
if (cached) guild.members.delete(data.user.id);
|
|
6039
|
+
const user = client.getOrCreateUser(data.user);
|
|
6040
|
+
const member = cached ?? new PartialGuildMember({
|
|
6041
|
+
client,
|
|
6042
|
+
id: data.user.id,
|
|
6043
|
+
user,
|
|
6044
|
+
guild
|
|
6045
|
+
});
|
|
4900
6046
|
guild.adjustMemberCount(-1);
|
|
4901
6047
|
client.emit(Events.GuildMemberRemove, member);
|
|
4902
6048
|
},
|
|
@@ -4915,7 +6061,7 @@ var memberHandlers = {
|
|
|
4915
6061
|
members,
|
|
4916
6062
|
chunkIndex: data.chunk_index,
|
|
4917
6063
|
chunkCount: data.chunk_count,
|
|
4918
|
-
notFound: [],
|
|
6064
|
+
notFound: data.not_found ?? [],
|
|
4919
6065
|
nonce: data.nonce ?? null
|
|
4920
6066
|
};
|
|
4921
6067
|
client.emit(Events.GuildMembersChunk, payload);
|
|
@@ -4923,7 +6069,35 @@ var memberHandlers = {
|
|
|
4923
6069
|
};
|
|
4924
6070
|
|
|
4925
6071
|
// src/ClientCore/EventHandlers/Messages.ts
|
|
4926
|
-
|
|
6072
|
+
import { SnowflakeUtil as SnowflakeUtil10 } from "@fluxerjs/util";
|
|
6073
|
+
function cachedTextChannel(client, channelId) {
|
|
6074
|
+
const channel = client.channels.get(channelId);
|
|
6075
|
+
return channel?.isTextBased() ? channel : null;
|
|
6076
|
+
}
|
|
6077
|
+
function cachedMessage(client, channelId, messageId) {
|
|
6078
|
+
const data = client._getMessageCache(channelId)?.get(messageId);
|
|
6079
|
+
return data ? new Message(client, data) : null;
|
|
6080
|
+
}
|
|
6081
|
+
function isHydratableMessage(data) {
|
|
6082
|
+
return Boolean(data.author?.id && data.timestamp);
|
|
6083
|
+
}
|
|
6084
|
+
function toPartialMessage(client, args) {
|
|
6085
|
+
const cached = args.cached;
|
|
6086
|
+
const authorId = args.authorId ?? cached?.author?.id ?? null;
|
|
6087
|
+
const author = cached?.author ? client.getOrCreateUser(cached.author) : authorId ? client.users.get(authorId) ?? null : null;
|
|
6088
|
+
const createdAt = cached?.timestamp ? new Date(cached.timestamp) : SnowflakeUtil10.isValid(args.id) ? SnowflakeUtil10.dateFromSnowflake(args.id) : null;
|
|
6089
|
+
return new PartialMessage(client, {
|
|
6090
|
+
id: args.id,
|
|
6091
|
+
channelId: args.channelId,
|
|
6092
|
+
guildId: args.guildId ?? cached?.guild_id ?? null,
|
|
6093
|
+
channel: cachedTextChannel(client, args.channelId),
|
|
6094
|
+
content: args.content ?? cached?.content ?? null,
|
|
6095
|
+
authorId,
|
|
6096
|
+
author,
|
|
6097
|
+
createdAt
|
|
6098
|
+
});
|
|
6099
|
+
}
|
|
6100
|
+
function toReactionEmoji(emoji) {
|
|
4927
6101
|
return {
|
|
4928
6102
|
name: emoji.name,
|
|
4929
6103
|
...emoji.id !== void 0 ? { id: emoji.id } : {},
|
|
@@ -4940,9 +6114,12 @@ function emitReaction(event) {
|
|
|
4940
6114
|
const payload = {
|
|
4941
6115
|
reaction,
|
|
4942
6116
|
user,
|
|
6117
|
+
message: cachedMessage(client, data.channel_id, data.message_id),
|
|
6118
|
+
channel: cachedTextChannel(client, data.channel_id),
|
|
6119
|
+
member,
|
|
4943
6120
|
messageId: data.message_id,
|
|
4944
6121
|
channelId: data.channel_id,
|
|
4945
|
-
emoji:
|
|
6122
|
+
emoji: toReactionEmoji(data.emoji),
|
|
4946
6123
|
userId: data.user_id
|
|
4947
6124
|
};
|
|
4948
6125
|
client.emit(event, payload);
|
|
@@ -4962,37 +6139,60 @@ var messageHandlers = {
|
|
|
4962
6139
|
},
|
|
4963
6140
|
MESSAGE_UPDATE(client, d) {
|
|
4964
6141
|
const partial = d;
|
|
4965
|
-
const
|
|
4966
|
-
|
|
4967
|
-
|
|
4968
|
-
if (
|
|
4969
|
-
|
|
4970
|
-
|
|
4971
|
-
|
|
4972
|
-
mergedData = { ...oldData, ...partial };
|
|
4973
|
-
}
|
|
6142
|
+
const oldData = client._getMessageCache(partial.channel_id)?.get(partial.id);
|
|
6143
|
+
const oldMessage = oldData ? new Message(client, oldData) : null;
|
|
6144
|
+
const mergedData = oldData ? { ...oldData, ...partial } : partial;
|
|
6145
|
+
if (isHydratableMessage(mergedData)) {
|
|
6146
|
+
client._addMessageToCache(partial.channel_id, mergedData);
|
|
6147
|
+
client.emit(Events.MessageUpdate, oldMessage, new Message(client, mergedData));
|
|
6148
|
+
return;
|
|
4974
6149
|
}
|
|
4975
|
-
client.
|
|
4976
|
-
|
|
6150
|
+
client.emit(
|
|
6151
|
+
Events.MessageUpdate,
|
|
6152
|
+
oldMessage,
|
|
6153
|
+
toPartialMessage(client, {
|
|
6154
|
+
id: partial.id,
|
|
6155
|
+
channelId: partial.channel_id,
|
|
6156
|
+
guildId: partial.guild_id ?? oldData?.guild_id ?? null,
|
|
6157
|
+
content: partial.content ?? oldData?.content ?? null,
|
|
6158
|
+
authorId: partial.author?.id ?? oldData?.author?.id ?? null,
|
|
6159
|
+
cached: oldData
|
|
6160
|
+
})
|
|
6161
|
+
);
|
|
4977
6162
|
},
|
|
4978
6163
|
MESSAGE_DELETE(client, d) {
|
|
4979
6164
|
const data = d;
|
|
4980
|
-
client.
|
|
4981
|
-
client
|
|
6165
|
+
const cached = client._getMessageCache(data.channel_id)?.get(data.id);
|
|
6166
|
+
const payload = toPartialMessage(client, {
|
|
4982
6167
|
id: data.id,
|
|
4983
6168
|
channelId: data.channel_id,
|
|
4984
|
-
|
|
4985
|
-
content: data.content ?? null,
|
|
4986
|
-
authorId: data.author_id ?? null
|
|
6169
|
+
guildId: data.guild_id ?? cached?.guild_id ?? null,
|
|
6170
|
+
content: data.content ?? cached?.content ?? null,
|
|
6171
|
+
authorId: data.author_id ?? cached?.author?.id ?? null,
|
|
6172
|
+
cached
|
|
4987
6173
|
});
|
|
6174
|
+
client._removeMessageFromCache(data.channel_id, data.id);
|
|
6175
|
+
client.emit(Events.MessageDelete, payload);
|
|
4988
6176
|
},
|
|
4989
6177
|
MESSAGE_DELETE_BULK(client, d) {
|
|
4990
6178
|
const data = d;
|
|
4991
|
-
|
|
6179
|
+
const ids = data.ids ?? [];
|
|
6180
|
+
const cache = client._getMessageCache(data.channel_id);
|
|
6181
|
+
const messages = ids.map(
|
|
6182
|
+
(id) => toPartialMessage(client, {
|
|
6183
|
+
id,
|
|
6184
|
+
channelId: data.channel_id,
|
|
6185
|
+
guildId: data.guild_id ?? cache?.get(id)?.guild_id ?? null,
|
|
6186
|
+
cached: cache?.get(id)
|
|
6187
|
+
})
|
|
6188
|
+
);
|
|
6189
|
+
for (const id of ids) client._removeMessageFromCache(data.channel_id, id);
|
|
4992
6190
|
client.emit(Events.MessageDeleteBulk, {
|
|
4993
|
-
ids
|
|
6191
|
+
ids,
|
|
4994
6192
|
channelId: data.channel_id,
|
|
4995
|
-
guildId: data.guild_id ?? null
|
|
6193
|
+
guildId: data.guild_id ?? null,
|
|
6194
|
+
channel: cachedTextChannel(client, data.channel_id),
|
|
6195
|
+
messages
|
|
4996
6196
|
});
|
|
4997
6197
|
},
|
|
4998
6198
|
MESSAGE_REACTION_ADD: emitReaction(Events.MessageReactionAdd),
|
|
@@ -5002,7 +6202,9 @@ var messageHandlers = {
|
|
|
5002
6202
|
const payload = {
|
|
5003
6203
|
messageId: data.message_id,
|
|
5004
6204
|
channelId: data.channel_id,
|
|
5005
|
-
guildId: data.guild_id ?? null
|
|
6205
|
+
guildId: data.guild_id ?? null,
|
|
6206
|
+
message: cachedMessage(client, data.channel_id, data.message_id),
|
|
6207
|
+
channel: cachedTextChannel(client, data.channel_id)
|
|
5006
6208
|
};
|
|
5007
6209
|
client.emit(Events.MessageReactionRemoveAll, payload);
|
|
5008
6210
|
},
|
|
@@ -5012,7 +6214,9 @@ var messageHandlers = {
|
|
|
5012
6214
|
messageId: data.message_id,
|
|
5013
6215
|
channelId: data.channel_id,
|
|
5014
6216
|
guildId: data.guild_id ?? null,
|
|
5015
|
-
emoji:
|
|
6217
|
+
emoji: toReactionEmoji(data.emoji),
|
|
6218
|
+
message: cachedMessage(client, data.channel_id, data.message_id),
|
|
6219
|
+
channel: cachedTextChannel(client, data.channel_id)
|
|
5016
6220
|
};
|
|
5017
6221
|
client.emit(Events.MessageReactionRemoveEmoji, payload);
|
|
5018
6222
|
},
|
|
@@ -5031,7 +6235,7 @@ var messageHandlers = {
|
|
|
5031
6235
|
}
|
|
5032
6236
|
reactions.push({
|
|
5033
6237
|
userId: entry.user_id,
|
|
5034
|
-
emoji:
|
|
6238
|
+
emoji: toReactionEmoji(entry.emoji),
|
|
5035
6239
|
member
|
|
5036
6240
|
});
|
|
5037
6241
|
}
|
|
@@ -5039,6 +6243,8 @@ var messageHandlers = {
|
|
|
5039
6243
|
channelId: data.channel_id,
|
|
5040
6244
|
messageId: data.message_id,
|
|
5041
6245
|
guildId: data.guild_id ?? null,
|
|
6246
|
+
message: cachedMessage(client, data.channel_id, data.message_id),
|
|
6247
|
+
channel: cachedTextChannel(client, data.channel_id),
|
|
5042
6248
|
reactions
|
|
5043
6249
|
};
|
|
5044
6250
|
client.emit(Events.MessageReactionAddMany, payload);
|
|
@@ -5213,10 +6419,15 @@ function hydrateReadyGuilds(client, guilds, waitForGuilds) {
|
|
|
5213
6419
|
for (const g of guilds ?? []) {
|
|
5214
6420
|
if (g.unavailable === true) {
|
|
5215
6421
|
if (typeof g.id === "string") {
|
|
5216
|
-
|
|
5217
|
-
if (
|
|
5218
|
-
|
|
6422
|
+
let guild = client.guilds.get(g.id);
|
|
6423
|
+
if (!guild) {
|
|
6424
|
+
guild = new Guild(client, { id: g.id });
|
|
6425
|
+
guild.available = false;
|
|
6426
|
+
client.guilds.set(g.id, guild);
|
|
6427
|
+
} else if (guild.available !== false) {
|
|
6428
|
+
guild.available = false;
|
|
5219
6429
|
}
|
|
6430
|
+
client._readyStubGuildIds.add(g.id);
|
|
5220
6431
|
if (pending !== null) pending.add(g.id);
|
|
5221
6432
|
}
|
|
5222
6433
|
continue;
|
|
@@ -5244,22 +6455,36 @@ function clearGuildStreamSettle(client) {
|
|
|
5244
6455
|
clearTimeout(client._guildStreamSettleTimeout);
|
|
5245
6456
|
client._guildStreamSettleTimeout = null;
|
|
5246
6457
|
}
|
|
6458
|
+
function resetGuildStreamSettle(client) {
|
|
6459
|
+
clearGuildStreamSettle(client);
|
|
6460
|
+
client._guildStreamSettleTimeout = setTimeout(() => {
|
|
6461
|
+
client._guildStreamSettleTimeout = null;
|
|
6462
|
+
if (client.readyAt === null) finalizeClientReady(client);
|
|
6463
|
+
}, GUILD_STREAM_SETTLE_MS);
|
|
6464
|
+
}
|
|
5247
6465
|
function handleReadyPayload(client, data) {
|
|
5248
6466
|
client.user = new ClientUser(client, data.user);
|
|
5249
6467
|
const waitForGuilds = client.options.waitForGuilds === true;
|
|
5250
6468
|
const guilds = data.guilds ?? [];
|
|
5251
6469
|
const pending = hydrateReadyGuilds(client, guilds, waitForGuilds);
|
|
5252
|
-
if (
|
|
5253
|
-
|
|
6470
|
+
if (client.readyAt !== null) {
|
|
6471
|
+
if (pending !== null && pending.size > 0) {
|
|
6472
|
+
const existing = client._pendingGuildIds ?? /* @__PURE__ */ new Set();
|
|
6473
|
+
for (const id of pending) existing.add(id);
|
|
6474
|
+
client._pendingGuildIds = existing;
|
|
6475
|
+
}
|
|
5254
6476
|
return;
|
|
5255
6477
|
}
|
|
5256
|
-
if (
|
|
5257
|
-
client.
|
|
5258
|
-
|
|
5259
|
-
|
|
5260
|
-
}, GUILD_STREAM_SETTLE_MS);
|
|
6478
|
+
if (pending !== null && pending.size > 0) {
|
|
6479
|
+
const existing = client._pendingGuildIds ?? /* @__PURE__ */ new Set();
|
|
6480
|
+
for (const id of pending) existing.add(id);
|
|
6481
|
+
client._pendingGuildIds = existing;
|
|
5261
6482
|
return;
|
|
5262
6483
|
}
|
|
6484
|
+
if (guilds.length === 0) {
|
|
6485
|
+
resetGuildStreamSettle(client);
|
|
6486
|
+
if (waitForGuilds) return;
|
|
6487
|
+
}
|
|
5263
6488
|
finalizeClientReady(client);
|
|
5264
6489
|
}
|
|
5265
6490
|
async function connectClientGateway(client, token, signal) {
|
|
@@ -5269,7 +6494,7 @@ async function connectClientGateway(client, token, signal) {
|
|
|
5269
6494
|
const ws = new WebSocketManager({
|
|
5270
6495
|
token,
|
|
5271
6496
|
intents: client.options.intents ?? 0,
|
|
5272
|
-
presence: client.options.presence,
|
|
6497
|
+
presence: client.options.presence ? toPresenceWire(client.options.presence) : void 0,
|
|
5273
6498
|
flags: client.options.identifyFlags,
|
|
5274
6499
|
ignoredEvents: client.options.ignoredEvents,
|
|
5275
6500
|
initialGuildId: client.options.initialGuildId,
|
|
@@ -5278,24 +6503,57 @@ async function connectClientGateway(client, token, signal) {
|
|
|
5278
6503
|
},
|
|
5279
6504
|
version: client.options.rest?.version ?? "1",
|
|
5280
6505
|
debug: client.options.gatewayDebug !== false,
|
|
5281
|
-
WebSocket: client.options.WebSocket
|
|
6506
|
+
WebSocket: client.options.WebSocket,
|
|
6507
|
+
shardCount: client.options.shardCount ?? client.options.totalShards,
|
|
6508
|
+
shardIds: client.options.shardIds ?? client.options.shardList,
|
|
6509
|
+
guildsPerShard: client.options.guildsPerShard,
|
|
6510
|
+
buildStrategy: client.options.buildStrategy,
|
|
6511
|
+
sessionStore: client.options.sessionStore,
|
|
6512
|
+
identifyThrottler: client.options.identifyThrottler
|
|
5282
6513
|
});
|
|
5283
6514
|
ws.on("dispatch", ({ payload }) => {
|
|
5284
6515
|
handleGatewayDispatch(client, payload, client._deferredGatewayDispatches).catch(
|
|
5285
6516
|
(err) => emitClientError(client, err)
|
|
5286
6517
|
);
|
|
5287
6518
|
});
|
|
5288
|
-
ws.on("ready", ({ data }) => {
|
|
5289
|
-
|
|
6519
|
+
ws.on("ready", ({ shardId, data }) => {
|
|
6520
|
+
client.emit(Events.ShardReady, shardId);
|
|
6521
|
+
try {
|
|
6522
|
+
handleReadyPayload(client, data);
|
|
6523
|
+
} catch (err) {
|
|
6524
|
+
emitClientError(client, err);
|
|
6525
|
+
}
|
|
6526
|
+
});
|
|
6527
|
+
ws.on("resumed", (shardId) => {
|
|
6528
|
+
client.emit(Events.ShardResumed, shardId);
|
|
6529
|
+
});
|
|
6530
|
+
ws.on("close", ({ shardId, code }) => {
|
|
6531
|
+
client.emit(Events.ShardDisconnect, shardId, code);
|
|
6532
|
+
if (code === GatewayCloseCodes.AuthenticationFailed) {
|
|
6533
|
+
emitClientError(
|
|
6534
|
+
client,
|
|
6535
|
+
new FluxerError("Gateway authentication failed (4004). Check the bot token.", {
|
|
6536
|
+
code: ErrorCodes.InvalidToken
|
|
6537
|
+
})
|
|
6538
|
+
);
|
|
6539
|
+
}
|
|
5290
6540
|
});
|
|
5291
|
-
ws.on("error", ({ error }) => {
|
|
5292
|
-
|
|
6541
|
+
ws.on("error", ({ shardId, error }) => {
|
|
6542
|
+
if (shardId >= 0) client.emit(Events.ShardError, shardId, error);
|
|
6543
|
+
client.logger.error("gateway error", {
|
|
6544
|
+
error: error.message,
|
|
6545
|
+
name: error.name,
|
|
6546
|
+
shardId
|
|
6547
|
+
});
|
|
5293
6548
|
client.emit(Events.Error, error);
|
|
5294
6549
|
});
|
|
5295
6550
|
ws.on("debug", (msg) => {
|
|
5296
6551
|
client.logger.debug(msg);
|
|
5297
6552
|
client.emit(Events.Debug, msg);
|
|
5298
6553
|
});
|
|
6554
|
+
ws.on("shardingRequired", (payload) => {
|
|
6555
|
+
client.emit(Events.ShardingRequired, payload);
|
|
6556
|
+
});
|
|
5299
6557
|
client._ws = ws;
|
|
5300
6558
|
const onAbort = () => {
|
|
5301
6559
|
ws.destroy();
|
|
@@ -5321,9 +6579,9 @@ async function connectClientGateway(client, token, signal) {
|
|
|
5321
6579
|
}
|
|
5322
6580
|
|
|
5323
6581
|
// src/ClientCore/GuildManager.ts
|
|
5324
|
-
import { LimitedCollection as
|
|
5325
|
-
import { Routes as
|
|
5326
|
-
var GuildManager = class extends
|
|
6582
|
+
import { LimitedCollection as LimitedCollection5 } from "@fluxerjs/collection";
|
|
6583
|
+
import { Routes as Routes32 } from "@fluxerjs/types";
|
|
6584
|
+
var GuildManager = class extends LimitedCollection5 {
|
|
5327
6585
|
constructor(client) {
|
|
5328
6586
|
super({
|
|
5329
6587
|
maxSize: client.cache.limits.guilds,
|
|
@@ -5332,8 +6590,8 @@ var GuildManager = class extends LimitedCollection4 {
|
|
|
5332
6590
|
this.client = client;
|
|
5333
6591
|
}
|
|
5334
6592
|
/**
|
|
5335
|
-
* Remove a guild and cascade its channels / message caches.
|
|
5336
|
-
*
|
|
6593
|
+
* Remove a guild from cache and cascade its channels / message caches.
|
|
6594
|
+
* Does not leave the guild. Use {@link ClientUser.leaveGuild} for that.
|
|
5337
6595
|
*/
|
|
5338
6596
|
delete(key) {
|
|
5339
6597
|
const guild = this.get(key);
|
|
@@ -5361,7 +6619,7 @@ var GuildManager = class extends LimitedCollection4 {
|
|
|
5361
6619
|
const cached = this.get(guildId);
|
|
5362
6620
|
if (cached && !options?.force) return cached;
|
|
5363
6621
|
try {
|
|
5364
|
-
const data = await this.client.rest.get(
|
|
6622
|
+
const data = await this.client.rest.get(Routes32.guild(guildId));
|
|
5365
6623
|
if (cached) {
|
|
5366
6624
|
cached._patch(data);
|
|
5367
6625
|
return cached;
|
|
@@ -5446,184 +6704,13 @@ var MessageCache = class {
|
|
|
5446
6704
|
}
|
|
5447
6705
|
};
|
|
5448
6706
|
|
|
5449
|
-
// src/ClientCore/PackManager.ts
|
|
5450
|
-
import {
|
|
5451
|
-
Routes as Routes32
|
|
5452
|
-
} from "@fluxerjs/types";
|
|
5453
|
-
function toPackSummaryPayload(data) {
|
|
5454
|
-
return {
|
|
5455
|
-
id: data.id,
|
|
5456
|
-
name: data.name,
|
|
5457
|
-
description: data.description,
|
|
5458
|
-
type: data.type,
|
|
5459
|
-
creatorId: data.creator_id,
|
|
5460
|
-
createdAt: data.created_at,
|
|
5461
|
-
updatedAt: data.updated_at,
|
|
5462
|
-
...data.installed_at !== void 0 ? { installedAt: data.installed_at } : {}
|
|
5463
|
-
};
|
|
5464
|
-
}
|
|
5465
|
-
function toEmojiPayload(data) {
|
|
5466
|
-
return {
|
|
5467
|
-
id: data.id,
|
|
5468
|
-
name: data.name,
|
|
5469
|
-
animated: data.animated
|
|
5470
|
-
};
|
|
5471
|
-
}
|
|
5472
|
-
function toStickerPayload(data) {
|
|
5473
|
-
return {
|
|
5474
|
-
id: data.id,
|
|
5475
|
-
name: data.name,
|
|
5476
|
-
description: data.description,
|
|
5477
|
-
tags: data.tags,
|
|
5478
|
-
animated: data.animated,
|
|
5479
|
-
nsfw: data.nsfw
|
|
5480
|
-
};
|
|
5481
|
-
}
|
|
5482
|
-
function toInvitePayload(data) {
|
|
5483
|
-
return {
|
|
5484
|
-
code: data.code,
|
|
5485
|
-
...data.max_uses !== void 0 ? { maxUses: data.max_uses } : {},
|
|
5486
|
-
...data.max_age !== void 0 ? { maxAge: data.max_age } : {},
|
|
5487
|
-
...data.uses !== void 0 ? { uses: data.uses } : {},
|
|
5488
|
-
...data.temporary !== void 0 ? { temporary: data.temporary } : {},
|
|
5489
|
-
...data.created_at !== void 0 ? { createdAt: data.created_at } : {},
|
|
5490
|
-
...data.expires_at !== void 0 ? { expiresAt: data.expires_at } : {}
|
|
5491
|
-
};
|
|
5492
|
-
}
|
|
5493
|
-
function mapDashboardSection(section) {
|
|
5494
|
-
return {
|
|
5495
|
-
installedLimit: section.installed_limit,
|
|
5496
|
-
createdLimit: section.created_limit,
|
|
5497
|
-
installed: section.installed.map(toPackSummaryPayload),
|
|
5498
|
-
created: section.created.map(toPackSummaryPayload)
|
|
5499
|
-
};
|
|
5500
|
-
}
|
|
5501
|
-
var PackManager = class {
|
|
5502
|
-
constructor(client) {
|
|
5503
|
-
this.client = client;
|
|
5504
|
-
}
|
|
5505
|
-
/** Fetch the current user's pack dashboard (camelCase summaries). */
|
|
5506
|
-
async fetchDashboard() {
|
|
5507
|
-
const data = await this.client.rest.get(Routes32.packs());
|
|
5508
|
-
return {
|
|
5509
|
-
emoji: mapDashboardSection(data.emoji),
|
|
5510
|
-
sticker: mapDashboardSection(data.sticker)
|
|
5511
|
-
};
|
|
5512
|
-
}
|
|
5513
|
-
/** Create a pack. */
|
|
5514
|
-
async create(packType, body) {
|
|
5515
|
-
const data = await this.client.rest.post(Routes32.packsByType(packType), {
|
|
5516
|
-
body
|
|
5517
|
-
});
|
|
5518
|
-
return toPackSummaryPayload(data);
|
|
5519
|
-
}
|
|
5520
|
-
/** Edit a pack. */
|
|
5521
|
-
async edit(packId, body) {
|
|
5522
|
-
const data = await this.client.rest.patch(Routes32.pack(packId), { body });
|
|
5523
|
-
return toPackSummaryPayload(data);
|
|
5524
|
-
}
|
|
5525
|
-
/** Delete a pack. */
|
|
5526
|
-
async delete(packId) {
|
|
5527
|
-
await this.client.rest.delete(Routes32.pack(packId));
|
|
5528
|
-
}
|
|
5529
|
-
/** Install a pack for the current user. */
|
|
5530
|
-
async install(packId) {
|
|
5531
|
-
await this.client.rest.post(Routes32.packInstall(packId));
|
|
5532
|
-
}
|
|
5533
|
-
/** Uninstall a pack for the current user. */
|
|
5534
|
-
async uninstall(packId) {
|
|
5535
|
-
await this.client.rest.delete(Routes32.packInstall(packId));
|
|
5536
|
-
}
|
|
5537
|
-
/** List invites for a pack. */
|
|
5538
|
-
async listInvites(packId) {
|
|
5539
|
-
const data = await this.client.rest.get(Routes32.packInvites(packId));
|
|
5540
|
-
return data.map(toInvitePayload);
|
|
5541
|
-
}
|
|
5542
|
-
/** Create an invite for a pack. */
|
|
5543
|
-
async createInvite(packId, options = {}) {
|
|
5544
|
-
const body = toPackInviteBody(options);
|
|
5545
|
-
const data = await this.client.rest.post(Routes32.packInvites(packId), {
|
|
5546
|
-
body: Object.keys(body).length ? body : void 0
|
|
5547
|
-
});
|
|
5548
|
-
return toInvitePayload(data);
|
|
5549
|
-
}
|
|
5550
|
-
/** List emojis in a pack. */
|
|
5551
|
-
async listEmojis(packId) {
|
|
5552
|
-
const data = await this.client.rest.get(Routes32.packEmojis(packId));
|
|
5553
|
-
return data.map(toEmojiPayload);
|
|
5554
|
-
}
|
|
5555
|
-
/** Create an emoji in a pack. */
|
|
5556
|
-
async createEmoji(packId, options) {
|
|
5557
|
-
const data = await this.client.rest.post(Routes32.packEmojis(packId), {
|
|
5558
|
-
body: toEmojiCreateBody(options)
|
|
5559
|
-
});
|
|
5560
|
-
return toEmojiPayload(data);
|
|
5561
|
-
}
|
|
5562
|
-
/** Bulk-create emojis in a pack. */
|
|
5563
|
-
async createEmojisBulk(packId, emojis) {
|
|
5564
|
-
const data = await this.client.rest.post(
|
|
5565
|
-
Routes32.packEmojisBulk(packId),
|
|
5566
|
-
{ body: { emojis: emojis.map(toEmojiCreateBody) } }
|
|
5567
|
-
);
|
|
5568
|
-
return {
|
|
5569
|
-
success: data.success.map(toEmojiPayload),
|
|
5570
|
-
failed: data.failed
|
|
5571
|
-
};
|
|
5572
|
-
}
|
|
5573
|
-
/** Edit an emoji in a pack. */
|
|
5574
|
-
async editEmoji(packId, emojiId, options) {
|
|
5575
|
-
const data = await this.client.rest.patch(Routes32.packEmoji(packId, emojiId), {
|
|
5576
|
-
body: toEmojiEditBody(options)
|
|
5577
|
-
});
|
|
5578
|
-
return toEmojiPayload(data);
|
|
5579
|
-
}
|
|
5580
|
-
/** Delete an emoji from a pack. */
|
|
5581
|
-
async deleteEmoji(packId, emojiId) {
|
|
5582
|
-
await this.client.rest.delete(Routes32.packEmoji(packId, emojiId));
|
|
5583
|
-
}
|
|
5584
|
-
/** List stickers in a pack. */
|
|
5585
|
-
async listStickers(packId) {
|
|
5586
|
-
const data = await this.client.rest.get(Routes32.packStickers(packId));
|
|
5587
|
-
return data.map(toStickerPayload);
|
|
5588
|
-
}
|
|
5589
|
-
/** Create a sticker in a pack. */
|
|
5590
|
-
async createSticker(packId, options) {
|
|
5591
|
-
const data = await this.client.rest.post(Routes32.packStickers(packId), {
|
|
5592
|
-
body: toStickerCreateBody(options)
|
|
5593
|
-
});
|
|
5594
|
-
return toStickerPayload(data);
|
|
5595
|
-
}
|
|
5596
|
-
/** Bulk-create stickers in a pack. */
|
|
5597
|
-
async createStickersBulk(packId, stickers) {
|
|
5598
|
-
const data = await this.client.rest.post(
|
|
5599
|
-
Routes32.packStickersBulk(packId),
|
|
5600
|
-
{ body: { stickers: stickers.map(toStickerCreateBody) } }
|
|
5601
|
-
);
|
|
5602
|
-
return {
|
|
5603
|
-
success: data.success.map(toStickerPayload),
|
|
5604
|
-
failed: data.failed
|
|
5605
|
-
};
|
|
5606
|
-
}
|
|
5607
|
-
/** Edit a sticker in a pack. */
|
|
5608
|
-
async editSticker(packId, stickerId, options) {
|
|
5609
|
-
const data = await this.client.rest.patch(Routes32.packSticker(packId, stickerId), {
|
|
5610
|
-
body: toStickerEditBody(options)
|
|
5611
|
-
});
|
|
5612
|
-
return toStickerPayload(data);
|
|
5613
|
-
}
|
|
5614
|
-
/** Delete a sticker from a pack. */
|
|
5615
|
-
async deleteSticker(packId, stickerId) {
|
|
5616
|
-
await this.client.rest.delete(Routes32.packSticker(packId, stickerId));
|
|
5617
|
-
}
|
|
5618
|
-
};
|
|
5619
|
-
|
|
5620
6707
|
// src/ClientCore/UserManager.ts
|
|
5621
|
-
import { LimitedCollection as
|
|
6708
|
+
import { LimitedCollection as LimitedCollection6 } from "@fluxerjs/collection";
|
|
5622
6709
|
import {
|
|
5623
6710
|
Routes as Routes33
|
|
5624
6711
|
} from "@fluxerjs/types";
|
|
5625
6712
|
var soft = (p) => p.catch(() => null);
|
|
5626
|
-
var UserManager = class extends
|
|
6713
|
+
var UserManager = class extends LimitedCollection6 {
|
|
5627
6714
|
constructor(client) {
|
|
5628
6715
|
super({ maxSize: client.cache.limits.users });
|
|
5629
6716
|
this.client = client;
|
|
@@ -5641,11 +6728,17 @@ var UserManager = class extends LimitedCollection5 {
|
|
|
5641
6728
|
}
|
|
5642
6729
|
return removed;
|
|
5643
6730
|
}
|
|
5644
|
-
/** Fetch a user by ID and update cache. */
|
|
5645
|
-
async fetch(userId) {
|
|
6731
|
+
/** Fetch a user by ID and update cache. Returns cache unless `force` is set. */
|
|
6732
|
+
async fetch(userId, options) {
|
|
6733
|
+
const cached = this.get(userId);
|
|
6734
|
+
if (cached && !options?.force) return cached;
|
|
5646
6735
|
const data = await this.client.rest.get(Routes33.user(userId));
|
|
5647
6736
|
return this.client.getOrCreateUser(data);
|
|
5648
6737
|
}
|
|
6738
|
+
/** Return a cached user, otherwise {@link fetch}. */
|
|
6739
|
+
async resolve(userId) {
|
|
6740
|
+
return this.get(userId) ?? this.fetch(userId);
|
|
6741
|
+
}
|
|
5649
6742
|
/**
|
|
5650
6743
|
* Fetch user + profiles (+ optional guild member). Ideal for userinfo commands.
|
|
5651
6744
|
* @example
|
|
@@ -5705,19 +6798,32 @@ var Client = class _Client extends EventEmitter3 {
|
|
|
5705
6798
|
users;
|
|
5706
6799
|
/** Cache limits, stats, sweeps, and cascade entry points. */
|
|
5707
6800
|
cache;
|
|
5708
|
-
/**
|
|
5709
|
-
packs = new PackManager(this);
|
|
5710
|
-
/** Typed event handlers. Prefer `client.events.*` or `client.on(Events.*, ...)`. */
|
|
6801
|
+
/** Typed event handlers. Prefer `client.on(Events.*, ...)`. */
|
|
5711
6802
|
events;
|
|
5712
6803
|
/** The authenticated bot user. Null until READY is received. */
|
|
5713
6804
|
user = null;
|
|
5714
6805
|
/** Timestamp when the client became ready. Null until READY is received. */
|
|
5715
6806
|
readyAt = null;
|
|
6807
|
+
/**
|
|
6808
|
+
* Milliseconds since {@link readyAt}, or `null` if the client is not ready.
|
|
6809
|
+
* @example
|
|
6810
|
+
* client.on(Events.Ready, () => {
|
|
6811
|
+
* console.log(client.uptime);
|
|
6812
|
+
* });
|
|
6813
|
+
*/
|
|
6814
|
+
get uptime() {
|
|
6815
|
+
return this.readyAt ? Date.now() - this.readyAt.getTime() : null;
|
|
6816
|
+
}
|
|
5716
6817
|
/** @internal WebSocket manager. */
|
|
5717
6818
|
_ws = null;
|
|
5718
6819
|
/** When waitForGuilds, guild IDs still expected via GUILD_CREATE. */
|
|
5719
6820
|
_pendingGuildIds = null;
|
|
5720
|
-
/**
|
|
6821
|
+
/** Guild IDs inserted as unavailable stubs from READY (startup / reconnect backfill). */
|
|
6822
|
+
_readyStubGuildIds = /* @__PURE__ */ new Set();
|
|
6823
|
+
/**
|
|
6824
|
+
* @internal Empty-READY guild stream window.
|
|
6825
|
+
* Classifies incoming GUILD_CREATE as startup hydration. Also delays Ready when waitForGuilds.
|
|
6826
|
+
*/
|
|
5721
6827
|
_guildStreamSettleTimeout = null;
|
|
5722
6828
|
/** @internal Dispatches queued until Ready when waitForGuilds delays Ready. */
|
|
5723
6829
|
_deferredGatewayDispatches = [];
|
|
@@ -5748,7 +6854,7 @@ var Client = class _Client extends EventEmitter3 {
|
|
|
5748
6854
|
const restApi = options.rest?.api;
|
|
5749
6855
|
if (options.instance !== void 0) {
|
|
5750
6856
|
this.instance = resolveInstanceEndpoints(options.instance);
|
|
5751
|
-
resolveRestApi(this.instance.endpoints.
|
|
6857
|
+
resolveRestApi(this.instance.endpoints.api_public, restApi);
|
|
5752
6858
|
} else {
|
|
5753
6859
|
this.instance = resolveInstanceEndpoints(
|
|
5754
6860
|
restApi !== void 0 ? { api: restApi } : void 0
|
|
@@ -5761,27 +6867,31 @@ var Client = class _Client extends EventEmitter3 {
|
|
|
5761
6867
|
}
|
|
5762
6868
|
this.rest = new REST({
|
|
5763
6869
|
...this.options.rest,
|
|
5764
|
-
api: this.instance.endpoints.
|
|
5765
|
-
version: this.options.rest?.version ?? "1"
|
|
6870
|
+
api: this.instance.endpoints.api_public,
|
|
6871
|
+
version: this.options.rest?.version ?? "1",
|
|
6872
|
+
locale: this.options.locale ?? this.options.rest?.locale
|
|
5766
6873
|
});
|
|
5767
6874
|
}
|
|
5768
6875
|
/**
|
|
5769
6876
|
* Create a client from instance discovery (`GET /.well-known/fluxer`).
|
|
5770
|
-
*
|
|
6877
|
+
* Fetches the unversioned well-known document from the given origin (not `{api}/v1/.well-known/fluxer`).
|
|
6878
|
+
* Wires REST from `endpoints.api_public`. `endpoints.api` / `api_client` stay on the instance for inspection.
|
|
6879
|
+
* Does not log in. Call {@link login} with a token afterward.
|
|
5771
6880
|
*
|
|
5772
|
-
* @param origin -
|
|
5773
|
-
* @param options - Client options (must not conflict with discovered `endpoints.
|
|
6881
|
+
* @param origin - Origin used only to fetch discovery (e.g. `https://fluxer.app` or `https://my.instance`)
|
|
6882
|
+
* @param options - Client options (must not conflict with discovered `endpoints.api_public`)
|
|
5774
6883
|
* @param connectOptions - Optional abort signal for the discovery request
|
|
5775
6884
|
*/
|
|
5776
6885
|
static async fromDiscovery(origin, options = {}, connectOptions) {
|
|
5777
|
-
const
|
|
6886
|
+
const bootstrapOrigin = typeof origin === "string" ? normalizeApiOrigin(origin) : normalizeApiOrigin(origin.api);
|
|
5778
6887
|
const version = typeof origin === "string" ? options.rest?.version ?? "1" : origin.version ?? options.rest?.version ?? "1";
|
|
5779
6888
|
const bootstrap = new REST({
|
|
5780
6889
|
...options.rest ?? {},
|
|
5781
|
-
api:
|
|
5782
|
-
version
|
|
6890
|
+
api: bootstrapOrigin,
|
|
6891
|
+
version,
|
|
6892
|
+
locale: options.locale ?? options.rest?.locale
|
|
5783
6893
|
});
|
|
5784
|
-
const raw = await bootstrap.get(
|
|
6894
|
+
const raw = await bootstrap.get(instanceDiscoveryUrl(bootstrapOrigin), {
|
|
5785
6895
|
auth: false,
|
|
5786
6896
|
...connectOptions?.signal ? { signal: connectOptions.signal } : {}
|
|
5787
6897
|
});
|
|
@@ -5789,7 +6899,7 @@ var Client = class _Client extends EventEmitter3 {
|
|
|
5789
6899
|
const { rest, ...restOptions } = options;
|
|
5790
6900
|
return new _Client({
|
|
5791
6901
|
...restOptions,
|
|
5792
|
-
// Drop rest.api so discovered endpoints.
|
|
6902
|
+
// Drop rest.api so discovered endpoints.api_public owns the REST host; keep other REST opts.
|
|
5793
6903
|
...rest ? { rest: { ...rest, api: void 0 } } : {},
|
|
5794
6904
|
instance: discovery
|
|
5795
6905
|
});
|
|
@@ -5816,7 +6926,7 @@ var Client = class _Client extends EventEmitter3 {
|
|
|
5816
6926
|
return resolveClientEmoji(this, emoji, guildId);
|
|
5817
6927
|
}
|
|
5818
6928
|
/**
|
|
5819
|
-
* Fetch instance discovery document (
|
|
6929
|
+
* Fetch instance discovery document (unversioned `GET /.well-known/fluxer` on the REST host).
|
|
5820
6930
|
* @returns Instance configuration (endpoints, features, metadata)
|
|
5821
6931
|
*/
|
|
5822
6932
|
fetchInstance() {
|
|
@@ -5853,33 +6963,23 @@ var Client = class _Client extends EventEmitter3 {
|
|
|
5853
6963
|
return fetchApplication(this);
|
|
5854
6964
|
}
|
|
5855
6965
|
/**
|
|
5856
|
-
* Fetch OAuth2 applications
|
|
5857
|
-
*
|
|
6966
|
+
* Fetch OAuth2 applications (`GET /oauth2/applications/@me`).
|
|
6967
|
+
* A bot token returns the bot application object (normalized to a one-element array).
|
|
6968
|
+
* A user token returns the owner's application list.
|
|
5858
6969
|
*/
|
|
5859
6970
|
fetchOAuthApplications() {
|
|
5860
6971
|
return fetchOAuthApplications(this);
|
|
5861
6972
|
}
|
|
5862
|
-
/**
|
|
5863
|
-
* Check username#discriminator availability.
|
|
5864
|
-
* @param username - Username to check
|
|
5865
|
-
* @param discriminator - Discriminator to check
|
|
5866
|
-
* @returns Availability result
|
|
5867
|
-
*/
|
|
5868
|
-
checkUsernameTag(username, discriminator) {
|
|
5869
|
-
return checkUsernameTag(this, username, discriminator);
|
|
5870
|
-
}
|
|
5871
6973
|
/**
|
|
5872
6974
|
* Preload recent messages for multiple channels (batch endpoint).
|
|
5873
|
-
* @
|
|
5874
|
-
* @returns Preload response with message counts/timestamps
|
|
6975
|
+
* Prefer this over {@link bulkFetchMessages} for bots (`bulkFetchMessages` is user-account only).
|
|
5875
6976
|
*/
|
|
5876
6977
|
preloadMessages(channelIds) {
|
|
5877
6978
|
return preloadMessages(this, channelIds);
|
|
5878
6979
|
}
|
|
5879
6980
|
/**
|
|
5880
6981
|
* Preload recent messages (alternate endpoint).
|
|
5881
|
-
*
|
|
5882
|
-
* @returns Preload response with message counts/timestamps
|
|
6982
|
+
* Prefer this over {@link bulkFetchMessages} for bots.
|
|
5883
6983
|
*/
|
|
5884
6984
|
preloadMessagesAlt(channelIds) {
|
|
5885
6985
|
return preloadMessagesAlt(this, channelIds);
|
|
@@ -5887,6 +6987,14 @@ var Client = class _Client extends EventEmitter3 {
|
|
|
5887
6987
|
bulkFetchMessages(requests, options = {}) {
|
|
5888
6988
|
return bulkFetchMessages(this, requests, options);
|
|
5889
6989
|
}
|
|
6990
|
+
/**
|
|
6991
|
+
* Search messages in the current bot scope (`POST /search/messages`, `scope: current`).
|
|
6992
|
+
* Other scopes are denied for bots (`BOT_SEARCH_SCOPE_UNAVAILABLE`).
|
|
6993
|
+
* Returns camelCase results (`hitsPerPage`) or `{ indexing: true }` while channels are indexed.
|
|
6994
|
+
*/
|
|
6995
|
+
searchMessages(options) {
|
|
6996
|
+
return searchMessages(this, options);
|
|
6997
|
+
}
|
|
5890
6998
|
/** @internal */
|
|
5891
6999
|
_getMessageCache(channelId) {
|
|
5892
7000
|
return this._messageCache.get(channelId);
|
|
@@ -5910,12 +7018,16 @@ var Client = class _Client extends EventEmitter3 {
|
|
|
5910
7018
|
/**
|
|
5911
7019
|
* Sweep cached messages (remove entries matching filter).
|
|
5912
7020
|
* Prefer {@link CacheController.sweepMessages} (`client.cache.sweepMessages`).
|
|
7021
|
+
* The filter receives a hydrated {@link Message} (`createdAt`), not the stored wire payload.
|
|
5913
7022
|
* @param filter - Predicate to test each message (return true to remove)
|
|
5914
7023
|
* @param channelId - Optional channel ID to scope sweep
|
|
5915
7024
|
* @returns Count of messages removed
|
|
5916
7025
|
*/
|
|
5917
7026
|
sweepMessages(filter, channelId) {
|
|
5918
|
-
return this._messageCache.sweep(
|
|
7027
|
+
return this._messageCache.sweep(
|
|
7028
|
+
filter ? (data, chId) => filter(new Message(this, data), chId) : void 0,
|
|
7029
|
+
channelId
|
|
7030
|
+
);
|
|
5919
7031
|
}
|
|
5920
7032
|
/**
|
|
5921
7033
|
* Sweep cached members across all guilds (remove entries matching filter).
|
|
@@ -5948,6 +7060,9 @@ var Client = class _Client extends EventEmitter3 {
|
|
|
5948
7060
|
}
|
|
5949
7061
|
/**
|
|
5950
7062
|
* The underlying {@link WebSocketManager} (throws if not logged in).
|
|
7063
|
+
* Gateway heartbeat ACK latency: `client.ws.ping` (ms, or `-1` before the first ACK).
|
|
7064
|
+
* @example
|
|
7065
|
+
* console.log(client.ws.ping);
|
|
5951
7066
|
* @throws {@link FluxerError} with {@link ErrorCodes.NotLoggedIn}
|
|
5952
7067
|
*/
|
|
5953
7068
|
get ws() {
|
|
@@ -5986,6 +7101,37 @@ var Client = class _Client extends EventEmitter3 {
|
|
|
5986
7101
|
if (options.nonce !== void 0) data.nonce = options.nonce;
|
|
5987
7102
|
this._sendToAllShards({ op: GatewayOpcodes2.RequestGuildMembers, d: data });
|
|
5988
7103
|
}
|
|
7104
|
+
/**
|
|
7105
|
+
* Request guild member/online counts via gateway opcode 15.
|
|
7106
|
+
* Listen for `guildCountsUpdate`. Cached `guild.memberCount` / `guild.onlineCount` update when that event arrives.
|
|
7107
|
+
*/
|
|
7108
|
+
requestGuildCounts(options) {
|
|
7109
|
+
const guildIds = [...new Set(options.guildIds.filter(Boolean))];
|
|
7110
|
+
if (!guildIds.length) {
|
|
7111
|
+
throw new FluxerError("requestGuildCounts requires at least one guildId", {
|
|
7112
|
+
code: ErrorCodes.InvalidGatewayRequest
|
|
7113
|
+
});
|
|
7114
|
+
}
|
|
7115
|
+
const data = { guild_ids: guildIds };
|
|
7116
|
+
if (options.nonce !== void 0) data.nonce = options.nonce;
|
|
7117
|
+
this._sendToAllShards({ op: GatewayOpcodes2.RequestGuildCounts, d: data });
|
|
7118
|
+
}
|
|
7119
|
+
/**
|
|
7120
|
+
* Request per-channel member counts via gateway opcode 16.
|
|
7121
|
+
* Event-only: listen for `channelMemberCountsUpdate`. There is no `channel.memberCount` field.
|
|
7122
|
+
*/
|
|
7123
|
+
requestChannelMemberCounts(options) {
|
|
7124
|
+
if (!options.guildId) {
|
|
7125
|
+
throw new FluxerError("requestChannelMemberCounts requires guildId", {
|
|
7126
|
+
code: ErrorCodes.InvalidGatewayRequest
|
|
7127
|
+
});
|
|
7128
|
+
}
|
|
7129
|
+
const data = { guild_id: options.guildId };
|
|
7130
|
+
if (options.channelId !== void 0) data.channel_id = options.channelId;
|
|
7131
|
+
if (options.channelIds !== void 0) data.channel_ids = [...new Set(options.channelIds)];
|
|
7132
|
+
if (options.nonce !== void 0) data.nonce = options.nonce;
|
|
7133
|
+
this._sendToAllShards({ op: GatewayOpcodes2.RequestChannelMemberCounts, d: data });
|
|
7134
|
+
}
|
|
5989
7135
|
/**
|
|
5990
7136
|
* Broadcast a gateway payload to all shards.
|
|
5991
7137
|
* @param payload - Gateway send payload
|
|
@@ -5999,9 +7145,13 @@ var Client = class _Client extends EventEmitter3 {
|
|
|
5999
7145
|
}
|
|
6000
7146
|
/**
|
|
6001
7147
|
* Connect to the gateway with a bot token.
|
|
7148
|
+
* @example
|
|
7149
|
+
* const client = new Client();
|
|
7150
|
+
* client.on(Events.Ready, () => console.log('Ready!'));
|
|
7151
|
+
* await client.login(process.env.FLUXER_BOT_TOKEN);
|
|
6002
7152
|
* @param token - Bot token from the developer portal
|
|
6003
7153
|
* @param options - Optional abort signal for cancellation
|
|
6004
|
-
* @returns
|
|
7154
|
+
* @returns This client (for chaining)
|
|
6005
7155
|
* @throws {@link FluxerError} if already logged in or token is invalid
|
|
6006
7156
|
*/
|
|
6007
7157
|
async login(token, options) {
|
|
@@ -6016,7 +7166,7 @@ var Client = class _Client extends EventEmitter3 {
|
|
|
6016
7166
|
this.rest.setToken(token);
|
|
6017
7167
|
try {
|
|
6018
7168
|
this._ws = await connectClientGateway(this, token, options?.signal);
|
|
6019
|
-
return
|
|
7169
|
+
return this;
|
|
6020
7170
|
} catch (err) {
|
|
6021
7171
|
this._ws?.destroy();
|
|
6022
7172
|
this._ws = null;
|
|
@@ -6045,6 +7195,7 @@ var Client = class _Client extends EventEmitter3 {
|
|
|
6045
7195
|
this.user = null;
|
|
6046
7196
|
this.readyAt = null;
|
|
6047
7197
|
this._pendingGuildIds = null;
|
|
7198
|
+
this._readyStubGuildIds.clear();
|
|
6048
7199
|
this.guilds.clear();
|
|
6049
7200
|
this.channels.clear();
|
|
6050
7201
|
this.users.clear();
|
|
@@ -6069,6 +7220,20 @@ var Client = class _Client extends EventEmitter3 {
|
|
|
6069
7220
|
);
|
|
6070
7221
|
}
|
|
6071
7222
|
}
|
|
7223
|
+
/**
|
|
7224
|
+
* REST path helpers ({@link Routes}). Pass the path to {@link REST client.rest}.
|
|
7225
|
+
* Prefer high-level helpers (`channel.send()`, `guild.members.fetch()`) when they exist.
|
|
7226
|
+
*
|
|
7227
|
+
* @example
|
|
7228
|
+
* const channel = await client.rest.get(Client.Routes.channel(channelId));
|
|
7229
|
+
*
|
|
7230
|
+
* @example
|
|
7231
|
+
* await client.rest.post(Client.Routes.channelMessages(channelId), {
|
|
7232
|
+
* body: { content: 'hello' },
|
|
7233
|
+
* });
|
|
7234
|
+
*
|
|
7235
|
+
* @see {@link Routes}
|
|
7236
|
+
*/
|
|
6072
7237
|
static get Routes() {
|
|
6073
7238
|
return Routes34;
|
|
6074
7239
|
}
|