@fluxerjs/core 3.0.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/dist/{SubpathMessage-CjQBbVmb.d.mts → SubpathMessage-Cj_U0V19.d.mts} +64 -21
- package/dist/{SubpathMessage-DNlKq2Nj.d.ts → SubpathMessage-DaimQAd9.d.ts} +64 -21
- package/dist/{Sudo-CFfbmis3.d.mts → Sudo-fOKSPbxN.d.mts} +8 -0
- package/dist/{Sudo-CFfbmis3.d.ts → Sudo-fOKSPbxN.d.ts} +8 -0
- package/dist/client.d.mts +2 -2
- package/dist/client.d.ts +2 -2
- package/dist/client.js +282 -89
- package/dist/client.mjs +282 -89
- package/dist/cluster.d.mts +3 -3
- package/dist/cluster.d.ts +3 -3
- package/dist/cluster.js +282 -89
- package/dist/cluster.mjs +282 -89
- package/dist/index.d.mts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +286 -89
- package/dist/index.mjs +284 -89
- package/dist/internal.d.mts +2 -2
- package/dist/internal.d.ts +2 -2
- package/dist/message.d.mts +2 -2
- package/dist/message.d.ts +2 -2
- package/dist/message.js +83 -3
- package/dist/message.mjs +83 -3
- package/package.json +5 -5
package/dist/cluster.mjs
CHANGED
|
@@ -495,6 +495,13 @@ function toSudoBody(options) {
|
|
|
495
495
|
return body;
|
|
496
496
|
}
|
|
497
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
|
+
|
|
498
505
|
// src/Helpers/MessageUtils/Body.ts
|
|
499
506
|
import { AttachmentBuilder, EmbedBuilder, MessagePayload } from "@fluxerjs/builders";
|
|
500
507
|
import { MessageAttachmentFlags, MessageReferenceType } from "@fluxerjs/types";
|
|
@@ -1074,6 +1081,67 @@ var CDN_URL = "https://fluxerusercontent.com";
|
|
|
1074
1081
|
var STATIC_CDN_URL = "https://fluxerstatic.com";
|
|
1075
1082
|
|
|
1076
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
|
+
}
|
|
1077
1145
|
function mediaBase(options) {
|
|
1078
1146
|
return (options?.mediaBase ?? CDN_URL).replace(/\/+$/, "");
|
|
1079
1147
|
}
|
|
@@ -1085,31 +1153,33 @@ function getExtension(hash, options) {
|
|
|
1085
1153
|
if (hash?.startsWith("a_")) return "gif";
|
|
1086
1154
|
return ext;
|
|
1087
1155
|
}
|
|
1088
|
-
function appendSize(options) {
|
|
1089
|
-
|
|
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)}`;
|
|
1090
1160
|
}
|
|
1091
1161
|
function cdnAvatarURL(userId, avatarHash, options) {
|
|
1092
1162
|
if (!avatarHash) return null;
|
|
1093
1163
|
const ext = getExtension(avatarHash, options);
|
|
1094
|
-
const size = appendSize(options);
|
|
1164
|
+
const size = appendSize(options, "icon");
|
|
1095
1165
|
return `${mediaBase(options)}/avatars/${userId}/${avatarHash}.${ext}${size}`;
|
|
1096
1166
|
}
|
|
1097
1167
|
function cdnBannerURL(resourceId, bannerHash, options) {
|
|
1098
1168
|
if (!bannerHash) return null;
|
|
1099
1169
|
const ext = getExtension(bannerHash, options);
|
|
1100
|
-
const size = appendSize(options);
|
|
1170
|
+
const size = appendSize(options, "banner");
|
|
1101
1171
|
return `${mediaBase(options)}/banners/${resourceId}/${bannerHash}.${ext}${size}`;
|
|
1102
1172
|
}
|
|
1103
1173
|
function cdnMemberAvatarURL(guildId, userId, avatarHash, options) {
|
|
1104
1174
|
if (!avatarHash) return null;
|
|
1105
1175
|
const ext = getExtension(avatarHash, options);
|
|
1106
|
-
const size = appendSize(options);
|
|
1176
|
+
const size = appendSize(options, "icon");
|
|
1107
1177
|
return `${mediaBase(options)}/guilds/${guildId}/users/${userId}/avatars/${avatarHash}.${ext}${size}`;
|
|
1108
1178
|
}
|
|
1109
1179
|
function cdnMemberBannerURL(guildId, userId, bannerHash, options) {
|
|
1110
1180
|
if (!bannerHash) return null;
|
|
1111
1181
|
const ext = getExtension(bannerHash, options);
|
|
1112
|
-
const size = appendSize(options);
|
|
1182
|
+
const size = appendSize(options, "banner");
|
|
1113
1183
|
return `${mediaBase(options)}/guilds/${guildId}/users/${userId}/banners/${bannerHash}.${ext}${size}`;
|
|
1114
1184
|
}
|
|
1115
1185
|
function cdnDefaultAvatarURL(userIdOrIndex, options) {
|
|
@@ -1118,16 +1188,19 @@ function cdnDefaultAvatarURL(userIdOrIndex, options) {
|
|
|
1118
1188
|
}
|
|
1119
1189
|
function cdnGuildAssetURL(kind, id, hash, options) {
|
|
1120
1190
|
if (!hash) return null;
|
|
1121
|
-
const
|
|
1191
|
+
const assetClass = kind === "icons" ? "icon" : "banner";
|
|
1192
|
+
const size = appendSize(options, assetClass);
|
|
1122
1193
|
return `${mediaBase(options)}/${kind}/${id}/${hash}.png${size}`;
|
|
1123
1194
|
}
|
|
1124
1195
|
function cdnEmojiURL(emojiId, animated, options) {
|
|
1125
1196
|
const ext = animated ? "gif" : "png";
|
|
1126
|
-
|
|
1197
|
+
const size = appendSize(options, "emoji");
|
|
1198
|
+
return `${mediaBase(options)}/emojis/${emojiId}.${ext}${size}`;
|
|
1127
1199
|
}
|
|
1128
1200
|
function cdnStickerURL(stickerId, animated, options) {
|
|
1129
1201
|
const ext = animated ? "gif" : "png";
|
|
1130
|
-
|
|
1202
|
+
const size = appendSize(options, "sticker");
|
|
1203
|
+
return `${mediaBase(options)}/stickers/${stickerId}.${ext}${size}`;
|
|
1131
1204
|
}
|
|
1132
1205
|
|
|
1133
1206
|
// src/Domain/Message/MessageSticker.ts
|
|
@@ -1355,6 +1428,8 @@ var Message = class _Message extends Base {
|
|
|
1355
1428
|
mentionRoles;
|
|
1356
1429
|
/** Client-side nonce for deduplication. */
|
|
1357
1430
|
nonce;
|
|
1431
|
+
/** IDs of custom emojis in the message classified as explicit. */
|
|
1432
|
+
nsfwEmojis;
|
|
1358
1433
|
/**
|
|
1359
1434
|
* Cached text-capable channel (guild text, guild voice, or DM), or null if uncached / not text-based.
|
|
1360
1435
|
* Narrowed type has {@link Channel.send} and {@link Channel.delete}.
|
|
@@ -1429,6 +1504,7 @@ var Message = class _Message extends Base {
|
|
|
1429
1504
|
this.mentions = (data.mentions ?? []).map((u) => client.getOrCreateUser(u));
|
|
1430
1505
|
this.mentionRoles = data.mention_roles ?? [];
|
|
1431
1506
|
this.nonce = data.nonce ?? null;
|
|
1507
|
+
this.nsfwEmojis = data.nsfw_emojis ?? [];
|
|
1432
1508
|
}
|
|
1433
1509
|
/**
|
|
1434
1510
|
* Apply an API message payload in place (cache identity / MESSAGE_UPDATE).
|
|
@@ -1461,6 +1537,7 @@ var Message = class _Message extends Base {
|
|
|
1461
1537
|
this.mentions = (data.mentions ?? []).map((u) => this.client.getOrCreateUser(u));
|
|
1462
1538
|
this.mentionRoles = data.mention_roles ?? [];
|
|
1463
1539
|
this.nonce = data.nonce ?? null;
|
|
1540
|
+
this.nsfwEmojis = data.nsfw_emojis ?? [];
|
|
1464
1541
|
}
|
|
1465
1542
|
/**
|
|
1466
1543
|
* Send a standalone message in this channel (not a reply).
|
|
@@ -1544,8 +1621,10 @@ var Message = class _Message extends Base {
|
|
|
1544
1621
|
return this.client.channels.fetchMessage(this.channelId, this.id);
|
|
1545
1622
|
}
|
|
1546
1623
|
/** Delete this message. */
|
|
1547
|
-
async delete() {
|
|
1548
|
-
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
|
+
});
|
|
1549
1628
|
this.client._removeMessageFromCache(this.channelId, this.id);
|
|
1550
1629
|
}
|
|
1551
1630
|
/** Delete a specific attachment from this message. */
|
|
@@ -1859,6 +1938,29 @@ var MessageCollector = class _MessageCollector extends EventEmitter2 {
|
|
|
1859
1938
|
|
|
1860
1939
|
// src/Domain/Channel/Attachments.ts
|
|
1861
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
|
+
}
|
|
1862
1964
|
function asBytes(data) {
|
|
1863
1965
|
const src = data instanceof ArrayBuffer ? new Uint8Array(data) : new Uint8Array(data);
|
|
1864
1966
|
const out = new Uint8Array(src.byteLength);
|
|
@@ -1878,6 +1980,7 @@ async function putBlob(url, body, contentType) {
|
|
|
1878
1980
|
}
|
|
1879
1981
|
}
|
|
1880
1982
|
async function uploadAttachmentsForSend(client, channelId, files) {
|
|
1983
|
+
assertBotAttachmentLimits(client, files);
|
|
1881
1984
|
const plan = await client.rest.post(
|
|
1882
1985
|
Routes6.channelAttachments(channelId),
|
|
1883
1986
|
{
|
|
@@ -2174,11 +2277,12 @@ var Channel = class extends Base {
|
|
|
2174
2277
|
if (options?.silent) params.set("silent", "true");
|
|
2175
2278
|
if (options?.deleteMessages) params.set("delete_messages", "true");
|
|
2176
2279
|
const qs2 = params.toString();
|
|
2177
|
-
const { silent: _s, deleteMessages: _d, ...sudo } = options ?? {};
|
|
2280
|
+
const { silent: _s, deleteMessages: _d, reason: _reason, ...sudo } = options ?? {};
|
|
2178
2281
|
const body = Object.keys(sudo).length ? toSudoBody(sudo) : void 0;
|
|
2179
2282
|
await this.client.rest.delete(Routes7.channel(this.id) + (qs2 ? `?${qs2}` : ""), {
|
|
2180
2283
|
body,
|
|
2181
|
-
auth: true
|
|
2284
|
+
auth: true,
|
|
2285
|
+
...auditReasonHeaders(_reason)
|
|
2182
2286
|
});
|
|
2183
2287
|
this.client.channels.delete(this.id);
|
|
2184
2288
|
this.client._clearMessageCache(this.id);
|
|
@@ -2343,7 +2447,7 @@ import {
|
|
|
2343
2447
|
// src/Helpers/Instance.ts
|
|
2344
2448
|
import { isRecord } from "@fluxerjs/util";
|
|
2345
2449
|
var DEFAULT_INSTANCE_ENDPOINTS = Object.freeze({
|
|
2346
|
-
api: "https://
|
|
2450
|
+
api: "https://web.fluxer.app/api",
|
|
2347
2451
|
api_client: "https://web.fluxer.app/api",
|
|
2348
2452
|
api_public: "https://api.fluxer.app",
|
|
2349
2453
|
gateway: "wss://gateway.fluxer.app",
|
|
@@ -2377,6 +2481,10 @@ function requireString(obj, key, path) {
|
|
|
2377
2481
|
}
|
|
2378
2482
|
return value;
|
|
2379
2483
|
}
|
|
2484
|
+
var INSTANCE_DISCOVERY_PATH = "/.well-known/fluxer";
|
|
2485
|
+
function instanceDiscoveryUrl(origin) {
|
|
2486
|
+
return `${normalizeApiOrigin(origin)}${INSTANCE_DISCOVERY_PATH}`;
|
|
2487
|
+
}
|
|
2380
2488
|
function normalizeApiOrigin(api) {
|
|
2381
2489
|
const trimmed = api.trim().replace(/\/+$/, "");
|
|
2382
2490
|
return trimmed.replace(/\/v\d+$/i, "");
|
|
@@ -2405,6 +2513,8 @@ function parseInstanceDiscovery(raw) {
|
|
|
2405
2513
|
endpoints[key] = requireString(raw.endpoints, key, "endpoints");
|
|
2406
2514
|
}
|
|
2407
2515
|
endpoints.api = normalizeApiOrigin(endpoints.api);
|
|
2516
|
+
endpoints.api_client = normalizeApiOrigin(endpoints.api_client);
|
|
2517
|
+
endpoints.api_public = normalizeApiOrigin(endpoints.api_public);
|
|
2408
2518
|
endpoints.invite = normalizeInviteBase(endpoints.invite);
|
|
2409
2519
|
endpoints.media = endpoints.media.replace(/\/+$/, "");
|
|
2410
2520
|
endpoints.static_cdn = endpoints.static_cdn.replace(/\/+$/, "");
|
|
@@ -2482,6 +2592,11 @@ function resolveInstanceEndpoints(input) {
|
|
|
2482
2592
|
}
|
|
2483
2593
|
}
|
|
2484
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
|
+
}
|
|
2485
2600
|
merged.invite = normalizeInviteBase(merged.invite);
|
|
2486
2601
|
merged.media = merged.media.replace(/\/+$/, "");
|
|
2487
2602
|
merged.static_cdn = merged.static_cdn.replace(/\/+$/, "");
|
|
@@ -2490,13 +2605,13 @@ function resolveInstanceEndpoints(input) {
|
|
|
2490
2605
|
discovery: null
|
|
2491
2606
|
});
|
|
2492
2607
|
}
|
|
2493
|
-
function resolveRestApi(
|
|
2494
|
-
const fromInstance = normalizeApiOrigin(
|
|
2608
|
+
function resolveRestApi(instanceApiPublic, restApi) {
|
|
2609
|
+
const fromInstance = normalizeApiOrigin(instanceApiPublic);
|
|
2495
2610
|
if (restApi === void 0) return fromInstance;
|
|
2496
2611
|
const fromRest = normalizeApiOrigin(restApi);
|
|
2497
2612
|
if (fromRest !== fromInstance) {
|
|
2498
2613
|
throw new FluxerError(
|
|
2499
|
-
`Conflicting API hosts: instance.
|
|
2614
|
+
`Conflicting API hosts: instance.api_public (${fromInstance}) vs rest.api (${fromRest}). Prefer ClientOptions.instance.`,
|
|
2500
2615
|
{ code: ErrorCodes.ConflictingInstanceConfig }
|
|
2501
2616
|
);
|
|
2502
2617
|
}
|
|
@@ -2978,7 +3093,8 @@ var GuildChannel = class extends Channel {
|
|
|
2978
3093
|
async edit(options) {
|
|
2979
3094
|
const data = await this.client.rest.patch(Routes13.channel(this.id), {
|
|
2980
3095
|
body: toChannelEditBody(options),
|
|
2981
|
-
auth: true
|
|
3096
|
+
auth: true,
|
|
3097
|
+
...auditReasonHeaders(options.reason)
|
|
2982
3098
|
});
|
|
2983
3099
|
this.name = data.name ?? this.name;
|
|
2984
3100
|
this.parentId = data.parent_id ?? this.parentId;
|
|
@@ -3510,9 +3626,10 @@ var GuildEmoji = class extends Base {
|
|
|
3510
3626
|
return `<${this.animated ? "a" : ""}:${this.name}:${this.id}>`;
|
|
3511
3627
|
}
|
|
3512
3628
|
/** Delete this emoji. Requires Manage Emojis and Stickers permission. */
|
|
3513
|
-
async delete() {
|
|
3629
|
+
async delete(reason) {
|
|
3514
3630
|
await this.client.rest.delete(Routes15.guildEmoji(this.guildId, this.id), {
|
|
3515
|
-
auth: true
|
|
3631
|
+
auth: true,
|
|
3632
|
+
...auditReasonHeaders(reason)
|
|
3516
3633
|
});
|
|
3517
3634
|
const guild = this.client.guilds.get(this.guildId);
|
|
3518
3635
|
if (guild) guild.emojis.delete(this.id);
|
|
@@ -3522,9 +3639,11 @@ var GuildEmoji = class extends Base {
|
|
|
3522
3639
|
* Requires Manage Emojis and Stickers permission.
|
|
3523
3640
|
*/
|
|
3524
3641
|
async edit(options) {
|
|
3642
|
+
const { reason, name } = options;
|
|
3525
3643
|
const data = await this.client.rest.patch(Routes15.guildEmoji(this.guildId, this.id), {
|
|
3526
|
-
body:
|
|
3527
|
-
auth: true
|
|
3644
|
+
body: { name },
|
|
3645
|
+
auth: true,
|
|
3646
|
+
...auditReasonHeaders(reason)
|
|
3528
3647
|
});
|
|
3529
3648
|
this.name = data.name;
|
|
3530
3649
|
return this;
|
|
@@ -3540,6 +3659,9 @@ import { OverwriteType } from "@fluxerjs/types";
|
|
|
3540
3659
|
import { ALL_PERMISSIONS_BIGINT, PermissionFlags as PermissionFlags2 } from "@fluxerjs/util";
|
|
3541
3660
|
function computePermissions(basePermissions, overwrites, memberRoles, memberId, isOwner) {
|
|
3542
3661
|
if (isOwner) return ALL_PERMISSIONS_BIGINT;
|
|
3662
|
+
if ((basePermissions & PermissionFlags2.Administrator) !== 0n) {
|
|
3663
|
+
return ALL_PERMISSIONS_BIGINT;
|
|
3664
|
+
}
|
|
3543
3665
|
let perms = basePermissions;
|
|
3544
3666
|
for (const overwrite of overwrites ?? []) {
|
|
3545
3667
|
const applies = overwrite.type === OverwriteType.Role && memberRoles.includes(overwrite.id) || overwrite.type === OverwriteType.Member && overwrite.id === memberId;
|
|
@@ -3548,7 +3670,7 @@ function computePermissions(basePermissions, overwrites, memberRoles, memberId,
|
|
|
3548
3670
|
const deny = BigInt(overwrite.deny || "0");
|
|
3549
3671
|
perms = perms & ~deny | allow;
|
|
3550
3672
|
}
|
|
3551
|
-
return
|
|
3673
|
+
return perms;
|
|
3552
3674
|
}
|
|
3553
3675
|
|
|
3554
3676
|
// src/Domain/Guild/GuildMemberRoleManager.ts
|
|
@@ -3754,7 +3876,8 @@ var GuildMember = class _GuildMember extends Base {
|
|
|
3754
3876
|
const route = isMe ? Routes17.guildMemberMe(this.guild.id) : Routes17.guildMember(this.guild.id, this.id);
|
|
3755
3877
|
const data = await this.client.rest.patch(route, {
|
|
3756
3878
|
body: toMemberEditBody(options),
|
|
3757
|
-
auth: true
|
|
3879
|
+
auth: true,
|
|
3880
|
+
...auditReasonHeaders(options.reason ?? options.timeoutReason)
|
|
3758
3881
|
});
|
|
3759
3882
|
this._patch(data);
|
|
3760
3883
|
if (options.bio !== void 0) this.bio = options.bio;
|
|
@@ -3788,8 +3911,8 @@ var GuildMember = class _GuildMember extends Base {
|
|
|
3788
3911
|
await this.edit({ channelId, connectionId });
|
|
3789
3912
|
}
|
|
3790
3913
|
/** Kick this member. Requires Kick Members. */
|
|
3791
|
-
async kick() {
|
|
3792
|
-
await this.guild.kick(this.id);
|
|
3914
|
+
async kick(reason) {
|
|
3915
|
+
await this.guild.kick(this.id, reason);
|
|
3793
3916
|
}
|
|
3794
3917
|
/** Ban this member. Requires Ban Members. */
|
|
3795
3918
|
async ban(options) {
|
|
@@ -3913,9 +4036,10 @@ var GuildSticker = class extends Base {
|
|
|
3913
4036
|
return SnowflakeUtil7.dateFromSnowflake(this.id);
|
|
3914
4037
|
}
|
|
3915
4038
|
/** Delete this sticker. Requires Manage Emojis and Stickers permission. */
|
|
3916
|
-
async delete() {
|
|
4039
|
+
async delete(reason) {
|
|
3917
4040
|
await this.client.rest.delete(Routes18.guildSticker(this.guildId, this.id), {
|
|
3918
|
-
auth: true
|
|
4041
|
+
auth: true,
|
|
4042
|
+
...auditReasonHeaders(reason)
|
|
3919
4043
|
});
|
|
3920
4044
|
const guild = this.client.guilds.get(this.guildId);
|
|
3921
4045
|
if (guild) guild.stickers.delete(this.id);
|
|
@@ -3925,9 +4049,11 @@ var GuildSticker = class extends Base {
|
|
|
3925
4049
|
* Requires Manage Emojis and Stickers permission.
|
|
3926
4050
|
*/
|
|
3927
4051
|
async edit(options) {
|
|
4052
|
+
const { reason, ...body } = options;
|
|
3928
4053
|
const data = await this.client.rest.patch(Routes18.guildSticker(this.guildId, this.id), {
|
|
3929
|
-
body
|
|
3930
|
-
auth: true
|
|
4054
|
+
body,
|
|
4055
|
+
auth: true,
|
|
4056
|
+
...auditReasonHeaders(reason)
|
|
3931
4057
|
});
|
|
3932
4058
|
const s = data;
|
|
3933
4059
|
this.name = s.name;
|
|
@@ -4054,16 +4180,21 @@ var Role = class _Role extends Base {
|
|
|
4054
4180
|
const body = toRoleEditBody(options);
|
|
4055
4181
|
const data = await this.client.rest.patch(Routes19.guildRole(this.guildId, this.id), {
|
|
4056
4182
|
body: Object.keys(body).length ? body : void 0,
|
|
4057
|
-
auth: true
|
|
4183
|
+
auth: true,
|
|
4184
|
+
...auditReasonHeaders(options.reason)
|
|
4058
4185
|
});
|
|
4059
4186
|
this._patch(data);
|
|
4060
4187
|
return this;
|
|
4061
4188
|
}
|
|
4062
4189
|
/**
|
|
4063
4190
|
* DELETE role. Requires Manage Roles.
|
|
4191
|
+
* @param reason - Audit log reason (`X-Audit-Log-Reason`)
|
|
4064
4192
|
*/
|
|
4065
|
-
async delete() {
|
|
4066
|
-
await this.client.rest.delete(Routes19.guildRole(this.guildId, this.id), {
|
|
4193
|
+
async delete(reason) {
|
|
4194
|
+
await this.client.rest.delete(Routes19.guildRole(this.guildId, this.id), {
|
|
4195
|
+
auth: true,
|
|
4196
|
+
...auditReasonHeaders(reason)
|
|
4197
|
+
});
|
|
4067
4198
|
this.client.guilds.get(this.guildId)?.roles.delete(this.id);
|
|
4068
4199
|
}
|
|
4069
4200
|
};
|
|
@@ -4314,7 +4445,10 @@ async function resolveClientEmoji(client, emoji, guildId) {
|
|
|
4314
4445
|
return parsed.name;
|
|
4315
4446
|
}
|
|
4316
4447
|
async function fetchInstance(client) {
|
|
4317
|
-
const raw = await client.rest.get(Routes21.instanceDiscovery(), {
|
|
4448
|
+
const raw = await client.rest.get(Routes21.instanceDiscovery(), {
|
|
4449
|
+
auth: false,
|
|
4450
|
+
unversioned: true
|
|
4451
|
+
});
|
|
4318
4452
|
return parseInstanceDiscovery(raw);
|
|
4319
4453
|
}
|
|
4320
4454
|
function fetchGatewayInfo(client) {
|
|
@@ -4693,9 +4827,11 @@ async function fetchEmoji(guild, emojiId) {
|
|
|
4693
4827
|
}
|
|
4694
4828
|
}
|
|
4695
4829
|
async function createEmoji(guild, options) {
|
|
4830
|
+
const { reason, ...body } = options;
|
|
4696
4831
|
const data = await guild.client.rest.post(Routes25.guildEmojis(guild.id), {
|
|
4697
|
-
body
|
|
4698
|
-
auth: true
|
|
4832
|
+
body,
|
|
4833
|
+
auth: true,
|
|
4834
|
+
...auditReasonHeaders(reason)
|
|
4699
4835
|
});
|
|
4700
4836
|
return cacheEmoji(guild, data);
|
|
4701
4837
|
}
|
|
@@ -4714,6 +4850,19 @@ async function createEmojisBulk(guild, emojis) {
|
|
|
4714
4850
|
return { success: data.success.map((e) => cacheEmoji(guild, e)), failed: data.failed };
|
|
4715
4851
|
}
|
|
4716
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
|
+
|
|
4717
4866
|
// src/Domain/Guild/MemberHttp.ts
|
|
4718
4867
|
import { Routes as Routes26 } from "@fluxerjs/types";
|
|
4719
4868
|
async function fetchMember(guild, userId) {
|
|
@@ -4770,9 +4919,10 @@ var GuildBan = class extends Base {
|
|
|
4770
4919
|
* Remove this ban (unban the user).
|
|
4771
4920
|
* Requires Ban Members permission.
|
|
4772
4921
|
*/
|
|
4773
|
-
async unban() {
|
|
4922
|
+
async unban(reason) {
|
|
4774
4923
|
await this.client.rest.delete(Routes27.guildBan(this.guildId, this.user.id), {
|
|
4775
|
-
auth: true
|
|
4924
|
+
auth: true,
|
|
4925
|
+
...auditReasonHeaders(reason)
|
|
4776
4926
|
});
|
|
4777
4927
|
}
|
|
4778
4928
|
};
|
|
@@ -4782,33 +4932,27 @@ async function ban(guild, userId, options) {
|
|
|
4782
4932
|
const body = options ? toGuildBanBody(options) : {};
|
|
4783
4933
|
await guild.client.rest.put(Routes28.guildBan(guild.id, userId), {
|
|
4784
4934
|
body: Object.keys(body).length ? body : void 0,
|
|
4785
|
-
auth: true
|
|
4935
|
+
auth: true,
|
|
4936
|
+
...auditReasonHeaders(options?.reason)
|
|
4786
4937
|
});
|
|
4787
4938
|
}
|
|
4788
4939
|
async function fetchBans(guild) {
|
|
4789
4940
|
const data = await guild.client.rest.get(Routes28.guildBans(guild.id));
|
|
4790
4941
|
return data.map((b) => new GuildBan(guild.client, { ...b, guild_id: guild.id }, guild.id));
|
|
4791
4942
|
}
|
|
4792
|
-
async function unban(guild, userId) {
|
|
4793
|
-
await guild.client.rest.delete(Routes28.guildBan(guild.id, userId), {
|
|
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
|
+
});
|
|
4794
4948
|
}
|
|
4795
|
-
async function kick(guild, userId) {
|
|
4796
|
-
await guild.client.rest.delete(Routes28.guildMember(guild.id, userId), {
|
|
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
|
+
});
|
|
4797
4954
|
}
|
|
4798
4955
|
|
|
4799
|
-
// src/Domain/Guild/GuildRoleManager.ts
|
|
4800
|
-
import { LimitedCollection as LimitedCollection3 } from "@fluxerjs/collection";
|
|
4801
|
-
var GuildRoleManager = class extends LimitedCollection3 {
|
|
4802
|
-
constructor(guildId, options) {
|
|
4803
|
-
super(options);
|
|
4804
|
-
this.guildId = guildId;
|
|
4805
|
-
}
|
|
4806
|
-
/** The @everyone role (`id === guild.id`), or undefined if uncached. */
|
|
4807
|
-
get everyone() {
|
|
4808
|
-
return this.get(this.guildId);
|
|
4809
|
-
}
|
|
4810
|
-
};
|
|
4811
|
-
|
|
4812
4956
|
// src/Domain/Guild/Roles.ts
|
|
4813
4957
|
import { Routes as Routes29 } from "@fluxerjs/types";
|
|
4814
4958
|
import { parseRoleMention } from "@fluxerjs/util";
|
|
@@ -4816,7 +4960,8 @@ async function createRole(guild, options = {}) {
|
|
|
4816
4960
|
const body = toRoleCreateBody(options);
|
|
4817
4961
|
const data = await guild.client.rest.post(Routes29.guildRoles(guild.id), {
|
|
4818
4962
|
body: Object.keys(body).length ? body : void 0,
|
|
4819
|
-
auth: true
|
|
4963
|
+
auth: true,
|
|
4964
|
+
...auditReasonHeaders(options.reason)
|
|
4820
4965
|
});
|
|
4821
4966
|
return cacheRole(guild, data);
|
|
4822
4967
|
}
|
|
@@ -4882,9 +5027,11 @@ async function resetRoleHoistPositions(guild) {
|
|
|
4882
5027
|
// src/Domain/Guild/Stickers.ts
|
|
4883
5028
|
import { Routes as Routes30 } from "@fluxerjs/types";
|
|
4884
5029
|
async function createSticker(guild, options) {
|
|
5030
|
+
const { reason, ...body } = options;
|
|
4885
5031
|
const data = await guild.client.rest.post(Routes30.guildStickers(guild.id), {
|
|
4886
|
-
body
|
|
4887
|
-
auth: true
|
|
5032
|
+
body,
|
|
5033
|
+
auth: true,
|
|
5034
|
+
...auditReasonHeaders(reason)
|
|
4888
5035
|
});
|
|
4889
5036
|
return cacheSticker(guild, data);
|
|
4890
5037
|
}
|
|
@@ -5214,12 +5361,12 @@ var Guild = class extends Base {
|
|
|
5214
5361
|
return fetchBans(this);
|
|
5215
5362
|
}
|
|
5216
5363
|
/** Unban a user from the guild. Requires Ban Members. */
|
|
5217
|
-
unban(userId) {
|
|
5218
|
-
return unban(this, userId);
|
|
5364
|
+
unban(userId, reason) {
|
|
5365
|
+
return unban(this, userId, reason);
|
|
5219
5366
|
}
|
|
5220
5367
|
/** Kick a user from the guild. Requires Kick Members. */
|
|
5221
|
-
kick(userId) {
|
|
5222
|
-
return kick(this, userId);
|
|
5368
|
+
kick(userId, reason) {
|
|
5369
|
+
return kick(this, userId, reason);
|
|
5223
5370
|
}
|
|
5224
5371
|
/** Fetch all emojis in this guild from the API. */
|
|
5225
5372
|
fetchEmojis() {
|
|
@@ -5669,7 +5816,14 @@ function markGuildUnavailable(client, id) {
|
|
|
5669
5816
|
guild.available = false;
|
|
5670
5817
|
client.emit(Events.GuildUnavailable, guild);
|
|
5671
5818
|
}
|
|
5819
|
+
function isStartupGuildHydration(client) {
|
|
5820
|
+
return client._guildStreamSettleTimeout !== null;
|
|
5821
|
+
}
|
|
5672
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
|
+
*/
|
|
5673
5827
|
GUILD_CREATE(client, d) {
|
|
5674
5828
|
const raw = d;
|
|
5675
5829
|
if (raw.unavailable === true) {
|
|
@@ -5682,11 +5836,32 @@ var guildHandlers = {
|
|
|
5682
5836
|
}
|
|
5683
5837
|
return;
|
|
5684
5838
|
}
|
|
5839
|
+
const startupHydration = isStartupGuildHydration(client);
|
|
5840
|
+
if (startupHydration) {
|
|
5841
|
+
resetGuildStreamSettle(client);
|
|
5842
|
+
}
|
|
5685
5843
|
const result = applyGuildSnapshotFromGateway(client, d);
|
|
5686
5844
|
if (!result) return;
|
|
5687
5845
|
const { guild, recovered } = result;
|
|
5688
|
-
|
|
5689
|
-
|
|
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
|
+
}
|
|
5690
5865
|
client._onGuildReceived(guild.id);
|
|
5691
5866
|
},
|
|
5692
5867
|
GUILD_UPDATE(client, d) {
|
|
@@ -5725,6 +5900,7 @@ var guildHandlers = {
|
|
|
5725
5900
|
markGuildUnavailable(client, id);
|
|
5726
5901
|
return;
|
|
5727
5902
|
}
|
|
5903
|
+
client._readyStubGuildIds.delete(id);
|
|
5728
5904
|
const guild = client.guilds.get(id);
|
|
5729
5905
|
if (!guild) return;
|
|
5730
5906
|
client.guilds.delete(id);
|
|
@@ -6243,10 +6419,15 @@ function hydrateReadyGuilds(client, guilds, waitForGuilds) {
|
|
|
6243
6419
|
for (const g of guilds ?? []) {
|
|
6244
6420
|
if (g.unavailable === true) {
|
|
6245
6421
|
if (typeof g.id === "string") {
|
|
6246
|
-
|
|
6247
|
-
if (
|
|
6248
|
-
|
|
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;
|
|
6249
6429
|
}
|
|
6430
|
+
client._readyStubGuildIds.add(g.id);
|
|
6250
6431
|
if (pending !== null) pending.add(g.id);
|
|
6251
6432
|
}
|
|
6252
6433
|
continue;
|
|
@@ -6274,6 +6455,13 @@ function clearGuildStreamSettle(client) {
|
|
|
6274
6455
|
clearTimeout(client._guildStreamSettleTimeout);
|
|
6275
6456
|
client._guildStreamSettleTimeout = null;
|
|
6276
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
|
+
}
|
|
6277
6465
|
function handleReadyPayload(client, data) {
|
|
6278
6466
|
client.user = new ClientUser(client, data.user);
|
|
6279
6467
|
const waitForGuilds = client.options.waitForGuilds === true;
|
|
@@ -6293,14 +6481,9 @@ function handleReadyPayload(client, data) {
|
|
|
6293
6481
|
client._pendingGuildIds = existing;
|
|
6294
6482
|
return;
|
|
6295
6483
|
}
|
|
6296
|
-
if (
|
|
6297
|
-
|
|
6298
|
-
|
|
6299
|
-
client._guildStreamSettleTimeout = null;
|
|
6300
|
-
if (client.readyAt === null) finalizeClientReady(client);
|
|
6301
|
-
}, GUILD_STREAM_SETTLE_MS);
|
|
6302
|
-
}
|
|
6303
|
-
return;
|
|
6484
|
+
if (guilds.length === 0) {
|
|
6485
|
+
resetGuildStreamSettle(client);
|
|
6486
|
+
if (waitForGuilds) return;
|
|
6304
6487
|
}
|
|
6305
6488
|
finalizeClientReady(client);
|
|
6306
6489
|
}
|
|
@@ -6635,7 +6818,12 @@ var Client = class _Client extends EventEmitter3 {
|
|
|
6635
6818
|
_ws = null;
|
|
6636
6819
|
/** When waitForGuilds, guild IDs still expected via GUILD_CREATE. */
|
|
6637
6820
|
_pendingGuildIds = null;
|
|
6638
|
-
/**
|
|
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
|
+
*/
|
|
6639
6827
|
_guildStreamSettleTimeout = null;
|
|
6640
6828
|
/** @internal Dispatches queued until Ready when waitForGuilds delays Ready. */
|
|
6641
6829
|
_deferredGatewayDispatches = [];
|
|
@@ -6666,7 +6854,7 @@ var Client = class _Client extends EventEmitter3 {
|
|
|
6666
6854
|
const restApi = options.rest?.api;
|
|
6667
6855
|
if (options.instance !== void 0) {
|
|
6668
6856
|
this.instance = resolveInstanceEndpoints(options.instance);
|
|
6669
|
-
resolveRestApi(this.instance.endpoints.
|
|
6857
|
+
resolveRestApi(this.instance.endpoints.api_public, restApi);
|
|
6670
6858
|
} else {
|
|
6671
6859
|
this.instance = resolveInstanceEndpoints(
|
|
6672
6860
|
restApi !== void 0 ? { api: restApi } : void 0
|
|
@@ -6679,27 +6867,31 @@ var Client = class _Client extends EventEmitter3 {
|
|
|
6679
6867
|
}
|
|
6680
6868
|
this.rest = new REST({
|
|
6681
6869
|
...this.options.rest,
|
|
6682
|
-
api: this.instance.endpoints.
|
|
6683
|
-
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
|
|
6684
6873
|
});
|
|
6685
6874
|
}
|
|
6686
6875
|
/**
|
|
6687
6876
|
* Create a client from instance discovery (`GET /.well-known/fluxer`).
|
|
6688
|
-
*
|
|
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.
|
|
6689
6880
|
*
|
|
6690
|
-
* @param origin -
|
|
6691
|
-
* @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`)
|
|
6692
6883
|
* @param connectOptions - Optional abort signal for the discovery request
|
|
6693
6884
|
*/
|
|
6694
6885
|
static async fromDiscovery(origin, options = {}, connectOptions) {
|
|
6695
|
-
const
|
|
6886
|
+
const bootstrapOrigin = typeof origin === "string" ? normalizeApiOrigin(origin) : normalizeApiOrigin(origin.api);
|
|
6696
6887
|
const version = typeof origin === "string" ? options.rest?.version ?? "1" : origin.version ?? options.rest?.version ?? "1";
|
|
6697
6888
|
const bootstrap = new REST({
|
|
6698
6889
|
...options.rest ?? {},
|
|
6699
|
-
api:
|
|
6700
|
-
version
|
|
6890
|
+
api: bootstrapOrigin,
|
|
6891
|
+
version,
|
|
6892
|
+
locale: options.locale ?? options.rest?.locale
|
|
6701
6893
|
});
|
|
6702
|
-
const raw = await bootstrap.get(
|
|
6894
|
+
const raw = await bootstrap.get(instanceDiscoveryUrl(bootstrapOrigin), {
|
|
6703
6895
|
auth: false,
|
|
6704
6896
|
...connectOptions?.signal ? { signal: connectOptions.signal } : {}
|
|
6705
6897
|
});
|
|
@@ -6707,7 +6899,7 @@ var Client = class _Client extends EventEmitter3 {
|
|
|
6707
6899
|
const { rest, ...restOptions } = options;
|
|
6708
6900
|
return new _Client({
|
|
6709
6901
|
...restOptions,
|
|
6710
|
-
// Drop rest.api so discovered endpoints.
|
|
6902
|
+
// Drop rest.api so discovered endpoints.api_public owns the REST host; keep other REST opts.
|
|
6711
6903
|
...rest ? { rest: { ...rest, api: void 0 } } : {},
|
|
6712
6904
|
instance: discovery
|
|
6713
6905
|
});
|
|
@@ -6734,7 +6926,7 @@ var Client = class _Client extends EventEmitter3 {
|
|
|
6734
6926
|
return resolveClientEmoji(this, emoji, guildId);
|
|
6735
6927
|
}
|
|
6736
6928
|
/**
|
|
6737
|
-
* Fetch instance discovery document (
|
|
6929
|
+
* Fetch instance discovery document (unversioned `GET /.well-known/fluxer` on the REST host).
|
|
6738
6930
|
* @returns Instance configuration (endpoints, features, metadata)
|
|
6739
6931
|
*/
|
|
6740
6932
|
fetchInstance() {
|
|
@@ -7003,6 +7195,7 @@ var Client = class _Client extends EventEmitter3 {
|
|
|
7003
7195
|
this.user = null;
|
|
7004
7196
|
this.readyAt = null;
|
|
7005
7197
|
this._pendingGuildIds = null;
|
|
7198
|
+
this._readyStubGuildIds.clear();
|
|
7006
7199
|
this.guilds.clear();
|
|
7007
7200
|
this.channels.clear();
|
|
7008
7201
|
this.users.clear();
|