@fluxerjs/core 1.3.1 → 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 +294 -198
- package/dist/client.mjs +169 -71
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +310 -202
- package/dist/index.mjs +185 -72
- 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-CZC4oGko.d.mts → subpath-message-DSs_mdc4.d.mts} +131 -23
- package/dist/{subpath-message-CZC4oGko.d.ts → subpath-message-DSs_mdc4.d.ts} +131 -23
- package/package.json +7 -7
package/dist/index.js
CHANGED
|
@@ -20,6 +20,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
// src/index.ts
|
|
21
21
|
var src_exports = {};
|
|
22
22
|
__export(src_exports, {
|
|
23
|
+
AllowedMentions: () => AllowedMentions,
|
|
23
24
|
AttachmentBuilder: () => import_builders4.AttachmentBuilder,
|
|
24
25
|
Base: () => Base,
|
|
25
26
|
BaseInteraction: () => BaseInteraction,
|
|
@@ -35,7 +36,7 @@ __export(src_exports, {
|
|
|
35
36
|
ErrorCodes: () => import_util2.ErrorCodes,
|
|
36
37
|
Events: () => Events,
|
|
37
38
|
FluxerError: () => import_util.FluxerError,
|
|
38
|
-
GatewayOpcodes: () =>
|
|
39
|
+
GatewayOpcodes: () => import_types23.GatewayOpcodes,
|
|
39
40
|
Guild: () => Guild,
|
|
40
41
|
GuildBan: () => GuildBan,
|
|
41
42
|
GuildChannel: () => GuildChannel,
|
|
@@ -47,8 +48,9 @@ __export(src_exports, {
|
|
|
47
48
|
Invite: () => Invite,
|
|
48
49
|
LinkChannel: () => LinkChannel,
|
|
49
50
|
Message: () => Message,
|
|
50
|
-
MessageAttachmentFlags: () =>
|
|
51
|
+
MessageAttachmentFlags: () => import_types23.MessageAttachmentFlags,
|
|
51
52
|
MessageCollector: () => MessageCollector,
|
|
53
|
+
MessageFlags: () => import_types23.MessageFlags,
|
|
52
54
|
MessageManager: () => MessageManager,
|
|
53
55
|
MessagePayload: () => import_builders4.MessagePayload,
|
|
54
56
|
MessageReaction: () => MessageReaction,
|
|
@@ -56,7 +58,7 @@ __export(src_exports, {
|
|
|
56
58
|
PermissionsBitField: () => import_util12.PermissionsBitField,
|
|
57
59
|
ReactionCollector: () => ReactionCollector,
|
|
58
60
|
Role: () => Role,
|
|
59
|
-
Routes: () =>
|
|
61
|
+
Routes: () => import_types23.Routes,
|
|
60
62
|
STATIC_CDN_URL: () => STATIC_CDN_URL,
|
|
61
63
|
TextChannel: () => TextChannel,
|
|
62
64
|
User: () => User,
|
|
@@ -84,11 +86,11 @@ module.exports = __toCommonJS(src_exports);
|
|
|
84
86
|
var import_events3 = require("events");
|
|
85
87
|
var import_rest5 = require("@fluxerjs/rest");
|
|
86
88
|
var import_ws = require("@fluxerjs/ws");
|
|
87
|
-
var
|
|
89
|
+
var import_types22 = require("@fluxerjs/types");
|
|
88
90
|
|
|
89
91
|
// src/client/ChannelManager.ts
|
|
90
|
-
var
|
|
91
|
-
var
|
|
92
|
+
var import_collection5 = require("@fluxerjs/collection");
|
|
93
|
+
var import_types7 = require("@fluxerjs/types");
|
|
92
94
|
var import_util5 = require("@fluxerjs/util");
|
|
93
95
|
var import_rest2 = require("@fluxerjs/rest");
|
|
94
96
|
|
|
@@ -99,12 +101,14 @@ var import_util = require("@fluxerjs/util");
|
|
|
99
101
|
var import_util2 = require("@fluxerjs/util");
|
|
100
102
|
|
|
101
103
|
// src/util/messageUtils.ts
|
|
104
|
+
var import_types = require("@fluxerjs/types");
|
|
102
105
|
var import_builders = require("@fluxerjs/builders");
|
|
103
106
|
var FILE_FETCH_TIMEOUT_MS = 3e4;
|
|
104
107
|
async function resolveMessageFiles(files) {
|
|
105
108
|
const result = [];
|
|
106
109
|
for (let i = 0; i < files.length; i++) {
|
|
107
110
|
const f = files[i];
|
|
111
|
+
if (!f) continue;
|
|
108
112
|
const filename = f.filename ?? f.name;
|
|
109
113
|
if ("url" in f && f.url) {
|
|
110
114
|
if (!URL.canParse(f.url)) {
|
|
@@ -143,6 +147,29 @@ async function resolveMessageFiles(files) {
|
|
|
143
147
|
}
|
|
144
148
|
return result;
|
|
145
149
|
}
|
|
150
|
+
var AllowedMentions = {
|
|
151
|
+
/** Suppress the replied-to user's @mention notification. The reply thread still appears. */
|
|
152
|
+
suppressReplyPing: { repliedUser: false },
|
|
153
|
+
/** Parse no mentions from content — @user, @role, and @everyone will not notify. */
|
|
154
|
+
none: { parse: [] },
|
|
155
|
+
/** Parse user, role, and @everyone mentions (typical default when the field is omitted). */
|
|
156
|
+
all: { parse: ["users", "roles", "everyone"] }
|
|
157
|
+
};
|
|
158
|
+
function toAPIAllowedMentions(options) {
|
|
159
|
+
const result = {};
|
|
160
|
+
if (options.parse?.length) result.parse = options.parse;
|
|
161
|
+
if (options.users?.length) result.users = options.users;
|
|
162
|
+
if (options.roles?.length) result.roles = options.roles;
|
|
163
|
+
if (options.repliedUser !== void 0) result.replied_user = options.repliedUser;
|
|
164
|
+
return result;
|
|
165
|
+
}
|
|
166
|
+
function applyReplyPingSuppression(body) {
|
|
167
|
+
body.flags = (body.flags ?? 0) | import_types.MessageFlags.SuppressNotifications;
|
|
168
|
+
body.allowed_mentions = {
|
|
169
|
+
...body.allowed_mentions ?? {},
|
|
170
|
+
replied_user: false
|
|
171
|
+
};
|
|
172
|
+
}
|
|
146
173
|
function buildSendBody(options) {
|
|
147
174
|
const body = typeof options === "string" ? { content: options } : options;
|
|
148
175
|
const result = {};
|
|
@@ -164,12 +191,43 @@ function buildSendBody(options) {
|
|
|
164
191
|
filename: f.filename ?? f.name
|
|
165
192
|
}));
|
|
166
193
|
}
|
|
194
|
+
if (body.allowedMentions) result.allowed_mentions = toAPIAllowedMentions(body.allowedMentions);
|
|
195
|
+
if (body.stickerIds?.length) result.sticker_ids = body.stickerIds;
|
|
196
|
+
if (body.nonce !== void 0) result.nonce = body.nonce;
|
|
197
|
+
if (body.favoriteMemeId !== void 0) result.favorite_meme_id = body.favoriteMemeId;
|
|
198
|
+
if (body.tts !== void 0) result.tts = body.tts;
|
|
167
199
|
if (body.flags !== void 0) result.flags = body.flags;
|
|
168
200
|
return result;
|
|
169
201
|
}
|
|
202
|
+
function toMessageReference(target) {
|
|
203
|
+
const ref = {
|
|
204
|
+
channel_id: target.channelId,
|
|
205
|
+
message_id: target.messageId
|
|
206
|
+
};
|
|
207
|
+
if (target.guildId != null && target.guildId !== "") ref.guild_id = target.guildId;
|
|
208
|
+
return ref;
|
|
209
|
+
}
|
|
210
|
+
async function prepareMessagePostPayload(options) {
|
|
211
|
+
if (typeof options === "string") {
|
|
212
|
+
if (options.length === 0) throw new RangeError("Cannot send an empty message");
|
|
213
|
+
options = { content: options };
|
|
214
|
+
}
|
|
215
|
+
const { replyTo, ping, files, allowedMentions, ...sendFields } = options;
|
|
216
|
+
const body = buildSendBody({ ...sendFields, files, allowedMentions });
|
|
217
|
+
if (replyTo) {
|
|
218
|
+
body.message_reference = toMessageReference(replyTo);
|
|
219
|
+
const suppressPing = ping === false || allowedMentions?.repliedUser === false || body.allowed_mentions?.replied_user === false;
|
|
220
|
+
if (suppressPing) applyReplyPingSuppression(body);
|
|
221
|
+
} else if (allowedMentions?.repliedUser === false) {
|
|
222
|
+
applyReplyPingSuppression(body);
|
|
223
|
+
}
|
|
224
|
+
const resolvedFiles = files?.length ? await resolveMessageFiles(files) : void 0;
|
|
225
|
+
return { body, files: resolvedFiles };
|
|
226
|
+
}
|
|
170
227
|
|
|
171
228
|
// src/client/MessageManager.ts
|
|
172
|
-
var
|
|
229
|
+
var import_types3 = require("@fluxerjs/types");
|
|
230
|
+
var import_collection3 = require("@fluxerjs/collection");
|
|
173
231
|
var import_rest = require("@fluxerjs/rest");
|
|
174
232
|
|
|
175
233
|
// src/structures/Base.ts
|
|
@@ -178,7 +236,7 @@ var Base = class {
|
|
|
178
236
|
|
|
179
237
|
// src/structures/Message.ts
|
|
180
238
|
var import_collection2 = require("@fluxerjs/collection");
|
|
181
|
-
var
|
|
239
|
+
var import_types2 = require("@fluxerjs/types");
|
|
182
240
|
var import_builders2 = require("@fluxerjs/builders");
|
|
183
241
|
|
|
184
242
|
// src/util/ReactionCollector.ts
|
|
@@ -357,7 +415,7 @@ var Message = class _Message extends Base {
|
|
|
357
415
|
this.pinned = data.pinned;
|
|
358
416
|
this.attachments = new import_collection2.Collection();
|
|
359
417
|
for (const a of data.attachments ?? []) this.attachments.set(a.id, a);
|
|
360
|
-
this.type = data.type ??
|
|
418
|
+
this.type = data.type ?? import_types2.MessageType.Default;
|
|
361
419
|
this.flags = data.flags ?? 0;
|
|
362
420
|
this.mentionEveryone = data.mention_everyone ?? false;
|
|
363
421
|
this.tts = data.tts ?? false;
|
|
@@ -382,7 +440,7 @@ var Message = class _Message extends Base {
|
|
|
382
440
|
* await message.send({ content: 'File', files: [{ name: 'data.txt', data }] });
|
|
383
441
|
*/
|
|
384
442
|
async send(options) {
|
|
385
|
-
const payload = await
|
|
443
|
+
const payload = await prepareMessagePostPayload(options);
|
|
386
444
|
return this._send(payload);
|
|
387
445
|
}
|
|
388
446
|
/**
|
|
@@ -403,46 +461,57 @@ var Message = class _Message extends Base {
|
|
|
403
461
|
* await message.reply('Pong!');
|
|
404
462
|
* await message.reply({ embeds: [embed] });
|
|
405
463
|
* await message.reply('No ping!', { ping: false });
|
|
464
|
+
* await message.reply({ content: 'Silent reply', allowedMentions: AllowedMentions.suppressReplyPing });
|
|
406
465
|
* await message.reply({ content: 'Reply to other', replyTo: otherMessage });
|
|
407
466
|
*/
|
|
408
467
|
async reply(options, replyOptions) {
|
|
409
468
|
const opts = typeof options === "string" ? { content: options } : options;
|
|
410
469
|
const mergedReply = replyOptions ?? (opts.ping !== void 0 || opts.replyTo !== void 0) ? { ping: opts.ping, replyTo: opts.replyTo } : void 0;
|
|
411
470
|
const refMessage = mergedReply?.replyTo ?? this;
|
|
412
|
-
const
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
} :
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
471
|
+
const replyTo = refMessage instanceof _Message ? {
|
|
472
|
+
channelId: refMessage.channelId,
|
|
473
|
+
messageId: refMessage.id,
|
|
474
|
+
guildId: refMessage.guildId
|
|
475
|
+
} : refMessage;
|
|
476
|
+
const { replyTo: _ignored, ping: _ping, ...sendOpts } = opts;
|
|
477
|
+
const payload = await prepareMessagePostPayload({
|
|
478
|
+
...sendOpts,
|
|
479
|
+
replyTo,
|
|
480
|
+
ping: mergedReply?.ping
|
|
481
|
+
});
|
|
422
482
|
return this._send(payload);
|
|
423
483
|
}
|
|
424
|
-
/** Exposed for testing
|
|
484
|
+
/** Exposed for testing — prefer `message.reply()` / `prepareMessagePostPayload()`. */
|
|
425
485
|
static async _createMessageBody(content, referenced_message, ping) {
|
|
486
|
+
if (typeof content === "string" && content.length === 0) {
|
|
487
|
+
throw new RangeError("Cannot send an empty message");
|
|
488
|
+
}
|
|
426
489
|
if (typeof content === "string") {
|
|
427
|
-
|
|
428
|
-
|
|
490
|
+
const opts2 = { content };
|
|
491
|
+
if (referenced_message) {
|
|
492
|
+
opts2.replyTo = {
|
|
493
|
+
channelId: referenced_message.channel_id,
|
|
494
|
+
messageId: referenced_message.message_id,
|
|
495
|
+
...referenced_message.guild_id != null ? { guildId: referenced_message.guild_id } : {}
|
|
496
|
+
};
|
|
497
|
+
if (ping !== void 0) opts2.ping = ping;
|
|
429
498
|
}
|
|
430
|
-
|
|
499
|
+
return prepareMessagePostPayload(opts2);
|
|
431
500
|
}
|
|
432
|
-
const
|
|
433
|
-
const files = content.files?.length ? await resolveMessageFiles(content.files) : void 0;
|
|
434
|
-
const body = { ...base };
|
|
501
|
+
const opts = { ...content };
|
|
435
502
|
if (referenced_message) {
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
503
|
+
opts.replyTo = {
|
|
504
|
+
channelId: referenced_message.channel_id,
|
|
505
|
+
messageId: referenced_message.message_id,
|
|
506
|
+
...referenced_message.guild_id != null ? { guildId: referenced_message.guild_id } : {}
|
|
507
|
+
};
|
|
508
|
+
if (ping !== void 0) opts.ping = ping;
|
|
440
509
|
}
|
|
441
|
-
return
|
|
510
|
+
return prepareMessagePostPayload(opts);
|
|
442
511
|
}
|
|
443
512
|
async _send(payload) {
|
|
444
513
|
const data = await this.client.rest.post(
|
|
445
|
-
|
|
514
|
+
import_types2.Routes.channelMessages(this.channelId),
|
|
446
515
|
payload
|
|
447
516
|
);
|
|
448
517
|
this.client._addMessageToCache(this.channelId, data);
|
|
@@ -458,7 +527,10 @@ var Message = class _Message extends Base {
|
|
|
458
527
|
if (options.embeds?.length) {
|
|
459
528
|
body.embeds = options.embeds.map((e) => e instanceof import_builders2.EmbedBuilder ? e.toJSON() : e);
|
|
460
529
|
}
|
|
461
|
-
|
|
530
|
+
if (options.allowedMentions) {
|
|
531
|
+
body.allowed_mentions = toAPIAllowedMentions(options.allowedMentions);
|
|
532
|
+
}
|
|
533
|
+
const data = await this.client.rest.patch(import_types2.Routes.channelMessage(this.channelId, this.id), {
|
|
462
534
|
body
|
|
463
535
|
});
|
|
464
536
|
return new _Message(this.client, data);
|
|
@@ -489,7 +561,7 @@ var Message = class _Message extends Base {
|
|
|
489
561
|
}
|
|
490
562
|
/** Delete this message. */
|
|
491
563
|
async delete() {
|
|
492
|
-
await this.client.rest.delete(
|
|
564
|
+
await this.client.rest.delete(import_types2.Routes.channelMessage(this.channelId, this.id));
|
|
493
565
|
}
|
|
494
566
|
/**
|
|
495
567
|
* Delete a specific attachment from this message.
|
|
@@ -497,19 +569,19 @@ var Message = class _Message extends Base {
|
|
|
497
569
|
*/
|
|
498
570
|
async deleteAttachment(attachmentId) {
|
|
499
571
|
await this.client.rest.delete(
|
|
500
|
-
|
|
572
|
+
import_types2.Routes.channelMessageAttachment(this.channelId, this.id, attachmentId),
|
|
501
573
|
{ auth: true }
|
|
502
574
|
);
|
|
503
575
|
this.attachments.delete(attachmentId);
|
|
504
576
|
}
|
|
505
577
|
/** Pin this message to the channel. Requires Manage Messages permission. */
|
|
506
578
|
async pin() {
|
|
507
|
-
await this.client.rest.put(
|
|
579
|
+
await this.client.rest.put(import_types2.Routes.channelPinMessage(this.channelId, this.id));
|
|
508
580
|
this.pinned = true;
|
|
509
581
|
}
|
|
510
582
|
/** Unpin this message from the channel. Requires Manage Messages permission. */
|
|
511
583
|
async unpin() {
|
|
512
|
-
await this.client.rest.delete(
|
|
584
|
+
await this.client.rest.delete(import_types2.Routes.channelPinMessage(this.channelId, this.id));
|
|
513
585
|
this.pinned = false;
|
|
514
586
|
}
|
|
515
587
|
/**
|
|
@@ -529,7 +601,7 @@ var Message = class _Message extends Base {
|
|
|
529
601
|
*/
|
|
530
602
|
async react(emoji) {
|
|
531
603
|
const emojiStr = await this.resolveEmojiForReaction(emoji);
|
|
532
|
-
const route = `${
|
|
604
|
+
const route = `${import_types2.Routes.channelMessageReaction(this.channelId, this.id, emojiStr)}/@me`;
|
|
533
605
|
await this.client.rest.put(route);
|
|
534
606
|
}
|
|
535
607
|
/**
|
|
@@ -539,7 +611,7 @@ var Message = class _Message extends Base {
|
|
|
539
611
|
*/
|
|
540
612
|
async removeReaction(emoji, userId) {
|
|
541
613
|
const emojiStr = await this.resolveEmojiForReaction(emoji);
|
|
542
|
-
const route = `${
|
|
614
|
+
const route = `${import_types2.Routes.channelMessageReaction(this.channelId, this.id, emojiStr)}/${userId ?? "@me"}`;
|
|
543
615
|
await this.client.rest.delete(route);
|
|
544
616
|
}
|
|
545
617
|
/**
|
|
@@ -547,7 +619,7 @@ var Message = class _Message extends Base {
|
|
|
547
619
|
* Requires moderator permissions.
|
|
548
620
|
*/
|
|
549
621
|
async removeAllReactions() {
|
|
550
|
-
await this.client.rest.delete(
|
|
622
|
+
await this.client.rest.delete(import_types2.Routes.channelMessageReactions(this.channelId, this.id));
|
|
551
623
|
}
|
|
552
624
|
/**
|
|
553
625
|
* Remove all reactions of a specific emoji from this message.
|
|
@@ -555,7 +627,7 @@ var Message = class _Message extends Base {
|
|
|
555
627
|
*/
|
|
556
628
|
async removeReactionEmoji(emoji) {
|
|
557
629
|
const emojiStr = await this.resolveEmojiForReaction(emoji);
|
|
558
|
-
await this.client.rest.delete(
|
|
630
|
+
await this.client.rest.delete(import_types2.Routes.channelMessageReaction(this.channelId, this.id, emojiStr));
|
|
559
631
|
}
|
|
560
632
|
/**
|
|
561
633
|
* Fetch users who reacted with the given emoji.
|
|
@@ -569,7 +641,7 @@ var Message = class _Message extends Base {
|
|
|
569
641
|
if (options?.limit != null) params.set("limit", String(options.limit));
|
|
570
642
|
if (options?.after) params.set("after", options.after);
|
|
571
643
|
const qs = params.toString();
|
|
572
|
-
const route =
|
|
644
|
+
const route = import_types2.Routes.channelMessageReaction(this.channelId, this.id, emojiStr) + (qs ? `?${qs}` : "");
|
|
573
645
|
const data = await this.client.rest.get(route);
|
|
574
646
|
const list = Array.isArray(data) ? data : data?.users ?? [];
|
|
575
647
|
return list.map((u) => this.client.getOrCreateUser(u));
|
|
@@ -591,17 +663,16 @@ var MessageManager = class {
|
|
|
591
663
|
const data = this.client._getMessageCache(this.channelId)?.get(messageId);
|
|
592
664
|
return data ? new Message(this.client, data) : void 0;
|
|
593
665
|
}
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
async fetch(messageId) {
|
|
666
|
+
async fetch(messageIdOrOptions) {
|
|
667
|
+
if (typeof messageIdOrOptions === "string") {
|
|
668
|
+
return this.fetchOne(messageIdOrOptions);
|
|
669
|
+
}
|
|
670
|
+
return this.fetchMany(messageIdOrOptions);
|
|
671
|
+
}
|
|
672
|
+
async fetchOne(messageId) {
|
|
602
673
|
try {
|
|
603
674
|
const data = await this.client.rest.get(
|
|
604
|
-
|
|
675
|
+
import_types3.Routes.channelMessage(this.channelId, messageId)
|
|
605
676
|
);
|
|
606
677
|
this.client._addMessageToCache(this.channelId, data);
|
|
607
678
|
return new Message(this.client, data);
|
|
@@ -616,16 +687,37 @@ var MessageManager = class {
|
|
|
616
687
|
throw err instanceof import_util.FluxerError ? err : new import_util.FluxerError(String(err), { cause: err });
|
|
617
688
|
}
|
|
618
689
|
}
|
|
690
|
+
async fetchMany(options) {
|
|
691
|
+
const params = new URLSearchParams();
|
|
692
|
+
if (options.limit != null) {
|
|
693
|
+
if (options.limit < 1 || options.limit > 100) {
|
|
694
|
+
throw new RangeError("limit must be between 1 and 100");
|
|
695
|
+
}
|
|
696
|
+
params.set("limit", String(options.limit));
|
|
697
|
+
}
|
|
698
|
+
if (options.before) params.set("before", options.before);
|
|
699
|
+
if (options.after) params.set("after", options.after);
|
|
700
|
+
if (options.around) params.set("around", options.around);
|
|
701
|
+
const qs = params.toString();
|
|
702
|
+
const route = import_types3.Routes.channelMessages(this.channelId) + (qs ? `?${qs}` : "");
|
|
703
|
+
const data = await this.client.rest.get(route);
|
|
704
|
+
const collection = new import_collection3.Collection();
|
|
705
|
+
for (const msg of data) {
|
|
706
|
+
this.client._addMessageToCache(this.channelId, msg);
|
|
707
|
+
collection.set(msg.id, new Message(this.client, msg));
|
|
708
|
+
}
|
|
709
|
+
return collection;
|
|
710
|
+
}
|
|
619
711
|
};
|
|
620
712
|
|
|
621
713
|
// src/util/MessageCollector.ts
|
|
622
714
|
var import_events2 = require("events");
|
|
623
|
-
var
|
|
715
|
+
var import_collection4 = require("@fluxerjs/collection");
|
|
624
716
|
var MessageCollector = class extends import_events2.EventEmitter {
|
|
625
717
|
client;
|
|
626
718
|
channelId;
|
|
627
719
|
options;
|
|
628
|
-
collected = new
|
|
720
|
+
collected = new import_collection4.Collection();
|
|
629
721
|
_timeout = null;
|
|
630
722
|
_ended = false;
|
|
631
723
|
_listener;
|
|
@@ -671,12 +763,12 @@ var MessageCollector = class extends import_events2.EventEmitter {
|
|
|
671
763
|
};
|
|
672
764
|
|
|
673
765
|
// src/structures/Channel.ts
|
|
674
|
-
var
|
|
766
|
+
var import_types6 = require("@fluxerjs/types");
|
|
675
767
|
var import_util3 = require("@fluxerjs/util");
|
|
676
768
|
var import_util4 = require("@fluxerjs/util");
|
|
677
769
|
|
|
678
770
|
// src/structures/Webhook.ts
|
|
679
|
-
var
|
|
771
|
+
var import_types4 = require("@fluxerjs/types");
|
|
680
772
|
var import_builders3 = require("@fluxerjs/builders");
|
|
681
773
|
|
|
682
774
|
// src/util/Constants.ts
|
|
@@ -757,7 +849,7 @@ var Webhook = class _Webhook extends Base {
|
|
|
757
849
|
}
|
|
758
850
|
/** Delete this webhook. Requires bot token with Manage Webhooks permission. */
|
|
759
851
|
async delete() {
|
|
760
|
-
await this.client.rest.delete(
|
|
852
|
+
await this.client.rest.delete(import_types4.Routes.webhook(this.id), { auth: true });
|
|
761
853
|
}
|
|
762
854
|
/**
|
|
763
855
|
* Edit this webhook. With token: name and avatar only. Without token (bot auth): name, avatar, and channel_id.
|
|
@@ -772,7 +864,7 @@ var Webhook = class _Webhook extends Base {
|
|
|
772
864
|
body.channel_id = options.channel_id;
|
|
773
865
|
}
|
|
774
866
|
if (this.token) {
|
|
775
|
-
const data2 = await this.client.rest.patch(
|
|
867
|
+
const data2 = await this.client.rest.patch(import_types4.Routes.webhookExecute(this.id, this.token), {
|
|
776
868
|
body,
|
|
777
869
|
auth: false
|
|
778
870
|
});
|
|
@@ -781,7 +873,7 @@ var Webhook = class _Webhook extends Base {
|
|
|
781
873
|
this.avatar = w2.avatar ?? null;
|
|
782
874
|
return this;
|
|
783
875
|
}
|
|
784
|
-
const data = await this.client.rest.patch(
|
|
876
|
+
const data = await this.client.rest.patch(import_types4.Routes.webhook(this.id), {
|
|
785
877
|
body,
|
|
786
878
|
auth: true
|
|
787
879
|
});
|
|
@@ -813,8 +905,7 @@ var Webhook = class _Webhook extends Base {
|
|
|
813
905
|
const body = buildSendBody(opts);
|
|
814
906
|
if (opts.username !== void 0) body.username = opts.username;
|
|
815
907
|
if (opts.avatar_url !== void 0) body.avatar_url = opts.avatar_url;
|
|
816
|
-
|
|
817
|
-
const route = import_types3.Routes.webhookExecute(this.id, this.token) + (wait ? "?wait=true" : "");
|
|
908
|
+
const route = import_types4.Routes.webhookExecute(this.id, this.token) + (wait ? "?wait=true" : "");
|
|
818
909
|
const files = opts.files?.length ? await resolveMessageFiles(opts.files) : void 0;
|
|
819
910
|
const postOptions = files?.length ? { body, files, auth: false } : { body, auth: false };
|
|
820
911
|
const data = await this.client.rest.post(route, postOptions);
|
|
@@ -839,7 +930,7 @@ var Webhook = class _Webhook extends Base {
|
|
|
839
930
|
body.embeds = options.embeds.map((e) => e instanceof import_builders3.EmbedBuilder ? e.toJSON() : e);
|
|
840
931
|
}
|
|
841
932
|
const data = await this.client.rest.patch(
|
|
842
|
-
|
|
933
|
+
import_types4.Routes.webhookMessage(this.id, this.token, messageId),
|
|
843
934
|
{ body, auth: false }
|
|
844
935
|
);
|
|
845
936
|
return new Message(this.client, data);
|
|
@@ -856,7 +947,7 @@ var Webhook = class _Webhook extends Base {
|
|
|
856
947
|
);
|
|
857
948
|
}
|
|
858
949
|
const data = await this.client.rest.get(
|
|
859
|
-
|
|
950
|
+
import_types4.Routes.webhookMessage(this.id, this.token, messageId),
|
|
860
951
|
{ auth: false }
|
|
861
952
|
);
|
|
862
953
|
return new Message(this.client, data);
|
|
@@ -872,7 +963,7 @@ var Webhook = class _Webhook extends Base {
|
|
|
872
963
|
{ code: import_util2.ErrorCodes.WebhookTokenRequired }
|
|
873
964
|
);
|
|
874
965
|
}
|
|
875
|
-
await this.client.rest.delete(
|
|
966
|
+
await this.client.rest.delete(import_types4.Routes.webhookMessage(this.id, this.token, messageId), {
|
|
876
967
|
auth: false
|
|
877
968
|
});
|
|
878
969
|
}
|
|
@@ -883,7 +974,7 @@ var Webhook = class _Webhook extends Base {
|
|
|
883
974
|
* @returns Webhook without token (cannot send)
|
|
884
975
|
*/
|
|
885
976
|
static async fetch(client, webhookId) {
|
|
886
|
-
const data = await client.rest.get(
|
|
977
|
+
const data = await client.rest.get(import_types4.Routes.webhook(webhookId));
|
|
887
978
|
return new _Webhook(client, data);
|
|
888
979
|
}
|
|
889
980
|
/**
|
|
@@ -907,7 +998,7 @@ var Webhook = class _Webhook extends Base {
|
|
|
907
998
|
};
|
|
908
999
|
|
|
909
1000
|
// src/structures/Invite.ts
|
|
910
|
-
var
|
|
1001
|
+
var import_types5 = require("@fluxerjs/types");
|
|
911
1002
|
var Invite = class _Invite extends Base {
|
|
912
1003
|
client;
|
|
913
1004
|
code;
|
|
@@ -981,7 +1072,7 @@ var Invite = class _Invite extends Base {
|
|
|
981
1072
|
*/
|
|
982
1073
|
static async fetch(client, codeOrUrl) {
|
|
983
1074
|
const code = _Invite.normalizeCode(codeOrUrl);
|
|
984
|
-
const data = await client.rest.get(
|
|
1075
|
+
const data = await client.rest.get(import_types5.Routes.invite(code));
|
|
985
1076
|
return new _Invite(client, data);
|
|
986
1077
|
}
|
|
987
1078
|
/** Full invite URL (https://fluxer.gg/{code} or instance-specific). */
|
|
@@ -1000,7 +1091,7 @@ var Invite = class _Invite extends Base {
|
|
|
1000
1091
|
* Requires Manage Guild or Create Instant Invite permission.
|
|
1001
1092
|
*/
|
|
1002
1093
|
async delete() {
|
|
1003
|
-
await this.client.rest.delete(
|
|
1094
|
+
await this.client.rest.delete(import_types5.Routes.invite(this.code), { auth: true });
|
|
1004
1095
|
}
|
|
1005
1096
|
};
|
|
1006
1097
|
|
|
@@ -1012,7 +1103,7 @@ var Channel = class _Channel extends Base {
|
|
|
1012
1103
|
}
|
|
1013
1104
|
/** Whether this channel is a DM or Group DM. */
|
|
1014
1105
|
isDM() {
|
|
1015
|
-
return this.type ===
|
|
1106
|
+
return this.type === import_types6.ChannelType.DM || this.type === import_types6.ChannelType.GroupDM;
|
|
1016
1107
|
}
|
|
1017
1108
|
/** Whether this channel is voice-based (VoiceChannel). */
|
|
1018
1109
|
isVoice() {
|
|
@@ -1051,10 +1142,10 @@ var Channel = class _Channel extends Base {
|
|
|
1051
1142
|
*/
|
|
1052
1143
|
static from(client, data) {
|
|
1053
1144
|
const type = data.type ?? 0;
|
|
1054
|
-
if (type ===
|
|
1055
|
-
if (type ===
|
|
1056
|
-
if (type ===
|
|
1057
|
-
if (type ===
|
|
1145
|
+
if (type === import_types6.ChannelType.GuildText) return new TextChannel(client, data);
|
|
1146
|
+
if (type === import_types6.ChannelType.GuildCategory) return new CategoryChannel(client, data);
|
|
1147
|
+
if (type === import_types6.ChannelType.GuildVoice) return new VoiceChannel(client, data);
|
|
1148
|
+
if (type === import_types6.ChannelType.GuildLink || type === import_types6.ChannelType.GuildLinkExtended)
|
|
1058
1149
|
return new LinkChannel(client, data);
|
|
1059
1150
|
return new GuildChannel(client, data);
|
|
1060
1151
|
}
|
|
@@ -1064,7 +1155,7 @@ var Channel = class _Channel extends Base {
|
|
|
1064
1155
|
*/
|
|
1065
1156
|
static fromOrCreate(client, data) {
|
|
1066
1157
|
const type = data.type ?? 0;
|
|
1067
|
-
if (type ===
|
|
1158
|
+
if (type === import_types6.ChannelType.DM || type === import_types6.ChannelType.GroupDM)
|
|
1068
1159
|
return _Channel.createDM(client, data);
|
|
1069
1160
|
return _Channel.from(client, data);
|
|
1070
1161
|
}
|
|
@@ -1073,7 +1164,7 @@ var Channel = class _Channel extends Base {
|
|
|
1073
1164
|
* @param messageIds - Array of message IDs to delete (2–100)
|
|
1074
1165
|
*/
|
|
1075
1166
|
async bulkDeleteMessages(messageIds) {
|
|
1076
|
-
await this.client.rest.post(
|
|
1167
|
+
await this.client.rest.post(import_types6.Routes.channelBulkDelete(this.id), {
|
|
1077
1168
|
body: { message_ids: messageIds },
|
|
1078
1169
|
auth: true
|
|
1079
1170
|
});
|
|
@@ -1082,7 +1173,21 @@ var Channel = class _Channel extends Base {
|
|
|
1082
1173
|
* Send a typing indicator to the channel. Lasts ~10 seconds.
|
|
1083
1174
|
*/
|
|
1084
1175
|
async sendTyping() {
|
|
1085
|
-
await this.client.rest.post(
|
|
1176
|
+
await this.client.rest.post(import_types6.Routes.channelTyping(this.id), { auth: true });
|
|
1177
|
+
}
|
|
1178
|
+
/**
|
|
1179
|
+
* Fetch available RTC regions for voice/video in this channel.
|
|
1180
|
+
* GET /channels/{id}/rtc-regions
|
|
1181
|
+
*/
|
|
1182
|
+
async fetchRtcRegions() {
|
|
1183
|
+
return this.client.rest.get(import_types6.Routes.channelRtcRegions(this.id), { auth: true });
|
|
1184
|
+
}
|
|
1185
|
+
/**
|
|
1186
|
+
* Fetch the current user's slowmode state in this channel.
|
|
1187
|
+
* GET /channels/{id}/slowmode
|
|
1188
|
+
*/
|
|
1189
|
+
async fetchSlowmode() {
|
|
1190
|
+
return this.client.rest.get(import_types6.Routes.channelSlowmode(this.id), { auth: true });
|
|
1086
1191
|
}
|
|
1087
1192
|
/**
|
|
1088
1193
|
* Whether the bot can send messages in this channel.
|
|
@@ -1115,7 +1220,7 @@ var GuildChannel = class extends Channel {
|
|
|
1115
1220
|
* @returns The webhook with token (required for send()). Requires Manage Webhooks permission.
|
|
1116
1221
|
*/
|
|
1117
1222
|
async createWebhook(options) {
|
|
1118
|
-
const data = await this.client.rest.post(
|
|
1223
|
+
const data = await this.client.rest.post(import_types6.Routes.channelWebhooks(this.id), {
|
|
1119
1224
|
body: options,
|
|
1120
1225
|
auth: true
|
|
1121
1226
|
});
|
|
@@ -1126,7 +1231,7 @@ var GuildChannel = class extends Channel {
|
|
|
1126
1231
|
* @returns Webhooks (includes token when listing from channel; can send via send())
|
|
1127
1232
|
*/
|
|
1128
1233
|
async fetchWebhooks() {
|
|
1129
|
-
const data = await this.client.rest.get(
|
|
1234
|
+
const data = await this.client.rest.get(import_types6.Routes.channelWebhooks(this.id));
|
|
1130
1235
|
const list = Array.isArray(data) ? data : Object.values(data ?? {});
|
|
1131
1236
|
return list.map((w) => new Webhook(this.client, w));
|
|
1132
1237
|
}
|
|
@@ -1141,7 +1246,7 @@ var GuildChannel = class extends Channel {
|
|
|
1141
1246
|
if (options?.max_age != null) body.max_age = options.max_age;
|
|
1142
1247
|
if (options?.unique != null) body.unique = options.unique;
|
|
1143
1248
|
if (options?.temporary != null) body.temporary = options.temporary;
|
|
1144
|
-
const data = await this.client.rest.post(
|
|
1249
|
+
const data = await this.client.rest.post(import_types6.Routes.channelInvites(this.id), {
|
|
1145
1250
|
body: Object.keys(body).length ? body : void 0,
|
|
1146
1251
|
auth: true
|
|
1147
1252
|
});
|
|
@@ -1152,7 +1257,7 @@ var GuildChannel = class extends Channel {
|
|
|
1152
1257
|
* Requires Manage Channel permission.
|
|
1153
1258
|
*/
|
|
1154
1259
|
async fetchInvites() {
|
|
1155
|
-
const data = await this.client.rest.get(
|
|
1260
|
+
const data = await this.client.rest.get(import_types6.Routes.channelInvites(this.id));
|
|
1156
1261
|
const list = Array.isArray(data) ? data : Object.values(data ?? {});
|
|
1157
1262
|
return list.map((i) => new Invite(this.client, i));
|
|
1158
1263
|
}
|
|
@@ -1162,7 +1267,7 @@ var GuildChannel = class extends Channel {
|
|
|
1162
1267
|
* @param options - type (0=role, 1=member), allow, deny (permission bitfields)
|
|
1163
1268
|
*/
|
|
1164
1269
|
async editPermission(overwriteId, options) {
|
|
1165
|
-
await this.client.rest.put(
|
|
1270
|
+
await this.client.rest.put(import_types6.Routes.channelPermission(this.id, overwriteId), {
|
|
1166
1271
|
body: options,
|
|
1167
1272
|
auth: true
|
|
1168
1273
|
});
|
|
@@ -1194,11 +1299,8 @@ var GuildChannel = class extends Channel {
|
|
|
1194
1299
|
* Works for text and announcement channels. Voice/category/link channels will fail at the API.
|
|
1195
1300
|
*/
|
|
1196
1301
|
async send(options) {
|
|
1197
|
-
const
|
|
1198
|
-
const
|
|
1199
|
-
const files = opts.files?.length ? await resolveMessageFiles(opts.files) : void 0;
|
|
1200
|
-
const postOptions = files?.length ? { body, files } : { body };
|
|
1201
|
-
const data = await this.client.rest.post(import_types5.Routes.channelMessages(this.id), postOptions);
|
|
1302
|
+
const payload = await prepareMessagePostPayload(options);
|
|
1303
|
+
const data = await this.client.rest.post(import_types6.Routes.channelMessages(this.id), payload);
|
|
1202
1304
|
this.client._addMessageToCache(this.id, data);
|
|
1203
1305
|
return new Message(this.client, data);
|
|
1204
1306
|
}
|
|
@@ -1206,7 +1308,7 @@ var GuildChannel = class extends Channel {
|
|
|
1206
1308
|
* Remove a permission overwrite. DELETE /channels/{id}/permissions/{overwriteId}.
|
|
1207
1309
|
*/
|
|
1208
1310
|
async deletePermission(overwriteId) {
|
|
1209
|
-
await this.client.rest.delete(
|
|
1311
|
+
await this.client.rest.delete(import_types6.Routes.channelPermission(this.id, overwriteId), { auth: true });
|
|
1210
1312
|
const idx = this.permissionOverwrites.findIndex((o) => o.id === overwriteId);
|
|
1211
1313
|
if (idx >= 0) this.permissionOverwrites.splice(idx, 1);
|
|
1212
1314
|
}
|
|
@@ -1215,7 +1317,7 @@ var GuildChannel = class extends Channel {
|
|
|
1215
1317
|
* Requires Manage Channel permission.
|
|
1216
1318
|
*/
|
|
1217
1319
|
async edit(options) {
|
|
1218
|
-
const data = await this.client.rest.patch(
|
|
1320
|
+
const data = await this.client.rest.patch(import_types6.Routes.channel(this.id), {
|
|
1219
1321
|
body: options,
|
|
1220
1322
|
auth: true
|
|
1221
1323
|
});
|
|
@@ -1236,7 +1338,7 @@ var GuildChannel = class extends Channel {
|
|
|
1236
1338
|
* @param options - silent: if true, does not send a system message (default false)
|
|
1237
1339
|
*/
|
|
1238
1340
|
async delete(options) {
|
|
1239
|
-
const url =
|
|
1341
|
+
const url = import_types6.Routes.channel(this.id) + (options?.silent ? "?silent=true" : "");
|
|
1240
1342
|
await this.client.rest.delete(url, { auth: true });
|
|
1241
1343
|
this.client.channels.delete(this.id);
|
|
1242
1344
|
const guild = this.client.guilds.get(this.guildId);
|
|
@@ -1260,11 +1362,8 @@ var TextChannel = class extends GuildChannel {
|
|
|
1260
1362
|
* @param options - Text content or object with content, embeds, and/or files
|
|
1261
1363
|
*/
|
|
1262
1364
|
async send(options) {
|
|
1263
|
-
const
|
|
1264
|
-
const
|
|
1265
|
-
const files = opts.files?.length ? await resolveMessageFiles(opts.files) : void 0;
|
|
1266
|
-
const postOptions = files?.length ? { body, files } : { body };
|
|
1267
|
-
const data = await this.client.rest.post(import_types5.Routes.channelMessages(this.id), postOptions);
|
|
1365
|
+
const payload = await prepareMessagePostPayload(options);
|
|
1366
|
+
const data = await this.client.rest.post(import_types6.Routes.channelMessages(this.id), payload);
|
|
1268
1367
|
this.client._addMessageToCache(this.id, data);
|
|
1269
1368
|
return new Message(this.client, data);
|
|
1270
1369
|
}
|
|
@@ -1289,7 +1388,7 @@ var TextChannel = class extends GuildChannel {
|
|
|
1289
1388
|
* @returns Pinned messages
|
|
1290
1389
|
*/
|
|
1291
1390
|
async fetchPinnedMessages() {
|
|
1292
|
-
const data = await this.client.rest.get(
|
|
1391
|
+
const data = await this.client.rest.get(import_types6.Routes.channelPins(this.id));
|
|
1293
1392
|
const list = Array.isArray(data) ? data : data?.items ?? [];
|
|
1294
1393
|
return list.map((item) => {
|
|
1295
1394
|
const msg = typeof item === "object" && item && "message" in item ? item.message : item;
|
|
@@ -1352,11 +1451,8 @@ var DMChannel = class extends Channel {
|
|
|
1352
1451
|
* @param options - Text content or object with content, embeds, and/or files
|
|
1353
1452
|
*/
|
|
1354
1453
|
async send(options) {
|
|
1355
|
-
const
|
|
1356
|
-
const
|
|
1357
|
-
const files = opts.files?.length ? await resolveMessageFiles(opts.files) : void 0;
|
|
1358
|
-
const postOptions = files?.length ? { body, files } : { body };
|
|
1359
|
-
const data = await this.client.rest.post(import_types5.Routes.channelMessages(this.id), postOptions);
|
|
1454
|
+
const payload = await prepareMessagePostPayload(options);
|
|
1455
|
+
const data = await this.client.rest.post(import_types6.Routes.channelMessages(this.id), payload);
|
|
1360
1456
|
this.client._addMessageToCache(this.id, data);
|
|
1361
1457
|
return new Message(this.client, data);
|
|
1362
1458
|
}
|
|
@@ -1376,7 +1472,7 @@ var DMChannel = class extends Channel {
|
|
|
1376
1472
|
* @returns Pinned messages
|
|
1377
1473
|
*/
|
|
1378
1474
|
async fetchPinnedMessages() {
|
|
1379
|
-
const data = await this.client.rest.get(
|
|
1475
|
+
const data = await this.client.rest.get(import_types6.Routes.channelPins(this.id));
|
|
1380
1476
|
const list = Array.isArray(data) ? data : data?.items ?? [];
|
|
1381
1477
|
return list.map((item) => {
|
|
1382
1478
|
const msg = typeof item === "object" && item && "message" in item ? item.message : item;
|
|
@@ -1401,7 +1497,7 @@ var DMChannel = class extends Channel {
|
|
|
1401
1497
|
* PUT /channels/{id}/recipients/{userId}.
|
|
1402
1498
|
*/
|
|
1403
1499
|
async addRecipient(userId) {
|
|
1404
|
-
await this.client.rest.put(
|
|
1500
|
+
await this.client.rest.put(import_types6.Routes.channelRecipient(this.id, userId), { auth: true });
|
|
1405
1501
|
const user = this.client.users.get(userId) ?? await this.client.users.fetch(userId);
|
|
1406
1502
|
if (user) this.recipients.push(user);
|
|
1407
1503
|
}
|
|
@@ -1411,7 +1507,7 @@ var DMChannel = class extends Channel {
|
|
|
1411
1507
|
* @param options - silent: if true, does not send a system message (default false)
|
|
1412
1508
|
*/
|
|
1413
1509
|
async removeRecipient(userId, options) {
|
|
1414
|
-
const url =
|
|
1510
|
+
const url = import_types6.Routes.channelRecipient(this.id, userId) + (options?.silent ? "?silent=true" : "");
|
|
1415
1511
|
await this.client.rest.delete(url, { auth: true });
|
|
1416
1512
|
const idx = this.recipients.findIndex((u) => u.id === userId);
|
|
1417
1513
|
if (idx >= 0) this.recipients.splice(idx, 1);
|
|
@@ -1419,7 +1515,7 @@ var DMChannel = class extends Channel {
|
|
|
1419
1515
|
};
|
|
1420
1516
|
|
|
1421
1517
|
// src/client/ChannelManager.ts
|
|
1422
|
-
var ChannelManager = class extends
|
|
1518
|
+
var ChannelManager = class extends import_collection5.Collection {
|
|
1423
1519
|
constructor(client) {
|
|
1424
1520
|
super();
|
|
1425
1521
|
this.client = client;
|
|
@@ -1459,7 +1555,7 @@ var ChannelManager = class extends import_collection4.Collection {
|
|
|
1459
1555
|
const cached = this.get(channelId);
|
|
1460
1556
|
if (cached) return cached;
|
|
1461
1557
|
try {
|
|
1462
|
-
const data = await this.client.rest.get(
|
|
1558
|
+
const data = await this.client.rest.get(import_types7.Routes.channel(channelId));
|
|
1463
1559
|
const channel = Channel.fromOrCreate(this.client, data);
|
|
1464
1560
|
if (!channel) {
|
|
1465
1561
|
throw new import_util.FluxerError("Channel data invalid or unsupported type", {
|
|
@@ -1501,7 +1597,7 @@ var ChannelManager = class extends import_collection4.Collection {
|
|
|
1501
1597
|
);
|
|
1502
1598
|
try {
|
|
1503
1599
|
const data = await this.client.rest.get(
|
|
1504
|
-
|
|
1600
|
+
import_types7.Routes.channelMessage(channelId, messageId)
|
|
1505
1601
|
);
|
|
1506
1602
|
return new Message(this.client, data);
|
|
1507
1603
|
} catch (err) {
|
|
@@ -1527,41 +1623,38 @@ var ChannelManager = class extends import_collection4.Collection {
|
|
|
1527
1623
|
* await client.channels.send(channelId, { content: 'Report', files: [{ name: 'log.txt', data }] });
|
|
1528
1624
|
*/
|
|
1529
1625
|
async send(channelId, payload) {
|
|
1530
|
-
const
|
|
1531
|
-
const
|
|
1532
|
-
const files = opts.files?.length ? await resolveMessageFiles(opts.files) : void 0;
|
|
1533
|
-
const postOptions = files?.length ? { body, files } : { body };
|
|
1534
|
-
const data = await this.client.rest.post(import_types6.Routes.channelMessages(channelId), postOptions);
|
|
1626
|
+
const postPayload = await prepareMessagePostPayload(payload);
|
|
1627
|
+
const data = await this.client.rest.post(import_types7.Routes.channelMessages(channelId), postPayload);
|
|
1535
1628
|
this.client._addMessageToCache(channelId, data);
|
|
1536
1629
|
return new Message(this.client, data);
|
|
1537
1630
|
}
|
|
1538
1631
|
};
|
|
1539
1632
|
|
|
1540
1633
|
// src/client/GuildManager.ts
|
|
1541
|
-
var
|
|
1542
|
-
var
|
|
1634
|
+
var import_collection9 = require("@fluxerjs/collection");
|
|
1635
|
+
var import_types17 = require("@fluxerjs/types");
|
|
1543
1636
|
|
|
1544
1637
|
// src/structures/Guild.ts
|
|
1545
1638
|
var import_util9 = require("@fluxerjs/util");
|
|
1546
1639
|
var import_rest3 = require("@fluxerjs/rest");
|
|
1547
|
-
var
|
|
1640
|
+
var import_collection8 = require("@fluxerjs/collection");
|
|
1548
1641
|
|
|
1549
1642
|
// src/client/GuildMemberManager.ts
|
|
1550
|
-
var
|
|
1551
|
-
var
|
|
1643
|
+
var import_collection7 = require("@fluxerjs/collection");
|
|
1644
|
+
var import_types11 = require("@fluxerjs/types");
|
|
1552
1645
|
|
|
1553
1646
|
// src/structures/GuildMember.ts
|
|
1554
1647
|
var import_util7 = require("@fluxerjs/util");
|
|
1555
|
-
var
|
|
1648
|
+
var import_types10 = require("@fluxerjs/types");
|
|
1556
1649
|
|
|
1557
1650
|
// src/util/permissions.ts
|
|
1558
|
-
var
|
|
1651
|
+
var import_types8 = require("@fluxerjs/types");
|
|
1559
1652
|
var import_util6 = require("@fluxerjs/util");
|
|
1560
1653
|
function computePermissions(basePermissions, overwrites, memberRoles, memberId, isOwner) {
|
|
1561
1654
|
if (isOwner) return import_util6.ALL_PERMISSIONS_BIGINT;
|
|
1562
1655
|
let perms = basePermissions;
|
|
1563
1656
|
for (const overwrite of overwrites ?? []) {
|
|
1564
|
-
const applies = overwrite.type ===
|
|
1657
|
+
const applies = overwrite.type === import_types8.OverwriteType.Role && memberRoles.includes(overwrite.id) || overwrite.type === import_types8.OverwriteType.Member && overwrite.id === memberId;
|
|
1565
1658
|
if (!applies) continue;
|
|
1566
1659
|
const allow = BigInt(overwrite.allow || "0");
|
|
1567
1660
|
const deny = BigInt(overwrite.deny || "0");
|
|
@@ -1571,8 +1664,8 @@ function computePermissions(basePermissions, overwrites, memberRoles, memberId,
|
|
|
1571
1664
|
}
|
|
1572
1665
|
|
|
1573
1666
|
// src/structures/GuildMemberRoleManager.ts
|
|
1574
|
-
var
|
|
1575
|
-
var
|
|
1667
|
+
var import_collection6 = require("@fluxerjs/collection");
|
|
1668
|
+
var import_types9 = require("@fluxerjs/types");
|
|
1576
1669
|
var GuildMemberRoleManager = class {
|
|
1577
1670
|
constructor(member, initialRoleIds = []) {
|
|
1578
1671
|
this.member = member;
|
|
@@ -1593,7 +1686,7 @@ var GuildMemberRoleManager = class {
|
|
|
1593
1686
|
* @discordJsCompat https://discord.js.org/docs/packages/discord.js/main/GuildMemberRoleManager
|
|
1594
1687
|
*/
|
|
1595
1688
|
get cache() {
|
|
1596
|
-
const coll = new
|
|
1689
|
+
const coll = new import_collection6.Collection();
|
|
1597
1690
|
for (const id of this._roleIds) {
|
|
1598
1691
|
const role = this.member.guild.roles.get(id);
|
|
1599
1692
|
if (role) coll.set(id, role);
|
|
@@ -1614,7 +1707,7 @@ var GuildMemberRoleManager = class {
|
|
|
1614
1707
|
const roleId = this._resolveId(roleOrId);
|
|
1615
1708
|
if (this._roleIds.includes(roleId)) return;
|
|
1616
1709
|
await this.member.client.rest.put(
|
|
1617
|
-
|
|
1710
|
+
import_types9.Routes.guildMemberRole(this.member.guild.id, this.member.id, roleId)
|
|
1618
1711
|
);
|
|
1619
1712
|
this._roleIds.push(roleId);
|
|
1620
1713
|
}
|
|
@@ -1629,7 +1722,7 @@ var GuildMemberRoleManager = class {
|
|
|
1629
1722
|
const idx = this._roleIds.indexOf(roleId);
|
|
1630
1723
|
if (idx === -1) return;
|
|
1631
1724
|
await this.member.client.rest.delete(
|
|
1632
|
-
|
|
1725
|
+
import_types9.Routes.guildMemberRole(this.member.guild.id, this.member.id, roleId)
|
|
1633
1726
|
);
|
|
1634
1727
|
this._roleIds.splice(idx, 1);
|
|
1635
1728
|
}
|
|
@@ -1641,7 +1734,7 @@ var GuildMemberRoleManager = class {
|
|
|
1641
1734
|
*/
|
|
1642
1735
|
async set(roleIds) {
|
|
1643
1736
|
const data = await this.member.client.rest.patch(
|
|
1644
|
-
|
|
1737
|
+
import_types9.Routes.guildMember(this.member.guild.id, this.member.id),
|
|
1645
1738
|
{ body: { roles: roleIds }, auth: true }
|
|
1646
1739
|
);
|
|
1647
1740
|
this._roleIds = data.roles ? [...data.roles] : [];
|
|
@@ -1744,7 +1837,7 @@ var GuildMember = class extends Base {
|
|
|
1744
1837
|
*/
|
|
1745
1838
|
async edit(options) {
|
|
1746
1839
|
const isMe = this.client.user?.id === this.id;
|
|
1747
|
-
const route = isMe ? `/guilds/${this.guild.id}/members/@me` :
|
|
1840
|
+
const route = isMe ? `/guilds/${this.guild.id}/members/@me` : import_types10.Routes.guildMember(this.guild.id, this.id);
|
|
1748
1841
|
const data = await this.client.rest.patch(route, {
|
|
1749
1842
|
body: options,
|
|
1750
1843
|
auth: true
|
|
@@ -1826,7 +1919,7 @@ var GuildMember = class extends Base {
|
|
|
1826
1919
|
};
|
|
1827
1920
|
|
|
1828
1921
|
// src/client/GuildMemberManager.ts
|
|
1829
|
-
var GuildMemberManager = class extends
|
|
1922
|
+
var GuildMemberManager = class extends import_collection7.Collection {
|
|
1830
1923
|
constructor(guild) {
|
|
1831
1924
|
super();
|
|
1832
1925
|
this.guild = guild;
|
|
@@ -1886,7 +1979,7 @@ var GuildMemberManager = class extends import_collection6.Collection {
|
|
|
1886
1979
|
if (options?.limit != null) params.set("limit", String(options.limit));
|
|
1887
1980
|
if (options?.after) params.set("after", options.after);
|
|
1888
1981
|
const qs = params.toString();
|
|
1889
|
-
const url =
|
|
1982
|
+
const url = import_types11.Routes.guildMembers(this.guild.id) + (qs ? `?${qs}` : "");
|
|
1890
1983
|
const data = await this.guild.client.rest.get(url, { auth: true });
|
|
1891
1984
|
const list = Array.isArray(data) ? data : data?.members ?? [];
|
|
1892
1985
|
const members = [];
|
|
@@ -1901,10 +1994,23 @@ var GuildMemberManager = class extends import_collection6.Collection {
|
|
|
1901
1994
|
}
|
|
1902
1995
|
return members;
|
|
1903
1996
|
}
|
|
1997
|
+
/**
|
|
1998
|
+
* Search guild members. POST /guilds/{id}/members-search.
|
|
1999
|
+
* @param options - Search query, filters, and pagination
|
|
2000
|
+
* @returns Search results with matching members
|
|
2001
|
+
* @example
|
|
2002
|
+
* const { members } = await guild.members.search({ query: 'alex', limit: 25 });
|
|
2003
|
+
*/
|
|
2004
|
+
async search(options) {
|
|
2005
|
+
return this.guild.client.rest.post(import_types11.Routes.guildMembersSearch(this.guild.id), {
|
|
2006
|
+
body: options,
|
|
2007
|
+
auth: true
|
|
2008
|
+
});
|
|
2009
|
+
}
|
|
1904
2010
|
};
|
|
1905
2011
|
|
|
1906
2012
|
// src/structures/Role.ts
|
|
1907
|
-
var
|
|
2013
|
+
var import_types12 = require("@fluxerjs/types");
|
|
1908
2014
|
var import_util8 = require("@fluxerjs/util");
|
|
1909
2015
|
var Role = class extends Base {
|
|
1910
2016
|
client;
|
|
@@ -1977,7 +2083,7 @@ var Role = class extends Base {
|
|
|
1977
2083
|
if (options.unicode_emoji !== void 0) body.unicode_emoji = options.unicode_emoji;
|
|
1978
2084
|
if (options.position !== void 0) body.position = options.position;
|
|
1979
2085
|
if (options.hoist_position !== void 0) body.hoist_position = options.hoist_position;
|
|
1980
|
-
const data = await this.client.rest.patch(
|
|
2086
|
+
const data = await this.client.rest.patch(import_types12.Routes.guildRole(this.guildId, this.id), {
|
|
1981
2087
|
body: Object.keys(body).length ? body : void 0,
|
|
1982
2088
|
auth: true
|
|
1983
2089
|
});
|
|
@@ -1989,17 +2095,17 @@ var Role = class extends Base {
|
|
|
1989
2095
|
* Requires Manage Roles permission.
|
|
1990
2096
|
*/
|
|
1991
2097
|
async delete() {
|
|
1992
|
-
await this.client.rest.delete(
|
|
2098
|
+
await this.client.rest.delete(import_types12.Routes.guildRole(this.guildId, this.id), { auth: true });
|
|
1993
2099
|
const guild = this.client.guilds.get(this.guildId);
|
|
1994
2100
|
if (guild) guild.roles.delete(this.id);
|
|
1995
2101
|
}
|
|
1996
2102
|
};
|
|
1997
2103
|
|
|
1998
2104
|
// src/structures/Guild.ts
|
|
1999
|
-
var
|
|
2105
|
+
var import_types16 = require("@fluxerjs/types");
|
|
2000
2106
|
|
|
2001
2107
|
// src/structures/GuildBan.ts
|
|
2002
|
-
var
|
|
2108
|
+
var import_types13 = require("@fluxerjs/types");
|
|
2003
2109
|
var GuildBan = class extends Base {
|
|
2004
2110
|
client;
|
|
2005
2111
|
guildId;
|
|
@@ -2021,14 +2127,14 @@ var GuildBan = class extends Base {
|
|
|
2021
2127
|
* Requires Ban Members permission.
|
|
2022
2128
|
*/
|
|
2023
2129
|
async unban() {
|
|
2024
|
-
await this.client.rest.delete(
|
|
2130
|
+
await this.client.rest.delete(import_types13.Routes.guildBan(this.guildId, this.user.id), {
|
|
2025
2131
|
auth: true
|
|
2026
2132
|
});
|
|
2027
2133
|
}
|
|
2028
2134
|
};
|
|
2029
2135
|
|
|
2030
2136
|
// src/structures/GuildEmoji.ts
|
|
2031
|
-
var
|
|
2137
|
+
var import_types14 = require("@fluxerjs/types");
|
|
2032
2138
|
var GuildEmoji = class extends Base {
|
|
2033
2139
|
client;
|
|
2034
2140
|
id;
|
|
@@ -2055,7 +2161,7 @@ var GuildEmoji = class extends Base {
|
|
|
2055
2161
|
}
|
|
2056
2162
|
/** Delete this emoji. Requires Manage Emojis and Stickers permission. */
|
|
2057
2163
|
async delete() {
|
|
2058
|
-
await this.client.rest.delete(
|
|
2164
|
+
await this.client.rest.delete(import_types14.Routes.guildEmoji(this.guildId, this.id), {
|
|
2059
2165
|
auth: true
|
|
2060
2166
|
});
|
|
2061
2167
|
const guild = this.client.guilds.get(this.guildId);
|
|
@@ -2066,7 +2172,7 @@ var GuildEmoji = class extends Base {
|
|
|
2066
2172
|
* Requires Manage Emojis and Stickers permission.
|
|
2067
2173
|
*/
|
|
2068
2174
|
async edit(options) {
|
|
2069
|
-
const data = await this.client.rest.patch(
|
|
2175
|
+
const data = await this.client.rest.patch(import_types14.Routes.guildEmoji(this.guildId, this.id), {
|
|
2070
2176
|
body: options,
|
|
2071
2177
|
auth: true
|
|
2072
2178
|
});
|
|
@@ -2076,7 +2182,7 @@ var GuildEmoji = class extends Base {
|
|
|
2076
2182
|
};
|
|
2077
2183
|
|
|
2078
2184
|
// src/structures/GuildSticker.ts
|
|
2079
|
-
var
|
|
2185
|
+
var import_types15 = require("@fluxerjs/types");
|
|
2080
2186
|
var GuildSticker = class extends Base {
|
|
2081
2187
|
client;
|
|
2082
2188
|
id;
|
|
@@ -2103,7 +2209,7 @@ var GuildSticker = class extends Base {
|
|
|
2103
2209
|
}
|
|
2104
2210
|
/** Delete this sticker. Requires Manage Emojis and Stickers permission. */
|
|
2105
2211
|
async delete() {
|
|
2106
|
-
await this.client.rest.delete(
|
|
2212
|
+
await this.client.rest.delete(import_types15.Routes.guildSticker(this.guildId, this.id), {
|
|
2107
2213
|
auth: true
|
|
2108
2214
|
});
|
|
2109
2215
|
}
|
|
@@ -2112,7 +2218,7 @@ var GuildSticker = class extends Base {
|
|
|
2112
2218
|
* Requires Manage Emojis and Stickers permission.
|
|
2113
2219
|
*/
|
|
2114
2220
|
async edit(options) {
|
|
2115
|
-
const data = await this.client.rest.patch(
|
|
2221
|
+
const data = await this.client.rest.patch(import_types15.Routes.guildSticker(this.guildId, this.id), {
|
|
2116
2222
|
body: options,
|
|
2117
2223
|
auth: true
|
|
2118
2224
|
});
|
|
@@ -2159,10 +2265,10 @@ var Guild = class extends Base {
|
|
|
2159
2265
|
/** Splash image height. Optional. */
|
|
2160
2266
|
splashHeight;
|
|
2161
2267
|
members;
|
|
2162
|
-
channels = new
|
|
2163
|
-
roles = new
|
|
2164
|
-
emojis = new
|
|
2165
|
-
stickers = new
|
|
2268
|
+
channels = new import_collection8.Collection();
|
|
2269
|
+
roles = new import_collection8.Collection();
|
|
2270
|
+
emojis = new import_collection8.Collection();
|
|
2271
|
+
stickers = new import_collection8.Collection();
|
|
2166
2272
|
/** @param data - API guild from GET /guilds/{id} or gateway GUILD_CREATE */
|
|
2167
2273
|
constructor(client, data) {
|
|
2168
2274
|
super();
|
|
@@ -2218,7 +2324,7 @@ var Guild = class extends Base {
|
|
|
2218
2324
|
* Requires Manage Roles permission.
|
|
2219
2325
|
*/
|
|
2220
2326
|
async addRoleToMember(userId, roleId) {
|
|
2221
|
-
await this.client.rest.put(
|
|
2327
|
+
await this.client.rest.put(import_types16.Routes.guildMemberRole(this.id, userId, roleId));
|
|
2222
2328
|
}
|
|
2223
2329
|
/**
|
|
2224
2330
|
* Remove a role from a member by user ID. Does not require fetching the member first.
|
|
@@ -2227,7 +2333,7 @@ var Guild = class extends Base {
|
|
|
2227
2333
|
* Requires Manage Roles permission.
|
|
2228
2334
|
*/
|
|
2229
2335
|
async removeRoleFromMember(userId, roleId) {
|
|
2230
|
-
await this.client.rest.delete(
|
|
2336
|
+
await this.client.rest.delete(import_types16.Routes.guildMemberRole(this.id, userId, roleId));
|
|
2231
2337
|
}
|
|
2232
2338
|
/**
|
|
2233
2339
|
* Create a role in this guild.
|
|
@@ -2249,7 +2355,7 @@ var Guild = class extends Base {
|
|
|
2249
2355
|
if (options.unicode_emoji !== void 0) body.unicode_emoji = options.unicode_emoji;
|
|
2250
2356
|
if (options.position !== void 0) body.position = options.position;
|
|
2251
2357
|
if (options.hoist_position !== void 0) body.hoist_position = options.hoist_position;
|
|
2252
|
-
const data = await this.client.rest.post(
|
|
2358
|
+
const data = await this.client.rest.post(import_types16.Routes.guildRoles(this.id), {
|
|
2253
2359
|
body: Object.keys(body).length ? body : void 0,
|
|
2254
2360
|
auth: true
|
|
2255
2361
|
});
|
|
@@ -2263,7 +2369,7 @@ var Guild = class extends Base {
|
|
|
2263
2369
|
*/
|
|
2264
2370
|
async fetchRoles() {
|
|
2265
2371
|
const data = await this.client.rest.get(
|
|
2266
|
-
|
|
2372
|
+
import_types16.Routes.guildRoles(this.id)
|
|
2267
2373
|
);
|
|
2268
2374
|
const list = Array.isArray(data) ? data : Object.values(data ?? {});
|
|
2269
2375
|
const roles = [];
|
|
@@ -2282,7 +2388,7 @@ var Guild = class extends Base {
|
|
|
2282
2388
|
*/
|
|
2283
2389
|
async fetchRole(roleId) {
|
|
2284
2390
|
try {
|
|
2285
|
-
const data = await this.client.rest.get(
|
|
2391
|
+
const data = await this.client.rest.get(import_types16.Routes.guildRole(this.id, roleId));
|
|
2286
2392
|
const role = new Role(this.client, data, this.id);
|
|
2287
2393
|
this.roles.set(role.id, role);
|
|
2288
2394
|
return role;
|
|
@@ -2311,7 +2417,7 @@ var Guild = class extends Base {
|
|
|
2311
2417
|
(r) => !!(r.name && r.name.toLowerCase() === arg.trim().toLowerCase())
|
|
2312
2418
|
);
|
|
2313
2419
|
if (cached) return cached.id;
|
|
2314
|
-
const roles = await this.client.rest.get(
|
|
2420
|
+
const roles = await this.client.rest.get(import_types16.Routes.guildRoles(this.id));
|
|
2315
2421
|
const list = Array.isArray(roles) ? roles : Object.values(roles ?? {});
|
|
2316
2422
|
const role = list.find((r) => !!(r.name && r.name.toLowerCase() === arg.trim().toLowerCase()));
|
|
2317
2423
|
if (role) {
|
|
@@ -2334,7 +2440,7 @@ var Guild = class extends Base {
|
|
|
2334
2440
|
body.delete_message_days = options.delete_message_days;
|
|
2335
2441
|
if (options?.ban_duration_seconds != null)
|
|
2336
2442
|
body.ban_duration_seconds = options.ban_duration_seconds;
|
|
2337
|
-
await this.client.rest.put(
|
|
2443
|
+
await this.client.rest.put(import_types16.Routes.guildBan(this.id, userId), {
|
|
2338
2444
|
body: Object.keys(body).length ? body : void 0,
|
|
2339
2445
|
auth: true
|
|
2340
2446
|
});
|
|
@@ -2345,7 +2451,7 @@ var Guild = class extends Base {
|
|
|
2345
2451
|
*/
|
|
2346
2452
|
async fetchBans() {
|
|
2347
2453
|
const data = await this.client.rest.get(
|
|
2348
|
-
|
|
2454
|
+
import_types16.Routes.guildBans(this.id)
|
|
2349
2455
|
);
|
|
2350
2456
|
const list = Array.isArray(data) ? data : data?.bans ?? [];
|
|
2351
2457
|
return list.map((b) => new GuildBan(this.client, { ...b, guild_id: this.id }, this.id));
|
|
@@ -2356,7 +2462,7 @@ var Guild = class extends Base {
|
|
|
2356
2462
|
* Requires Ban Members permission.
|
|
2357
2463
|
*/
|
|
2358
2464
|
async unban(userId) {
|
|
2359
|
-
await this.client.rest.delete(
|
|
2465
|
+
await this.client.rest.delete(import_types16.Routes.guildBan(this.id, userId), { auth: true });
|
|
2360
2466
|
}
|
|
2361
2467
|
/**
|
|
2362
2468
|
* Kick a member from this guild.
|
|
@@ -2364,7 +2470,7 @@ var Guild = class extends Base {
|
|
|
2364
2470
|
* Requires Kick Members permission.
|
|
2365
2471
|
*/
|
|
2366
2472
|
async kick(userId) {
|
|
2367
|
-
await this.client.rest.delete(
|
|
2473
|
+
await this.client.rest.delete(import_types16.Routes.guildMember(this.id, userId), { auth: true });
|
|
2368
2474
|
}
|
|
2369
2475
|
/**
|
|
2370
2476
|
* Fetch a guild member by user ID.
|
|
@@ -2376,7 +2482,7 @@ var Guild = class extends Base {
|
|
|
2376
2482
|
async fetchMember(userId) {
|
|
2377
2483
|
try {
|
|
2378
2484
|
const data = await this.client.rest.get(
|
|
2379
|
-
|
|
2485
|
+
import_types16.Routes.guildMember(this.id, userId)
|
|
2380
2486
|
);
|
|
2381
2487
|
const member = new GuildMember(this.client, { ...data, guild_id: this.id }, this);
|
|
2382
2488
|
this.members.set(member.id, member);
|
|
@@ -2404,12 +2510,12 @@ var Guild = class extends Base {
|
|
|
2404
2510
|
if (options?.userId) params.set("user_id", options.userId);
|
|
2405
2511
|
if (options?.actionType != null) params.set("action_type", String(options.actionType));
|
|
2406
2512
|
const qs = params.toString();
|
|
2407
|
-
const url =
|
|
2513
|
+
const url = import_types16.Routes.guildAuditLogs(this.id) + (qs ? `?${qs}` : "");
|
|
2408
2514
|
return this.client.rest.get(url);
|
|
2409
2515
|
}
|
|
2410
2516
|
/** Fetch all webhooks in this guild. Returned webhooks do not include the token (cannot send). */
|
|
2411
2517
|
async fetchWebhooks() {
|
|
2412
|
-
const data = await this.client.rest.get(
|
|
2518
|
+
const data = await this.client.rest.get(import_types16.Routes.guildWebhooks(this.id));
|
|
2413
2519
|
const list = Array.isArray(data) ? data : Object.values(data ?? {});
|
|
2414
2520
|
return list.map((w) => new Webhook(this.client, w));
|
|
2415
2521
|
}
|
|
@@ -2419,7 +2525,7 @@ var Guild = class extends Base {
|
|
|
2419
2525
|
*/
|
|
2420
2526
|
async fetchInvites() {
|
|
2421
2527
|
const data = await this.client.rest.get(
|
|
2422
|
-
|
|
2528
|
+
import_types16.Routes.guildInvites(this.id)
|
|
2423
2529
|
);
|
|
2424
2530
|
const list = Array.isArray(data) ? data : Object.values(data ?? {});
|
|
2425
2531
|
return list.map((invite) => new Invite(this.client, invite));
|
|
@@ -2437,7 +2543,7 @@ var Guild = class extends Base {
|
|
|
2437
2543
|
* Requires Manage Channels permission.
|
|
2438
2544
|
*/
|
|
2439
2545
|
async createChannel(data) {
|
|
2440
|
-
const created = await this.client.rest.post(
|
|
2546
|
+
const created = await this.client.rest.post(import_types16.Routes.guildChannels(this.id), {
|
|
2441
2547
|
body: data,
|
|
2442
2548
|
auth: true
|
|
2443
2549
|
});
|
|
@@ -2453,7 +2559,7 @@ var Guild = class extends Base {
|
|
|
2453
2559
|
* @returns Array of GuildChannel objects (cached in guild.channels and client.channels)
|
|
2454
2560
|
*/
|
|
2455
2561
|
async fetchChannels() {
|
|
2456
|
-
const data = await this.client.rest.get(
|
|
2562
|
+
const data = await this.client.rest.get(import_types16.Routes.guildChannels(this.id));
|
|
2457
2563
|
const list = Array.isArray(data) ? data : Object.values(data ?? {});
|
|
2458
2564
|
const channels = [];
|
|
2459
2565
|
for (const ch of list) {
|
|
@@ -2471,7 +2577,7 @@ var Guild = class extends Base {
|
|
|
2471
2577
|
* Requires guild owner or Administrator.
|
|
2472
2578
|
*/
|
|
2473
2579
|
async edit(options) {
|
|
2474
|
-
const data = await this.client.rest.patch(
|
|
2580
|
+
const data = await this.client.rest.patch(import_types16.Routes.guild(this.id), {
|
|
2475
2581
|
body: options,
|
|
2476
2582
|
auth: true
|
|
2477
2583
|
});
|
|
@@ -2494,7 +2600,7 @@ var Guild = class extends Base {
|
|
|
2494
2600
|
* Must be the guild owner.
|
|
2495
2601
|
*/
|
|
2496
2602
|
async delete() {
|
|
2497
|
-
await this.client.rest.post(
|
|
2603
|
+
await this.client.rest.post(import_types16.Routes.guildDelete(this.id), { auth: true });
|
|
2498
2604
|
this.client.guilds.delete(this.id);
|
|
2499
2605
|
}
|
|
2500
2606
|
/**
|
|
@@ -2502,14 +2608,14 @@ var Guild = class extends Base {
|
|
|
2502
2608
|
* Requires Manage Guild permission.
|
|
2503
2609
|
*/
|
|
2504
2610
|
async fetchVanityURL() {
|
|
2505
|
-
return this.client.rest.get(
|
|
2611
|
+
return this.client.rest.get(import_types16.Routes.guildVanityUrl(this.id), { auth: true });
|
|
2506
2612
|
}
|
|
2507
2613
|
/**
|
|
2508
2614
|
* Transfer guild ownership to another user. POST /guilds/{id}/transfer-ownership.
|
|
2509
2615
|
* Must be the guild owner.
|
|
2510
2616
|
*/
|
|
2511
2617
|
async transferOwnership(newOwnerId, password) {
|
|
2512
|
-
await this.client.rest.post(
|
|
2618
|
+
await this.client.rest.post(import_types16.Routes.guildTransferOwnership(this.id), {
|
|
2513
2619
|
body: { new_owner_id: newOwnerId, ...password != null && { password } },
|
|
2514
2620
|
auth: true
|
|
2515
2621
|
});
|
|
@@ -2518,7 +2624,7 @@ var Guild = class extends Base {
|
|
|
2518
2624
|
* Set text channel flexible names feature. PATCH /guilds/{id}/text-channel-flexible-names.
|
|
2519
2625
|
*/
|
|
2520
2626
|
setTextChannelFlexibleNames(enabled) {
|
|
2521
|
-
return this.client.rest.patch(
|
|
2627
|
+
return this.client.rest.patch(import_types16.Routes.guildTextChannelFlexibleNames(this.id), {
|
|
2522
2628
|
body: { enabled },
|
|
2523
2629
|
auth: true
|
|
2524
2630
|
}).then(() => this);
|
|
@@ -2527,7 +2633,7 @@ var Guild = class extends Base {
|
|
|
2527
2633
|
* Set detached banner feature. PATCH /guilds/{id}/detached-banner.
|
|
2528
2634
|
*/
|
|
2529
2635
|
setDetachedBanner(enabled) {
|
|
2530
|
-
return this.client.rest.patch(
|
|
2636
|
+
return this.client.rest.patch(import_types16.Routes.guildDetachedBanner(this.id), {
|
|
2531
2637
|
body: { enabled },
|
|
2532
2638
|
auth: true
|
|
2533
2639
|
}).then(() => this);
|
|
@@ -2536,7 +2642,7 @@ var Guild = class extends Base {
|
|
|
2536
2642
|
* Set disallow unclaimed accounts. PATCH /guilds/{id}/disallow-unclaimed-accounts.
|
|
2537
2643
|
*/
|
|
2538
2644
|
setDisallowUnclaimedAccounts(enabled) {
|
|
2539
|
-
return this.client.rest.patch(
|
|
2645
|
+
return this.client.rest.patch(import_types16.Routes.guildDisallowUnclaimedAccounts(this.id), {
|
|
2540
2646
|
body: { enabled },
|
|
2541
2647
|
auth: true
|
|
2542
2648
|
}).then(() => this);
|
|
@@ -2547,7 +2653,7 @@ var Guild = class extends Base {
|
|
|
2547
2653
|
*/
|
|
2548
2654
|
async setRolePositions(updates) {
|
|
2549
2655
|
const data = await this.client.rest.patch(
|
|
2550
|
-
|
|
2656
|
+
import_types16.Routes.guildRoles(this.id),
|
|
2551
2657
|
{ body: updates, auth: true }
|
|
2552
2658
|
);
|
|
2553
2659
|
const list = Array.isArray(data) ? data : Object.values(data ?? {});
|
|
@@ -2561,7 +2667,7 @@ var Guild = class extends Base {
|
|
|
2561
2667
|
*/
|
|
2562
2668
|
async setRoleHoistPositions(updates) {
|
|
2563
2669
|
const data = await this.client.rest.patch(
|
|
2564
|
-
|
|
2670
|
+
import_types16.Routes.guildRolesHoistPositions(this.id),
|
|
2565
2671
|
{ body: updates, auth: true }
|
|
2566
2672
|
);
|
|
2567
2673
|
const list = Array.isArray(data) ? data : Object.values(data ?? {});
|
|
@@ -2575,7 +2681,7 @@ var Guild = class extends Base {
|
|
|
2575
2681
|
*/
|
|
2576
2682
|
async resetRoleHoistPositions() {
|
|
2577
2683
|
const data = await this.client.rest.delete(
|
|
2578
|
-
|
|
2684
|
+
import_types16.Routes.guildRolesHoistPositions(this.id),
|
|
2579
2685
|
{ auth: true }
|
|
2580
2686
|
);
|
|
2581
2687
|
const list = Array.isArray(data) ? data : Object.values(data ?? {});
|
|
@@ -2590,7 +2696,7 @@ var Guild = class extends Base {
|
|
|
2590
2696
|
* Requires Manage Channels permission.
|
|
2591
2697
|
*/
|
|
2592
2698
|
async setChannelPositions(updates) {
|
|
2593
|
-
await this.client.rest.patch(
|
|
2699
|
+
await this.client.rest.patch(import_types16.Routes.guildChannels(this.id), {
|
|
2594
2700
|
body: updates,
|
|
2595
2701
|
auth: true
|
|
2596
2702
|
});
|
|
@@ -2601,7 +2707,7 @@ var Guild = class extends Base {
|
|
|
2601
2707
|
*/
|
|
2602
2708
|
async fetchEmojis() {
|
|
2603
2709
|
const data = await this.client.rest.get(
|
|
2604
|
-
|
|
2710
|
+
import_types16.Routes.guildEmojis(this.id)
|
|
2605
2711
|
);
|
|
2606
2712
|
const list = Array.isArray(data) ? data : Object.values(data ?? {});
|
|
2607
2713
|
const emojis = [];
|
|
@@ -2620,7 +2726,7 @@ var Guild = class extends Base {
|
|
|
2620
2726
|
*/
|
|
2621
2727
|
async fetchEmoji(emojiId) {
|
|
2622
2728
|
try {
|
|
2623
|
-
const data = await this.client.rest.get(
|
|
2729
|
+
const data = await this.client.rest.get(import_types16.Routes.guildEmoji(this.id, emojiId));
|
|
2624
2730
|
const emoji = new GuildEmoji(this.client, { ...data, guild_id: this.id }, this.id);
|
|
2625
2731
|
this.emojis.set(emoji.id, emoji);
|
|
2626
2732
|
return emoji;
|
|
@@ -2642,7 +2748,7 @@ var Guild = class extends Base {
|
|
|
2642
2748
|
*/
|
|
2643
2749
|
async createEmojisBulk(emojis) {
|
|
2644
2750
|
const data = await this.client.rest.post(
|
|
2645
|
-
|
|
2751
|
+
import_types16.Routes.guildEmojisBulk(this.id),
|
|
2646
2752
|
{
|
|
2647
2753
|
body: { emojis },
|
|
2648
2754
|
auth: true
|
|
@@ -2658,7 +2764,7 @@ var Guild = class extends Base {
|
|
|
2658
2764
|
*/
|
|
2659
2765
|
async createStickersBulk(stickers) {
|
|
2660
2766
|
const data = await this.client.rest.post(
|
|
2661
|
-
|
|
2767
|
+
import_types16.Routes.guildStickersBulk(this.id),
|
|
2662
2768
|
{
|
|
2663
2769
|
body: { stickers },
|
|
2664
2770
|
auth: true
|
|
@@ -2679,7 +2785,7 @@ var Guild = class extends Base {
|
|
|
2679
2785
|
*/
|
|
2680
2786
|
async fetchStickers() {
|
|
2681
2787
|
const data = await this.client.rest.get(
|
|
2682
|
-
|
|
2788
|
+
import_types16.Routes.guildStickers(this.id)
|
|
2683
2789
|
);
|
|
2684
2790
|
const list = Array.isArray(data) ? data : Object.values(data ?? {});
|
|
2685
2791
|
const stickers = [];
|
|
@@ -2694,7 +2800,7 @@ var Guild = class extends Base {
|
|
|
2694
2800
|
* Fetch a single guild sticker by ID.
|
|
2695
2801
|
*/
|
|
2696
2802
|
async fetchSticker(stickerId) {
|
|
2697
|
-
const data = await this.client.rest.get(
|
|
2803
|
+
const data = await this.client.rest.get(import_types16.Routes.guildSticker(this.id, stickerId));
|
|
2698
2804
|
const sticker = new GuildSticker(this.client, { ...data, guild_id: this.id }, this.id);
|
|
2699
2805
|
this.stickers.set(sticker.id, sticker);
|
|
2700
2806
|
return sticker;
|
|
@@ -2702,7 +2808,7 @@ var Guild = class extends Base {
|
|
|
2702
2808
|
};
|
|
2703
2809
|
|
|
2704
2810
|
// src/client/GuildManager.ts
|
|
2705
|
-
var GuildManager = class extends
|
|
2811
|
+
var GuildManager = class extends import_collection9.Collection {
|
|
2706
2812
|
constructor(client) {
|
|
2707
2813
|
super();
|
|
2708
2814
|
this.client = client;
|
|
@@ -2734,7 +2840,7 @@ var GuildManager = class extends import_collection8.Collection {
|
|
|
2734
2840
|
* @returns The created guild
|
|
2735
2841
|
*/
|
|
2736
2842
|
async create(options) {
|
|
2737
|
-
const data = await this.client.rest.post(
|
|
2843
|
+
const data = await this.client.rest.post(import_types17.Routes.guilds(), {
|
|
2738
2844
|
body: options,
|
|
2739
2845
|
auth: true
|
|
2740
2846
|
});
|
|
@@ -2754,7 +2860,7 @@ var GuildManager = class extends import_collection8.Collection {
|
|
|
2754
2860
|
const cached = this.get(guildId);
|
|
2755
2861
|
if (cached) return cached;
|
|
2756
2862
|
try {
|
|
2757
|
-
const data = await this.client.rest.get(
|
|
2863
|
+
const data = await this.client.rest.get(import_types17.Routes.guild(guildId));
|
|
2758
2864
|
const guild = new Guild(this.client, data);
|
|
2759
2865
|
this.set(guild.id, guild);
|
|
2760
2866
|
return guild;
|
|
@@ -2765,7 +2871,7 @@ var GuildManager = class extends import_collection8.Collection {
|
|
|
2765
2871
|
};
|
|
2766
2872
|
|
|
2767
2873
|
// src/structures/User.ts
|
|
2768
|
-
var
|
|
2874
|
+
var import_types18 = require("@fluxerjs/types");
|
|
2769
2875
|
var User = class extends Base {
|
|
2770
2876
|
client;
|
|
2771
2877
|
id;
|
|
@@ -2841,7 +2947,7 @@ var User = class extends Base {
|
|
|
2841
2947
|
* Returns the DM channel; use {@link DMChannel.send} to send messages.
|
|
2842
2948
|
*/
|
|
2843
2949
|
async createDM() {
|
|
2844
|
-
const data = await this.client.rest.post(
|
|
2950
|
+
const data = await this.client.rest.post(import_types18.Routes.userMeChannels(), {
|
|
2845
2951
|
body: { recipient_id: this.id },
|
|
2846
2952
|
auth: true
|
|
2847
2953
|
});
|
|
@@ -2858,7 +2964,7 @@ var User = class extends Base {
|
|
|
2858
2964
|
};
|
|
2859
2965
|
|
|
2860
2966
|
// src/client/ClientUser.ts
|
|
2861
|
-
var
|
|
2967
|
+
var import_types19 = require("@fluxerjs/types");
|
|
2862
2968
|
var ClientUser = class extends User {
|
|
2863
2969
|
constructor(client, data) {
|
|
2864
2970
|
super(client, { ...data });
|
|
@@ -2869,7 +2975,7 @@ var ClientUser = class extends User {
|
|
|
2869
2975
|
*/
|
|
2870
2976
|
async fetchGuilds() {
|
|
2871
2977
|
const data = await this.client.rest.get(
|
|
2872
|
-
|
|
2978
|
+
import_types19.Routes.currentUserGuilds()
|
|
2873
2979
|
);
|
|
2874
2980
|
const list = Array.isArray(data) ? data : data?.guilds ?? [];
|
|
2875
2981
|
const guilds = [];
|
|
@@ -2885,7 +2991,7 @@ var ClientUser = class extends User {
|
|
|
2885
2991
|
* @param guildId - The guild ID to leave
|
|
2886
2992
|
*/
|
|
2887
2993
|
async leaveGuild(guildId) {
|
|
2888
|
-
await this.client.rest.delete(
|
|
2994
|
+
await this.client.rest.delete(import_types19.Routes.leaveGuild(guildId), { auth: true });
|
|
2889
2995
|
this.client.guilds.delete(guildId);
|
|
2890
2996
|
}
|
|
2891
2997
|
};
|
|
@@ -2894,9 +3000,9 @@ var ClientUser = class extends User {
|
|
|
2894
3000
|
var import_util10 = require("@fluxerjs/util");
|
|
2895
3001
|
|
|
2896
3002
|
// src/client/UsersManager.ts
|
|
2897
|
-
var
|
|
2898
|
-
var
|
|
2899
|
-
var UsersManager = class extends
|
|
3003
|
+
var import_collection10 = require("@fluxerjs/collection");
|
|
3004
|
+
var import_types20 = require("@fluxerjs/types");
|
|
3005
|
+
var UsersManager = class extends import_collection10.Collection {
|
|
2900
3006
|
constructor(client) {
|
|
2901
3007
|
super();
|
|
2902
3008
|
this.client = client;
|
|
@@ -2921,7 +3027,7 @@ var UsersManager = class extends import_collection9.Collection {
|
|
|
2921
3027
|
* console.log(user.username);
|
|
2922
3028
|
*/
|
|
2923
3029
|
async fetch(userId) {
|
|
2924
|
-
const data = await this.client.rest.get(
|
|
3030
|
+
const data = await this.client.rest.get(import_types20.Routes.user(userId));
|
|
2925
3031
|
return this.client.getOrCreateUser(data);
|
|
2926
3032
|
}
|
|
2927
3033
|
/**
|
|
@@ -2941,10 +3047,10 @@ var UsersManager = class extends import_collection9.Collection {
|
|
|
2941
3047
|
async fetchWithProfile(userId, options) {
|
|
2942
3048
|
const guildId = options?.guildId ?? void 0;
|
|
2943
3049
|
const [userData, globalProfileData, serverProfileData, memberData] = await Promise.all([
|
|
2944
|
-
this.client.rest.get(
|
|
2945
|
-
this.client.rest.get(
|
|
2946
|
-
guildId ? this.client.rest.get(
|
|
2947
|
-
guildId ? this.client.rest.get(
|
|
3050
|
+
this.client.rest.get(import_types20.Routes.user(userId)),
|
|
3051
|
+
this.client.rest.get(import_types20.Routes.userProfile(userId)).catch(() => null),
|
|
3052
|
+
guildId ? this.client.rest.get(import_types20.Routes.userProfile(userId, guildId)).catch(() => null) : Promise.resolve(null),
|
|
3053
|
+
guildId ? this.client.rest.get(import_types20.Routes.guildMember(guildId, userId)).catch(() => null) : Promise.resolve(null)
|
|
2948
3054
|
]);
|
|
2949
3055
|
const user = this.client.getOrCreateUser(userData);
|
|
2950
3056
|
const globalProfile = globalProfileData && typeof globalProfileData === "object" ? globalProfileData : null;
|
|
@@ -3134,7 +3240,7 @@ function normalizeGuildPayload(raw) {
|
|
|
3134
3240
|
}
|
|
3135
3241
|
|
|
3136
3242
|
// src/structures/MessageReaction.ts
|
|
3137
|
-
var
|
|
3243
|
+
var import_types21 = require("@fluxerjs/types");
|
|
3138
3244
|
var import_rest4 = require("@fluxerjs/rest");
|
|
3139
3245
|
var MessageReaction = class extends Base {
|
|
3140
3246
|
client;
|
|
@@ -3169,7 +3275,7 @@ var MessageReaction = class extends Base {
|
|
|
3169
3275
|
async fetchMessage() {
|
|
3170
3276
|
try {
|
|
3171
3277
|
const data = await this.client.rest.get(
|
|
3172
|
-
|
|
3278
|
+
import_types21.Routes.channelMessage(this.channelId, this.messageId)
|
|
3173
3279
|
);
|
|
3174
3280
|
return new Message(this.client, data);
|
|
3175
3281
|
} catch (err) {
|
|
@@ -3664,7 +3770,7 @@ var Client = class extends import_events3.EventEmitter {
|
|
|
3664
3770
|
const unicodeFromShortcode = (0, import_util10.getUnicodeFromShortcode)(parsed.name);
|
|
3665
3771
|
if (unicodeFromShortcode) return unicodeFromShortcode;
|
|
3666
3772
|
if (guildId) {
|
|
3667
|
-
const emojis = await this.rest.get(
|
|
3773
|
+
const emojis = await this.rest.get(import_types22.Routes.guildEmojis(guildId));
|
|
3668
3774
|
const list = Array.isArray(emojis) ? emojis : Object.values(emojis ?? {});
|
|
3669
3775
|
const found = list.find((e) => e.name && e.name.toLowerCase() === parsed.name.toLowerCase());
|
|
3670
3776
|
if (found) return (0, import_util10.formatEmoji)({ ...parsed, id: found.id, animated: found.animated });
|
|
@@ -3687,7 +3793,7 @@ var Client = class extends import_events3.EventEmitter {
|
|
|
3687
3793
|
* @throws FluxerError with EMOJI_NOT_IN_GUILD if the emoji is not in the guild
|
|
3688
3794
|
*/
|
|
3689
3795
|
async assertEmojiInGuild(emojiId, guildId) {
|
|
3690
|
-
const emojis = await this.rest.get(
|
|
3796
|
+
const emojis = await this.rest.get(import_types22.Routes.guildEmojis(guildId));
|
|
3691
3797
|
const list = Array.isArray(emojis) ? emojis : Object.values(emojis ?? {});
|
|
3692
3798
|
const found = list.some((e) => e.id === emojiId);
|
|
3693
3799
|
if (!found) {
|
|
@@ -3701,21 +3807,21 @@ var Client = class extends import_events3.EventEmitter {
|
|
|
3701
3807
|
* Does not require authentication.
|
|
3702
3808
|
*/
|
|
3703
3809
|
async fetchInstance() {
|
|
3704
|
-
return this.rest.get(
|
|
3810
|
+
return this.rest.get(import_types22.Routes.instance(), { auth: false });
|
|
3705
3811
|
}
|
|
3706
3812
|
/**
|
|
3707
3813
|
* Fetch instance discovery document (API URL, gateway URL, features). GET /.well-known/fluxer.
|
|
3708
3814
|
* Does not require authentication.
|
|
3709
3815
|
*/
|
|
3710
3816
|
async fetchInstanceDiscovery() {
|
|
3711
|
-
return this.rest.get(
|
|
3817
|
+
return this.rest.get(import_types22.Routes.instanceDiscovery(), { auth: false });
|
|
3712
3818
|
}
|
|
3713
3819
|
/**
|
|
3714
3820
|
* Fetch gateway connection metadata (WebSocket URL, recommended shards, session limits).
|
|
3715
3821
|
* GET /gateway/bot (authenticated).
|
|
3716
3822
|
*/
|
|
3717
3823
|
async fetchGatewayInfo() {
|
|
3718
|
-
return this.rest.get(
|
|
3824
|
+
return this.rest.get(import_types22.Routes.gatewayBot());
|
|
3719
3825
|
}
|
|
3720
3826
|
/**
|
|
3721
3827
|
* Fetch a message by channel and message ID. Use when you have IDs (e.g. from a DB).
|
|
@@ -4023,17 +4129,18 @@ var Client = class extends import_events3.EventEmitter {
|
|
|
4023
4129
|
}
|
|
4024
4130
|
}
|
|
4025
4131
|
static get Routes() {
|
|
4026
|
-
return
|
|
4132
|
+
return import_types22.Routes;
|
|
4027
4133
|
}
|
|
4028
4134
|
};
|
|
4029
4135
|
|
|
4030
4136
|
// src/index.ts
|
|
4031
4137
|
var import_builders4 = require("@fluxerjs/builders");
|
|
4032
|
-
var
|
|
4138
|
+
var import_types23 = require("@fluxerjs/types");
|
|
4033
4139
|
var import_util11 = require("@fluxerjs/util");
|
|
4034
4140
|
var import_util12 = require("@fluxerjs/util");
|
|
4035
4141
|
// Annotate the CommonJS export names for ESM import in node:
|
|
4036
4142
|
0 && (module.exports = {
|
|
4143
|
+
AllowedMentions,
|
|
4037
4144
|
AttachmentBuilder,
|
|
4038
4145
|
Base,
|
|
4039
4146
|
BaseInteraction,
|
|
@@ -4063,6 +4170,7 @@ var import_util12 = require("@fluxerjs/util");
|
|
|
4063
4170
|
Message,
|
|
4064
4171
|
MessageAttachmentFlags,
|
|
4065
4172
|
MessageCollector,
|
|
4173
|
+
MessageFlags,
|
|
4066
4174
|
MessageManager,
|
|
4067
4175
|
MessagePayload,
|
|
4068
4176
|
MessageReaction,
|