@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/client.js
CHANGED
|
@@ -29,11 +29,11 @@ module.exports = __toCommonJS(subpath_client_exports);
|
|
|
29
29
|
var import_events3 = require("events");
|
|
30
30
|
var import_rest5 = require("@fluxerjs/rest");
|
|
31
31
|
var import_ws = require("@fluxerjs/ws");
|
|
32
|
-
var
|
|
32
|
+
var import_types22 = require("@fluxerjs/types");
|
|
33
33
|
|
|
34
34
|
// src/client/ChannelManager.ts
|
|
35
|
-
var
|
|
36
|
-
var
|
|
35
|
+
var import_collection5 = require("@fluxerjs/collection");
|
|
36
|
+
var import_types7 = require("@fluxerjs/types");
|
|
37
37
|
var import_util5 = require("@fluxerjs/util");
|
|
38
38
|
var import_rest2 = require("@fluxerjs/rest");
|
|
39
39
|
|
|
@@ -44,12 +44,14 @@ var import_util = require("@fluxerjs/util");
|
|
|
44
44
|
var import_util2 = require("@fluxerjs/util");
|
|
45
45
|
|
|
46
46
|
// src/util/messageUtils.ts
|
|
47
|
+
var import_types = require("@fluxerjs/types");
|
|
47
48
|
var import_builders = require("@fluxerjs/builders");
|
|
48
49
|
var FILE_FETCH_TIMEOUT_MS = 3e4;
|
|
49
50
|
async function resolveMessageFiles(files) {
|
|
50
51
|
const result = [];
|
|
51
52
|
for (let i = 0; i < files.length; i++) {
|
|
52
53
|
const f = files[i];
|
|
54
|
+
if (!f) continue;
|
|
53
55
|
const filename = f.filename ?? f.name;
|
|
54
56
|
if ("url" in f && f.url) {
|
|
55
57
|
if (!URL.canParse(f.url)) {
|
|
@@ -88,6 +90,21 @@ async function resolveMessageFiles(files) {
|
|
|
88
90
|
}
|
|
89
91
|
return result;
|
|
90
92
|
}
|
|
93
|
+
function toAPIAllowedMentions(options) {
|
|
94
|
+
const result = {};
|
|
95
|
+
if (options.parse?.length) result.parse = options.parse;
|
|
96
|
+
if (options.users?.length) result.users = options.users;
|
|
97
|
+
if (options.roles?.length) result.roles = options.roles;
|
|
98
|
+
if (options.repliedUser !== void 0) result.replied_user = options.repliedUser;
|
|
99
|
+
return result;
|
|
100
|
+
}
|
|
101
|
+
function applyReplyPingSuppression(body) {
|
|
102
|
+
body.flags = (body.flags ?? 0) | import_types.MessageFlags.SuppressNotifications;
|
|
103
|
+
body.allowed_mentions = {
|
|
104
|
+
...body.allowed_mentions ?? {},
|
|
105
|
+
replied_user: false
|
|
106
|
+
};
|
|
107
|
+
}
|
|
91
108
|
function buildSendBody(options) {
|
|
92
109
|
const body = typeof options === "string" ? { content: options } : options;
|
|
93
110
|
const result = {};
|
|
@@ -109,12 +126,43 @@ function buildSendBody(options) {
|
|
|
109
126
|
filename: f.filename ?? f.name
|
|
110
127
|
}));
|
|
111
128
|
}
|
|
129
|
+
if (body.allowedMentions) result.allowed_mentions = toAPIAllowedMentions(body.allowedMentions);
|
|
130
|
+
if (body.stickerIds?.length) result.sticker_ids = body.stickerIds;
|
|
131
|
+
if (body.nonce !== void 0) result.nonce = body.nonce;
|
|
132
|
+
if (body.favoriteMemeId !== void 0) result.favorite_meme_id = body.favoriteMemeId;
|
|
133
|
+
if (body.tts !== void 0) result.tts = body.tts;
|
|
112
134
|
if (body.flags !== void 0) result.flags = body.flags;
|
|
113
135
|
return result;
|
|
114
136
|
}
|
|
137
|
+
function toMessageReference(target) {
|
|
138
|
+
const ref = {
|
|
139
|
+
channel_id: target.channelId,
|
|
140
|
+
message_id: target.messageId
|
|
141
|
+
};
|
|
142
|
+
if (target.guildId != null && target.guildId !== "") ref.guild_id = target.guildId;
|
|
143
|
+
return ref;
|
|
144
|
+
}
|
|
145
|
+
async function prepareMessagePostPayload(options) {
|
|
146
|
+
if (typeof options === "string") {
|
|
147
|
+
if (options.length === 0) throw new RangeError("Cannot send an empty message");
|
|
148
|
+
options = { content: options };
|
|
149
|
+
}
|
|
150
|
+
const { replyTo, ping, files, allowedMentions, ...sendFields } = options;
|
|
151
|
+
const body = buildSendBody({ ...sendFields, files, allowedMentions });
|
|
152
|
+
if (replyTo) {
|
|
153
|
+
body.message_reference = toMessageReference(replyTo);
|
|
154
|
+
const suppressPing = ping === false || allowedMentions?.repliedUser === false || body.allowed_mentions?.replied_user === false;
|
|
155
|
+
if (suppressPing) applyReplyPingSuppression(body);
|
|
156
|
+
} else if (allowedMentions?.repliedUser === false) {
|
|
157
|
+
applyReplyPingSuppression(body);
|
|
158
|
+
}
|
|
159
|
+
const resolvedFiles = files?.length ? await resolveMessageFiles(files) : void 0;
|
|
160
|
+
return { body, files: resolvedFiles };
|
|
161
|
+
}
|
|
115
162
|
|
|
116
163
|
// src/client/MessageManager.ts
|
|
117
|
-
var
|
|
164
|
+
var import_types3 = require("@fluxerjs/types");
|
|
165
|
+
var import_collection3 = require("@fluxerjs/collection");
|
|
118
166
|
var import_rest = require("@fluxerjs/rest");
|
|
119
167
|
|
|
120
168
|
// src/structures/Base.ts
|
|
@@ -123,7 +171,7 @@ var Base = class {
|
|
|
123
171
|
|
|
124
172
|
// src/structures/Message.ts
|
|
125
173
|
var import_collection2 = require("@fluxerjs/collection");
|
|
126
|
-
var
|
|
174
|
+
var import_types2 = require("@fluxerjs/types");
|
|
127
175
|
var import_builders2 = require("@fluxerjs/builders");
|
|
128
176
|
|
|
129
177
|
// src/util/ReactionCollector.ts
|
|
@@ -302,7 +350,7 @@ var Message = class _Message extends Base {
|
|
|
302
350
|
this.pinned = data.pinned;
|
|
303
351
|
this.attachments = new import_collection2.Collection();
|
|
304
352
|
for (const a of data.attachments ?? []) this.attachments.set(a.id, a);
|
|
305
|
-
this.type = data.type ??
|
|
353
|
+
this.type = data.type ?? import_types2.MessageType.Default;
|
|
306
354
|
this.flags = data.flags ?? 0;
|
|
307
355
|
this.mentionEveryone = data.mention_everyone ?? false;
|
|
308
356
|
this.tts = data.tts ?? false;
|
|
@@ -327,7 +375,7 @@ var Message = class _Message extends Base {
|
|
|
327
375
|
* await message.send({ content: 'File', files: [{ name: 'data.txt', data }] });
|
|
328
376
|
*/
|
|
329
377
|
async send(options) {
|
|
330
|
-
const payload = await
|
|
378
|
+
const payload = await prepareMessagePostPayload(options);
|
|
331
379
|
return this._send(payload);
|
|
332
380
|
}
|
|
333
381
|
/**
|
|
@@ -348,46 +396,57 @@ var Message = class _Message extends Base {
|
|
|
348
396
|
* await message.reply('Pong!');
|
|
349
397
|
* await message.reply({ embeds: [embed] });
|
|
350
398
|
* await message.reply('No ping!', { ping: false });
|
|
399
|
+
* await message.reply({ content: 'Silent reply', allowedMentions: AllowedMentions.suppressReplyPing });
|
|
351
400
|
* await message.reply({ content: 'Reply to other', replyTo: otherMessage });
|
|
352
401
|
*/
|
|
353
402
|
async reply(options, replyOptions) {
|
|
354
403
|
const opts = typeof options === "string" ? { content: options } : options;
|
|
355
404
|
const mergedReply = replyOptions ?? (opts.ping !== void 0 || opts.replyTo !== void 0) ? { ping: opts.ping, replyTo: opts.replyTo } : void 0;
|
|
356
405
|
const refMessage = mergedReply?.replyTo ?? this;
|
|
357
|
-
const
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
} :
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
406
|
+
const replyTo = refMessage instanceof _Message ? {
|
|
407
|
+
channelId: refMessage.channelId,
|
|
408
|
+
messageId: refMessage.id,
|
|
409
|
+
guildId: refMessage.guildId
|
|
410
|
+
} : refMessage;
|
|
411
|
+
const { replyTo: _ignored, ping: _ping, ...sendOpts } = opts;
|
|
412
|
+
const payload = await prepareMessagePostPayload({
|
|
413
|
+
...sendOpts,
|
|
414
|
+
replyTo,
|
|
415
|
+
ping: mergedReply?.ping
|
|
416
|
+
});
|
|
367
417
|
return this._send(payload);
|
|
368
418
|
}
|
|
369
|
-
/** Exposed for testing
|
|
419
|
+
/** Exposed for testing — prefer `message.reply()` / `prepareMessagePostPayload()`. */
|
|
370
420
|
static async _createMessageBody(content, referenced_message, ping) {
|
|
421
|
+
if (typeof content === "string" && content.length === 0) {
|
|
422
|
+
throw new RangeError("Cannot send an empty message");
|
|
423
|
+
}
|
|
371
424
|
if (typeof content === "string") {
|
|
372
|
-
|
|
373
|
-
|
|
425
|
+
const opts2 = { content };
|
|
426
|
+
if (referenced_message) {
|
|
427
|
+
opts2.replyTo = {
|
|
428
|
+
channelId: referenced_message.channel_id,
|
|
429
|
+
messageId: referenced_message.message_id,
|
|
430
|
+
...referenced_message.guild_id != null ? { guildId: referenced_message.guild_id } : {}
|
|
431
|
+
};
|
|
432
|
+
if (ping !== void 0) opts2.ping = ping;
|
|
374
433
|
}
|
|
375
|
-
|
|
434
|
+
return prepareMessagePostPayload(opts2);
|
|
376
435
|
}
|
|
377
|
-
const
|
|
378
|
-
const files = content.files?.length ? await resolveMessageFiles(content.files) : void 0;
|
|
379
|
-
const body = { ...base };
|
|
436
|
+
const opts = { ...content };
|
|
380
437
|
if (referenced_message) {
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
438
|
+
opts.replyTo = {
|
|
439
|
+
channelId: referenced_message.channel_id,
|
|
440
|
+
messageId: referenced_message.message_id,
|
|
441
|
+
...referenced_message.guild_id != null ? { guildId: referenced_message.guild_id } : {}
|
|
442
|
+
};
|
|
443
|
+
if (ping !== void 0) opts.ping = ping;
|
|
385
444
|
}
|
|
386
|
-
return
|
|
445
|
+
return prepareMessagePostPayload(opts);
|
|
387
446
|
}
|
|
388
447
|
async _send(payload) {
|
|
389
448
|
const data = await this.client.rest.post(
|
|
390
|
-
|
|
449
|
+
import_types2.Routes.channelMessages(this.channelId),
|
|
391
450
|
payload
|
|
392
451
|
);
|
|
393
452
|
this.client._addMessageToCache(this.channelId, data);
|
|
@@ -403,7 +462,10 @@ var Message = class _Message extends Base {
|
|
|
403
462
|
if (options.embeds?.length) {
|
|
404
463
|
body.embeds = options.embeds.map((e) => e instanceof import_builders2.EmbedBuilder ? e.toJSON() : e);
|
|
405
464
|
}
|
|
406
|
-
|
|
465
|
+
if (options.allowedMentions) {
|
|
466
|
+
body.allowed_mentions = toAPIAllowedMentions(options.allowedMentions);
|
|
467
|
+
}
|
|
468
|
+
const data = await this.client.rest.patch(import_types2.Routes.channelMessage(this.channelId, this.id), {
|
|
407
469
|
body
|
|
408
470
|
});
|
|
409
471
|
return new _Message(this.client, data);
|
|
@@ -434,7 +496,7 @@ var Message = class _Message extends Base {
|
|
|
434
496
|
}
|
|
435
497
|
/** Delete this message. */
|
|
436
498
|
async delete() {
|
|
437
|
-
await this.client.rest.delete(
|
|
499
|
+
await this.client.rest.delete(import_types2.Routes.channelMessage(this.channelId, this.id));
|
|
438
500
|
}
|
|
439
501
|
/**
|
|
440
502
|
* Delete a specific attachment from this message.
|
|
@@ -442,19 +504,19 @@ var Message = class _Message extends Base {
|
|
|
442
504
|
*/
|
|
443
505
|
async deleteAttachment(attachmentId) {
|
|
444
506
|
await this.client.rest.delete(
|
|
445
|
-
|
|
507
|
+
import_types2.Routes.channelMessageAttachment(this.channelId, this.id, attachmentId),
|
|
446
508
|
{ auth: true }
|
|
447
509
|
);
|
|
448
510
|
this.attachments.delete(attachmentId);
|
|
449
511
|
}
|
|
450
512
|
/** Pin this message to the channel. Requires Manage Messages permission. */
|
|
451
513
|
async pin() {
|
|
452
|
-
await this.client.rest.put(
|
|
514
|
+
await this.client.rest.put(import_types2.Routes.channelPinMessage(this.channelId, this.id));
|
|
453
515
|
this.pinned = true;
|
|
454
516
|
}
|
|
455
517
|
/** Unpin this message from the channel. Requires Manage Messages permission. */
|
|
456
518
|
async unpin() {
|
|
457
|
-
await this.client.rest.delete(
|
|
519
|
+
await this.client.rest.delete(import_types2.Routes.channelPinMessage(this.channelId, this.id));
|
|
458
520
|
this.pinned = false;
|
|
459
521
|
}
|
|
460
522
|
/**
|
|
@@ -474,7 +536,7 @@ var Message = class _Message extends Base {
|
|
|
474
536
|
*/
|
|
475
537
|
async react(emoji) {
|
|
476
538
|
const emojiStr = await this.resolveEmojiForReaction(emoji);
|
|
477
|
-
const route = `${
|
|
539
|
+
const route = `${import_types2.Routes.channelMessageReaction(this.channelId, this.id, emojiStr)}/@me`;
|
|
478
540
|
await this.client.rest.put(route);
|
|
479
541
|
}
|
|
480
542
|
/**
|
|
@@ -484,7 +546,7 @@ var Message = class _Message extends Base {
|
|
|
484
546
|
*/
|
|
485
547
|
async removeReaction(emoji, userId) {
|
|
486
548
|
const emojiStr = await this.resolveEmojiForReaction(emoji);
|
|
487
|
-
const route = `${
|
|
549
|
+
const route = `${import_types2.Routes.channelMessageReaction(this.channelId, this.id, emojiStr)}/${userId ?? "@me"}`;
|
|
488
550
|
await this.client.rest.delete(route);
|
|
489
551
|
}
|
|
490
552
|
/**
|
|
@@ -492,7 +554,7 @@ var Message = class _Message extends Base {
|
|
|
492
554
|
* Requires moderator permissions.
|
|
493
555
|
*/
|
|
494
556
|
async removeAllReactions() {
|
|
495
|
-
await this.client.rest.delete(
|
|
557
|
+
await this.client.rest.delete(import_types2.Routes.channelMessageReactions(this.channelId, this.id));
|
|
496
558
|
}
|
|
497
559
|
/**
|
|
498
560
|
* Remove all reactions of a specific emoji from this message.
|
|
@@ -500,7 +562,7 @@ var Message = class _Message extends Base {
|
|
|
500
562
|
*/
|
|
501
563
|
async removeReactionEmoji(emoji) {
|
|
502
564
|
const emojiStr = await this.resolveEmojiForReaction(emoji);
|
|
503
|
-
await this.client.rest.delete(
|
|
565
|
+
await this.client.rest.delete(import_types2.Routes.channelMessageReaction(this.channelId, this.id, emojiStr));
|
|
504
566
|
}
|
|
505
567
|
/**
|
|
506
568
|
* Fetch users who reacted with the given emoji.
|
|
@@ -514,7 +576,7 @@ var Message = class _Message extends Base {
|
|
|
514
576
|
if (options?.limit != null) params.set("limit", String(options.limit));
|
|
515
577
|
if (options?.after) params.set("after", options.after);
|
|
516
578
|
const qs = params.toString();
|
|
517
|
-
const route =
|
|
579
|
+
const route = import_types2.Routes.channelMessageReaction(this.channelId, this.id, emojiStr) + (qs ? `?${qs}` : "");
|
|
518
580
|
const data = await this.client.rest.get(route);
|
|
519
581
|
const list = Array.isArray(data) ? data : data?.users ?? [];
|
|
520
582
|
return list.map((u) => this.client.getOrCreateUser(u));
|
|
@@ -536,17 +598,16 @@ var MessageManager = class {
|
|
|
536
598
|
const data = this.client._getMessageCache(this.channelId)?.get(messageId);
|
|
537
599
|
return data ? new Message(this.client, data) : void 0;
|
|
538
600
|
}
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
async fetch(messageId) {
|
|
601
|
+
async fetch(messageIdOrOptions) {
|
|
602
|
+
if (typeof messageIdOrOptions === "string") {
|
|
603
|
+
return this.fetchOne(messageIdOrOptions);
|
|
604
|
+
}
|
|
605
|
+
return this.fetchMany(messageIdOrOptions);
|
|
606
|
+
}
|
|
607
|
+
async fetchOne(messageId) {
|
|
547
608
|
try {
|
|
548
609
|
const data = await this.client.rest.get(
|
|
549
|
-
|
|
610
|
+
import_types3.Routes.channelMessage(this.channelId, messageId)
|
|
550
611
|
);
|
|
551
612
|
this.client._addMessageToCache(this.channelId, data);
|
|
552
613
|
return new Message(this.client, data);
|
|
@@ -561,16 +622,37 @@ var MessageManager = class {
|
|
|
561
622
|
throw err instanceof import_util.FluxerError ? err : new import_util.FluxerError(String(err), { cause: err });
|
|
562
623
|
}
|
|
563
624
|
}
|
|
625
|
+
async fetchMany(options) {
|
|
626
|
+
const params = new URLSearchParams();
|
|
627
|
+
if (options.limit != null) {
|
|
628
|
+
if (options.limit < 1 || options.limit > 100) {
|
|
629
|
+
throw new RangeError("limit must be between 1 and 100");
|
|
630
|
+
}
|
|
631
|
+
params.set("limit", String(options.limit));
|
|
632
|
+
}
|
|
633
|
+
if (options.before) params.set("before", options.before);
|
|
634
|
+
if (options.after) params.set("after", options.after);
|
|
635
|
+
if (options.around) params.set("around", options.around);
|
|
636
|
+
const qs = params.toString();
|
|
637
|
+
const route = import_types3.Routes.channelMessages(this.channelId) + (qs ? `?${qs}` : "");
|
|
638
|
+
const data = await this.client.rest.get(route);
|
|
639
|
+
const collection = new import_collection3.Collection();
|
|
640
|
+
for (const msg of data) {
|
|
641
|
+
this.client._addMessageToCache(this.channelId, msg);
|
|
642
|
+
collection.set(msg.id, new Message(this.client, msg));
|
|
643
|
+
}
|
|
644
|
+
return collection;
|
|
645
|
+
}
|
|
564
646
|
};
|
|
565
647
|
|
|
566
648
|
// src/util/MessageCollector.ts
|
|
567
649
|
var import_events2 = require("events");
|
|
568
|
-
var
|
|
650
|
+
var import_collection4 = require("@fluxerjs/collection");
|
|
569
651
|
var MessageCollector = class extends import_events2.EventEmitter {
|
|
570
652
|
client;
|
|
571
653
|
channelId;
|
|
572
654
|
options;
|
|
573
|
-
collected = new
|
|
655
|
+
collected = new import_collection4.Collection();
|
|
574
656
|
_timeout = null;
|
|
575
657
|
_ended = false;
|
|
576
658
|
_listener;
|
|
@@ -616,12 +698,12 @@ var MessageCollector = class extends import_events2.EventEmitter {
|
|
|
616
698
|
};
|
|
617
699
|
|
|
618
700
|
// src/structures/Channel.ts
|
|
619
|
-
var
|
|
701
|
+
var import_types6 = require("@fluxerjs/types");
|
|
620
702
|
var import_util3 = require("@fluxerjs/util");
|
|
621
703
|
var import_util4 = require("@fluxerjs/util");
|
|
622
704
|
|
|
623
705
|
// src/structures/Webhook.ts
|
|
624
|
-
var
|
|
706
|
+
var import_types4 = require("@fluxerjs/types");
|
|
625
707
|
var import_builders3 = require("@fluxerjs/builders");
|
|
626
708
|
|
|
627
709
|
// src/util/Constants.ts
|
|
@@ -693,7 +775,7 @@ var Webhook = class _Webhook extends Base {
|
|
|
693
775
|
}
|
|
694
776
|
/** Delete this webhook. Requires bot token with Manage Webhooks permission. */
|
|
695
777
|
async delete() {
|
|
696
|
-
await this.client.rest.delete(
|
|
778
|
+
await this.client.rest.delete(import_types4.Routes.webhook(this.id), { auth: true });
|
|
697
779
|
}
|
|
698
780
|
/**
|
|
699
781
|
* Edit this webhook. With token: name and avatar only. Without token (bot auth): name, avatar, and channel_id.
|
|
@@ -708,7 +790,7 @@ var Webhook = class _Webhook extends Base {
|
|
|
708
790
|
body.channel_id = options.channel_id;
|
|
709
791
|
}
|
|
710
792
|
if (this.token) {
|
|
711
|
-
const data2 = await this.client.rest.patch(
|
|
793
|
+
const data2 = await this.client.rest.patch(import_types4.Routes.webhookExecute(this.id, this.token), {
|
|
712
794
|
body,
|
|
713
795
|
auth: false
|
|
714
796
|
});
|
|
@@ -717,7 +799,7 @@ var Webhook = class _Webhook extends Base {
|
|
|
717
799
|
this.avatar = w2.avatar ?? null;
|
|
718
800
|
return this;
|
|
719
801
|
}
|
|
720
|
-
const data = await this.client.rest.patch(
|
|
802
|
+
const data = await this.client.rest.patch(import_types4.Routes.webhook(this.id), {
|
|
721
803
|
body,
|
|
722
804
|
auth: true
|
|
723
805
|
});
|
|
@@ -749,8 +831,7 @@ var Webhook = class _Webhook extends Base {
|
|
|
749
831
|
const body = buildSendBody(opts);
|
|
750
832
|
if (opts.username !== void 0) body.username = opts.username;
|
|
751
833
|
if (opts.avatar_url !== void 0) body.avatar_url = opts.avatar_url;
|
|
752
|
-
|
|
753
|
-
const route = import_types3.Routes.webhookExecute(this.id, this.token) + (wait ? "?wait=true" : "");
|
|
834
|
+
const route = import_types4.Routes.webhookExecute(this.id, this.token) + (wait ? "?wait=true" : "");
|
|
754
835
|
const files = opts.files?.length ? await resolveMessageFiles(opts.files) : void 0;
|
|
755
836
|
const postOptions = files?.length ? { body, files, auth: false } : { body, auth: false };
|
|
756
837
|
const data = await this.client.rest.post(route, postOptions);
|
|
@@ -775,7 +856,7 @@ var Webhook = class _Webhook extends Base {
|
|
|
775
856
|
body.embeds = options.embeds.map((e) => e instanceof import_builders3.EmbedBuilder ? e.toJSON() : e);
|
|
776
857
|
}
|
|
777
858
|
const data = await this.client.rest.patch(
|
|
778
|
-
|
|
859
|
+
import_types4.Routes.webhookMessage(this.id, this.token, messageId),
|
|
779
860
|
{ body, auth: false }
|
|
780
861
|
);
|
|
781
862
|
return new Message(this.client, data);
|
|
@@ -792,7 +873,7 @@ var Webhook = class _Webhook extends Base {
|
|
|
792
873
|
);
|
|
793
874
|
}
|
|
794
875
|
const data = await this.client.rest.get(
|
|
795
|
-
|
|
876
|
+
import_types4.Routes.webhookMessage(this.id, this.token, messageId),
|
|
796
877
|
{ auth: false }
|
|
797
878
|
);
|
|
798
879
|
return new Message(this.client, data);
|
|
@@ -808,7 +889,7 @@ var Webhook = class _Webhook extends Base {
|
|
|
808
889
|
{ code: import_util2.ErrorCodes.WebhookTokenRequired }
|
|
809
890
|
);
|
|
810
891
|
}
|
|
811
|
-
await this.client.rest.delete(
|
|
892
|
+
await this.client.rest.delete(import_types4.Routes.webhookMessage(this.id, this.token, messageId), {
|
|
812
893
|
auth: false
|
|
813
894
|
});
|
|
814
895
|
}
|
|
@@ -819,7 +900,7 @@ var Webhook = class _Webhook extends Base {
|
|
|
819
900
|
* @returns Webhook without token (cannot send)
|
|
820
901
|
*/
|
|
821
902
|
static async fetch(client, webhookId) {
|
|
822
|
-
const data = await client.rest.get(
|
|
903
|
+
const data = await client.rest.get(import_types4.Routes.webhook(webhookId));
|
|
823
904
|
return new _Webhook(client, data);
|
|
824
905
|
}
|
|
825
906
|
/**
|
|
@@ -843,7 +924,7 @@ var Webhook = class _Webhook extends Base {
|
|
|
843
924
|
};
|
|
844
925
|
|
|
845
926
|
// src/structures/Invite.ts
|
|
846
|
-
var
|
|
927
|
+
var import_types5 = require("@fluxerjs/types");
|
|
847
928
|
var Invite = class _Invite extends Base {
|
|
848
929
|
client;
|
|
849
930
|
code;
|
|
@@ -917,7 +998,7 @@ var Invite = class _Invite extends Base {
|
|
|
917
998
|
*/
|
|
918
999
|
static async fetch(client, codeOrUrl) {
|
|
919
1000
|
const code = _Invite.normalizeCode(codeOrUrl);
|
|
920
|
-
const data = await client.rest.get(
|
|
1001
|
+
const data = await client.rest.get(import_types5.Routes.invite(code));
|
|
921
1002
|
return new _Invite(client, data);
|
|
922
1003
|
}
|
|
923
1004
|
/** Full invite URL (https://fluxer.gg/{code} or instance-specific). */
|
|
@@ -936,7 +1017,7 @@ var Invite = class _Invite extends Base {
|
|
|
936
1017
|
* Requires Manage Guild or Create Instant Invite permission.
|
|
937
1018
|
*/
|
|
938
1019
|
async delete() {
|
|
939
|
-
await this.client.rest.delete(
|
|
1020
|
+
await this.client.rest.delete(import_types5.Routes.invite(this.code), { auth: true });
|
|
940
1021
|
}
|
|
941
1022
|
};
|
|
942
1023
|
|
|
@@ -948,7 +1029,7 @@ var Channel = class _Channel extends Base {
|
|
|
948
1029
|
}
|
|
949
1030
|
/** Whether this channel is a DM or Group DM. */
|
|
950
1031
|
isDM() {
|
|
951
|
-
return this.type ===
|
|
1032
|
+
return this.type === import_types6.ChannelType.DM || this.type === import_types6.ChannelType.GroupDM;
|
|
952
1033
|
}
|
|
953
1034
|
/** Whether this channel is voice-based (VoiceChannel). */
|
|
954
1035
|
isVoice() {
|
|
@@ -987,10 +1068,10 @@ var Channel = class _Channel extends Base {
|
|
|
987
1068
|
*/
|
|
988
1069
|
static from(client, data) {
|
|
989
1070
|
const type = data.type ?? 0;
|
|
990
|
-
if (type ===
|
|
991
|
-
if (type ===
|
|
992
|
-
if (type ===
|
|
993
|
-
if (type ===
|
|
1071
|
+
if (type === import_types6.ChannelType.GuildText) return new TextChannel(client, data);
|
|
1072
|
+
if (type === import_types6.ChannelType.GuildCategory) return new CategoryChannel(client, data);
|
|
1073
|
+
if (type === import_types6.ChannelType.GuildVoice) return new VoiceChannel(client, data);
|
|
1074
|
+
if (type === import_types6.ChannelType.GuildLink || type === import_types6.ChannelType.GuildLinkExtended)
|
|
994
1075
|
return new LinkChannel(client, data);
|
|
995
1076
|
return new GuildChannel(client, data);
|
|
996
1077
|
}
|
|
@@ -1000,7 +1081,7 @@ var Channel = class _Channel extends Base {
|
|
|
1000
1081
|
*/
|
|
1001
1082
|
static fromOrCreate(client, data) {
|
|
1002
1083
|
const type = data.type ?? 0;
|
|
1003
|
-
if (type ===
|
|
1084
|
+
if (type === import_types6.ChannelType.DM || type === import_types6.ChannelType.GroupDM)
|
|
1004
1085
|
return _Channel.createDM(client, data);
|
|
1005
1086
|
return _Channel.from(client, data);
|
|
1006
1087
|
}
|
|
@@ -1009,7 +1090,7 @@ var Channel = class _Channel extends Base {
|
|
|
1009
1090
|
* @param messageIds - Array of message IDs to delete (2–100)
|
|
1010
1091
|
*/
|
|
1011
1092
|
async bulkDeleteMessages(messageIds) {
|
|
1012
|
-
await this.client.rest.post(
|
|
1093
|
+
await this.client.rest.post(import_types6.Routes.channelBulkDelete(this.id), {
|
|
1013
1094
|
body: { message_ids: messageIds },
|
|
1014
1095
|
auth: true
|
|
1015
1096
|
});
|
|
@@ -1018,7 +1099,21 @@ var Channel = class _Channel extends Base {
|
|
|
1018
1099
|
* Send a typing indicator to the channel. Lasts ~10 seconds.
|
|
1019
1100
|
*/
|
|
1020
1101
|
async sendTyping() {
|
|
1021
|
-
await this.client.rest.post(
|
|
1102
|
+
await this.client.rest.post(import_types6.Routes.channelTyping(this.id), { auth: true });
|
|
1103
|
+
}
|
|
1104
|
+
/**
|
|
1105
|
+
* Fetch available RTC regions for voice/video in this channel.
|
|
1106
|
+
* GET /channels/{id}/rtc-regions
|
|
1107
|
+
*/
|
|
1108
|
+
async fetchRtcRegions() {
|
|
1109
|
+
return this.client.rest.get(import_types6.Routes.channelRtcRegions(this.id), { auth: true });
|
|
1110
|
+
}
|
|
1111
|
+
/**
|
|
1112
|
+
* Fetch the current user's slowmode state in this channel.
|
|
1113
|
+
* GET /channels/{id}/slowmode
|
|
1114
|
+
*/
|
|
1115
|
+
async fetchSlowmode() {
|
|
1116
|
+
return this.client.rest.get(import_types6.Routes.channelSlowmode(this.id), { auth: true });
|
|
1022
1117
|
}
|
|
1023
1118
|
/**
|
|
1024
1119
|
* Whether the bot can send messages in this channel.
|
|
@@ -1051,7 +1146,7 @@ var GuildChannel = class extends Channel {
|
|
|
1051
1146
|
* @returns The webhook with token (required for send()). Requires Manage Webhooks permission.
|
|
1052
1147
|
*/
|
|
1053
1148
|
async createWebhook(options) {
|
|
1054
|
-
const data = await this.client.rest.post(
|
|
1149
|
+
const data = await this.client.rest.post(import_types6.Routes.channelWebhooks(this.id), {
|
|
1055
1150
|
body: options,
|
|
1056
1151
|
auth: true
|
|
1057
1152
|
});
|
|
@@ -1062,7 +1157,7 @@ var GuildChannel = class extends Channel {
|
|
|
1062
1157
|
* @returns Webhooks (includes token when listing from channel; can send via send())
|
|
1063
1158
|
*/
|
|
1064
1159
|
async fetchWebhooks() {
|
|
1065
|
-
const data = await this.client.rest.get(
|
|
1160
|
+
const data = await this.client.rest.get(import_types6.Routes.channelWebhooks(this.id));
|
|
1066
1161
|
const list = Array.isArray(data) ? data : Object.values(data ?? {});
|
|
1067
1162
|
return list.map((w) => new Webhook(this.client, w));
|
|
1068
1163
|
}
|
|
@@ -1077,7 +1172,7 @@ var GuildChannel = class extends Channel {
|
|
|
1077
1172
|
if (options?.max_age != null) body.max_age = options.max_age;
|
|
1078
1173
|
if (options?.unique != null) body.unique = options.unique;
|
|
1079
1174
|
if (options?.temporary != null) body.temporary = options.temporary;
|
|
1080
|
-
const data = await this.client.rest.post(
|
|
1175
|
+
const data = await this.client.rest.post(import_types6.Routes.channelInvites(this.id), {
|
|
1081
1176
|
body: Object.keys(body).length ? body : void 0,
|
|
1082
1177
|
auth: true
|
|
1083
1178
|
});
|
|
@@ -1088,7 +1183,7 @@ var GuildChannel = class extends Channel {
|
|
|
1088
1183
|
* Requires Manage Channel permission.
|
|
1089
1184
|
*/
|
|
1090
1185
|
async fetchInvites() {
|
|
1091
|
-
const data = await this.client.rest.get(
|
|
1186
|
+
const data = await this.client.rest.get(import_types6.Routes.channelInvites(this.id));
|
|
1092
1187
|
const list = Array.isArray(data) ? data : Object.values(data ?? {});
|
|
1093
1188
|
return list.map((i) => new Invite(this.client, i));
|
|
1094
1189
|
}
|
|
@@ -1098,7 +1193,7 @@ var GuildChannel = class extends Channel {
|
|
|
1098
1193
|
* @param options - type (0=role, 1=member), allow, deny (permission bitfields)
|
|
1099
1194
|
*/
|
|
1100
1195
|
async editPermission(overwriteId, options) {
|
|
1101
|
-
await this.client.rest.put(
|
|
1196
|
+
await this.client.rest.put(import_types6.Routes.channelPermission(this.id, overwriteId), {
|
|
1102
1197
|
body: options,
|
|
1103
1198
|
auth: true
|
|
1104
1199
|
});
|
|
@@ -1130,11 +1225,8 @@ var GuildChannel = class extends Channel {
|
|
|
1130
1225
|
* Works for text and announcement channels. Voice/category/link channels will fail at the API.
|
|
1131
1226
|
*/
|
|
1132
1227
|
async send(options) {
|
|
1133
|
-
const
|
|
1134
|
-
const
|
|
1135
|
-
const files = opts.files?.length ? await resolveMessageFiles(opts.files) : void 0;
|
|
1136
|
-
const postOptions = files?.length ? { body, files } : { body };
|
|
1137
|
-
const data = await this.client.rest.post(import_types5.Routes.channelMessages(this.id), postOptions);
|
|
1228
|
+
const payload = await prepareMessagePostPayload(options);
|
|
1229
|
+
const data = await this.client.rest.post(import_types6.Routes.channelMessages(this.id), payload);
|
|
1138
1230
|
this.client._addMessageToCache(this.id, data);
|
|
1139
1231
|
return new Message(this.client, data);
|
|
1140
1232
|
}
|
|
@@ -1142,7 +1234,7 @@ var GuildChannel = class extends Channel {
|
|
|
1142
1234
|
* Remove a permission overwrite. DELETE /channels/{id}/permissions/{overwriteId}.
|
|
1143
1235
|
*/
|
|
1144
1236
|
async deletePermission(overwriteId) {
|
|
1145
|
-
await this.client.rest.delete(
|
|
1237
|
+
await this.client.rest.delete(import_types6.Routes.channelPermission(this.id, overwriteId), { auth: true });
|
|
1146
1238
|
const idx = this.permissionOverwrites.findIndex((o) => o.id === overwriteId);
|
|
1147
1239
|
if (idx >= 0) this.permissionOverwrites.splice(idx, 1);
|
|
1148
1240
|
}
|
|
@@ -1151,7 +1243,7 @@ var GuildChannel = class extends Channel {
|
|
|
1151
1243
|
* Requires Manage Channel permission.
|
|
1152
1244
|
*/
|
|
1153
1245
|
async edit(options) {
|
|
1154
|
-
const data = await this.client.rest.patch(
|
|
1246
|
+
const data = await this.client.rest.patch(import_types6.Routes.channel(this.id), {
|
|
1155
1247
|
body: options,
|
|
1156
1248
|
auth: true
|
|
1157
1249
|
});
|
|
@@ -1172,7 +1264,7 @@ var GuildChannel = class extends Channel {
|
|
|
1172
1264
|
* @param options - silent: if true, does not send a system message (default false)
|
|
1173
1265
|
*/
|
|
1174
1266
|
async delete(options) {
|
|
1175
|
-
const url =
|
|
1267
|
+
const url = import_types6.Routes.channel(this.id) + (options?.silent ? "?silent=true" : "");
|
|
1176
1268
|
await this.client.rest.delete(url, { auth: true });
|
|
1177
1269
|
this.client.channels.delete(this.id);
|
|
1178
1270
|
const guild = this.client.guilds.get(this.guildId);
|
|
@@ -1196,11 +1288,8 @@ var TextChannel = class extends GuildChannel {
|
|
|
1196
1288
|
* @param options - Text content or object with content, embeds, and/or files
|
|
1197
1289
|
*/
|
|
1198
1290
|
async send(options) {
|
|
1199
|
-
const
|
|
1200
|
-
const
|
|
1201
|
-
const files = opts.files?.length ? await resolveMessageFiles(opts.files) : void 0;
|
|
1202
|
-
const postOptions = files?.length ? { body, files } : { body };
|
|
1203
|
-
const data = await this.client.rest.post(import_types5.Routes.channelMessages(this.id), postOptions);
|
|
1291
|
+
const payload = await prepareMessagePostPayload(options);
|
|
1292
|
+
const data = await this.client.rest.post(import_types6.Routes.channelMessages(this.id), payload);
|
|
1204
1293
|
this.client._addMessageToCache(this.id, data);
|
|
1205
1294
|
return new Message(this.client, data);
|
|
1206
1295
|
}
|
|
@@ -1225,7 +1314,7 @@ var TextChannel = class extends GuildChannel {
|
|
|
1225
1314
|
* @returns Pinned messages
|
|
1226
1315
|
*/
|
|
1227
1316
|
async fetchPinnedMessages() {
|
|
1228
|
-
const data = await this.client.rest.get(
|
|
1317
|
+
const data = await this.client.rest.get(import_types6.Routes.channelPins(this.id));
|
|
1229
1318
|
const list = Array.isArray(data) ? data : data?.items ?? [];
|
|
1230
1319
|
return list.map((item) => {
|
|
1231
1320
|
const msg = typeof item === "object" && item && "message" in item ? item.message : item;
|
|
@@ -1288,11 +1377,8 @@ var DMChannel = class extends Channel {
|
|
|
1288
1377
|
* @param options - Text content or object with content, embeds, and/or files
|
|
1289
1378
|
*/
|
|
1290
1379
|
async send(options) {
|
|
1291
|
-
const
|
|
1292
|
-
const
|
|
1293
|
-
const files = opts.files?.length ? await resolveMessageFiles(opts.files) : void 0;
|
|
1294
|
-
const postOptions = files?.length ? { body, files } : { body };
|
|
1295
|
-
const data = await this.client.rest.post(import_types5.Routes.channelMessages(this.id), postOptions);
|
|
1380
|
+
const payload = await prepareMessagePostPayload(options);
|
|
1381
|
+
const data = await this.client.rest.post(import_types6.Routes.channelMessages(this.id), payload);
|
|
1296
1382
|
this.client._addMessageToCache(this.id, data);
|
|
1297
1383
|
return new Message(this.client, data);
|
|
1298
1384
|
}
|
|
@@ -1312,7 +1398,7 @@ var DMChannel = class extends Channel {
|
|
|
1312
1398
|
* @returns Pinned messages
|
|
1313
1399
|
*/
|
|
1314
1400
|
async fetchPinnedMessages() {
|
|
1315
|
-
const data = await this.client.rest.get(
|
|
1401
|
+
const data = await this.client.rest.get(import_types6.Routes.channelPins(this.id));
|
|
1316
1402
|
const list = Array.isArray(data) ? data : data?.items ?? [];
|
|
1317
1403
|
return list.map((item) => {
|
|
1318
1404
|
const msg = typeof item === "object" && item && "message" in item ? item.message : item;
|
|
@@ -1337,7 +1423,7 @@ var DMChannel = class extends Channel {
|
|
|
1337
1423
|
* PUT /channels/{id}/recipients/{userId}.
|
|
1338
1424
|
*/
|
|
1339
1425
|
async addRecipient(userId) {
|
|
1340
|
-
await this.client.rest.put(
|
|
1426
|
+
await this.client.rest.put(import_types6.Routes.channelRecipient(this.id, userId), { auth: true });
|
|
1341
1427
|
const user = this.client.users.get(userId) ?? await this.client.users.fetch(userId);
|
|
1342
1428
|
if (user) this.recipients.push(user);
|
|
1343
1429
|
}
|
|
@@ -1347,7 +1433,7 @@ var DMChannel = class extends Channel {
|
|
|
1347
1433
|
* @param options - silent: if true, does not send a system message (default false)
|
|
1348
1434
|
*/
|
|
1349
1435
|
async removeRecipient(userId, options) {
|
|
1350
|
-
const url =
|
|
1436
|
+
const url = import_types6.Routes.channelRecipient(this.id, userId) + (options?.silent ? "?silent=true" : "");
|
|
1351
1437
|
await this.client.rest.delete(url, { auth: true });
|
|
1352
1438
|
const idx = this.recipients.findIndex((u) => u.id === userId);
|
|
1353
1439
|
if (idx >= 0) this.recipients.splice(idx, 1);
|
|
@@ -1355,7 +1441,7 @@ var DMChannel = class extends Channel {
|
|
|
1355
1441
|
};
|
|
1356
1442
|
|
|
1357
1443
|
// src/client/ChannelManager.ts
|
|
1358
|
-
var ChannelManager = class extends
|
|
1444
|
+
var ChannelManager = class extends import_collection5.Collection {
|
|
1359
1445
|
constructor(client) {
|
|
1360
1446
|
super();
|
|
1361
1447
|
this.client = client;
|
|
@@ -1395,7 +1481,7 @@ var ChannelManager = class extends import_collection4.Collection {
|
|
|
1395
1481
|
const cached = this.get(channelId);
|
|
1396
1482
|
if (cached) return cached;
|
|
1397
1483
|
try {
|
|
1398
|
-
const data = await this.client.rest.get(
|
|
1484
|
+
const data = await this.client.rest.get(import_types7.Routes.channel(channelId));
|
|
1399
1485
|
const channel = Channel.fromOrCreate(this.client, data);
|
|
1400
1486
|
if (!channel) {
|
|
1401
1487
|
throw new import_util.FluxerError("Channel data invalid or unsupported type", {
|
|
@@ -1437,7 +1523,7 @@ var ChannelManager = class extends import_collection4.Collection {
|
|
|
1437
1523
|
);
|
|
1438
1524
|
try {
|
|
1439
1525
|
const data = await this.client.rest.get(
|
|
1440
|
-
|
|
1526
|
+
import_types7.Routes.channelMessage(channelId, messageId)
|
|
1441
1527
|
);
|
|
1442
1528
|
return new Message(this.client, data);
|
|
1443
1529
|
} catch (err) {
|
|
@@ -1463,41 +1549,38 @@ var ChannelManager = class extends import_collection4.Collection {
|
|
|
1463
1549
|
* await client.channels.send(channelId, { content: 'Report', files: [{ name: 'log.txt', data }] });
|
|
1464
1550
|
*/
|
|
1465
1551
|
async send(channelId, payload) {
|
|
1466
|
-
const
|
|
1467
|
-
const
|
|
1468
|
-
const files = opts.files?.length ? await resolveMessageFiles(opts.files) : void 0;
|
|
1469
|
-
const postOptions = files?.length ? { body, files } : { body };
|
|
1470
|
-
const data = await this.client.rest.post(import_types6.Routes.channelMessages(channelId), postOptions);
|
|
1552
|
+
const postPayload = await prepareMessagePostPayload(payload);
|
|
1553
|
+
const data = await this.client.rest.post(import_types7.Routes.channelMessages(channelId), postPayload);
|
|
1471
1554
|
this.client._addMessageToCache(channelId, data);
|
|
1472
1555
|
return new Message(this.client, data);
|
|
1473
1556
|
}
|
|
1474
1557
|
};
|
|
1475
1558
|
|
|
1476
1559
|
// src/client/GuildManager.ts
|
|
1477
|
-
var
|
|
1478
|
-
var
|
|
1560
|
+
var import_collection9 = require("@fluxerjs/collection");
|
|
1561
|
+
var import_types17 = require("@fluxerjs/types");
|
|
1479
1562
|
|
|
1480
1563
|
// src/structures/Guild.ts
|
|
1481
1564
|
var import_util9 = require("@fluxerjs/util");
|
|
1482
1565
|
var import_rest3 = require("@fluxerjs/rest");
|
|
1483
|
-
var
|
|
1566
|
+
var import_collection8 = require("@fluxerjs/collection");
|
|
1484
1567
|
|
|
1485
1568
|
// src/client/GuildMemberManager.ts
|
|
1486
|
-
var
|
|
1487
|
-
var
|
|
1569
|
+
var import_collection7 = require("@fluxerjs/collection");
|
|
1570
|
+
var import_types11 = require("@fluxerjs/types");
|
|
1488
1571
|
|
|
1489
1572
|
// src/structures/GuildMember.ts
|
|
1490
1573
|
var import_util7 = require("@fluxerjs/util");
|
|
1491
|
-
var
|
|
1574
|
+
var import_types10 = require("@fluxerjs/types");
|
|
1492
1575
|
|
|
1493
1576
|
// src/util/permissions.ts
|
|
1494
|
-
var
|
|
1577
|
+
var import_types8 = require("@fluxerjs/types");
|
|
1495
1578
|
var import_util6 = require("@fluxerjs/util");
|
|
1496
1579
|
function computePermissions(basePermissions, overwrites, memberRoles, memberId, isOwner) {
|
|
1497
1580
|
if (isOwner) return import_util6.ALL_PERMISSIONS_BIGINT;
|
|
1498
1581
|
let perms = basePermissions;
|
|
1499
1582
|
for (const overwrite of overwrites ?? []) {
|
|
1500
|
-
const applies = overwrite.type ===
|
|
1583
|
+
const applies = overwrite.type === import_types8.OverwriteType.Role && memberRoles.includes(overwrite.id) || overwrite.type === import_types8.OverwriteType.Member && overwrite.id === memberId;
|
|
1501
1584
|
if (!applies) continue;
|
|
1502
1585
|
const allow = BigInt(overwrite.allow || "0");
|
|
1503
1586
|
const deny = BigInt(overwrite.deny || "0");
|
|
@@ -1507,8 +1590,8 @@ function computePermissions(basePermissions, overwrites, memberRoles, memberId,
|
|
|
1507
1590
|
}
|
|
1508
1591
|
|
|
1509
1592
|
// src/structures/GuildMemberRoleManager.ts
|
|
1510
|
-
var
|
|
1511
|
-
var
|
|
1593
|
+
var import_collection6 = require("@fluxerjs/collection");
|
|
1594
|
+
var import_types9 = require("@fluxerjs/types");
|
|
1512
1595
|
var GuildMemberRoleManager = class {
|
|
1513
1596
|
constructor(member, initialRoleIds = []) {
|
|
1514
1597
|
this.member = member;
|
|
@@ -1529,7 +1612,7 @@ var GuildMemberRoleManager = class {
|
|
|
1529
1612
|
* @discordJsCompat https://discord.js.org/docs/packages/discord.js/main/GuildMemberRoleManager
|
|
1530
1613
|
*/
|
|
1531
1614
|
get cache() {
|
|
1532
|
-
const coll = new
|
|
1615
|
+
const coll = new import_collection6.Collection();
|
|
1533
1616
|
for (const id of this._roleIds) {
|
|
1534
1617
|
const role = this.member.guild.roles.get(id);
|
|
1535
1618
|
if (role) coll.set(id, role);
|
|
@@ -1550,7 +1633,7 @@ var GuildMemberRoleManager = class {
|
|
|
1550
1633
|
const roleId = this._resolveId(roleOrId);
|
|
1551
1634
|
if (this._roleIds.includes(roleId)) return;
|
|
1552
1635
|
await this.member.client.rest.put(
|
|
1553
|
-
|
|
1636
|
+
import_types9.Routes.guildMemberRole(this.member.guild.id, this.member.id, roleId)
|
|
1554
1637
|
);
|
|
1555
1638
|
this._roleIds.push(roleId);
|
|
1556
1639
|
}
|
|
@@ -1565,7 +1648,7 @@ var GuildMemberRoleManager = class {
|
|
|
1565
1648
|
const idx = this._roleIds.indexOf(roleId);
|
|
1566
1649
|
if (idx === -1) return;
|
|
1567
1650
|
await this.member.client.rest.delete(
|
|
1568
|
-
|
|
1651
|
+
import_types9.Routes.guildMemberRole(this.member.guild.id, this.member.id, roleId)
|
|
1569
1652
|
);
|
|
1570
1653
|
this._roleIds.splice(idx, 1);
|
|
1571
1654
|
}
|
|
@@ -1577,7 +1660,7 @@ var GuildMemberRoleManager = class {
|
|
|
1577
1660
|
*/
|
|
1578
1661
|
async set(roleIds) {
|
|
1579
1662
|
const data = await this.member.client.rest.patch(
|
|
1580
|
-
|
|
1663
|
+
import_types9.Routes.guildMember(this.member.guild.id, this.member.id),
|
|
1581
1664
|
{ body: { roles: roleIds }, auth: true }
|
|
1582
1665
|
);
|
|
1583
1666
|
this._roleIds = data.roles ? [...data.roles] : [];
|
|
@@ -1680,7 +1763,7 @@ var GuildMember = class extends Base {
|
|
|
1680
1763
|
*/
|
|
1681
1764
|
async edit(options) {
|
|
1682
1765
|
const isMe = this.client.user?.id === this.id;
|
|
1683
|
-
const route = isMe ? `/guilds/${this.guild.id}/members/@me` :
|
|
1766
|
+
const route = isMe ? `/guilds/${this.guild.id}/members/@me` : import_types10.Routes.guildMember(this.guild.id, this.id);
|
|
1684
1767
|
const data = await this.client.rest.patch(route, {
|
|
1685
1768
|
body: options,
|
|
1686
1769
|
auth: true
|
|
@@ -1762,7 +1845,7 @@ var GuildMember = class extends Base {
|
|
|
1762
1845
|
};
|
|
1763
1846
|
|
|
1764
1847
|
// src/client/GuildMemberManager.ts
|
|
1765
|
-
var GuildMemberManager = class extends
|
|
1848
|
+
var GuildMemberManager = class extends import_collection7.Collection {
|
|
1766
1849
|
constructor(guild) {
|
|
1767
1850
|
super();
|
|
1768
1851
|
this.guild = guild;
|
|
@@ -1822,7 +1905,7 @@ var GuildMemberManager = class extends import_collection6.Collection {
|
|
|
1822
1905
|
if (options?.limit != null) params.set("limit", String(options.limit));
|
|
1823
1906
|
if (options?.after) params.set("after", options.after);
|
|
1824
1907
|
const qs = params.toString();
|
|
1825
|
-
const url =
|
|
1908
|
+
const url = import_types11.Routes.guildMembers(this.guild.id) + (qs ? `?${qs}` : "");
|
|
1826
1909
|
const data = await this.guild.client.rest.get(url, { auth: true });
|
|
1827
1910
|
const list = Array.isArray(data) ? data : data?.members ?? [];
|
|
1828
1911
|
const members = [];
|
|
@@ -1837,10 +1920,23 @@ var GuildMemberManager = class extends import_collection6.Collection {
|
|
|
1837
1920
|
}
|
|
1838
1921
|
return members;
|
|
1839
1922
|
}
|
|
1923
|
+
/**
|
|
1924
|
+
* Search guild members. POST /guilds/{id}/members-search.
|
|
1925
|
+
* @param options - Search query, filters, and pagination
|
|
1926
|
+
* @returns Search results with matching members
|
|
1927
|
+
* @example
|
|
1928
|
+
* const { members } = await guild.members.search({ query: 'alex', limit: 25 });
|
|
1929
|
+
*/
|
|
1930
|
+
async search(options) {
|
|
1931
|
+
return this.guild.client.rest.post(import_types11.Routes.guildMembersSearch(this.guild.id), {
|
|
1932
|
+
body: options,
|
|
1933
|
+
auth: true
|
|
1934
|
+
});
|
|
1935
|
+
}
|
|
1840
1936
|
};
|
|
1841
1937
|
|
|
1842
1938
|
// src/structures/Role.ts
|
|
1843
|
-
var
|
|
1939
|
+
var import_types12 = require("@fluxerjs/types");
|
|
1844
1940
|
var import_util8 = require("@fluxerjs/util");
|
|
1845
1941
|
var Role = class extends Base {
|
|
1846
1942
|
client;
|
|
@@ -1913,7 +2009,7 @@ var Role = class extends Base {
|
|
|
1913
2009
|
if (options.unicode_emoji !== void 0) body.unicode_emoji = options.unicode_emoji;
|
|
1914
2010
|
if (options.position !== void 0) body.position = options.position;
|
|
1915
2011
|
if (options.hoist_position !== void 0) body.hoist_position = options.hoist_position;
|
|
1916
|
-
const data = await this.client.rest.patch(
|
|
2012
|
+
const data = await this.client.rest.patch(import_types12.Routes.guildRole(this.guildId, this.id), {
|
|
1917
2013
|
body: Object.keys(body).length ? body : void 0,
|
|
1918
2014
|
auth: true
|
|
1919
2015
|
});
|
|
@@ -1925,17 +2021,17 @@ var Role = class extends Base {
|
|
|
1925
2021
|
* Requires Manage Roles permission.
|
|
1926
2022
|
*/
|
|
1927
2023
|
async delete() {
|
|
1928
|
-
await this.client.rest.delete(
|
|
2024
|
+
await this.client.rest.delete(import_types12.Routes.guildRole(this.guildId, this.id), { auth: true });
|
|
1929
2025
|
const guild = this.client.guilds.get(this.guildId);
|
|
1930
2026
|
if (guild) guild.roles.delete(this.id);
|
|
1931
2027
|
}
|
|
1932
2028
|
};
|
|
1933
2029
|
|
|
1934
2030
|
// src/structures/Guild.ts
|
|
1935
|
-
var
|
|
2031
|
+
var import_types16 = require("@fluxerjs/types");
|
|
1936
2032
|
|
|
1937
2033
|
// src/structures/GuildBan.ts
|
|
1938
|
-
var
|
|
2034
|
+
var import_types13 = require("@fluxerjs/types");
|
|
1939
2035
|
var GuildBan = class extends Base {
|
|
1940
2036
|
client;
|
|
1941
2037
|
guildId;
|
|
@@ -1957,14 +2053,14 @@ var GuildBan = class extends Base {
|
|
|
1957
2053
|
* Requires Ban Members permission.
|
|
1958
2054
|
*/
|
|
1959
2055
|
async unban() {
|
|
1960
|
-
await this.client.rest.delete(
|
|
2056
|
+
await this.client.rest.delete(import_types13.Routes.guildBan(this.guildId, this.user.id), {
|
|
1961
2057
|
auth: true
|
|
1962
2058
|
});
|
|
1963
2059
|
}
|
|
1964
2060
|
};
|
|
1965
2061
|
|
|
1966
2062
|
// src/structures/GuildEmoji.ts
|
|
1967
|
-
var
|
|
2063
|
+
var import_types14 = require("@fluxerjs/types");
|
|
1968
2064
|
var GuildEmoji = class extends Base {
|
|
1969
2065
|
client;
|
|
1970
2066
|
id;
|
|
@@ -1991,7 +2087,7 @@ var GuildEmoji = class extends Base {
|
|
|
1991
2087
|
}
|
|
1992
2088
|
/** Delete this emoji. Requires Manage Emojis and Stickers permission. */
|
|
1993
2089
|
async delete() {
|
|
1994
|
-
await this.client.rest.delete(
|
|
2090
|
+
await this.client.rest.delete(import_types14.Routes.guildEmoji(this.guildId, this.id), {
|
|
1995
2091
|
auth: true
|
|
1996
2092
|
});
|
|
1997
2093
|
const guild = this.client.guilds.get(this.guildId);
|
|
@@ -2002,7 +2098,7 @@ var GuildEmoji = class extends Base {
|
|
|
2002
2098
|
* Requires Manage Emojis and Stickers permission.
|
|
2003
2099
|
*/
|
|
2004
2100
|
async edit(options) {
|
|
2005
|
-
const data = await this.client.rest.patch(
|
|
2101
|
+
const data = await this.client.rest.patch(import_types14.Routes.guildEmoji(this.guildId, this.id), {
|
|
2006
2102
|
body: options,
|
|
2007
2103
|
auth: true
|
|
2008
2104
|
});
|
|
@@ -2012,7 +2108,7 @@ var GuildEmoji = class extends Base {
|
|
|
2012
2108
|
};
|
|
2013
2109
|
|
|
2014
2110
|
// src/structures/GuildSticker.ts
|
|
2015
|
-
var
|
|
2111
|
+
var import_types15 = require("@fluxerjs/types");
|
|
2016
2112
|
var GuildSticker = class extends Base {
|
|
2017
2113
|
client;
|
|
2018
2114
|
id;
|
|
@@ -2039,7 +2135,7 @@ var GuildSticker = class extends Base {
|
|
|
2039
2135
|
}
|
|
2040
2136
|
/** Delete this sticker. Requires Manage Emojis and Stickers permission. */
|
|
2041
2137
|
async delete() {
|
|
2042
|
-
await this.client.rest.delete(
|
|
2138
|
+
await this.client.rest.delete(import_types15.Routes.guildSticker(this.guildId, this.id), {
|
|
2043
2139
|
auth: true
|
|
2044
2140
|
});
|
|
2045
2141
|
}
|
|
@@ -2048,7 +2144,7 @@ var GuildSticker = class extends Base {
|
|
|
2048
2144
|
* Requires Manage Emojis and Stickers permission.
|
|
2049
2145
|
*/
|
|
2050
2146
|
async edit(options) {
|
|
2051
|
-
const data = await this.client.rest.patch(
|
|
2147
|
+
const data = await this.client.rest.patch(import_types15.Routes.guildSticker(this.guildId, this.id), {
|
|
2052
2148
|
body: options,
|
|
2053
2149
|
auth: true
|
|
2054
2150
|
});
|
|
@@ -2095,10 +2191,10 @@ var Guild = class extends Base {
|
|
|
2095
2191
|
/** Splash image height. Optional. */
|
|
2096
2192
|
splashHeight;
|
|
2097
2193
|
members;
|
|
2098
|
-
channels = new
|
|
2099
|
-
roles = new
|
|
2100
|
-
emojis = new
|
|
2101
|
-
stickers = new
|
|
2194
|
+
channels = new import_collection8.Collection();
|
|
2195
|
+
roles = new import_collection8.Collection();
|
|
2196
|
+
emojis = new import_collection8.Collection();
|
|
2197
|
+
stickers = new import_collection8.Collection();
|
|
2102
2198
|
/** @param data - API guild from GET /guilds/{id} or gateway GUILD_CREATE */
|
|
2103
2199
|
constructor(client, data) {
|
|
2104
2200
|
super();
|
|
@@ -2154,7 +2250,7 @@ var Guild = class extends Base {
|
|
|
2154
2250
|
* Requires Manage Roles permission.
|
|
2155
2251
|
*/
|
|
2156
2252
|
async addRoleToMember(userId, roleId) {
|
|
2157
|
-
await this.client.rest.put(
|
|
2253
|
+
await this.client.rest.put(import_types16.Routes.guildMemberRole(this.id, userId, roleId));
|
|
2158
2254
|
}
|
|
2159
2255
|
/**
|
|
2160
2256
|
* Remove a role from a member by user ID. Does not require fetching the member first.
|
|
@@ -2163,7 +2259,7 @@ var Guild = class extends Base {
|
|
|
2163
2259
|
* Requires Manage Roles permission.
|
|
2164
2260
|
*/
|
|
2165
2261
|
async removeRoleFromMember(userId, roleId) {
|
|
2166
|
-
await this.client.rest.delete(
|
|
2262
|
+
await this.client.rest.delete(import_types16.Routes.guildMemberRole(this.id, userId, roleId));
|
|
2167
2263
|
}
|
|
2168
2264
|
/**
|
|
2169
2265
|
* Create a role in this guild.
|
|
@@ -2185,7 +2281,7 @@ var Guild = class extends Base {
|
|
|
2185
2281
|
if (options.unicode_emoji !== void 0) body.unicode_emoji = options.unicode_emoji;
|
|
2186
2282
|
if (options.position !== void 0) body.position = options.position;
|
|
2187
2283
|
if (options.hoist_position !== void 0) body.hoist_position = options.hoist_position;
|
|
2188
|
-
const data = await this.client.rest.post(
|
|
2284
|
+
const data = await this.client.rest.post(import_types16.Routes.guildRoles(this.id), {
|
|
2189
2285
|
body: Object.keys(body).length ? body : void 0,
|
|
2190
2286
|
auth: true
|
|
2191
2287
|
});
|
|
@@ -2199,7 +2295,7 @@ var Guild = class extends Base {
|
|
|
2199
2295
|
*/
|
|
2200
2296
|
async fetchRoles() {
|
|
2201
2297
|
const data = await this.client.rest.get(
|
|
2202
|
-
|
|
2298
|
+
import_types16.Routes.guildRoles(this.id)
|
|
2203
2299
|
);
|
|
2204
2300
|
const list = Array.isArray(data) ? data : Object.values(data ?? {});
|
|
2205
2301
|
const roles = [];
|
|
@@ -2218,7 +2314,7 @@ var Guild = class extends Base {
|
|
|
2218
2314
|
*/
|
|
2219
2315
|
async fetchRole(roleId) {
|
|
2220
2316
|
try {
|
|
2221
|
-
const data = await this.client.rest.get(
|
|
2317
|
+
const data = await this.client.rest.get(import_types16.Routes.guildRole(this.id, roleId));
|
|
2222
2318
|
const role = new Role(this.client, data, this.id);
|
|
2223
2319
|
this.roles.set(role.id, role);
|
|
2224
2320
|
return role;
|
|
@@ -2247,7 +2343,7 @@ var Guild = class extends Base {
|
|
|
2247
2343
|
(r) => !!(r.name && r.name.toLowerCase() === arg.trim().toLowerCase())
|
|
2248
2344
|
);
|
|
2249
2345
|
if (cached) return cached.id;
|
|
2250
|
-
const roles = await this.client.rest.get(
|
|
2346
|
+
const roles = await this.client.rest.get(import_types16.Routes.guildRoles(this.id));
|
|
2251
2347
|
const list = Array.isArray(roles) ? roles : Object.values(roles ?? {});
|
|
2252
2348
|
const role = list.find((r) => !!(r.name && r.name.toLowerCase() === arg.trim().toLowerCase()));
|
|
2253
2349
|
if (role) {
|
|
@@ -2270,7 +2366,7 @@ var Guild = class extends Base {
|
|
|
2270
2366
|
body.delete_message_days = options.delete_message_days;
|
|
2271
2367
|
if (options?.ban_duration_seconds != null)
|
|
2272
2368
|
body.ban_duration_seconds = options.ban_duration_seconds;
|
|
2273
|
-
await this.client.rest.put(
|
|
2369
|
+
await this.client.rest.put(import_types16.Routes.guildBan(this.id, userId), {
|
|
2274
2370
|
body: Object.keys(body).length ? body : void 0,
|
|
2275
2371
|
auth: true
|
|
2276
2372
|
});
|
|
@@ -2281,7 +2377,7 @@ var Guild = class extends Base {
|
|
|
2281
2377
|
*/
|
|
2282
2378
|
async fetchBans() {
|
|
2283
2379
|
const data = await this.client.rest.get(
|
|
2284
|
-
|
|
2380
|
+
import_types16.Routes.guildBans(this.id)
|
|
2285
2381
|
);
|
|
2286
2382
|
const list = Array.isArray(data) ? data : data?.bans ?? [];
|
|
2287
2383
|
return list.map((b) => new GuildBan(this.client, { ...b, guild_id: this.id }, this.id));
|
|
@@ -2292,7 +2388,7 @@ var Guild = class extends Base {
|
|
|
2292
2388
|
* Requires Ban Members permission.
|
|
2293
2389
|
*/
|
|
2294
2390
|
async unban(userId) {
|
|
2295
|
-
await this.client.rest.delete(
|
|
2391
|
+
await this.client.rest.delete(import_types16.Routes.guildBan(this.id, userId), { auth: true });
|
|
2296
2392
|
}
|
|
2297
2393
|
/**
|
|
2298
2394
|
* Kick a member from this guild.
|
|
@@ -2300,7 +2396,7 @@ var Guild = class extends Base {
|
|
|
2300
2396
|
* Requires Kick Members permission.
|
|
2301
2397
|
*/
|
|
2302
2398
|
async kick(userId) {
|
|
2303
|
-
await this.client.rest.delete(
|
|
2399
|
+
await this.client.rest.delete(import_types16.Routes.guildMember(this.id, userId), { auth: true });
|
|
2304
2400
|
}
|
|
2305
2401
|
/**
|
|
2306
2402
|
* Fetch a guild member by user ID.
|
|
@@ -2312,7 +2408,7 @@ var Guild = class extends Base {
|
|
|
2312
2408
|
async fetchMember(userId) {
|
|
2313
2409
|
try {
|
|
2314
2410
|
const data = await this.client.rest.get(
|
|
2315
|
-
|
|
2411
|
+
import_types16.Routes.guildMember(this.id, userId)
|
|
2316
2412
|
);
|
|
2317
2413
|
const member = new GuildMember(this.client, { ...data, guild_id: this.id }, this);
|
|
2318
2414
|
this.members.set(member.id, member);
|
|
@@ -2340,12 +2436,12 @@ var Guild = class extends Base {
|
|
|
2340
2436
|
if (options?.userId) params.set("user_id", options.userId);
|
|
2341
2437
|
if (options?.actionType != null) params.set("action_type", String(options.actionType));
|
|
2342
2438
|
const qs = params.toString();
|
|
2343
|
-
const url =
|
|
2439
|
+
const url = import_types16.Routes.guildAuditLogs(this.id) + (qs ? `?${qs}` : "");
|
|
2344
2440
|
return this.client.rest.get(url);
|
|
2345
2441
|
}
|
|
2346
2442
|
/** Fetch all webhooks in this guild. Returned webhooks do not include the token (cannot send). */
|
|
2347
2443
|
async fetchWebhooks() {
|
|
2348
|
-
const data = await this.client.rest.get(
|
|
2444
|
+
const data = await this.client.rest.get(import_types16.Routes.guildWebhooks(this.id));
|
|
2349
2445
|
const list = Array.isArray(data) ? data : Object.values(data ?? {});
|
|
2350
2446
|
return list.map((w) => new Webhook(this.client, w));
|
|
2351
2447
|
}
|
|
@@ -2355,7 +2451,7 @@ var Guild = class extends Base {
|
|
|
2355
2451
|
*/
|
|
2356
2452
|
async fetchInvites() {
|
|
2357
2453
|
const data = await this.client.rest.get(
|
|
2358
|
-
|
|
2454
|
+
import_types16.Routes.guildInvites(this.id)
|
|
2359
2455
|
);
|
|
2360
2456
|
const list = Array.isArray(data) ? data : Object.values(data ?? {});
|
|
2361
2457
|
return list.map((invite) => new Invite(this.client, invite));
|
|
@@ -2373,7 +2469,7 @@ var Guild = class extends Base {
|
|
|
2373
2469
|
* Requires Manage Channels permission.
|
|
2374
2470
|
*/
|
|
2375
2471
|
async createChannel(data) {
|
|
2376
|
-
const created = await this.client.rest.post(
|
|
2472
|
+
const created = await this.client.rest.post(import_types16.Routes.guildChannels(this.id), {
|
|
2377
2473
|
body: data,
|
|
2378
2474
|
auth: true
|
|
2379
2475
|
});
|
|
@@ -2389,7 +2485,7 @@ var Guild = class extends Base {
|
|
|
2389
2485
|
* @returns Array of GuildChannel objects (cached in guild.channels and client.channels)
|
|
2390
2486
|
*/
|
|
2391
2487
|
async fetchChannels() {
|
|
2392
|
-
const data = await this.client.rest.get(
|
|
2488
|
+
const data = await this.client.rest.get(import_types16.Routes.guildChannels(this.id));
|
|
2393
2489
|
const list = Array.isArray(data) ? data : Object.values(data ?? {});
|
|
2394
2490
|
const channels = [];
|
|
2395
2491
|
for (const ch of list) {
|
|
@@ -2407,7 +2503,7 @@ var Guild = class extends Base {
|
|
|
2407
2503
|
* Requires guild owner or Administrator.
|
|
2408
2504
|
*/
|
|
2409
2505
|
async edit(options) {
|
|
2410
|
-
const data = await this.client.rest.patch(
|
|
2506
|
+
const data = await this.client.rest.patch(import_types16.Routes.guild(this.id), {
|
|
2411
2507
|
body: options,
|
|
2412
2508
|
auth: true
|
|
2413
2509
|
});
|
|
@@ -2430,7 +2526,7 @@ var Guild = class extends Base {
|
|
|
2430
2526
|
* Must be the guild owner.
|
|
2431
2527
|
*/
|
|
2432
2528
|
async delete() {
|
|
2433
|
-
await this.client.rest.post(
|
|
2529
|
+
await this.client.rest.post(import_types16.Routes.guildDelete(this.id), { auth: true });
|
|
2434
2530
|
this.client.guilds.delete(this.id);
|
|
2435
2531
|
}
|
|
2436
2532
|
/**
|
|
@@ -2438,14 +2534,14 @@ var Guild = class extends Base {
|
|
|
2438
2534
|
* Requires Manage Guild permission.
|
|
2439
2535
|
*/
|
|
2440
2536
|
async fetchVanityURL() {
|
|
2441
|
-
return this.client.rest.get(
|
|
2537
|
+
return this.client.rest.get(import_types16.Routes.guildVanityUrl(this.id), { auth: true });
|
|
2442
2538
|
}
|
|
2443
2539
|
/**
|
|
2444
2540
|
* Transfer guild ownership to another user. POST /guilds/{id}/transfer-ownership.
|
|
2445
2541
|
* Must be the guild owner.
|
|
2446
2542
|
*/
|
|
2447
2543
|
async transferOwnership(newOwnerId, password) {
|
|
2448
|
-
await this.client.rest.post(
|
|
2544
|
+
await this.client.rest.post(import_types16.Routes.guildTransferOwnership(this.id), {
|
|
2449
2545
|
body: { new_owner_id: newOwnerId, ...password != null && { password } },
|
|
2450
2546
|
auth: true
|
|
2451
2547
|
});
|
|
@@ -2454,7 +2550,7 @@ var Guild = class extends Base {
|
|
|
2454
2550
|
* Set text channel flexible names feature. PATCH /guilds/{id}/text-channel-flexible-names.
|
|
2455
2551
|
*/
|
|
2456
2552
|
setTextChannelFlexibleNames(enabled) {
|
|
2457
|
-
return this.client.rest.patch(
|
|
2553
|
+
return this.client.rest.patch(import_types16.Routes.guildTextChannelFlexibleNames(this.id), {
|
|
2458
2554
|
body: { enabled },
|
|
2459
2555
|
auth: true
|
|
2460
2556
|
}).then(() => this);
|
|
@@ -2463,7 +2559,7 @@ var Guild = class extends Base {
|
|
|
2463
2559
|
* Set detached banner feature. PATCH /guilds/{id}/detached-banner.
|
|
2464
2560
|
*/
|
|
2465
2561
|
setDetachedBanner(enabled) {
|
|
2466
|
-
return this.client.rest.patch(
|
|
2562
|
+
return this.client.rest.patch(import_types16.Routes.guildDetachedBanner(this.id), {
|
|
2467
2563
|
body: { enabled },
|
|
2468
2564
|
auth: true
|
|
2469
2565
|
}).then(() => this);
|
|
@@ -2472,7 +2568,7 @@ var Guild = class extends Base {
|
|
|
2472
2568
|
* Set disallow unclaimed accounts. PATCH /guilds/{id}/disallow-unclaimed-accounts.
|
|
2473
2569
|
*/
|
|
2474
2570
|
setDisallowUnclaimedAccounts(enabled) {
|
|
2475
|
-
return this.client.rest.patch(
|
|
2571
|
+
return this.client.rest.patch(import_types16.Routes.guildDisallowUnclaimedAccounts(this.id), {
|
|
2476
2572
|
body: { enabled },
|
|
2477
2573
|
auth: true
|
|
2478
2574
|
}).then(() => this);
|
|
@@ -2483,7 +2579,7 @@ var Guild = class extends Base {
|
|
|
2483
2579
|
*/
|
|
2484
2580
|
async setRolePositions(updates) {
|
|
2485
2581
|
const data = await this.client.rest.patch(
|
|
2486
|
-
|
|
2582
|
+
import_types16.Routes.guildRoles(this.id),
|
|
2487
2583
|
{ body: updates, auth: true }
|
|
2488
2584
|
);
|
|
2489
2585
|
const list = Array.isArray(data) ? data : Object.values(data ?? {});
|
|
@@ -2497,7 +2593,7 @@ var Guild = class extends Base {
|
|
|
2497
2593
|
*/
|
|
2498
2594
|
async setRoleHoistPositions(updates) {
|
|
2499
2595
|
const data = await this.client.rest.patch(
|
|
2500
|
-
|
|
2596
|
+
import_types16.Routes.guildRolesHoistPositions(this.id),
|
|
2501
2597
|
{ body: updates, auth: true }
|
|
2502
2598
|
);
|
|
2503
2599
|
const list = Array.isArray(data) ? data : Object.values(data ?? {});
|
|
@@ -2511,7 +2607,7 @@ var Guild = class extends Base {
|
|
|
2511
2607
|
*/
|
|
2512
2608
|
async resetRoleHoistPositions() {
|
|
2513
2609
|
const data = await this.client.rest.delete(
|
|
2514
|
-
|
|
2610
|
+
import_types16.Routes.guildRolesHoistPositions(this.id),
|
|
2515
2611
|
{ auth: true }
|
|
2516
2612
|
);
|
|
2517
2613
|
const list = Array.isArray(data) ? data : Object.values(data ?? {});
|
|
@@ -2526,7 +2622,7 @@ var Guild = class extends Base {
|
|
|
2526
2622
|
* Requires Manage Channels permission.
|
|
2527
2623
|
*/
|
|
2528
2624
|
async setChannelPositions(updates) {
|
|
2529
|
-
await this.client.rest.patch(
|
|
2625
|
+
await this.client.rest.patch(import_types16.Routes.guildChannels(this.id), {
|
|
2530
2626
|
body: updates,
|
|
2531
2627
|
auth: true
|
|
2532
2628
|
});
|
|
@@ -2537,7 +2633,7 @@ var Guild = class extends Base {
|
|
|
2537
2633
|
*/
|
|
2538
2634
|
async fetchEmojis() {
|
|
2539
2635
|
const data = await this.client.rest.get(
|
|
2540
|
-
|
|
2636
|
+
import_types16.Routes.guildEmojis(this.id)
|
|
2541
2637
|
);
|
|
2542
2638
|
const list = Array.isArray(data) ? data : Object.values(data ?? {});
|
|
2543
2639
|
const emojis = [];
|
|
@@ -2556,7 +2652,7 @@ var Guild = class extends Base {
|
|
|
2556
2652
|
*/
|
|
2557
2653
|
async fetchEmoji(emojiId) {
|
|
2558
2654
|
try {
|
|
2559
|
-
const data = await this.client.rest.get(
|
|
2655
|
+
const data = await this.client.rest.get(import_types16.Routes.guildEmoji(this.id, emojiId));
|
|
2560
2656
|
const emoji = new GuildEmoji(this.client, { ...data, guild_id: this.id }, this.id);
|
|
2561
2657
|
this.emojis.set(emoji.id, emoji);
|
|
2562
2658
|
return emoji;
|
|
@@ -2578,7 +2674,7 @@ var Guild = class extends Base {
|
|
|
2578
2674
|
*/
|
|
2579
2675
|
async createEmojisBulk(emojis) {
|
|
2580
2676
|
const data = await this.client.rest.post(
|
|
2581
|
-
|
|
2677
|
+
import_types16.Routes.guildEmojisBulk(this.id),
|
|
2582
2678
|
{
|
|
2583
2679
|
body: { emojis },
|
|
2584
2680
|
auth: true
|
|
@@ -2594,7 +2690,7 @@ var Guild = class extends Base {
|
|
|
2594
2690
|
*/
|
|
2595
2691
|
async createStickersBulk(stickers) {
|
|
2596
2692
|
const data = await this.client.rest.post(
|
|
2597
|
-
|
|
2693
|
+
import_types16.Routes.guildStickersBulk(this.id),
|
|
2598
2694
|
{
|
|
2599
2695
|
body: { stickers },
|
|
2600
2696
|
auth: true
|
|
@@ -2615,7 +2711,7 @@ var Guild = class extends Base {
|
|
|
2615
2711
|
*/
|
|
2616
2712
|
async fetchStickers() {
|
|
2617
2713
|
const data = await this.client.rest.get(
|
|
2618
|
-
|
|
2714
|
+
import_types16.Routes.guildStickers(this.id)
|
|
2619
2715
|
);
|
|
2620
2716
|
const list = Array.isArray(data) ? data : Object.values(data ?? {});
|
|
2621
2717
|
const stickers = [];
|
|
@@ -2630,7 +2726,7 @@ var Guild = class extends Base {
|
|
|
2630
2726
|
* Fetch a single guild sticker by ID.
|
|
2631
2727
|
*/
|
|
2632
2728
|
async fetchSticker(stickerId) {
|
|
2633
|
-
const data = await this.client.rest.get(
|
|
2729
|
+
const data = await this.client.rest.get(import_types16.Routes.guildSticker(this.id, stickerId));
|
|
2634
2730
|
const sticker = new GuildSticker(this.client, { ...data, guild_id: this.id }, this.id);
|
|
2635
2731
|
this.stickers.set(sticker.id, sticker);
|
|
2636
2732
|
return sticker;
|
|
@@ -2638,7 +2734,7 @@ var Guild = class extends Base {
|
|
|
2638
2734
|
};
|
|
2639
2735
|
|
|
2640
2736
|
// src/client/GuildManager.ts
|
|
2641
|
-
var GuildManager = class extends
|
|
2737
|
+
var GuildManager = class extends import_collection9.Collection {
|
|
2642
2738
|
constructor(client) {
|
|
2643
2739
|
super();
|
|
2644
2740
|
this.client = client;
|
|
@@ -2670,7 +2766,7 @@ var GuildManager = class extends import_collection8.Collection {
|
|
|
2670
2766
|
* @returns The created guild
|
|
2671
2767
|
*/
|
|
2672
2768
|
async create(options) {
|
|
2673
|
-
const data = await this.client.rest.post(
|
|
2769
|
+
const data = await this.client.rest.post(import_types17.Routes.guilds(), {
|
|
2674
2770
|
body: options,
|
|
2675
2771
|
auth: true
|
|
2676
2772
|
});
|
|
@@ -2690,7 +2786,7 @@ var GuildManager = class extends import_collection8.Collection {
|
|
|
2690
2786
|
const cached = this.get(guildId);
|
|
2691
2787
|
if (cached) return cached;
|
|
2692
2788
|
try {
|
|
2693
|
-
const data = await this.client.rest.get(
|
|
2789
|
+
const data = await this.client.rest.get(import_types17.Routes.guild(guildId));
|
|
2694
2790
|
const guild = new Guild(this.client, data);
|
|
2695
2791
|
this.set(guild.id, guild);
|
|
2696
2792
|
return guild;
|
|
@@ -2701,7 +2797,7 @@ var GuildManager = class extends import_collection8.Collection {
|
|
|
2701
2797
|
};
|
|
2702
2798
|
|
|
2703
2799
|
// src/structures/User.ts
|
|
2704
|
-
var
|
|
2800
|
+
var import_types18 = require("@fluxerjs/types");
|
|
2705
2801
|
var User = class extends Base {
|
|
2706
2802
|
client;
|
|
2707
2803
|
id;
|
|
@@ -2777,7 +2873,7 @@ var User = class extends Base {
|
|
|
2777
2873
|
* Returns the DM channel; use {@link DMChannel.send} to send messages.
|
|
2778
2874
|
*/
|
|
2779
2875
|
async createDM() {
|
|
2780
|
-
const data = await this.client.rest.post(
|
|
2876
|
+
const data = await this.client.rest.post(import_types18.Routes.userMeChannels(), {
|
|
2781
2877
|
body: { recipient_id: this.id },
|
|
2782
2878
|
auth: true
|
|
2783
2879
|
});
|
|
@@ -2794,7 +2890,7 @@ var User = class extends Base {
|
|
|
2794
2890
|
};
|
|
2795
2891
|
|
|
2796
2892
|
// src/client/ClientUser.ts
|
|
2797
|
-
var
|
|
2893
|
+
var import_types19 = require("@fluxerjs/types");
|
|
2798
2894
|
var ClientUser = class extends User {
|
|
2799
2895
|
constructor(client, data) {
|
|
2800
2896
|
super(client, { ...data });
|
|
@@ -2805,7 +2901,7 @@ var ClientUser = class extends User {
|
|
|
2805
2901
|
*/
|
|
2806
2902
|
async fetchGuilds() {
|
|
2807
2903
|
const data = await this.client.rest.get(
|
|
2808
|
-
|
|
2904
|
+
import_types19.Routes.currentUserGuilds()
|
|
2809
2905
|
);
|
|
2810
2906
|
const list = Array.isArray(data) ? data : data?.guilds ?? [];
|
|
2811
2907
|
const guilds = [];
|
|
@@ -2821,7 +2917,7 @@ var ClientUser = class extends User {
|
|
|
2821
2917
|
* @param guildId - The guild ID to leave
|
|
2822
2918
|
*/
|
|
2823
2919
|
async leaveGuild(guildId) {
|
|
2824
|
-
await this.client.rest.delete(
|
|
2920
|
+
await this.client.rest.delete(import_types19.Routes.leaveGuild(guildId), { auth: true });
|
|
2825
2921
|
this.client.guilds.delete(guildId);
|
|
2826
2922
|
}
|
|
2827
2923
|
};
|
|
@@ -2830,9 +2926,9 @@ var ClientUser = class extends User {
|
|
|
2830
2926
|
var import_util10 = require("@fluxerjs/util");
|
|
2831
2927
|
|
|
2832
2928
|
// src/client/UsersManager.ts
|
|
2833
|
-
var
|
|
2834
|
-
var
|
|
2835
|
-
var UsersManager = class extends
|
|
2929
|
+
var import_collection10 = require("@fluxerjs/collection");
|
|
2930
|
+
var import_types20 = require("@fluxerjs/types");
|
|
2931
|
+
var UsersManager = class extends import_collection10.Collection {
|
|
2836
2932
|
constructor(client) {
|
|
2837
2933
|
super();
|
|
2838
2934
|
this.client = client;
|
|
@@ -2857,7 +2953,7 @@ var UsersManager = class extends import_collection9.Collection {
|
|
|
2857
2953
|
* console.log(user.username);
|
|
2858
2954
|
*/
|
|
2859
2955
|
async fetch(userId) {
|
|
2860
|
-
const data = await this.client.rest.get(
|
|
2956
|
+
const data = await this.client.rest.get(import_types20.Routes.user(userId));
|
|
2861
2957
|
return this.client.getOrCreateUser(data);
|
|
2862
2958
|
}
|
|
2863
2959
|
/**
|
|
@@ -2877,10 +2973,10 @@ var UsersManager = class extends import_collection9.Collection {
|
|
|
2877
2973
|
async fetchWithProfile(userId, options) {
|
|
2878
2974
|
const guildId = options?.guildId ?? void 0;
|
|
2879
2975
|
const [userData, globalProfileData, serverProfileData, memberData] = await Promise.all([
|
|
2880
|
-
this.client.rest.get(
|
|
2881
|
-
this.client.rest.get(
|
|
2882
|
-
guildId ? this.client.rest.get(
|
|
2883
|
-
guildId ? this.client.rest.get(
|
|
2976
|
+
this.client.rest.get(import_types20.Routes.user(userId)),
|
|
2977
|
+
this.client.rest.get(import_types20.Routes.userProfile(userId)).catch(() => null),
|
|
2978
|
+
guildId ? this.client.rest.get(import_types20.Routes.userProfile(userId, guildId)).catch(() => null) : Promise.resolve(null),
|
|
2979
|
+
guildId ? this.client.rest.get(import_types20.Routes.guildMember(guildId, userId)).catch(() => null) : Promise.resolve(null)
|
|
2884
2980
|
]);
|
|
2885
2981
|
const user = this.client.getOrCreateUser(userData);
|
|
2886
2982
|
const globalProfile = globalProfileData && typeof globalProfileData === "object" ? globalProfileData : null;
|
|
@@ -3067,7 +3163,7 @@ function normalizeGuildPayload(raw) {
|
|
|
3067
3163
|
}
|
|
3068
3164
|
|
|
3069
3165
|
// src/structures/MessageReaction.ts
|
|
3070
|
-
var
|
|
3166
|
+
var import_types21 = require("@fluxerjs/types");
|
|
3071
3167
|
var import_rest4 = require("@fluxerjs/rest");
|
|
3072
3168
|
var MessageReaction = class extends Base {
|
|
3073
3169
|
client;
|
|
@@ -3102,7 +3198,7 @@ var MessageReaction = class extends Base {
|
|
|
3102
3198
|
async fetchMessage() {
|
|
3103
3199
|
try {
|
|
3104
3200
|
const data = await this.client.rest.get(
|
|
3105
|
-
|
|
3201
|
+
import_types21.Routes.channelMessage(this.channelId, this.messageId)
|
|
3106
3202
|
);
|
|
3107
3203
|
return new Message(this.client, data);
|
|
3108
3204
|
} catch (err) {
|
|
@@ -3597,7 +3693,7 @@ var Client = class extends import_events3.EventEmitter {
|
|
|
3597
3693
|
const unicodeFromShortcode = (0, import_util10.getUnicodeFromShortcode)(parsed.name);
|
|
3598
3694
|
if (unicodeFromShortcode) return unicodeFromShortcode;
|
|
3599
3695
|
if (guildId) {
|
|
3600
|
-
const emojis = await this.rest.get(
|
|
3696
|
+
const emojis = await this.rest.get(import_types22.Routes.guildEmojis(guildId));
|
|
3601
3697
|
const list = Array.isArray(emojis) ? emojis : Object.values(emojis ?? {});
|
|
3602
3698
|
const found = list.find((e) => e.name && e.name.toLowerCase() === parsed.name.toLowerCase());
|
|
3603
3699
|
if (found) return (0, import_util10.formatEmoji)({ ...parsed, id: found.id, animated: found.animated });
|
|
@@ -3620,7 +3716,7 @@ var Client = class extends import_events3.EventEmitter {
|
|
|
3620
3716
|
* @throws FluxerError with EMOJI_NOT_IN_GUILD if the emoji is not in the guild
|
|
3621
3717
|
*/
|
|
3622
3718
|
async assertEmojiInGuild(emojiId, guildId) {
|
|
3623
|
-
const emojis = await this.rest.get(
|
|
3719
|
+
const emojis = await this.rest.get(import_types22.Routes.guildEmojis(guildId));
|
|
3624
3720
|
const list = Array.isArray(emojis) ? emojis : Object.values(emojis ?? {});
|
|
3625
3721
|
const found = list.some((e) => e.id === emojiId);
|
|
3626
3722
|
if (!found) {
|
|
@@ -3634,21 +3730,21 @@ var Client = class extends import_events3.EventEmitter {
|
|
|
3634
3730
|
* Does not require authentication.
|
|
3635
3731
|
*/
|
|
3636
3732
|
async fetchInstance() {
|
|
3637
|
-
return this.rest.get(
|
|
3733
|
+
return this.rest.get(import_types22.Routes.instance(), { auth: false });
|
|
3638
3734
|
}
|
|
3639
3735
|
/**
|
|
3640
3736
|
* Fetch instance discovery document (API URL, gateway URL, features). GET /.well-known/fluxer.
|
|
3641
3737
|
* Does not require authentication.
|
|
3642
3738
|
*/
|
|
3643
3739
|
async fetchInstanceDiscovery() {
|
|
3644
|
-
return this.rest.get(
|
|
3740
|
+
return this.rest.get(import_types22.Routes.instanceDiscovery(), { auth: false });
|
|
3645
3741
|
}
|
|
3646
3742
|
/**
|
|
3647
3743
|
* Fetch gateway connection metadata (WebSocket URL, recommended shards, session limits).
|
|
3648
3744
|
* GET /gateway/bot (authenticated).
|
|
3649
3745
|
*/
|
|
3650
3746
|
async fetchGatewayInfo() {
|
|
3651
|
-
return this.rest.get(
|
|
3747
|
+
return this.rest.get(import_types22.Routes.gatewayBot());
|
|
3652
3748
|
}
|
|
3653
3749
|
/**
|
|
3654
3750
|
* Fetch a message by channel and message ID. Use when you have IDs (e.g. from a DB).
|
|
@@ -3956,7 +4052,7 @@ var Client = class extends import_events3.EventEmitter {
|
|
|
3956
4052
|
}
|
|
3957
4053
|
}
|
|
3958
4054
|
static get Routes() {
|
|
3959
|
-
return
|
|
4055
|
+
return import_types22.Routes;
|
|
3960
4056
|
}
|
|
3961
4057
|
};
|
|
3962
4058
|
// Annotate the CommonJS export names for ESM import in node:
|