@fluxerjs/core 1.3.0 → 1.4.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/client.d.mts +1 -1
- package/dist/client.d.ts +1 -1
- package/dist/client.js +338 -202
- package/dist/client.mjs +213 -75
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +354 -206
- package/dist/index.mjs +229 -76
- package/dist/message.d.mts +1 -1
- package/dist/message.d.ts +1 -1
- package/dist/message.js +97 -36
- package/dist/message.mjs +85 -24
- package/dist/{subpath-message-b43enjDT.d.mts → subpath-message-DSs_mdc4.d.mts} +148 -24
- package/dist/{subpath-message-b43enjDT.d.ts → subpath-message-DSs_mdc4.d.ts} +148 -24
- package/package.json +7 -7
package/dist/index.mjs
CHANGED
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
} from "@fluxerjs/types";
|
|
8
8
|
|
|
9
9
|
// src/client/ChannelManager.ts
|
|
10
|
-
import { Collection as
|
|
10
|
+
import { Collection as Collection5 } from "@fluxerjs/collection";
|
|
11
11
|
import { Routes as Routes6 } from "@fluxerjs/types";
|
|
12
12
|
import { emitDeprecationWarning as emitDeprecationWarning2 } from "@fluxerjs/util";
|
|
13
13
|
import { FluxerAPIError as FluxerAPIError2, RateLimitError as RateLimitError2 } from "@fluxerjs/rest";
|
|
@@ -19,12 +19,14 @@ import { FluxerError } from "@fluxerjs/util";
|
|
|
19
19
|
import { ErrorCodes } from "@fluxerjs/util";
|
|
20
20
|
|
|
21
21
|
// src/util/messageUtils.ts
|
|
22
|
+
import { MessageFlags } from "@fluxerjs/types";
|
|
22
23
|
import { EmbedBuilder } from "@fluxerjs/builders";
|
|
23
24
|
var FILE_FETCH_TIMEOUT_MS = 3e4;
|
|
24
25
|
async function resolveMessageFiles(files) {
|
|
25
26
|
const result = [];
|
|
26
27
|
for (let i = 0; i < files.length; i++) {
|
|
27
28
|
const f = files[i];
|
|
29
|
+
if (!f) continue;
|
|
28
30
|
const filename = f.filename ?? f.name;
|
|
29
31
|
if ("url" in f && f.url) {
|
|
30
32
|
if (!URL.canParse(f.url)) {
|
|
@@ -63,6 +65,29 @@ async function resolveMessageFiles(files) {
|
|
|
63
65
|
}
|
|
64
66
|
return result;
|
|
65
67
|
}
|
|
68
|
+
var AllowedMentions = {
|
|
69
|
+
/** Suppress the replied-to user's @mention notification. The reply thread still appears. */
|
|
70
|
+
suppressReplyPing: { repliedUser: false },
|
|
71
|
+
/** Parse no mentions from content — @user, @role, and @everyone will not notify. */
|
|
72
|
+
none: { parse: [] },
|
|
73
|
+
/** Parse user, role, and @everyone mentions (typical default when the field is omitted). */
|
|
74
|
+
all: { parse: ["users", "roles", "everyone"] }
|
|
75
|
+
};
|
|
76
|
+
function toAPIAllowedMentions(options) {
|
|
77
|
+
const result = {};
|
|
78
|
+
if (options.parse?.length) result.parse = options.parse;
|
|
79
|
+
if (options.users?.length) result.users = options.users;
|
|
80
|
+
if (options.roles?.length) result.roles = options.roles;
|
|
81
|
+
if (options.repliedUser !== void 0) result.replied_user = options.repliedUser;
|
|
82
|
+
return result;
|
|
83
|
+
}
|
|
84
|
+
function applyReplyPingSuppression(body) {
|
|
85
|
+
body.flags = (body.flags ?? 0) | MessageFlags.SuppressNotifications;
|
|
86
|
+
body.allowed_mentions = {
|
|
87
|
+
...body.allowed_mentions ?? {},
|
|
88
|
+
replied_user: false
|
|
89
|
+
};
|
|
90
|
+
}
|
|
66
91
|
function buildSendBody(options) {
|
|
67
92
|
const body = typeof options === "string" ? { content: options } : options;
|
|
68
93
|
const result = {};
|
|
@@ -84,12 +109,43 @@ function buildSendBody(options) {
|
|
|
84
109
|
filename: f.filename ?? f.name
|
|
85
110
|
}));
|
|
86
111
|
}
|
|
112
|
+
if (body.allowedMentions) result.allowed_mentions = toAPIAllowedMentions(body.allowedMentions);
|
|
113
|
+
if (body.stickerIds?.length) result.sticker_ids = body.stickerIds;
|
|
114
|
+
if (body.nonce !== void 0) result.nonce = body.nonce;
|
|
115
|
+
if (body.favoriteMemeId !== void 0) result.favorite_meme_id = body.favoriteMemeId;
|
|
116
|
+
if (body.tts !== void 0) result.tts = body.tts;
|
|
87
117
|
if (body.flags !== void 0) result.flags = body.flags;
|
|
88
118
|
return result;
|
|
89
119
|
}
|
|
120
|
+
function toMessageReference(target) {
|
|
121
|
+
const ref = {
|
|
122
|
+
channel_id: target.channelId,
|
|
123
|
+
message_id: target.messageId
|
|
124
|
+
};
|
|
125
|
+
if (target.guildId != null && target.guildId !== "") ref.guild_id = target.guildId;
|
|
126
|
+
return ref;
|
|
127
|
+
}
|
|
128
|
+
async function prepareMessagePostPayload(options) {
|
|
129
|
+
if (typeof options === "string") {
|
|
130
|
+
if (options.length === 0) throw new RangeError("Cannot send an empty message");
|
|
131
|
+
options = { content: options };
|
|
132
|
+
}
|
|
133
|
+
const { replyTo, ping, files, allowedMentions, ...sendFields } = options;
|
|
134
|
+
const body = buildSendBody({ ...sendFields, files, allowedMentions });
|
|
135
|
+
if (replyTo) {
|
|
136
|
+
body.message_reference = toMessageReference(replyTo);
|
|
137
|
+
const suppressPing = ping === false || allowedMentions?.repliedUser === false || body.allowed_mentions?.replied_user === false;
|
|
138
|
+
if (suppressPing) applyReplyPingSuppression(body);
|
|
139
|
+
} else if (allowedMentions?.repliedUser === false) {
|
|
140
|
+
applyReplyPingSuppression(body);
|
|
141
|
+
}
|
|
142
|
+
const resolvedFiles = files?.length ? await resolveMessageFiles(files) : void 0;
|
|
143
|
+
return { body, files: resolvedFiles };
|
|
144
|
+
}
|
|
90
145
|
|
|
91
146
|
// src/client/MessageManager.ts
|
|
92
147
|
import { Routes as Routes2 } from "@fluxerjs/types";
|
|
148
|
+
import { Collection as Collection3 } from "@fluxerjs/collection";
|
|
93
149
|
import { FluxerAPIError, RateLimitError } from "@fluxerjs/rest";
|
|
94
150
|
|
|
95
151
|
// src/structures/Base.ts
|
|
@@ -98,7 +154,7 @@ var Base = class {
|
|
|
98
154
|
|
|
99
155
|
// src/structures/Message.ts
|
|
100
156
|
import { Collection as Collection2 } from "@fluxerjs/collection";
|
|
101
|
-
import { MessageType,
|
|
157
|
+
import { MessageType, Routes } from "@fluxerjs/types";
|
|
102
158
|
import { EmbedBuilder as EmbedBuilder2 } from "@fluxerjs/builders";
|
|
103
159
|
|
|
104
160
|
// src/util/ReactionCollector.ts
|
|
@@ -302,7 +358,7 @@ var Message = class _Message extends Base {
|
|
|
302
358
|
* await message.send({ content: 'File', files: [{ name: 'data.txt', data }] });
|
|
303
359
|
*/
|
|
304
360
|
async send(options) {
|
|
305
|
-
const payload = await
|
|
361
|
+
const payload = await prepareMessagePostPayload(options);
|
|
306
362
|
return this._send(payload);
|
|
307
363
|
}
|
|
308
364
|
/**
|
|
@@ -323,42 +379,53 @@ var Message = class _Message extends Base {
|
|
|
323
379
|
* await message.reply('Pong!');
|
|
324
380
|
* await message.reply({ embeds: [embed] });
|
|
325
381
|
* await message.reply('No ping!', { ping: false });
|
|
382
|
+
* await message.reply({ content: 'Silent reply', allowedMentions: AllowedMentions.suppressReplyPing });
|
|
326
383
|
* await message.reply({ content: 'Reply to other', replyTo: otherMessage });
|
|
327
384
|
*/
|
|
328
385
|
async reply(options, replyOptions) {
|
|
329
386
|
const opts = typeof options === "string" ? { content: options } : options;
|
|
330
387
|
const mergedReply = replyOptions ?? (opts.ping !== void 0 || opts.replyTo !== void 0) ? { ping: opts.ping, replyTo: opts.replyTo } : void 0;
|
|
331
388
|
const refMessage = mergedReply?.replyTo ?? this;
|
|
332
|
-
const
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
} :
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
389
|
+
const replyTo = refMessage instanceof _Message ? {
|
|
390
|
+
channelId: refMessage.channelId,
|
|
391
|
+
messageId: refMessage.id,
|
|
392
|
+
guildId: refMessage.guildId
|
|
393
|
+
} : refMessage;
|
|
394
|
+
const { replyTo: _ignored, ping: _ping, ...sendOpts } = opts;
|
|
395
|
+
const payload = await prepareMessagePostPayload({
|
|
396
|
+
...sendOpts,
|
|
397
|
+
replyTo,
|
|
398
|
+
ping: mergedReply?.ping
|
|
399
|
+
});
|
|
342
400
|
return this._send(payload);
|
|
343
401
|
}
|
|
344
|
-
/** Exposed for testing
|
|
402
|
+
/** Exposed for testing — prefer `message.reply()` / `prepareMessagePostPayload()`. */
|
|
345
403
|
static async _createMessageBody(content, referenced_message, ping) {
|
|
404
|
+
if (typeof content === "string" && content.length === 0) {
|
|
405
|
+
throw new RangeError("Cannot send an empty message");
|
|
406
|
+
}
|
|
346
407
|
if (typeof content === "string") {
|
|
347
|
-
|
|
348
|
-
|
|
408
|
+
const opts2 = { content };
|
|
409
|
+
if (referenced_message) {
|
|
410
|
+
opts2.replyTo = {
|
|
411
|
+
channelId: referenced_message.channel_id,
|
|
412
|
+
messageId: referenced_message.message_id,
|
|
413
|
+
...referenced_message.guild_id != null ? { guildId: referenced_message.guild_id } : {}
|
|
414
|
+
};
|
|
415
|
+
if (ping !== void 0) opts2.ping = ping;
|
|
349
416
|
}
|
|
350
|
-
|
|
417
|
+
return prepareMessagePostPayload(opts2);
|
|
351
418
|
}
|
|
352
|
-
const
|
|
353
|
-
const files = content.files?.length ? await resolveMessageFiles(content.files) : void 0;
|
|
354
|
-
const body = { ...base };
|
|
419
|
+
const opts = { ...content };
|
|
355
420
|
if (referenced_message) {
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
421
|
+
opts.replyTo = {
|
|
422
|
+
channelId: referenced_message.channel_id,
|
|
423
|
+
messageId: referenced_message.message_id,
|
|
424
|
+
...referenced_message.guild_id != null ? { guildId: referenced_message.guild_id } : {}
|
|
425
|
+
};
|
|
426
|
+
if (ping !== void 0) opts.ping = ping;
|
|
360
427
|
}
|
|
361
|
-
return
|
|
428
|
+
return prepareMessagePostPayload(opts);
|
|
362
429
|
}
|
|
363
430
|
async _send(payload) {
|
|
364
431
|
const data = await this.client.rest.post(
|
|
@@ -378,6 +445,9 @@ var Message = class _Message extends Base {
|
|
|
378
445
|
if (options.embeds?.length) {
|
|
379
446
|
body.embeds = options.embeds.map((e) => e instanceof EmbedBuilder2 ? e.toJSON() : e);
|
|
380
447
|
}
|
|
448
|
+
if (options.allowedMentions) {
|
|
449
|
+
body.allowed_mentions = toAPIAllowedMentions(options.allowedMentions);
|
|
450
|
+
}
|
|
381
451
|
const data = await this.client.rest.patch(Routes.channelMessage(this.channelId, this.id), {
|
|
382
452
|
body
|
|
383
453
|
});
|
|
@@ -511,14 +581,13 @@ var MessageManager = class {
|
|
|
511
581
|
const data = this.client._getMessageCache(this.channelId)?.get(messageId);
|
|
512
582
|
return data ? new Message(this.client, data) : void 0;
|
|
513
583
|
}
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
async fetch(messageId) {
|
|
584
|
+
async fetch(messageIdOrOptions) {
|
|
585
|
+
if (typeof messageIdOrOptions === "string") {
|
|
586
|
+
return this.fetchOne(messageIdOrOptions);
|
|
587
|
+
}
|
|
588
|
+
return this.fetchMany(messageIdOrOptions);
|
|
589
|
+
}
|
|
590
|
+
async fetchOne(messageId) {
|
|
522
591
|
try {
|
|
523
592
|
const data = await this.client.rest.get(
|
|
524
593
|
Routes2.channelMessage(this.channelId, messageId)
|
|
@@ -536,16 +605,37 @@ var MessageManager = class {
|
|
|
536
605
|
throw err instanceof FluxerError ? err : new FluxerError(String(err), { cause: err });
|
|
537
606
|
}
|
|
538
607
|
}
|
|
608
|
+
async fetchMany(options) {
|
|
609
|
+
const params = new URLSearchParams();
|
|
610
|
+
if (options.limit != null) {
|
|
611
|
+
if (options.limit < 1 || options.limit > 100) {
|
|
612
|
+
throw new RangeError("limit must be between 1 and 100");
|
|
613
|
+
}
|
|
614
|
+
params.set("limit", String(options.limit));
|
|
615
|
+
}
|
|
616
|
+
if (options.before) params.set("before", options.before);
|
|
617
|
+
if (options.after) params.set("after", options.after);
|
|
618
|
+
if (options.around) params.set("around", options.around);
|
|
619
|
+
const qs = params.toString();
|
|
620
|
+
const route = Routes2.channelMessages(this.channelId) + (qs ? `?${qs}` : "");
|
|
621
|
+
const data = await this.client.rest.get(route);
|
|
622
|
+
const collection = new Collection3();
|
|
623
|
+
for (const msg of data) {
|
|
624
|
+
this.client._addMessageToCache(this.channelId, msg);
|
|
625
|
+
collection.set(msg.id, new Message(this.client, msg));
|
|
626
|
+
}
|
|
627
|
+
return collection;
|
|
628
|
+
}
|
|
539
629
|
};
|
|
540
630
|
|
|
541
631
|
// src/util/MessageCollector.ts
|
|
542
632
|
import { EventEmitter as EventEmitter2 } from "events";
|
|
543
|
-
import { Collection as
|
|
633
|
+
import { Collection as Collection4 } from "@fluxerjs/collection";
|
|
544
634
|
var MessageCollector = class extends EventEmitter2 {
|
|
545
635
|
client;
|
|
546
636
|
channelId;
|
|
547
637
|
options;
|
|
548
|
-
collected = new
|
|
638
|
+
collected = new Collection4();
|
|
549
639
|
_timeout = null;
|
|
550
640
|
_ended = false;
|
|
551
641
|
_listener;
|
|
@@ -733,7 +823,6 @@ var Webhook = class _Webhook extends Base {
|
|
|
733
823
|
const body = buildSendBody(opts);
|
|
734
824
|
if (opts.username !== void 0) body.username = opts.username;
|
|
735
825
|
if (opts.avatar_url !== void 0) body.avatar_url = opts.avatar_url;
|
|
736
|
-
if (opts.tts !== void 0) body.tts = opts.tts;
|
|
737
826
|
const route = Routes3.webhookExecute(this.id, this.token) + (wait ? "?wait=true" : "");
|
|
738
827
|
const files = opts.files?.length ? await resolveMessageFiles(opts.files) : void 0;
|
|
739
828
|
const postOptions = files?.length ? { body, files, auth: false } : { body, auth: false };
|
|
@@ -1004,6 +1093,20 @@ var Channel = class _Channel extends Base {
|
|
|
1004
1093
|
async sendTyping() {
|
|
1005
1094
|
await this.client.rest.post(Routes5.channelTyping(this.id), { auth: true });
|
|
1006
1095
|
}
|
|
1096
|
+
/**
|
|
1097
|
+
* Fetch available RTC regions for voice/video in this channel.
|
|
1098
|
+
* GET /channels/{id}/rtc-regions
|
|
1099
|
+
*/
|
|
1100
|
+
async fetchRtcRegions() {
|
|
1101
|
+
return this.client.rest.get(Routes5.channelRtcRegions(this.id), { auth: true });
|
|
1102
|
+
}
|
|
1103
|
+
/**
|
|
1104
|
+
* Fetch the current user's slowmode state in this channel.
|
|
1105
|
+
* GET /channels/{id}/slowmode
|
|
1106
|
+
*/
|
|
1107
|
+
async fetchSlowmode() {
|
|
1108
|
+
return this.client.rest.get(Routes5.channelSlowmode(this.id), { auth: true });
|
|
1109
|
+
}
|
|
1007
1110
|
/**
|
|
1008
1111
|
* Whether the bot can send messages in this channel.
|
|
1009
1112
|
* For DMs: always true (when the channel exists).
|
|
@@ -1114,11 +1217,8 @@ var GuildChannel = class extends Channel {
|
|
|
1114
1217
|
* Works for text and announcement channels. Voice/category/link channels will fail at the API.
|
|
1115
1218
|
*/
|
|
1116
1219
|
async send(options) {
|
|
1117
|
-
const
|
|
1118
|
-
const
|
|
1119
|
-
const files = opts.files?.length ? await resolveMessageFiles(opts.files) : void 0;
|
|
1120
|
-
const postOptions = files?.length ? { body, files } : { body };
|
|
1121
|
-
const data = await this.client.rest.post(Routes5.channelMessages(this.id), postOptions);
|
|
1220
|
+
const payload = await prepareMessagePostPayload(options);
|
|
1221
|
+
const data = await this.client.rest.post(Routes5.channelMessages(this.id), payload);
|
|
1122
1222
|
this.client._addMessageToCache(this.id, data);
|
|
1123
1223
|
return new Message(this.client, data);
|
|
1124
1224
|
}
|
|
@@ -1180,11 +1280,8 @@ var TextChannel = class extends GuildChannel {
|
|
|
1180
1280
|
* @param options - Text content or object with content, embeds, and/or files
|
|
1181
1281
|
*/
|
|
1182
1282
|
async send(options) {
|
|
1183
|
-
const
|
|
1184
|
-
const
|
|
1185
|
-
const files = opts.files?.length ? await resolveMessageFiles(opts.files) : void 0;
|
|
1186
|
-
const postOptions = files?.length ? { body, files } : { body };
|
|
1187
|
-
const data = await this.client.rest.post(Routes5.channelMessages(this.id), postOptions);
|
|
1283
|
+
const payload = await prepareMessagePostPayload(options);
|
|
1284
|
+
const data = await this.client.rest.post(Routes5.channelMessages(this.id), payload);
|
|
1188
1285
|
this.client._addMessageToCache(this.id, data);
|
|
1189
1286
|
return new Message(this.client, data);
|
|
1190
1287
|
}
|
|
@@ -1272,11 +1369,8 @@ var DMChannel = class extends Channel {
|
|
|
1272
1369
|
* @param options - Text content or object with content, embeds, and/or files
|
|
1273
1370
|
*/
|
|
1274
1371
|
async send(options) {
|
|
1275
|
-
const
|
|
1276
|
-
const
|
|
1277
|
-
const files = opts.files?.length ? await resolveMessageFiles(opts.files) : void 0;
|
|
1278
|
-
const postOptions = files?.length ? { body, files } : { body };
|
|
1279
|
-
const data = await this.client.rest.post(Routes5.channelMessages(this.id), postOptions);
|
|
1372
|
+
const payload = await prepareMessagePostPayload(options);
|
|
1373
|
+
const data = await this.client.rest.post(Routes5.channelMessages(this.id), payload);
|
|
1280
1374
|
this.client._addMessageToCache(this.id, data);
|
|
1281
1375
|
return new Message(this.client, data);
|
|
1282
1376
|
}
|
|
@@ -1339,7 +1433,7 @@ var DMChannel = class extends Channel {
|
|
|
1339
1433
|
};
|
|
1340
1434
|
|
|
1341
1435
|
// src/client/ChannelManager.ts
|
|
1342
|
-
var ChannelManager = class extends
|
|
1436
|
+
var ChannelManager = class extends Collection5 {
|
|
1343
1437
|
constructor(client) {
|
|
1344
1438
|
super();
|
|
1345
1439
|
this.client = client;
|
|
@@ -1447,18 +1541,15 @@ var ChannelManager = class extends Collection4 {
|
|
|
1447
1541
|
* await client.channels.send(channelId, { content: 'Report', files: [{ name: 'log.txt', data }] });
|
|
1448
1542
|
*/
|
|
1449
1543
|
async send(channelId, payload) {
|
|
1450
|
-
const
|
|
1451
|
-
const
|
|
1452
|
-
const files = opts.files?.length ? await resolveMessageFiles(opts.files) : void 0;
|
|
1453
|
-
const postOptions = files?.length ? { body, files } : { body };
|
|
1454
|
-
const data = await this.client.rest.post(Routes6.channelMessages(channelId), postOptions);
|
|
1544
|
+
const postPayload = await prepareMessagePostPayload(payload);
|
|
1545
|
+
const data = await this.client.rest.post(Routes6.channelMessages(channelId), postPayload);
|
|
1455
1546
|
this.client._addMessageToCache(channelId, data);
|
|
1456
1547
|
return new Message(this.client, data);
|
|
1457
1548
|
}
|
|
1458
1549
|
};
|
|
1459
1550
|
|
|
1460
1551
|
// src/client/GuildManager.ts
|
|
1461
|
-
import { Collection as
|
|
1552
|
+
import { Collection as Collection9 } from "@fluxerjs/collection";
|
|
1462
1553
|
import { Routes as Routes15 } from "@fluxerjs/types";
|
|
1463
1554
|
|
|
1464
1555
|
// src/structures/Guild.ts
|
|
@@ -1467,11 +1558,13 @@ import {
|
|
|
1467
1558
|
resolvePermissionsToBitfield as resolvePermissionsToBitfield2
|
|
1468
1559
|
} from "@fluxerjs/util";
|
|
1469
1560
|
import { FluxerAPIError as FluxerAPIError3 } from "@fluxerjs/rest";
|
|
1470
|
-
import { Collection as
|
|
1561
|
+
import { Collection as Collection8 } from "@fluxerjs/collection";
|
|
1471
1562
|
|
|
1472
1563
|
// src/client/GuildMemberManager.ts
|
|
1473
|
-
import { Collection as
|
|
1474
|
-
import {
|
|
1564
|
+
import { Collection as Collection7 } from "@fluxerjs/collection";
|
|
1565
|
+
import {
|
|
1566
|
+
Routes as Routes9
|
|
1567
|
+
} from "@fluxerjs/types";
|
|
1475
1568
|
|
|
1476
1569
|
// src/structures/GuildMember.ts
|
|
1477
1570
|
import { BitField } from "@fluxerjs/util";
|
|
@@ -1494,7 +1587,7 @@ function computePermissions(basePermissions, overwrites, memberRoles, memberId,
|
|
|
1494
1587
|
}
|
|
1495
1588
|
|
|
1496
1589
|
// src/structures/GuildMemberRoleManager.ts
|
|
1497
|
-
import { Collection as
|
|
1590
|
+
import { Collection as Collection6 } from "@fluxerjs/collection";
|
|
1498
1591
|
import { Routes as Routes7 } from "@fluxerjs/types";
|
|
1499
1592
|
var GuildMemberRoleManager = class {
|
|
1500
1593
|
constructor(member, initialRoleIds = []) {
|
|
@@ -1516,7 +1609,7 @@ var GuildMemberRoleManager = class {
|
|
|
1516
1609
|
* @discordJsCompat https://discord.js.org/docs/packages/discord.js/main/GuildMemberRoleManager
|
|
1517
1610
|
*/
|
|
1518
1611
|
get cache() {
|
|
1519
|
-
const coll = new
|
|
1612
|
+
const coll = new Collection6();
|
|
1520
1613
|
for (const id of this._roleIds) {
|
|
1521
1614
|
const role = this.member.guild.roles.get(id);
|
|
1522
1615
|
if (role) coll.set(id, role);
|
|
@@ -1749,7 +1842,7 @@ var GuildMember = class extends Base {
|
|
|
1749
1842
|
};
|
|
1750
1843
|
|
|
1751
1844
|
// src/client/GuildMemberManager.ts
|
|
1752
|
-
var GuildMemberManager = class extends
|
|
1845
|
+
var GuildMemberManager = class extends Collection7 {
|
|
1753
1846
|
constructor(guild) {
|
|
1754
1847
|
super();
|
|
1755
1848
|
this.guild = guild;
|
|
@@ -1824,6 +1917,19 @@ var GuildMemberManager = class extends Collection6 {
|
|
|
1824
1917
|
}
|
|
1825
1918
|
return members;
|
|
1826
1919
|
}
|
|
1920
|
+
/**
|
|
1921
|
+
* Search guild members. POST /guilds/{id}/members-search.
|
|
1922
|
+
* @param options - Search query, filters, and pagination
|
|
1923
|
+
* @returns Search results with matching members
|
|
1924
|
+
* @example
|
|
1925
|
+
* const { members } = await guild.members.search({ query: 'alex', limit: 25 });
|
|
1926
|
+
*/
|
|
1927
|
+
async search(options) {
|
|
1928
|
+
return this.guild.client.rest.post(Routes9.guildMembersSearch(this.guild.id), {
|
|
1929
|
+
body: options,
|
|
1930
|
+
auth: true
|
|
1931
|
+
});
|
|
1932
|
+
}
|
|
1827
1933
|
};
|
|
1828
1934
|
|
|
1829
1935
|
// src/structures/Role.ts
|
|
@@ -2087,10 +2193,10 @@ var Guild = class extends Base {
|
|
|
2087
2193
|
/** Splash image height. Optional. */
|
|
2088
2194
|
splashHeight;
|
|
2089
2195
|
members;
|
|
2090
|
-
channels = new
|
|
2091
|
-
roles = new
|
|
2092
|
-
emojis = new
|
|
2093
|
-
stickers = new
|
|
2196
|
+
channels = new Collection8();
|
|
2197
|
+
roles = new Collection8();
|
|
2198
|
+
emojis = new Collection8();
|
|
2199
|
+
stickers = new Collection8();
|
|
2094
2200
|
/** @param data - API guild from GET /guilds/{id} or gateway GUILD_CREATE */
|
|
2095
2201
|
constructor(client, data) {
|
|
2096
2202
|
super();
|
|
@@ -2630,7 +2736,7 @@ var Guild = class extends Base {
|
|
|
2630
2736
|
};
|
|
2631
2737
|
|
|
2632
2738
|
// src/client/GuildManager.ts
|
|
2633
|
-
var GuildManager = class extends
|
|
2739
|
+
var GuildManager = class extends Collection9 {
|
|
2634
2740
|
constructor(client) {
|
|
2635
2741
|
super();
|
|
2636
2742
|
this.client = client;
|
|
@@ -2827,9 +2933,9 @@ import {
|
|
|
2827
2933
|
} from "@fluxerjs/util";
|
|
2828
2934
|
|
|
2829
2935
|
// src/client/UsersManager.ts
|
|
2830
|
-
import { Collection as
|
|
2936
|
+
import { Collection as Collection10 } from "@fluxerjs/collection";
|
|
2831
2937
|
import { Routes as Routes18 } from "@fluxerjs/types";
|
|
2832
|
-
var UsersManager = class extends
|
|
2938
|
+
var UsersManager = class extends Collection10 {
|
|
2833
2939
|
constructor(client) {
|
|
2834
2940
|
super();
|
|
2835
2941
|
this.client = client;
|
|
@@ -2949,9 +3055,12 @@ var ChatInputCommandInteraction = class extends BaseInteraction {
|
|
|
2949
3055
|
constructor(client, raw) {
|
|
2950
3056
|
super(client, raw);
|
|
2951
3057
|
if (raw.data?.name == null) {
|
|
2952
|
-
throw new FluxerError(
|
|
2953
|
-
|
|
2954
|
-
|
|
3058
|
+
throw new FluxerError(
|
|
3059
|
+
"ChatInputCommandInteraction requires interaction data with a command name",
|
|
3060
|
+
{
|
|
3061
|
+
code: ErrorCodes.InteractionInvalidPayload
|
|
3062
|
+
}
|
|
3063
|
+
);
|
|
2955
3064
|
}
|
|
2956
3065
|
}
|
|
2957
3066
|
/** Command name (e.g. `ping`). */
|
|
@@ -3543,6 +3652,11 @@ var Client = class extends EventEmitter3 {
|
|
|
3543
3652
|
_pendingGuildIds = null;
|
|
3544
3653
|
/** Timeout for guild stream when READY has no guilds (gateway sends only GUILD_CREATE). Cleared in finally. */
|
|
3545
3654
|
_guildStreamSettleTimeout = null;
|
|
3655
|
+
/**
|
|
3656
|
+
* When waitForGuilds delays Ready, gateway dispatches (except GUILD_CREATE) are queued and replayed after Ready.
|
|
3657
|
+
* Ensures user handlers that assume post-Ready setup (e.g. DB in Ready) do not run during the guild sync window.
|
|
3658
|
+
*/
|
|
3659
|
+
_deferredGatewayDispatches = [];
|
|
3546
3660
|
/** Per-channel message cache (channelId -> messageId -> APIMessage). Used when options.cache.messages > 0. */
|
|
3547
3661
|
_messageCaches = null;
|
|
3548
3662
|
on(event, listener) {
|
|
@@ -3740,13 +3854,32 @@ var Client = class extends EventEmitter3 {
|
|
|
3740
3854
|
sendToGateway(shardId, payload) {
|
|
3741
3855
|
this.ws.send(shardId, payload);
|
|
3742
3856
|
}
|
|
3857
|
+
/**
|
|
3858
|
+
* While {@link ClientOptions.waitForGuilds} delays Ready, defer user-facing dispatch handling until Ready fires.
|
|
3859
|
+
* GUILD_CREATE must still run immediately so guild cache and {@link Client._onGuildReceived} can finish the handshake.
|
|
3860
|
+
*/
|
|
3861
|
+
_shouldDeferGatewayDispatchUntilReady(payload) {
|
|
3862
|
+
if (this.options.waitForGuilds !== true || this.readyAt !== null) return false;
|
|
3863
|
+
if (payload.op !== 0 || !payload.t) return false;
|
|
3864
|
+
if (payload.t === "GUILD_CREATE") return false;
|
|
3865
|
+
return true;
|
|
3866
|
+
}
|
|
3743
3867
|
/**
|
|
3744
3868
|
* Run gateway event handlers. By default (see {@link ClientOptions.gatewayDeferHandlers}) work is deferred to the next
|
|
3745
3869
|
* macrotask so user code does not block the WebSocket `message` callback.
|
|
3746
3870
|
*/
|
|
3747
3871
|
handleDispatch(payload) {
|
|
3748
3872
|
if (payload.op !== 0 || !payload.t) return Promise.resolve();
|
|
3749
|
-
|
|
3873
|
+
if (this._shouldDeferGatewayDispatchUntilReady(payload)) {
|
|
3874
|
+
this._deferredGatewayDispatches.push(payload);
|
|
3875
|
+
return Promise.resolve();
|
|
3876
|
+
}
|
|
3877
|
+
return this._dispatchGatewayPayload(payload);
|
|
3878
|
+
}
|
|
3879
|
+
_dispatchGatewayPayload(payload) {
|
|
3880
|
+
const event = payload.t;
|
|
3881
|
+
if (!event) return Promise.resolve();
|
|
3882
|
+
const { d } = payload;
|
|
3750
3883
|
const handler = eventHandlers.get(event);
|
|
3751
3884
|
if (!handler) return Promise.resolve();
|
|
3752
3885
|
const run = async () => {
|
|
@@ -3770,6 +3903,15 @@ var Client = class extends EventEmitter3 {
|
|
|
3770
3903
|
}
|
|
3771
3904
|
});
|
|
3772
3905
|
}
|
|
3906
|
+
async _flushDeferredGatewayDispatches() {
|
|
3907
|
+
while (this._deferredGatewayDispatches.length > 0) {
|
|
3908
|
+
const batch = this._deferredGatewayDispatches;
|
|
3909
|
+
this._deferredGatewayDispatches = [];
|
|
3910
|
+
for (const p of batch) {
|
|
3911
|
+
await this._dispatchGatewayPayload(p);
|
|
3912
|
+
}
|
|
3913
|
+
}
|
|
3914
|
+
}
|
|
3773
3915
|
/**
|
|
3774
3916
|
* Connect to the Fluxer gateway and authenticate.
|
|
3775
3917
|
* @param token - Bot token (e.g. from FLUXER_BOT_TOKEN)
|
|
@@ -3868,6 +4010,9 @@ var Client = class extends EventEmitter3 {
|
|
|
3868
4010
|
this._pendingGuildIds = null;
|
|
3869
4011
|
this.readyAt = /* @__PURE__ */ new Date();
|
|
3870
4012
|
this.emit(Events.Ready);
|
|
4013
|
+
void this._flushDeferredGatewayDispatches().catch(
|
|
4014
|
+
(err) => this.emit(Events.Error, err instanceof Error ? err : new Error(String(err)))
|
|
4015
|
+
);
|
|
3871
4016
|
}
|
|
3872
4017
|
/**
|
|
3873
4018
|
* Called by GUILD_CREATE handler when waitForGuilds is enabled.
|
|
@@ -3885,6 +4030,7 @@ var Client = class extends EventEmitter3 {
|
|
|
3885
4030
|
clearTimeout(this._guildStreamSettleTimeout);
|
|
3886
4031
|
this._guildStreamSettleTimeout = null;
|
|
3887
4032
|
}
|
|
4033
|
+
this._deferredGatewayDispatches = [];
|
|
3888
4034
|
if (this._ws) {
|
|
3889
4035
|
this._ws.destroy();
|
|
3890
4036
|
this._ws = null;
|
|
@@ -3922,7 +4068,12 @@ var Client = class extends EventEmitter3 {
|
|
|
3922
4068
|
|
|
3923
4069
|
// src/index.ts
|
|
3924
4070
|
import { EmbedBuilder as EmbedBuilder4, MessagePayload, AttachmentBuilder } from "@fluxerjs/builders";
|
|
3925
|
-
import {
|
|
4071
|
+
import {
|
|
4072
|
+
Routes as Routes21,
|
|
4073
|
+
GatewayOpcodes,
|
|
4074
|
+
MessageAttachmentFlags,
|
|
4075
|
+
MessageFlags as MessageFlags2
|
|
4076
|
+
} from "@fluxerjs/types";
|
|
3926
4077
|
import { resolveTenorToImageUrl, parseUserMention, parsePrefixCommand } from "@fluxerjs/util";
|
|
3927
4078
|
import {
|
|
3928
4079
|
PermissionsBitField as PermissionsBitField2,
|
|
@@ -3932,6 +4083,7 @@ import {
|
|
|
3932
4083
|
UserFlagsBits
|
|
3933
4084
|
} from "@fluxerjs/util";
|
|
3934
4085
|
export {
|
|
4086
|
+
AllowedMentions,
|
|
3935
4087
|
AttachmentBuilder,
|
|
3936
4088
|
Base,
|
|
3937
4089
|
BaseInteraction,
|
|
@@ -3961,6 +4113,7 @@ export {
|
|
|
3961
4113
|
Message,
|
|
3962
4114
|
MessageAttachmentFlags,
|
|
3963
4115
|
MessageCollector,
|
|
4116
|
+
MessageFlags2 as MessageFlags,
|
|
3964
4117
|
MessageManager,
|
|
3965
4118
|
MessagePayload,
|
|
3966
4119
|
MessageReaction,
|
package/dist/message.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { M as Message,
|
|
1
|
+
export { M as Message, y as MessageEditOptions, K as MessageSendOptions, P as PartialMessage, Q as ReplyOptions } from './subpath-message-DSs_mdc4.mjs';
|
|
2
2
|
import 'events';
|
|
3
3
|
import '@fluxerjs/rest';
|
|
4
4
|
import '@fluxerjs/ws';
|
package/dist/message.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { M as Message,
|
|
1
|
+
export { M as Message, y as MessageEditOptions, K as MessageSendOptions, P as PartialMessage, Q as ReplyOptions } from './subpath-message-DSs_mdc4.js';
|
|
2
2
|
import 'events';
|
|
3
3
|
import '@fluxerjs/rest';
|
|
4
4
|
import '@fluxerjs/ws';
|