@fluxerjs/core 2.0.2 → 2.0.3
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 +311 -277
- package/dist/client.mjs +285 -251
- package/dist/cluster.d.mts +1 -1
- package/dist/cluster.d.ts +1 -1
- package/dist/cluster.js +313 -277
- package/dist/cluster.mjs +287 -251
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +311 -277
- package/dist/index.mjs +285 -251
- package/dist/message.d.mts +1 -1
- package/dist/message.d.ts +1 -1
- package/dist/message.js +119 -29
- package/dist/message.mjs +118 -28
- package/dist/{subpath-message-CoDItxh0.d.mts → subpath-message-CWiBEUUV.d.mts} +7 -1
- package/dist/{subpath-message-CoDItxh0.d.ts → subpath-message-CWiBEUUV.d.ts} +7 -1
- package/package.json +4 -4
package/dist/client.mjs
CHANGED
|
@@ -5,8 +5,8 @@ import { Routes as Routes34 } from "@fluxerjs/types";
|
|
|
5
5
|
|
|
6
6
|
// src/client/ChannelManager.ts
|
|
7
7
|
import { Collection as Collection5 } from "@fluxerjs/collection";
|
|
8
|
-
import { Routes as
|
|
9
|
-
import { FluxerAPIError as
|
|
8
|
+
import { Routes as Routes13 } from "@fluxerjs/types";
|
|
9
|
+
import { FluxerAPIError as FluxerAPIError3, RateLimitError as RateLimitError3 } from "@fluxerjs/rest";
|
|
10
10
|
|
|
11
11
|
// src/errors/FluxerError.ts
|
|
12
12
|
import { FluxerError } from "@fluxerjs/util";
|
|
@@ -194,19 +194,19 @@ async function prepareMessagePostPayload(options, defaults) {
|
|
|
194
194
|
}
|
|
195
195
|
|
|
196
196
|
// src/structures/channel/base.ts
|
|
197
|
-
import { ChannelType, Routes as
|
|
197
|
+
import { ChannelType, Routes as Routes7 } from "@fluxerjs/types";
|
|
198
198
|
|
|
199
199
|
// src/client/MessageManager.ts
|
|
200
|
-
import { Routes as
|
|
200
|
+
import { Routes as Routes5 } from "@fluxerjs/types";
|
|
201
201
|
import { Collection as Collection3 } from "@fluxerjs/collection";
|
|
202
|
-
import { FluxerAPIError, RateLimitError } from "@fluxerjs/rest";
|
|
202
|
+
import { FluxerAPIError as FluxerAPIError2, RateLimitError as RateLimitError2 } from "@fluxerjs/rest";
|
|
203
203
|
|
|
204
204
|
// src/structures/message/Message.ts
|
|
205
205
|
import { Collection as Collection2 } from "@fluxerjs/collection";
|
|
206
206
|
import { EmbedBuilder as EmbedBuilder2 } from "@fluxerjs/builders";
|
|
207
207
|
import {
|
|
208
208
|
MessageType,
|
|
209
|
-
Routes as
|
|
209
|
+
Routes as Routes4
|
|
210
210
|
} from "@fluxerjs/types";
|
|
211
211
|
|
|
212
212
|
// src/client/sdkOptions.ts
|
|
@@ -448,6 +448,68 @@ function toProfilePayload(data) {
|
|
|
448
448
|
import { EventEmitter } from "events";
|
|
449
449
|
import { Collection } from "@fluxerjs/collection";
|
|
450
450
|
|
|
451
|
+
// src/structures/MessageReaction.ts
|
|
452
|
+
import { Routes } from "@fluxerjs/types";
|
|
453
|
+
import { FluxerAPIError, RateLimitError } from "@fluxerjs/rest";
|
|
454
|
+
|
|
455
|
+
// src/structures/Base.ts
|
|
456
|
+
var Base = class {
|
|
457
|
+
};
|
|
458
|
+
|
|
459
|
+
// src/structures/MessageReaction.ts
|
|
460
|
+
var MessageReaction = class extends Base {
|
|
461
|
+
client;
|
|
462
|
+
messageId;
|
|
463
|
+
channelId;
|
|
464
|
+
guildId;
|
|
465
|
+
emoji;
|
|
466
|
+
/** Raw gateway payload for low-level access. */
|
|
467
|
+
_data;
|
|
468
|
+
constructor(client, data) {
|
|
469
|
+
super();
|
|
470
|
+
this.client = client;
|
|
471
|
+
this._data = data;
|
|
472
|
+
this.messageId = data.message_id;
|
|
473
|
+
this.channelId = data.channel_id;
|
|
474
|
+
this.guildId = data.guild_id ?? null;
|
|
475
|
+
this.emoji = {
|
|
476
|
+
name: data.emoji.name,
|
|
477
|
+
...data.emoji.id !== void 0 ? { id: data.emoji.id } : {},
|
|
478
|
+
...data.emoji.animated !== void 0 ? { animated: data.emoji.animated } : {}
|
|
479
|
+
};
|
|
480
|
+
}
|
|
481
|
+
/** Emoji as a string: unicode or "name:id" for custom. */
|
|
482
|
+
get emojiIdentifier() {
|
|
483
|
+
return this.emoji.id ? `${this.emoji.name}:${this.emoji.id}` : this.emoji.name;
|
|
484
|
+
}
|
|
485
|
+
/** Guild where this reaction was added. Resolved from cache; null for DMs or if not cached. */
|
|
486
|
+
get guild() {
|
|
487
|
+
return this.guildId ? this.client.guilds.get(this.guildId) ?? null : null;
|
|
488
|
+
}
|
|
489
|
+
/**
|
|
490
|
+
* Fetch the message this reaction belongs to.
|
|
491
|
+
* Use when you need to edit, delete, or otherwise interact with the message.
|
|
492
|
+
* @throws FluxerError with MESSAGE_NOT_FOUND if the message does not exist
|
|
493
|
+
*/
|
|
494
|
+
async fetchMessage() {
|
|
495
|
+
try {
|
|
496
|
+
const data = await this.client.rest.get(
|
|
497
|
+
Routes.channelMessage(this.channelId, this.messageId)
|
|
498
|
+
);
|
|
499
|
+
return new Message(this.client, data);
|
|
500
|
+
} catch (err) {
|
|
501
|
+
if (err instanceof RateLimitError) throw err;
|
|
502
|
+
if (err instanceof FluxerAPIError && err.statusCode === 404) {
|
|
503
|
+
throw new FluxerError(`Message ${this.messageId} not found in channel ${this.channelId}`, {
|
|
504
|
+
code: ErrorCodes.MessageNotFound,
|
|
505
|
+
cause: err
|
|
506
|
+
});
|
|
507
|
+
}
|
|
508
|
+
throw err instanceof FluxerError ? err : new FluxerError(String(err), { cause: err });
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
};
|
|
512
|
+
|
|
451
513
|
// src/util/Events.ts
|
|
452
514
|
var Events = {
|
|
453
515
|
Ready: "ready",
|
|
@@ -511,7 +573,8 @@ var ReactionCollector = class extends EventEmitter {
|
|
|
511
573
|
collected = new Collection();
|
|
512
574
|
_timeout = null;
|
|
513
575
|
_ended = false;
|
|
514
|
-
|
|
576
|
+
_onAdd;
|
|
577
|
+
_onAddMany;
|
|
515
578
|
constructor(client, messageId, channelId, options = {}) {
|
|
516
579
|
super();
|
|
517
580
|
this.client = client;
|
|
@@ -522,27 +585,58 @@ var ReactionCollector = class extends EventEmitter {
|
|
|
522
585
|
time: options.time ?? 0,
|
|
523
586
|
max: options.max ?? 0
|
|
524
587
|
};
|
|
525
|
-
this.
|
|
588
|
+
this._onAdd = (payload) => {
|
|
526
589
|
if (this._ended || payload.reaction.messageId !== this.messageId || payload.channelId !== this.channelId) {
|
|
527
590
|
return;
|
|
528
591
|
}
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
this.
|
|
533
|
-
|
|
534
|
-
|
|
592
|
+
this._collect(payload.reaction, payload.user, payload.userId);
|
|
593
|
+
};
|
|
594
|
+
this._onAddMany = (payload) => {
|
|
595
|
+
if (this._ended || payload.messageId !== this.messageId || payload.channelId !== this.channelId) {
|
|
596
|
+
return;
|
|
597
|
+
}
|
|
598
|
+
for (const entry of payload.reactions) {
|
|
599
|
+
if (this._ended) return;
|
|
600
|
+
const reaction = new MessageReaction(this.client, {
|
|
601
|
+
message_id: payload.messageId,
|
|
602
|
+
channel_id: payload.channelId,
|
|
603
|
+
guild_id: payload.guildId ?? void 0,
|
|
604
|
+
user_id: entry.userId,
|
|
605
|
+
emoji: {
|
|
606
|
+
name: entry.emoji.name,
|
|
607
|
+
...entry.emoji.id !== void 0 ? { id: entry.emoji.id } : {},
|
|
608
|
+
...entry.emoji.animated !== void 0 ? { animated: entry.emoji.animated } : {}
|
|
609
|
+
}
|
|
610
|
+
});
|
|
611
|
+
const user = entry.member?.user ?? this.client.users.get(entry.userId) ?? this.client.getOrCreateUser({
|
|
612
|
+
id: entry.userId,
|
|
613
|
+
username: "Unknown",
|
|
614
|
+
discriminator: "0"
|
|
615
|
+
});
|
|
616
|
+
this._collect(reaction, user, entry.userId);
|
|
535
617
|
}
|
|
536
618
|
};
|
|
537
|
-
this.client.on(Events.MessageReactionAdd, this.
|
|
619
|
+
this.client.on(Events.MessageReactionAdd, this._onAdd);
|
|
620
|
+
this.client.on(Events.MessageReactionAddMany, this._onAddMany);
|
|
538
621
|
if (this.options.time > 0) {
|
|
539
622
|
this._timeout = setTimeout(() => this.stop("time"), this.options.time);
|
|
540
623
|
}
|
|
541
624
|
}
|
|
625
|
+
_collect(reaction, user, userId) {
|
|
626
|
+
if (this._ended) return;
|
|
627
|
+
if (!this.options.filter(reaction, user)) return;
|
|
628
|
+
const key = `${userId}:${reaction.emoji.id ?? reaction.emoji.name}`;
|
|
629
|
+
this.collected.set(key, { reaction, user });
|
|
630
|
+
this.emit("collect", reaction, user);
|
|
631
|
+
if (this.options.max > 0 && this.collected.size >= this.options.max) {
|
|
632
|
+
this.stop("limit");
|
|
633
|
+
}
|
|
634
|
+
}
|
|
542
635
|
stop(reason = "user") {
|
|
543
636
|
if (this._ended) return;
|
|
544
637
|
this._ended = true;
|
|
545
|
-
this.client.off(Events.MessageReactionAdd, this.
|
|
638
|
+
this.client.off(Events.MessageReactionAdd, this._onAdd);
|
|
639
|
+
this.client.off(Events.MessageReactionAddMany, this._onAddMany);
|
|
546
640
|
if (this._timeout) {
|
|
547
641
|
clearTimeout(this._timeout);
|
|
548
642
|
this._timeout = null;
|
|
@@ -557,30 +651,26 @@ var ReactionCollector = class extends EventEmitter {
|
|
|
557
651
|
}
|
|
558
652
|
};
|
|
559
653
|
|
|
560
|
-
// src/structures/Base.ts
|
|
561
|
-
var Base = class {
|
|
562
|
-
};
|
|
563
|
-
|
|
564
654
|
// src/structures/message/reactions.ts
|
|
565
|
-
import { Routes } from "@fluxerjs/types";
|
|
655
|
+
import { Routes as Routes2 } from "@fluxerjs/types";
|
|
566
656
|
async function emojiPath(message, emoji) {
|
|
567
657
|
return message.client.resolveEmoji(emoji, message.guildId);
|
|
568
658
|
}
|
|
569
659
|
async function reactToMessage(message, emoji) {
|
|
570
660
|
const e = await emojiPath(message, emoji);
|
|
571
|
-
await message.client.rest.put(
|
|
661
|
+
await message.client.rest.put(Routes2.channelMessageReactionMe(message.channelId, message.id, e));
|
|
572
662
|
}
|
|
573
663
|
async function removeMessageReaction(message, emoji, userId) {
|
|
574
664
|
const e = await emojiPath(message, emoji);
|
|
575
|
-
const route = userId ?
|
|
665
|
+
const route = userId ? Routes2.channelMessageReactionUser(message.channelId, message.id, e, userId) : Routes2.channelMessageReactionMe(message.channelId, message.id, e);
|
|
576
666
|
await message.client.rest.delete(route);
|
|
577
667
|
}
|
|
578
668
|
async function removeAllMessageReactions(message) {
|
|
579
|
-
await message.client.rest.delete(
|
|
669
|
+
await message.client.rest.delete(Routes2.channelMessageReactions(message.channelId, message.id));
|
|
580
670
|
}
|
|
581
671
|
async function removeMessageReactionEmoji(message, emoji) {
|
|
582
672
|
const e = await emojiPath(message, emoji);
|
|
583
|
-
await message.client.rest.delete(
|
|
673
|
+
await message.client.rest.delete(Routes2.channelMessageReaction(message.channelId, message.id, e));
|
|
584
674
|
}
|
|
585
675
|
async function fetchMessageReactionUsers(message, emoji, options) {
|
|
586
676
|
return (await fetchMessageReactionUsersPage(message, emoji, options)).users;
|
|
@@ -591,7 +681,7 @@ async function fetchMessageReactionUsersPage(message, emoji, options) {
|
|
|
591
681
|
if (options?.limit != null) params.set("limit", String(options.limit));
|
|
592
682
|
if (options?.after) params.set("after", options.after);
|
|
593
683
|
const qs2 = params.toString();
|
|
594
|
-
const route =
|
|
684
|
+
const route = Routes2.channelMessageReactionUsers(message.channelId, message.id, e) + (qs2 ? `?${qs2}` : "");
|
|
595
685
|
const data = await message.client.rest.get(route);
|
|
596
686
|
if (Array.isArray(data)) {
|
|
597
687
|
return {
|
|
@@ -610,7 +700,7 @@ async function fetchMessageReactionUsersPage(message, emoji, options) {
|
|
|
610
700
|
|
|
611
701
|
// src/structures/message/send.ts
|
|
612
702
|
import { MessagePayload as MessagePayloadBuilder } from "@fluxerjs/builders";
|
|
613
|
-
import { Routes as
|
|
703
|
+
import { Routes as Routes3 } from "@fluxerjs/types";
|
|
614
704
|
function toReplyTarget(ref) {
|
|
615
705
|
return {
|
|
616
706
|
channelId: ref.channel_id,
|
|
@@ -644,7 +734,7 @@ function asReplyTarget(value) {
|
|
|
644
734
|
}
|
|
645
735
|
async function sendPrepared(message, payload) {
|
|
646
736
|
const data = await message.client.rest.post(
|
|
647
|
-
|
|
737
|
+
Routes3.channelMessages(message.channelId),
|
|
648
738
|
payload
|
|
649
739
|
);
|
|
650
740
|
message.client._addMessageToCache(message.channelId, data);
|
|
@@ -821,7 +911,7 @@ var Message = class _Message extends Base {
|
|
|
821
911
|
if (options.attachments !== void 0) {
|
|
822
912
|
body.attachments = toMessageAttachmentEditWire(options.attachments);
|
|
823
913
|
}
|
|
824
|
-
const data = await this.client.rest.patch(
|
|
914
|
+
const data = await this.client.rest.patch(Routes4.channelMessage(this.channelId, this.id), {
|
|
825
915
|
body
|
|
826
916
|
});
|
|
827
917
|
const updated = new _Message(this.client, data);
|
|
@@ -838,25 +928,25 @@ var Message = class _Message extends Base {
|
|
|
838
928
|
}
|
|
839
929
|
/** Delete this message. */
|
|
840
930
|
async delete() {
|
|
841
|
-
await this.client.rest.delete(
|
|
931
|
+
await this.client.rest.delete(Routes4.channelMessage(this.channelId, this.id));
|
|
842
932
|
this.client._removeMessageFromCache(this.channelId, this.id);
|
|
843
933
|
}
|
|
844
934
|
/** Delete a specific attachment from this message. */
|
|
845
935
|
async deleteAttachment(attachmentId) {
|
|
846
936
|
await this.client.rest.delete(
|
|
847
|
-
|
|
937
|
+
Routes4.channelMessageAttachment(this.channelId, this.id, attachmentId),
|
|
848
938
|
{ auth: true }
|
|
849
939
|
);
|
|
850
940
|
this.attachments.delete(attachmentId);
|
|
851
941
|
}
|
|
852
942
|
/** Pin this message in the channel. */
|
|
853
943
|
async pin() {
|
|
854
|
-
await this.client.rest.put(
|
|
944
|
+
await this.client.rest.put(Routes4.channelPinMessage(this.channelId, this.id));
|
|
855
945
|
this.pinned = true;
|
|
856
946
|
}
|
|
857
947
|
/** Unpin this message from the channel. */
|
|
858
948
|
async unpin() {
|
|
859
|
-
await this.client.rest.delete(
|
|
949
|
+
await this.client.rest.delete(Routes4.channelPinMessage(this.channelId, this.id));
|
|
860
950
|
this.pinned = false;
|
|
861
951
|
}
|
|
862
952
|
/** React to this message with an emoji. */
|
|
@@ -937,12 +1027,12 @@ var MessageManager = class {
|
|
|
937
1027
|
async fetchOne(messageId) {
|
|
938
1028
|
try {
|
|
939
1029
|
const data = await this.client.rest.get(
|
|
940
|
-
|
|
1030
|
+
Routes5.channelMessage(this.channelId, messageId)
|
|
941
1031
|
);
|
|
942
1032
|
return this.wrap(data);
|
|
943
1033
|
} catch (err) {
|
|
944
|
-
if (err instanceof
|
|
945
|
-
if (err instanceof
|
|
1034
|
+
if (err instanceof RateLimitError2) throw err;
|
|
1035
|
+
if (err instanceof FluxerAPIError2 && err.statusCode === 404) {
|
|
946
1036
|
throw new FluxerError(`Message ${messageId} not found in channel ${this.channelId}`, {
|
|
947
1037
|
code: ErrorCodes.MessageNotFound,
|
|
948
1038
|
cause: err
|
|
@@ -963,7 +1053,7 @@ var MessageManager = class {
|
|
|
963
1053
|
const value = options[key];
|
|
964
1054
|
if (value != null && value !== "") qs2.set(key, String(value));
|
|
965
1055
|
}
|
|
966
|
-
const base =
|
|
1056
|
+
const base = Routes5.channelMessages(this.channelId);
|
|
967
1057
|
const data = await this.client.rest.get(qs2.size > 0 ? `${base}?${qs2}` : base);
|
|
968
1058
|
const collection = new Collection3();
|
|
969
1059
|
for (const msg of data) collection.set(msg.id, this.wrap(msg));
|
|
@@ -972,7 +1062,7 @@ var MessageManager = class {
|
|
|
972
1062
|
};
|
|
973
1063
|
|
|
974
1064
|
// src/structures/channel/attachments.ts
|
|
975
|
-
import { Routes as
|
|
1065
|
+
import { Routes as Routes6 } from "@fluxerjs/types";
|
|
976
1066
|
function asBytes(data) {
|
|
977
1067
|
const src = data instanceof ArrayBuffer ? new Uint8Array(data) : new Uint8Array(data);
|
|
978
1068
|
const out = new Uint8Array(src.byteLength);
|
|
@@ -993,7 +1083,7 @@ async function putBlob(url, body, contentType) {
|
|
|
993
1083
|
}
|
|
994
1084
|
async function uploadAttachmentsForSend(client, channelId, files) {
|
|
995
1085
|
const plan = await client.rest.post(
|
|
996
|
-
|
|
1086
|
+
Routes6.channelAttachments(channelId),
|
|
997
1087
|
{
|
|
998
1088
|
body: {
|
|
999
1089
|
attachments: files.map((f) => ({
|
|
@@ -1039,7 +1129,7 @@ async function uploadAttachmentsForSend(client, channelId, files) {
|
|
|
1039
1129
|
});
|
|
1040
1130
|
}
|
|
1041
1131
|
if (multipart.length) {
|
|
1042
|
-
await client.rest.post(
|
|
1132
|
+
await client.rest.post(Routes6.channelAttachmentsComplete(channelId), {
|
|
1043
1133
|
body: { uploads: multipart },
|
|
1044
1134
|
auth: true
|
|
1045
1135
|
});
|
|
@@ -1133,7 +1223,7 @@ var Channel = class extends Base {
|
|
|
1133
1223
|
}
|
|
1134
1224
|
if (ids.length === 0) return [];
|
|
1135
1225
|
if (ids.length === 1) {
|
|
1136
|
-
await this.client.rest.delete(
|
|
1226
|
+
await this.client.rest.delete(Routes7.channelMessage(this.id, ids[0]), { auth: true });
|
|
1137
1227
|
this.client._removeMessageFromCache(this.id, ids[0]);
|
|
1138
1228
|
return ids;
|
|
1139
1229
|
}
|
|
@@ -1142,7 +1232,7 @@ var Channel = class extends Base {
|
|
|
1142
1232
|
code: ErrorCodes.InvalidBulkDelete
|
|
1143
1233
|
});
|
|
1144
1234
|
}
|
|
1145
|
-
await this.client.rest.post(
|
|
1235
|
+
await this.client.rest.post(Routes7.channelBulkDelete(this.id), {
|
|
1146
1236
|
body: { message_ids: ids },
|
|
1147
1237
|
auth: true
|
|
1148
1238
|
});
|
|
@@ -1152,23 +1242,23 @@ var Channel = class extends Base {
|
|
|
1152
1242
|
/** Delete all messages sent by the bot in this channel (user account feature). */
|
|
1153
1243
|
async bulkDeleteMyMessages(options) {
|
|
1154
1244
|
const body = options ? toSudoBody(options) : void 0;
|
|
1155
|
-
await this.client.rest.post(
|
|
1245
|
+
await this.client.rest.post(Routes7.channelBulkDeleteMine(this.id), {
|
|
1156
1246
|
body: body && Object.keys(body).length ? body : void 0,
|
|
1157
1247
|
auth: true
|
|
1158
1248
|
});
|
|
1159
1249
|
}
|
|
1160
1250
|
/** Mark all pinned messages as read in this channel. */
|
|
1161
1251
|
async acknowledgePins() {
|
|
1162
|
-
await this.client.rest.post(
|
|
1252
|
+
await this.client.rest.post(Routes7.channelPinsAck(this.id), { auth: true });
|
|
1163
1253
|
}
|
|
1164
1254
|
/** Clear the read state for this channel. */
|
|
1165
1255
|
async clearReadState() {
|
|
1166
|
-
await this.client.rest.delete(
|
|
1256
|
+
await this.client.rest.delete(Routes7.channelMessagesAck(this.id), { auth: true });
|
|
1167
1257
|
}
|
|
1168
1258
|
/** Request upload URLs for attachments before sending a message. */
|
|
1169
1259
|
async requestAttachmentUploads(attachments) {
|
|
1170
1260
|
const data = await this.client.rest.post(
|
|
1171
|
-
|
|
1261
|
+
Routes7.channelAttachments(this.id),
|
|
1172
1262
|
{
|
|
1173
1263
|
body: toAttachmentUploadPlanBody(attachments),
|
|
1174
1264
|
auth: true
|
|
@@ -1179,7 +1269,7 @@ var Channel = class extends Base {
|
|
|
1179
1269
|
/** Complete the attachment upload flow after uploading to the CDN. */
|
|
1180
1270
|
async completeAttachmentUploads(uploads) {
|
|
1181
1271
|
const data = await this.client.rest.post(
|
|
1182
|
-
|
|
1272
|
+
Routes7.channelAttachmentsComplete(this.id),
|
|
1183
1273
|
{
|
|
1184
1274
|
body: toAttachmentUploadCompleteBody(uploads),
|
|
1185
1275
|
auth: true
|
|
@@ -1195,11 +1285,11 @@ var Channel = class extends Base {
|
|
|
1195
1285
|
}
|
|
1196
1286
|
/** Trigger the typing indicator in this channel. */
|
|
1197
1287
|
async sendTyping() {
|
|
1198
|
-
await this.client.rest.post(
|
|
1288
|
+
await this.client.rest.post(Routes7.channelTyping(this.id), { auth: true });
|
|
1199
1289
|
}
|
|
1200
1290
|
/** Fetch available RTC regions for voice channels. */
|
|
1201
1291
|
async fetchRtcRegions() {
|
|
1202
|
-
const data = await this.client.rest.get(
|
|
1292
|
+
const data = await this.client.rest.get(Routes7.channelRtcRegions(this.id), {
|
|
1203
1293
|
auth: true
|
|
1204
1294
|
});
|
|
1205
1295
|
return data.map((r) => ({ id: r.id, name: r.name, emoji: r.emoji }));
|
|
@@ -1207,7 +1297,7 @@ var Channel = class extends Base {
|
|
|
1207
1297
|
/** Fetch slowmode state for this channel. */
|
|
1208
1298
|
async fetchSlowmode() {
|
|
1209
1299
|
const data = await this.client.rest.get(
|
|
1210
|
-
|
|
1300
|
+
Routes7.channelSlowmode(this.id),
|
|
1211
1301
|
{ auth: true }
|
|
1212
1302
|
);
|
|
1213
1303
|
return {
|
|
@@ -1223,7 +1313,7 @@ var Channel = class extends Base {
|
|
|
1223
1313
|
};
|
|
1224
1314
|
|
|
1225
1315
|
// src/structures/channel/guild.ts
|
|
1226
|
-
import { Routes as
|
|
1316
|
+
import { Routes as Routes11 } from "@fluxerjs/types";
|
|
1227
1317
|
import { PermissionFlags } from "@fluxerjs/util";
|
|
1228
1318
|
|
|
1229
1319
|
// src/structures/Invite.ts
|
|
@@ -1232,7 +1322,7 @@ import {
|
|
|
1232
1322
|
isGroupDmInvite,
|
|
1233
1323
|
isGuildInvite,
|
|
1234
1324
|
isPackInvite,
|
|
1235
|
-
Routes as
|
|
1325
|
+
Routes as Routes8
|
|
1236
1326
|
} from "@fluxerjs/types";
|
|
1237
1327
|
|
|
1238
1328
|
// src/util/Constants.ts
|
|
@@ -1452,19 +1542,19 @@ var Invite = class _Invite extends Base {
|
|
|
1452
1542
|
}
|
|
1453
1543
|
/** Fetch invite metadata by code or URL (does not join). */
|
|
1454
1544
|
static async fetch(client, codeOrUrl) {
|
|
1455
|
-
const data = await client.rest.get(
|
|
1545
|
+
const data = await client.rest.get(Routes8.invite(parseInviteCode(codeOrUrl)));
|
|
1456
1546
|
return new _Invite(client, data);
|
|
1457
1547
|
}
|
|
1458
1548
|
/** Delete this invite. Requires Manage Guild or Create Instant Invite. */
|
|
1459
1549
|
async delete() {
|
|
1460
|
-
await this.client.rest.delete(
|
|
1550
|
+
await this.client.rest.delete(Routes8.invite(this.code), { auth: true });
|
|
1461
1551
|
}
|
|
1462
1552
|
};
|
|
1463
1553
|
|
|
1464
1554
|
// src/structures/Webhook.ts
|
|
1465
1555
|
import { EmbedBuilder as EmbedBuilder3 } from "@fluxerjs/builders";
|
|
1466
1556
|
import {
|
|
1467
|
-
Routes as
|
|
1557
|
+
Routes as Routes9
|
|
1468
1558
|
} from "@fluxerjs/types";
|
|
1469
1559
|
|
|
1470
1560
|
// src/util/cdn.ts
|
|
@@ -1557,10 +1647,10 @@ var Webhook = class _Webhook extends Base {
|
|
|
1557
1647
|
/** Delete this webhook (token auth when available, otherwise bot auth). */
|
|
1558
1648
|
async delete() {
|
|
1559
1649
|
if (this.token) {
|
|
1560
|
-
await this.client.rest.delete(
|
|
1650
|
+
await this.client.rest.delete(Routes9.webhookExecute(this.id, this.token), { auth: false });
|
|
1561
1651
|
return;
|
|
1562
1652
|
}
|
|
1563
|
-
await this.client.rest.delete(
|
|
1653
|
+
await this.client.rest.delete(Routes9.webhook(this.id), { auth: true });
|
|
1564
1654
|
}
|
|
1565
1655
|
/**
|
|
1566
1656
|
* Edit name/avatar. With bot auth (no token), `channelId` may also be set.
|
|
@@ -1572,10 +1662,10 @@ var Webhook = class _Webhook extends Base {
|
|
|
1572
1662
|
if (!this.token && options.channelId !== void 0) {
|
|
1573
1663
|
body.channel_id = options.channelId;
|
|
1574
1664
|
}
|
|
1575
|
-
const data = this.token ? await this.client.rest.patch(
|
|
1665
|
+
const data = this.token ? await this.client.rest.patch(Routes9.webhookExecute(this.id, this.token), {
|
|
1576
1666
|
body,
|
|
1577
1667
|
auth: false
|
|
1578
|
-
}) : await this.client.rest.patch(
|
|
1668
|
+
}) : await this.client.rest.patch(Routes9.webhook(this.id), { body, auth: true });
|
|
1579
1669
|
this.name = data.name ?? this.name;
|
|
1580
1670
|
this.avatar = data.avatar ?? null;
|
|
1581
1671
|
if (!this.token) this.channelId = data.channel_id ?? this.channelId;
|
|
@@ -1596,7 +1686,7 @@ var Webhook = class _Webhook extends Base {
|
|
|
1596
1686
|
if (overrides.avatarUrl !== void 0) {
|
|
1597
1687
|
body.avatar_url = overrides.avatarUrl;
|
|
1598
1688
|
}
|
|
1599
|
-
const route = `${
|
|
1689
|
+
const route = `${Routes9.webhookExecute(this.id, token)}${wait ? "?wait=true" : ""}`;
|
|
1600
1690
|
const data = await this.client.rest.post(route, {
|
|
1601
1691
|
body,
|
|
1602
1692
|
...files?.length ? { files } : {},
|
|
@@ -1637,7 +1727,7 @@ var Webhook = class _Webhook extends Base {
|
|
|
1637
1727
|
}
|
|
1638
1728
|
/** Fetch a webhook by ID (bot auth; no token). */
|
|
1639
1729
|
static async fetch(client, webhookId) {
|
|
1640
|
-
const data = await client.rest.get(
|
|
1730
|
+
const data = await client.rest.get(Routes9.webhook(webhookId));
|
|
1641
1731
|
return new _Webhook(client, data);
|
|
1642
1732
|
}
|
|
1643
1733
|
/** Build a webhook from a stored id + token (e.g. webhook URL). */
|
|
@@ -1662,12 +1752,12 @@ var Webhook = class _Webhook extends Base {
|
|
|
1662
1752
|
return this.token;
|
|
1663
1753
|
}
|
|
1664
1754
|
messageRoute(messageId) {
|
|
1665
|
-
return
|
|
1755
|
+
return Routes9.webhookMessage(this.id, this.requireToken(), messageId);
|
|
1666
1756
|
}
|
|
1667
1757
|
};
|
|
1668
1758
|
|
|
1669
1759
|
// src/structures/channel/textCapable.ts
|
|
1670
|
-
import { Routes as
|
|
1760
|
+
import { Routes as Routes10 } from "@fluxerjs/types";
|
|
1671
1761
|
|
|
1672
1762
|
// src/util/MessageCollector.ts
|
|
1673
1763
|
import { EventEmitter as EventEmitter2 } from "events";
|
|
@@ -1728,7 +1818,7 @@ async function fetchPinnedMessagesPageFor(client, channelId, options) {
|
|
|
1728
1818
|
if (options?.before) params.set("before", options.before);
|
|
1729
1819
|
const qs2 = params.toString();
|
|
1730
1820
|
const data = await client.rest.get(
|
|
1731
|
-
|
|
1821
|
+
Routes10.channelPins(channelId) + (qs2 ? `?${qs2}` : "")
|
|
1732
1822
|
);
|
|
1733
1823
|
const items = data.items ?? [];
|
|
1734
1824
|
return {
|
|
@@ -1744,7 +1834,7 @@ function TextCapable(Base2) {
|
|
|
1744
1834
|
const payload = await prepareMessagePostPayload(options, {
|
|
1745
1835
|
defaultAllowedMentions: this.client.options.defaultAllowedMentions
|
|
1746
1836
|
});
|
|
1747
|
-
const data = await this.client.rest.post(
|
|
1837
|
+
const data = await this.client.rest.post(Routes10.channelMessages(this.id), payload);
|
|
1748
1838
|
this.client._addMessageToCache(this.id, data);
|
|
1749
1839
|
return new Message(this.client, data);
|
|
1750
1840
|
}
|
|
@@ -1801,7 +1891,7 @@ var GuildChannel = class extends Channel {
|
|
|
1801
1891
|
}
|
|
1802
1892
|
/** Create a webhook for this channel. Requires Manage Webhooks. */
|
|
1803
1893
|
async createWebhook(options) {
|
|
1804
|
-
const data = await this.client.rest.post(
|
|
1894
|
+
const data = await this.client.rest.post(Routes11.channelWebhooks(this.id), {
|
|
1805
1895
|
body: options,
|
|
1806
1896
|
auth: true
|
|
1807
1897
|
});
|
|
@@ -1809,13 +1899,13 @@ var GuildChannel = class extends Channel {
|
|
|
1809
1899
|
}
|
|
1810
1900
|
/** Fetch all webhooks in this channel. Requires Manage Webhooks. */
|
|
1811
1901
|
async fetchWebhooks() {
|
|
1812
|
-
const data = await this.client.rest.get(
|
|
1902
|
+
const data = await this.client.rest.get(Routes11.channelWebhooks(this.id));
|
|
1813
1903
|
return data.map((w) => new Webhook(this.client, w));
|
|
1814
1904
|
}
|
|
1815
1905
|
/** Create an invite for this channel. Requires Create Instant Invite. */
|
|
1816
1906
|
async createInvite(options) {
|
|
1817
1907
|
const body = options ? toChannelInviteBody(options) : {};
|
|
1818
|
-
const data = await this.client.rest.post(
|
|
1908
|
+
const data = await this.client.rest.post(Routes11.channelInvites(this.id), {
|
|
1819
1909
|
body: Object.keys(body).length ? body : void 0,
|
|
1820
1910
|
auth: true
|
|
1821
1911
|
});
|
|
@@ -1823,12 +1913,12 @@ var GuildChannel = class extends Channel {
|
|
|
1823
1913
|
}
|
|
1824
1914
|
/** Fetch all invites for this channel. Requires Manage Channels. */
|
|
1825
1915
|
async fetchInvites() {
|
|
1826
|
-
const data = await this.client.rest.get(
|
|
1916
|
+
const data = await this.client.rest.get(Routes11.channelInvites(this.id));
|
|
1827
1917
|
return data.map((i) => new Invite(this.client, i));
|
|
1828
1918
|
}
|
|
1829
1919
|
/** Edit or create a permission overwrite. Requires Manage Roles. */
|
|
1830
1920
|
async editPermission(overwriteId, options) {
|
|
1831
|
-
await this.client.rest.put(
|
|
1921
|
+
await this.client.rest.put(Routes11.channelPermission(this.id, overwriteId), {
|
|
1832
1922
|
body: options,
|
|
1833
1923
|
auth: true
|
|
1834
1924
|
});
|
|
@@ -1844,7 +1934,7 @@ var GuildChannel = class extends Channel {
|
|
|
1844
1934
|
}
|
|
1845
1935
|
/** Delete a permission overwrite. Requires Manage Roles. */
|
|
1846
1936
|
async deletePermission(overwriteId) {
|
|
1847
|
-
await this.client.rest.delete(
|
|
1937
|
+
await this.client.rest.delete(Routes11.channelPermission(this.id, overwriteId), { auth: true });
|
|
1848
1938
|
const idx = this.permissionOverwrites.findIndex((o) => o.id === overwriteId);
|
|
1849
1939
|
if (idx >= 0) this.permissionOverwrites.splice(idx, 1);
|
|
1850
1940
|
}
|
|
@@ -1857,7 +1947,7 @@ var GuildChannel = class extends Channel {
|
|
|
1857
1947
|
}
|
|
1858
1948
|
/** Edit this channel's settings. Requires Manage Channels. */
|
|
1859
1949
|
async edit(options) {
|
|
1860
|
-
const data = await this.client.rest.patch(
|
|
1950
|
+
const data = await this.client.rest.patch(Routes11.channel(this.id), {
|
|
1861
1951
|
body: toChannelEditBody(options),
|
|
1862
1952
|
auth: true
|
|
1863
1953
|
});
|
|
@@ -1877,7 +1967,7 @@ var GuildChannel = class extends Channel {
|
|
|
1877
1967
|
const qs2 = params.toString();
|
|
1878
1968
|
const { silent: _s, deleteMessages: _d, ...sudo } = options ?? {};
|
|
1879
1969
|
const body = Object.keys(sudo).length ? toSudoBody(sudo) : void 0;
|
|
1880
|
-
await this.client.rest.delete(
|
|
1970
|
+
await this.client.rest.delete(Routes11.channel(this.id) + (qs2 ? `?${qs2}` : ""), {
|
|
1881
1971
|
body,
|
|
1882
1972
|
auth: true
|
|
1883
1973
|
});
|
|
@@ -1939,7 +2029,7 @@ var LinkChannel = class extends GuildChannel {
|
|
|
1939
2029
|
};
|
|
1940
2030
|
|
|
1941
2031
|
// src/structures/channel/dm.ts
|
|
1942
|
-
import { ChannelType as ChannelType2, Routes as
|
|
2032
|
+
import { ChannelType as ChannelType2, Routes as Routes12 } from "@fluxerjs/types";
|
|
1943
2033
|
var DMChannel = class extends TextCapable(Channel) {
|
|
1944
2034
|
/** ID of the last message sent in this channel. */
|
|
1945
2035
|
lastMessageId;
|
|
@@ -1965,28 +2055,28 @@ var DMChannel = class extends TextCapable(Channel) {
|
|
|
1965
2055
|
});
|
|
1966
2056
|
}
|
|
1967
2057
|
const data = await this.client.rest.post(
|
|
1968
|
-
|
|
2058
|
+
Routes12.channelMessagesPurge(this.id),
|
|
1969
2059
|
{ auth: true }
|
|
1970
2060
|
);
|
|
1971
2061
|
return data.deleted_count;
|
|
1972
2062
|
}
|
|
1973
2063
|
/** Pin this DM channel to the top of the DM list. */
|
|
1974
2064
|
async pinInList() {
|
|
1975
|
-
await this.client.rest.put(
|
|
2065
|
+
await this.client.rest.put(Routes12.userMeChannelPin(this.id), { auth: true });
|
|
1976
2066
|
}
|
|
1977
2067
|
/** Unpin this DM channel from the DM list. */
|
|
1978
2068
|
async unpinFromList() {
|
|
1979
|
-
await this.client.rest.delete(
|
|
2069
|
+
await this.client.rest.delete(Routes12.userMeChannelPin(this.id), { auth: true });
|
|
1980
2070
|
}
|
|
1981
2071
|
/** Add a user to this group DM. */
|
|
1982
2072
|
async addRecipient(userId) {
|
|
1983
|
-
await this.client.rest.put(
|
|
2073
|
+
await this.client.rest.put(Routes12.channelRecipient(this.id, userId), { auth: true });
|
|
1984
2074
|
const user = this.client.users.get(userId) ?? await this.client.users.fetch(userId);
|
|
1985
2075
|
if (user) this.recipients.push(user);
|
|
1986
2076
|
}
|
|
1987
2077
|
/** Remove a user from this group DM. */
|
|
1988
2078
|
async removeRecipient(userId, options) {
|
|
1989
|
-
const url =
|
|
2079
|
+
const url = Routes12.channelRecipient(this.id, userId) + (options?.silent ? "?silent=true" : "");
|
|
1990
2080
|
await this.client.rest.delete(url, { auth: true });
|
|
1991
2081
|
const idx = this.recipients.findIndex((u) => u.id === userId);
|
|
1992
2082
|
if (idx >= 0) this.recipients.splice(idx, 1);
|
|
@@ -2024,8 +2114,8 @@ Channel.createDM = createDM;
|
|
|
2024
2114
|
|
|
2025
2115
|
// src/client/ChannelManager.ts
|
|
2026
2116
|
function rethrowNotFound(err, message, code) {
|
|
2027
|
-
if (err instanceof
|
|
2028
|
-
if (err instanceof
|
|
2117
|
+
if (err instanceof RateLimitError3) throw err;
|
|
2118
|
+
if (err instanceof FluxerAPIError3 && err.statusCode === 404) {
|
|
2029
2119
|
throw new FluxerError(message, { code, cause: err });
|
|
2030
2120
|
}
|
|
2031
2121
|
throw err instanceof FluxerError ? err : new FluxerError(String(err), { cause: err });
|
|
@@ -2057,7 +2147,7 @@ var ChannelManager = class extends Collection5 {
|
|
|
2057
2147
|
const cached = this.get(channelId);
|
|
2058
2148
|
if (cached) return cached;
|
|
2059
2149
|
try {
|
|
2060
|
-
const data = await this.client.rest.get(
|
|
2150
|
+
const data = await this.client.rest.get(Routes13.channel(channelId));
|
|
2061
2151
|
const channel = Channel.fromOrCreate(this.client, data);
|
|
2062
2152
|
if (!channel) {
|
|
2063
2153
|
throw new FluxerError("Channel data invalid or unsupported type", {
|
|
@@ -2090,7 +2180,7 @@ var ChannelManager = class extends Collection5 {
|
|
|
2090
2180
|
defaultAllowedMentions: this.client.options.defaultAllowedMentions
|
|
2091
2181
|
});
|
|
2092
2182
|
const data = await this.client.rest.post(
|
|
2093
|
-
|
|
2183
|
+
Routes13.channelMessages(channelId),
|
|
2094
2184
|
postPayload
|
|
2095
2185
|
);
|
|
2096
2186
|
this.client._addMessageToCache(channelId, data);
|
|
@@ -2100,8 +2190,8 @@ var ChannelManager = class extends Collection5 {
|
|
|
2100
2190
|
|
|
2101
2191
|
// src/client/GuildManager.ts
|
|
2102
2192
|
import { Collection as Collection9 } from "@fluxerjs/collection";
|
|
2103
|
-
import { Routes as
|
|
2104
|
-
import { FluxerAPIError as
|
|
2193
|
+
import { Routes as Routes28 } from "@fluxerjs/types";
|
|
2194
|
+
import { FluxerAPIError as FluxerAPIError5, RateLimitError as RateLimitError4 } from "@fluxerjs/rest";
|
|
2105
2195
|
|
|
2106
2196
|
// src/structures/guild/Guild.ts
|
|
2107
2197
|
import { Collection as Collection8 } from "@fluxerjs/collection";
|
|
@@ -2109,10 +2199,10 @@ import { GuildNSFWLevel } from "@fluxerjs/types";
|
|
|
2109
2199
|
|
|
2110
2200
|
// src/client/GuildMemberManager.ts
|
|
2111
2201
|
import { Collection as Collection7 } from "@fluxerjs/collection";
|
|
2112
|
-
import { Routes as
|
|
2202
|
+
import { Routes as Routes16 } from "@fluxerjs/types";
|
|
2113
2203
|
|
|
2114
2204
|
// src/structures/GuildMember.ts
|
|
2115
|
-
import { Routes as
|
|
2205
|
+
import { Routes as Routes15 } from "@fluxerjs/types";
|
|
2116
2206
|
import { PermissionsBitField } from "@fluxerjs/util";
|
|
2117
2207
|
|
|
2118
2208
|
// src/util/permissions.ts
|
|
@@ -2133,7 +2223,7 @@ function computePermissions(basePermissions, overwrites, memberRoles, memberId,
|
|
|
2133
2223
|
|
|
2134
2224
|
// src/structures/GuildMemberRoleManager.ts
|
|
2135
2225
|
import { Collection as Collection6 } from "@fluxerjs/collection";
|
|
2136
|
-
import { Routes as
|
|
2226
|
+
import { Routes as Routes14 } from "@fluxerjs/types";
|
|
2137
2227
|
function roleId(roleOrId) {
|
|
2138
2228
|
return typeof roleOrId === "string" ? roleOrId : roleOrId.id;
|
|
2139
2229
|
}
|
|
@@ -2162,7 +2252,7 @@ var GuildMemberRoleManager = class {
|
|
|
2162
2252
|
const id = roleId(roleOrId);
|
|
2163
2253
|
if (this.ids.includes(id)) return;
|
|
2164
2254
|
await this.member.client.rest.put(
|
|
2165
|
-
|
|
2255
|
+
Routes14.guildMemberRole(this.member.guild.id, this.member.id, id)
|
|
2166
2256
|
);
|
|
2167
2257
|
this.ids.push(id);
|
|
2168
2258
|
}
|
|
@@ -2171,13 +2261,13 @@ var GuildMemberRoleManager = class {
|
|
|
2171
2261
|
const idx = this.ids.indexOf(id);
|
|
2172
2262
|
if (idx === -1) return;
|
|
2173
2263
|
await this.member.client.rest.delete(
|
|
2174
|
-
|
|
2264
|
+
Routes14.guildMemberRole(this.member.guild.id, this.member.id, id)
|
|
2175
2265
|
);
|
|
2176
2266
|
this.ids.splice(idx, 1);
|
|
2177
2267
|
}
|
|
2178
2268
|
async set(roleIds) {
|
|
2179
2269
|
const data = await this.member.client.rest.patch(
|
|
2180
|
-
|
|
2270
|
+
Routes14.guildMember(this.member.guild.id, this.member.id),
|
|
2181
2271
|
{ body: { roles: roleIds }, auth: true }
|
|
2182
2272
|
);
|
|
2183
2273
|
this.ids = data.roles ? [...data.roles] : [];
|
|
@@ -2304,7 +2394,7 @@ var GuildMember = class _GuildMember extends Base {
|
|
|
2304
2394
|
/** PATCH member (`/members/@me` when editing the bot). */
|
|
2305
2395
|
async edit(options) {
|
|
2306
2396
|
const isMe = this.client.user?.id === this.id;
|
|
2307
|
-
const route = isMe ?
|
|
2397
|
+
const route = isMe ? Routes15.guildMemberMe(this.guild.id) : Routes15.guildMember(this.guild.id, this.id);
|
|
2308
2398
|
const data = await this.client.rest.patch(route, {
|
|
2309
2399
|
body: toMemberEditBody(options),
|
|
2310
2400
|
auth: true
|
|
@@ -2433,7 +2523,7 @@ var GuildMemberManager = class extends Collection7 {
|
|
|
2433
2523
|
if (options?.limit != null) params.set("limit", String(options.limit));
|
|
2434
2524
|
if (options?.after) params.set("after", options.after);
|
|
2435
2525
|
const qs2 = params.toString();
|
|
2436
|
-
const url =
|
|
2526
|
+
const url = Routes16.guildMembers(this.guild.id) + (qs2 ? `?${qs2}` : "");
|
|
2437
2527
|
const data = await this.guild.client.rest.get(url, { auth: true });
|
|
2438
2528
|
const members = [];
|
|
2439
2529
|
for (const m of data) {
|
|
@@ -2456,7 +2546,7 @@ var GuildMemberManager = class extends Collection7 {
|
|
|
2456
2546
|
*/
|
|
2457
2547
|
async search(options = {}) {
|
|
2458
2548
|
const data = await this.guild.client.rest.post(
|
|
2459
|
-
|
|
2549
|
+
Routes16.guildMembersSearch(this.guild.id),
|
|
2460
2550
|
{ body: toMemberSearchBody(options), auth: true }
|
|
2461
2551
|
);
|
|
2462
2552
|
const offset = options.offset ?? 0;
|
|
@@ -2482,7 +2572,7 @@ var GuildMemberManager = class extends Collection7 {
|
|
|
2482
2572
|
};
|
|
2483
2573
|
|
|
2484
2574
|
// src/structures/Role.ts
|
|
2485
|
-
import { Routes as
|
|
2575
|
+
import { Routes as Routes17 } from "@fluxerjs/types";
|
|
2486
2576
|
import { ALL_PERMISSIONS_BIGINT as ALL_PERMISSIONS_BIGINT2, PermissionFlags as PermissionFlags4, PermissionsBitField as PermissionsBitField2 } from "@fluxerjs/util";
|
|
2487
2577
|
|
|
2488
2578
|
// src/structures/roleOptions.ts
|
|
@@ -2595,7 +2685,7 @@ var Role = class _Role extends Base {
|
|
|
2595
2685
|
*/
|
|
2596
2686
|
async edit(options) {
|
|
2597
2687
|
const body = toRoleRequestBody(options);
|
|
2598
|
-
const data = await this.client.rest.patch(
|
|
2688
|
+
const data = await this.client.rest.patch(Routes17.guildRole(this.guildId, this.id), {
|
|
2599
2689
|
body: Object.keys(body).length ? body : void 0,
|
|
2600
2690
|
auth: true
|
|
2601
2691
|
});
|
|
@@ -2606,18 +2696,18 @@ var Role = class _Role extends Base {
|
|
|
2606
2696
|
* DELETE role. Requires Manage Roles.
|
|
2607
2697
|
*/
|
|
2608
2698
|
async delete() {
|
|
2609
|
-
await this.client.rest.delete(
|
|
2699
|
+
await this.client.rest.delete(Routes17.guildRole(this.guildId, this.id), { auth: true });
|
|
2610
2700
|
this.client.guilds.get(this.guildId)?.roles.delete(this.id);
|
|
2611
2701
|
}
|
|
2612
2702
|
};
|
|
2613
2703
|
|
|
2614
2704
|
// src/structures/guild/admin.ts
|
|
2615
|
-
import { Routes as
|
|
2705
|
+
import { Routes as Routes18 } from "@fluxerjs/types";
|
|
2616
2706
|
|
|
2617
2707
|
// src/structures/guild/http.ts
|
|
2618
|
-
import { FluxerAPIError as
|
|
2708
|
+
import { FluxerAPIError as FluxerAPIError4 } from "@fluxerjs/rest";
|
|
2619
2709
|
function httpStatus(err) {
|
|
2620
|
-
if (err instanceof
|
|
2710
|
+
if (err instanceof FluxerAPIError4) return err.statusCode;
|
|
2621
2711
|
if (typeof err === "object" && err !== null && "statusCode" in err) {
|
|
2622
2712
|
const code = err.statusCode;
|
|
2623
2713
|
return typeof code === "number" ? code : void 0;
|
|
@@ -2717,7 +2807,7 @@ function toVanityPayload(data) {
|
|
|
2717
2807
|
return { code: data.code ?? null, uses: data.uses };
|
|
2718
2808
|
}
|
|
2719
2809
|
async function fetchAuditLogs(guild, options) {
|
|
2720
|
-
const url =
|
|
2810
|
+
const url = Routes18.guildAuditLogs(guild.id) + qs({
|
|
2721
2811
|
limit: options?.limit,
|
|
2722
2812
|
before: options?.before,
|
|
2723
2813
|
after: options?.after,
|
|
@@ -2738,7 +2828,7 @@ async function fetchAuditLogs(guild, options) {
|
|
|
2738
2828
|
};
|
|
2739
2829
|
}
|
|
2740
2830
|
async function editGuild(guild, options) {
|
|
2741
|
-
const data = await guild.client.rest.patch(
|
|
2831
|
+
const data = await guild.client.rest.patch(Routes18.guild(guild.id), {
|
|
2742
2832
|
body: toGuildEditBody(options),
|
|
2743
2833
|
auth: true
|
|
2744
2834
|
});
|
|
@@ -2746,13 +2836,13 @@ async function editGuild(guild, options) {
|
|
|
2746
2836
|
return guild;
|
|
2747
2837
|
}
|
|
2748
2838
|
async function fetchVanityURL(guild) {
|
|
2749
|
-
const data = await guild.client.rest.get(
|
|
2839
|
+
const data = await guild.client.rest.get(Routes18.guildVanityUrl(guild.id), {
|
|
2750
2840
|
auth: true
|
|
2751
2841
|
});
|
|
2752
2842
|
return toVanityPayload(data);
|
|
2753
2843
|
}
|
|
2754
2844
|
async function editVanityURL(guild, code) {
|
|
2755
|
-
const data = await guild.client.rest.patch(
|
|
2845
|
+
const data = await guild.client.rest.patch(Routes18.guildVanityUrl(guild.id), {
|
|
2756
2846
|
body: { code },
|
|
2757
2847
|
auth: true
|
|
2758
2848
|
});
|
|
@@ -2760,14 +2850,14 @@ async function editVanityURL(guild, code) {
|
|
|
2760
2850
|
return toVanityPayload(data);
|
|
2761
2851
|
}
|
|
2762
2852
|
async function fetchDiscoveryStatus(guild) {
|
|
2763
|
-
const data = await guild.client.rest.get(
|
|
2853
|
+
const data = await guild.client.rest.get(Routes18.guildDiscovery(guild.id), {
|
|
2764
2854
|
auth: true
|
|
2765
2855
|
});
|
|
2766
2856
|
return toDiscoveryStatusPayload(data);
|
|
2767
2857
|
}
|
|
2768
2858
|
async function applyForDiscovery(guild, options) {
|
|
2769
2859
|
const data = await guild.client.rest.post(
|
|
2770
|
-
|
|
2860
|
+
Routes18.guildDiscovery(guild.id),
|
|
2771
2861
|
{
|
|
2772
2862
|
body: toDiscoveryBody(options),
|
|
2773
2863
|
auth: true
|
|
@@ -2777,7 +2867,7 @@ async function applyForDiscovery(guild, options) {
|
|
|
2777
2867
|
}
|
|
2778
2868
|
async function editDiscoveryApplication(guild, options) {
|
|
2779
2869
|
const data = await guild.client.rest.patch(
|
|
2780
|
-
|
|
2870
|
+
Routes18.guildDiscovery(guild.id),
|
|
2781
2871
|
{
|
|
2782
2872
|
body: toDiscoveryBody(options),
|
|
2783
2873
|
auth: true
|
|
@@ -2786,28 +2876,28 @@ async function editDiscoveryApplication(guild, options) {
|
|
|
2786
2876
|
return toDiscoveryApplicationPayload(data);
|
|
2787
2877
|
}
|
|
2788
2878
|
async function withdrawDiscoveryApplication(guild) {
|
|
2789
|
-
await guild.client.rest.delete(
|
|
2879
|
+
await guild.client.rest.delete(Routes18.guildDiscovery(guild.id), { auth: true });
|
|
2790
2880
|
}
|
|
2791
2881
|
async function deleteGuild(guild, options) {
|
|
2792
2882
|
const body = options ? toSudoBody(options) : {};
|
|
2793
|
-
await guild.client.rest.post(
|
|
2883
|
+
await guild.client.rest.post(Routes18.guildDelete(guild.id), {
|
|
2794
2884
|
body,
|
|
2795
2885
|
auth: true
|
|
2796
2886
|
});
|
|
2797
2887
|
guild.client.guilds.delete(guild.id);
|
|
2798
2888
|
}
|
|
2799
2889
|
async function transferOwnership(guild, newOwnerId, password) {
|
|
2800
|
-
await guild.client.rest.post(
|
|
2890
|
+
await guild.client.rest.post(Routes18.guildTransferOwnership(guild.id), {
|
|
2801
2891
|
body: { new_owner_id: newOwnerId, ...password != null && { password } },
|
|
2802
2892
|
auth: true
|
|
2803
2893
|
});
|
|
2804
2894
|
}
|
|
2805
2895
|
|
|
2806
2896
|
// src/structures/guild/channels.ts
|
|
2807
|
-
import { Routes as
|
|
2897
|
+
import { Routes as Routes21 } from "@fluxerjs/types";
|
|
2808
2898
|
|
|
2809
2899
|
// src/structures/GuildEmoji.ts
|
|
2810
|
-
import { Routes as
|
|
2900
|
+
import { Routes as Routes19 } from "@fluxerjs/types";
|
|
2811
2901
|
var GuildEmoji = class extends Base {
|
|
2812
2902
|
client;
|
|
2813
2903
|
id;
|
|
@@ -2835,7 +2925,7 @@ var GuildEmoji = class extends Base {
|
|
|
2835
2925
|
}
|
|
2836
2926
|
/** Delete this emoji. Requires Manage Emojis and Stickers permission. */
|
|
2837
2927
|
async delete() {
|
|
2838
|
-
await this.client.rest.delete(
|
|
2928
|
+
await this.client.rest.delete(Routes19.guildEmoji(this.guildId, this.id), {
|
|
2839
2929
|
auth: true
|
|
2840
2930
|
});
|
|
2841
2931
|
const guild = this.client.guilds.get(this.guildId);
|
|
@@ -2846,7 +2936,7 @@ var GuildEmoji = class extends Base {
|
|
|
2846
2936
|
* Requires Manage Emojis and Stickers permission.
|
|
2847
2937
|
*/
|
|
2848
2938
|
async edit(options) {
|
|
2849
|
-
const data = await this.client.rest.patch(
|
|
2939
|
+
const data = await this.client.rest.patch(Routes19.guildEmoji(this.guildId, this.id), {
|
|
2850
2940
|
body: options,
|
|
2851
2941
|
auth: true
|
|
2852
2942
|
});
|
|
@@ -2856,7 +2946,7 @@ var GuildEmoji = class extends Base {
|
|
|
2856
2946
|
};
|
|
2857
2947
|
|
|
2858
2948
|
// src/structures/GuildSticker.ts
|
|
2859
|
-
import { Routes as
|
|
2949
|
+
import { Routes as Routes20 } from "@fluxerjs/types";
|
|
2860
2950
|
var GuildSticker = class extends Base {
|
|
2861
2951
|
client;
|
|
2862
2952
|
id;
|
|
@@ -2887,7 +2977,7 @@ var GuildSticker = class extends Base {
|
|
|
2887
2977
|
}
|
|
2888
2978
|
/** Delete this sticker. Requires Manage Emojis and Stickers permission. */
|
|
2889
2979
|
async delete() {
|
|
2890
|
-
await this.client.rest.delete(
|
|
2980
|
+
await this.client.rest.delete(Routes20.guildSticker(this.guildId, this.id), {
|
|
2891
2981
|
auth: true
|
|
2892
2982
|
});
|
|
2893
2983
|
}
|
|
@@ -2896,7 +2986,7 @@ var GuildSticker = class extends Base {
|
|
|
2896
2986
|
* Requires Manage Emojis and Stickers permission.
|
|
2897
2987
|
*/
|
|
2898
2988
|
async edit(options) {
|
|
2899
|
-
const data = await this.client.rest.patch(
|
|
2989
|
+
const data = await this.client.rest.patch(Routes20.guildSticker(this.guildId, this.id), {
|
|
2900
2990
|
body: options,
|
|
2901
2991
|
auth: true
|
|
2902
2992
|
});
|
|
@@ -2951,14 +3041,14 @@ function cacheSticker(guild, data) {
|
|
|
2951
3041
|
|
|
2952
3042
|
// src/structures/guild/channels.ts
|
|
2953
3043
|
async function createChannel(guild, data) {
|
|
2954
|
-
const created = await guild.client.rest.post(
|
|
3044
|
+
const created = await guild.client.rest.post(Routes21.guildChannels(guild.id), {
|
|
2955
3045
|
body: data,
|
|
2956
3046
|
auth: true
|
|
2957
3047
|
});
|
|
2958
3048
|
return cacheChannel(guild, created);
|
|
2959
3049
|
}
|
|
2960
3050
|
async function fetchChannels(guild) {
|
|
2961
|
-
const data = await guild.client.rest.get(
|
|
3051
|
+
const data = await guild.client.rest.get(Routes21.guildChannels(guild.id));
|
|
2962
3052
|
const channels = [];
|
|
2963
3053
|
for (const ch of data) {
|
|
2964
3054
|
const channel = cacheChannel(guild, ch);
|
|
@@ -2967,17 +3057,17 @@ async function fetchChannels(guild) {
|
|
|
2967
3057
|
return channels;
|
|
2968
3058
|
}
|
|
2969
3059
|
async function setChannelPositions(guild, updates) {
|
|
2970
|
-
await guild.client.rest.patch(
|
|
3060
|
+
await guild.client.rest.patch(Routes21.guildChannels(guild.id), {
|
|
2971
3061
|
body: toChannelPositionBody(updates),
|
|
2972
3062
|
auth: true
|
|
2973
3063
|
});
|
|
2974
3064
|
}
|
|
2975
3065
|
async function fetchWebhooks(guild) {
|
|
2976
|
-
const data = await guild.client.rest.get(
|
|
3066
|
+
const data = await guild.client.rest.get(Routes21.guildWebhooks(guild.id));
|
|
2977
3067
|
return data.map((w) => new Webhook(guild.client, w));
|
|
2978
3068
|
}
|
|
2979
3069
|
async function fetchInvites(guild) {
|
|
2980
|
-
const data = await guild.client.rest.get(
|
|
3070
|
+
const data = await guild.client.rest.get(Routes21.guildInvites(guild.id));
|
|
2981
3071
|
return data.map((invite) => new Invite(guild.client, invite));
|
|
2982
3072
|
}
|
|
2983
3073
|
async function fetchInvite(guild, codeOrUrl) {
|
|
@@ -2985,14 +3075,14 @@ async function fetchInvite(guild, codeOrUrl) {
|
|
|
2985
3075
|
}
|
|
2986
3076
|
|
|
2987
3077
|
// src/structures/guild/emojis.ts
|
|
2988
|
-
import { Routes as
|
|
3078
|
+
import { Routes as Routes22 } from "@fluxerjs/types";
|
|
2989
3079
|
async function fetchEmojis(guild) {
|
|
2990
|
-
const data = await guild.client.rest.get(
|
|
3080
|
+
const data = await guild.client.rest.get(Routes22.guildEmojis(guild.id));
|
|
2991
3081
|
return data.map((e) => cacheEmoji(guild, e));
|
|
2992
3082
|
}
|
|
2993
3083
|
async function fetchEmoji(guild, emojiId) {
|
|
2994
3084
|
try {
|
|
2995
|
-
const data = await guild.client.rest.get(
|
|
3085
|
+
const data = await guild.client.rest.get(Routes22.guildEmoji(guild.id, emojiId));
|
|
2996
3086
|
return cacheEmoji(guild, data);
|
|
2997
3087
|
} catch (err) {
|
|
2998
3088
|
rethrowNotFound2(
|
|
@@ -3003,14 +3093,14 @@ async function fetchEmoji(guild, emojiId) {
|
|
|
3003
3093
|
}
|
|
3004
3094
|
}
|
|
3005
3095
|
async function createEmoji(guild, options) {
|
|
3006
|
-
const data = await guild.client.rest.post(
|
|
3096
|
+
const data = await guild.client.rest.post(Routes22.guildEmojis(guild.id), {
|
|
3007
3097
|
body: options,
|
|
3008
3098
|
auth: true
|
|
3009
3099
|
});
|
|
3010
3100
|
return cacheEmoji(guild, data);
|
|
3011
3101
|
}
|
|
3012
3102
|
async function cloneEmoji(guild, sourceEmojiId) {
|
|
3013
|
-
const data = await guild.client.rest.post(
|
|
3103
|
+
const data = await guild.client.rest.post(Routes22.guildEmojisClone(guild.id), {
|
|
3014
3104
|
body: { source_emoji_id: sourceEmojiId },
|
|
3015
3105
|
auth: true
|
|
3016
3106
|
});
|
|
@@ -3018,18 +3108,18 @@ async function cloneEmoji(guild, sourceEmojiId) {
|
|
|
3018
3108
|
}
|
|
3019
3109
|
async function createEmojisBulk(guild, emojis) {
|
|
3020
3110
|
const data = await guild.client.rest.post(
|
|
3021
|
-
|
|
3111
|
+
Routes22.guildEmojisBulk(guild.id),
|
|
3022
3112
|
{ body: { emojis }, auth: true }
|
|
3023
3113
|
);
|
|
3024
3114
|
return { success: data.success.map((e) => cacheEmoji(guild, e)), failed: data.failed };
|
|
3025
3115
|
}
|
|
3026
3116
|
|
|
3027
3117
|
// src/structures/guild/members.ts
|
|
3028
|
-
import { Routes as
|
|
3118
|
+
import { Routes as Routes23 } from "@fluxerjs/types";
|
|
3029
3119
|
async function fetchMember(guild, userId) {
|
|
3030
3120
|
try {
|
|
3031
3121
|
const data = await guild.client.rest.get(
|
|
3032
|
-
|
|
3122
|
+
Routes23.guildMember(guild.id, userId)
|
|
3033
3123
|
);
|
|
3034
3124
|
return cacheMember(guild, data);
|
|
3035
3125
|
} catch (err) {
|
|
@@ -3042,17 +3132,17 @@ async function fetchMember(guild, userId) {
|
|
|
3042
3132
|
}
|
|
3043
3133
|
async function fetchMe(guild) {
|
|
3044
3134
|
const data = await guild.client.rest.get(
|
|
3045
|
-
|
|
3135
|
+
Routes23.guildMemberMe(guild.id),
|
|
3046
3136
|
{ auth: true }
|
|
3047
3137
|
);
|
|
3048
3138
|
return cacheMember(guild, data);
|
|
3049
3139
|
}
|
|
3050
3140
|
|
|
3051
3141
|
// src/structures/guild/moderation.ts
|
|
3052
|
-
import { Routes as
|
|
3142
|
+
import { Routes as Routes25 } from "@fluxerjs/types";
|
|
3053
3143
|
|
|
3054
3144
|
// src/structures/GuildBan.ts
|
|
3055
|
-
import { Routes as
|
|
3145
|
+
import { Routes as Routes24 } from "@fluxerjs/types";
|
|
3056
3146
|
var GuildBan = class extends Base {
|
|
3057
3147
|
client;
|
|
3058
3148
|
guildId;
|
|
@@ -3074,7 +3164,7 @@ var GuildBan = class extends Base {
|
|
|
3074
3164
|
* Requires Ban Members permission.
|
|
3075
3165
|
*/
|
|
3076
3166
|
async unban() {
|
|
3077
|
-
await this.client.rest.delete(
|
|
3167
|
+
await this.client.rest.delete(Routes24.guildBan(this.guildId, this.user.id), {
|
|
3078
3168
|
auth: true
|
|
3079
3169
|
});
|
|
3080
3170
|
}
|
|
@@ -3083,40 +3173,40 @@ var GuildBan = class extends Base {
|
|
|
3083
3173
|
// src/structures/guild/moderation.ts
|
|
3084
3174
|
async function ban(guild, userId, options) {
|
|
3085
3175
|
const body = options ? toGuildBanBody(options) : {};
|
|
3086
|
-
await guild.client.rest.put(
|
|
3176
|
+
await guild.client.rest.put(Routes25.guildBan(guild.id, userId), {
|
|
3087
3177
|
body: Object.keys(body).length ? body : void 0,
|
|
3088
3178
|
auth: true
|
|
3089
3179
|
});
|
|
3090
3180
|
}
|
|
3091
3181
|
async function fetchBans(guild) {
|
|
3092
|
-
const data = await guild.client.rest.get(
|
|
3182
|
+
const data = await guild.client.rest.get(Routes25.guildBans(guild.id));
|
|
3093
3183
|
return data.map((b) => new GuildBan(guild.client, { ...b, guild_id: guild.id }, guild.id));
|
|
3094
3184
|
}
|
|
3095
3185
|
async function unban(guild, userId) {
|
|
3096
|
-
await guild.client.rest.delete(
|
|
3186
|
+
await guild.client.rest.delete(Routes25.guildBan(guild.id, userId), { auth: true });
|
|
3097
3187
|
}
|
|
3098
3188
|
async function kick(guild, userId) {
|
|
3099
|
-
await guild.client.rest.delete(
|
|
3189
|
+
await guild.client.rest.delete(Routes25.guildMember(guild.id, userId), { auth: true });
|
|
3100
3190
|
}
|
|
3101
3191
|
|
|
3102
3192
|
// src/structures/guild/roles.ts
|
|
3103
|
-
import { Routes as
|
|
3193
|
+
import { Routes as Routes26 } from "@fluxerjs/types";
|
|
3104
3194
|
import { parseRoleMention } from "@fluxerjs/util";
|
|
3105
3195
|
async function createRole(guild, options = {}) {
|
|
3106
3196
|
const body = toRoleRequestBody(options);
|
|
3107
|
-
const data = await guild.client.rest.post(
|
|
3197
|
+
const data = await guild.client.rest.post(Routes26.guildRoles(guild.id), {
|
|
3108
3198
|
body: Object.keys(body).length ? body : void 0,
|
|
3109
3199
|
auth: true
|
|
3110
3200
|
});
|
|
3111
3201
|
return cacheRole(guild, data);
|
|
3112
3202
|
}
|
|
3113
3203
|
async function fetchRoles(guild) {
|
|
3114
|
-
const data = await guild.client.rest.get(
|
|
3204
|
+
const data = await guild.client.rest.get(Routes26.guildRoles(guild.id));
|
|
3115
3205
|
return data.map((r) => cacheRole(guild, r));
|
|
3116
3206
|
}
|
|
3117
3207
|
async function fetchRole(guild, roleId2) {
|
|
3118
3208
|
try {
|
|
3119
|
-
const data = await guild.client.rest.get(
|
|
3209
|
+
const data = await guild.client.rest.get(Routes26.guildRole(guild.id, roleId2));
|
|
3120
3210
|
return cacheRole(guild, data);
|
|
3121
3211
|
} catch (err) {
|
|
3122
3212
|
rethrowNotFound2(
|
|
@@ -3134,7 +3224,7 @@ async function resolveRoleId(guild, arg) {
|
|
|
3134
3224
|
const needle = trimmed.toLowerCase();
|
|
3135
3225
|
const cached = guild.roles.find((r) => r.name?.toLowerCase() === needle);
|
|
3136
3226
|
if (cached) return cached.id;
|
|
3137
|
-
const roles = await guild.client.rest.get(
|
|
3227
|
+
const roles = await guild.client.rest.get(Routes26.guildRoles(guild.id));
|
|
3138
3228
|
const role = roles.find((r) => r.name?.toLowerCase() === needle);
|
|
3139
3229
|
if (!role) return null;
|
|
3140
3230
|
cacheRole(guild, role);
|
|
@@ -3143,7 +3233,7 @@ async function resolveRoleId(guild, arg) {
|
|
|
3143
3233
|
async function setRolePositions(guild, updates) {
|
|
3144
3234
|
return replaceRoles(
|
|
3145
3235
|
guild,
|
|
3146
|
-
await guild.client.rest.patch(
|
|
3236
|
+
await guild.client.rest.patch(Routes26.guildRoles(guild.id), {
|
|
3147
3237
|
body: updates,
|
|
3148
3238
|
auth: true
|
|
3149
3239
|
})
|
|
@@ -3152,7 +3242,7 @@ async function setRolePositions(guild, updates) {
|
|
|
3152
3242
|
async function setRoleHoistPositions(guild, updates) {
|
|
3153
3243
|
return replaceRoles(
|
|
3154
3244
|
guild,
|
|
3155
|
-
await guild.client.rest.patch(
|
|
3245
|
+
await guild.client.rest.patch(Routes26.guildRolesHoistPositions(guild.id), {
|
|
3156
3246
|
body: updates.map((u) => ({
|
|
3157
3247
|
id: u.id,
|
|
3158
3248
|
...u.hoistPosition !== void 0 ? { hoist_position: u.hoistPosition } : {}
|
|
@@ -3164,23 +3254,23 @@ async function setRoleHoistPositions(guild, updates) {
|
|
|
3164
3254
|
async function resetRoleHoistPositions(guild) {
|
|
3165
3255
|
return replaceRoles(
|
|
3166
3256
|
guild,
|
|
3167
|
-
await guild.client.rest.delete(
|
|
3257
|
+
await guild.client.rest.delete(Routes26.guildRolesHoistPositions(guild.id), {
|
|
3168
3258
|
auth: true
|
|
3169
3259
|
})
|
|
3170
3260
|
);
|
|
3171
3261
|
}
|
|
3172
3262
|
|
|
3173
3263
|
// src/structures/guild/stickers.ts
|
|
3174
|
-
import { Routes as
|
|
3264
|
+
import { Routes as Routes27 } from "@fluxerjs/types";
|
|
3175
3265
|
async function createSticker(guild, options) {
|
|
3176
|
-
const data = await guild.client.rest.post(
|
|
3266
|
+
const data = await guild.client.rest.post(Routes27.guildStickers(guild.id), {
|
|
3177
3267
|
body: options,
|
|
3178
3268
|
auth: true
|
|
3179
3269
|
});
|
|
3180
3270
|
return cacheSticker(guild, data);
|
|
3181
3271
|
}
|
|
3182
3272
|
async function cloneSticker(guild, sourceStickerId) {
|
|
3183
|
-
const data = await guild.client.rest.post(
|
|
3273
|
+
const data = await guild.client.rest.post(Routes27.guildStickersClone(guild.id), {
|
|
3184
3274
|
body: { source_sticker_id: sourceStickerId },
|
|
3185
3275
|
auth: true
|
|
3186
3276
|
});
|
|
@@ -3188,17 +3278,17 @@ async function cloneSticker(guild, sourceStickerId) {
|
|
|
3188
3278
|
}
|
|
3189
3279
|
async function createStickersBulk(guild, stickers) {
|
|
3190
3280
|
const data = await guild.client.rest.post(
|
|
3191
|
-
|
|
3281
|
+
Routes27.guildStickersBulk(guild.id),
|
|
3192
3282
|
{ body: { stickers }, auth: true }
|
|
3193
3283
|
);
|
|
3194
3284
|
return { success: data.success.map((s) => cacheSticker(guild, s)), failed: data.failed };
|
|
3195
3285
|
}
|
|
3196
3286
|
async function fetchStickers(guild) {
|
|
3197
|
-
const data = await guild.client.rest.get(
|
|
3287
|
+
const data = await guild.client.rest.get(Routes27.guildStickers(guild.id));
|
|
3198
3288
|
return data.map((s) => cacheSticker(guild, s));
|
|
3199
3289
|
}
|
|
3200
3290
|
async function fetchSticker(guild, stickerId) {
|
|
3201
|
-
const data = await guild.client.rest.get(
|
|
3291
|
+
const data = await guild.client.rest.get(Routes27.guildSticker(guild.id, stickerId));
|
|
3202
3292
|
return cacheSticker(guild, data);
|
|
3203
3293
|
}
|
|
3204
3294
|
|
|
@@ -3545,13 +3635,13 @@ var GuildManager = class extends Collection9 {
|
|
|
3545
3635
|
const cached = this.get(guildId);
|
|
3546
3636
|
if (cached) return cached;
|
|
3547
3637
|
try {
|
|
3548
|
-
const data = await this.client.rest.get(
|
|
3638
|
+
const data = await this.client.rest.get(Routes28.guild(guildId));
|
|
3549
3639
|
const guild = new Guild(this.client, data);
|
|
3550
3640
|
this.set(guild.id, guild);
|
|
3551
3641
|
return guild;
|
|
3552
3642
|
} catch (err) {
|
|
3553
|
-
if (err instanceof
|
|
3554
|
-
if (err instanceof
|
|
3643
|
+
if (err instanceof RateLimitError4) throw err;
|
|
3644
|
+
if (err instanceof FluxerAPIError5 && err.statusCode === 404) {
|
|
3555
3645
|
throw new FluxerError(`Guild ${guildId} not found`, {
|
|
3556
3646
|
code: ErrorCodes.GuildNotFound,
|
|
3557
3647
|
cause: err
|
|
@@ -3572,7 +3662,7 @@ var DEFAULT_CACHE_LIMITS = {
|
|
|
3572
3662
|
};
|
|
3573
3663
|
|
|
3574
3664
|
// src/structures/User.ts
|
|
3575
|
-
import { Routes as
|
|
3665
|
+
import { Routes as Routes29 } from "@fluxerjs/types";
|
|
3576
3666
|
var User = class extends Base {
|
|
3577
3667
|
/** Parent client instance. */
|
|
3578
3668
|
client;
|
|
@@ -3662,7 +3752,7 @@ var User = class extends Base {
|
|
|
3662
3752
|
* @returns DM channel instance (cached if already open)
|
|
3663
3753
|
*/
|
|
3664
3754
|
async createDM() {
|
|
3665
|
-
const data = await this.client.rest.post(
|
|
3755
|
+
const data = await this.client.rest.post(Routes29.userMeChannels(), {
|
|
3666
3756
|
body: { recipient_id: this.id },
|
|
3667
3757
|
auth: true
|
|
3668
3758
|
});
|
|
@@ -3683,7 +3773,7 @@ var User = class extends Base {
|
|
|
3683
3773
|
// src/client/UserManager.ts
|
|
3684
3774
|
import { Collection as Collection10 } from "@fluxerjs/collection";
|
|
3685
3775
|
import {
|
|
3686
|
-
Routes as
|
|
3776
|
+
Routes as Routes30
|
|
3687
3777
|
} from "@fluxerjs/types";
|
|
3688
3778
|
var soft = (p) => p.catch(() => null);
|
|
3689
3779
|
var UserManager = class extends Collection10 {
|
|
@@ -3715,7 +3805,7 @@ var UserManager = class extends Collection10 {
|
|
|
3715
3805
|
}
|
|
3716
3806
|
/** Fetch a user by ID and update cache. */
|
|
3717
3807
|
async fetch(userId) {
|
|
3718
|
-
const data = await this.client.rest.get(
|
|
3808
|
+
const data = await this.client.rest.get(Routes30.user(userId));
|
|
3719
3809
|
return this.client.getOrCreateUser(data);
|
|
3720
3810
|
}
|
|
3721
3811
|
/**
|
|
@@ -3729,10 +3819,10 @@ var UserManager = class extends Collection10 {
|
|
|
3729
3819
|
async fetchWithProfile(userId, options) {
|
|
3730
3820
|
const guildId = options?.guildId ?? void 0;
|
|
3731
3821
|
const [userData, globalProfileRaw, serverProfileRaw, memberData] = await Promise.all([
|
|
3732
|
-
this.client.rest.get(
|
|
3733
|
-
soft(this.client.rest.get(
|
|
3734
|
-
guildId ? soft(this.client.rest.get(
|
|
3735
|
-
guildId ? soft(this.client.rest.get(
|
|
3822
|
+
this.client.rest.get(Routes30.user(userId)),
|
|
3823
|
+
soft(this.client.rest.get(Routes30.userProfile(userId))),
|
|
3824
|
+
guildId ? soft(this.client.rest.get(Routes30.userProfile(userId, guildId))) : null,
|
|
3825
|
+
guildId ? soft(this.client.rest.get(Routes30.guildMember(guildId, userId))) : null
|
|
3736
3826
|
]);
|
|
3737
3827
|
const user = this.client.getOrCreateUser(userData);
|
|
3738
3828
|
let member = null;
|
|
@@ -3762,7 +3852,7 @@ var UserManager = class extends Collection10 {
|
|
|
3762
3852
|
|
|
3763
3853
|
// src/client/PackManager.ts
|
|
3764
3854
|
import {
|
|
3765
|
-
Routes as
|
|
3855
|
+
Routes as Routes31
|
|
3766
3856
|
} from "@fluxerjs/types";
|
|
3767
3857
|
function toPackSummaryPayload(data) {
|
|
3768
3858
|
return {
|
|
@@ -3818,7 +3908,7 @@ var PackManager = class {
|
|
|
3818
3908
|
}
|
|
3819
3909
|
/** Fetch the current user's pack dashboard (camelCase summaries). */
|
|
3820
3910
|
async fetchDashboard() {
|
|
3821
|
-
const data = await this.client.rest.get(
|
|
3911
|
+
const data = await this.client.rest.get(Routes31.packs());
|
|
3822
3912
|
return {
|
|
3823
3913
|
emoji: mapDashboardSection(data.emoji),
|
|
3824
3914
|
sticker: mapDashboardSection(data.sticker)
|
|
@@ -3826,49 +3916,49 @@ var PackManager = class {
|
|
|
3826
3916
|
}
|
|
3827
3917
|
/** Create a pack. */
|
|
3828
3918
|
async create(packType, body) {
|
|
3829
|
-
const data = await this.client.rest.post(
|
|
3919
|
+
const data = await this.client.rest.post(Routes31.packsByType(packType), {
|
|
3830
3920
|
body
|
|
3831
3921
|
});
|
|
3832
3922
|
return toPackSummaryPayload(data);
|
|
3833
3923
|
}
|
|
3834
3924
|
/** Edit a pack. */
|
|
3835
3925
|
async edit(packId, body) {
|
|
3836
|
-
const data = await this.client.rest.patch(
|
|
3926
|
+
const data = await this.client.rest.patch(Routes31.pack(packId), { body });
|
|
3837
3927
|
return toPackSummaryPayload(data);
|
|
3838
3928
|
}
|
|
3839
3929
|
/** Delete a pack. */
|
|
3840
3930
|
async delete(packId) {
|
|
3841
|
-
await this.client.rest.delete(
|
|
3931
|
+
await this.client.rest.delete(Routes31.pack(packId));
|
|
3842
3932
|
}
|
|
3843
3933
|
/** Install a pack for the current user. */
|
|
3844
3934
|
async install(packId) {
|
|
3845
|
-
await this.client.rest.post(
|
|
3935
|
+
await this.client.rest.post(Routes31.packInstall(packId));
|
|
3846
3936
|
}
|
|
3847
3937
|
/** Uninstall a pack for the current user. */
|
|
3848
3938
|
async uninstall(packId) {
|
|
3849
|
-
await this.client.rest.delete(
|
|
3939
|
+
await this.client.rest.delete(Routes31.packInstall(packId));
|
|
3850
3940
|
}
|
|
3851
3941
|
/** List invites for a pack. */
|
|
3852
3942
|
async listInvites(packId) {
|
|
3853
|
-
const data = await this.client.rest.get(
|
|
3943
|
+
const data = await this.client.rest.get(Routes31.packInvites(packId));
|
|
3854
3944
|
return data.map(toInvitePayload);
|
|
3855
3945
|
}
|
|
3856
3946
|
/** Create an invite for a pack. */
|
|
3857
3947
|
async createInvite(packId, options = {}) {
|
|
3858
3948
|
const body = toPackInviteBody(options);
|
|
3859
|
-
const data = await this.client.rest.post(
|
|
3949
|
+
const data = await this.client.rest.post(Routes31.packInvites(packId), {
|
|
3860
3950
|
body: Object.keys(body).length ? body : void 0
|
|
3861
3951
|
});
|
|
3862
3952
|
return toInvitePayload(data);
|
|
3863
3953
|
}
|
|
3864
3954
|
/** List emojis in a pack. */
|
|
3865
3955
|
async listEmojis(packId) {
|
|
3866
|
-
const data = await this.client.rest.get(
|
|
3956
|
+
const data = await this.client.rest.get(Routes31.packEmojis(packId));
|
|
3867
3957
|
return data.map(toEmojiPayload);
|
|
3868
3958
|
}
|
|
3869
3959
|
/** Create an emoji in a pack. */
|
|
3870
3960
|
async createEmoji(packId, options) {
|
|
3871
|
-
const data = await this.client.rest.post(
|
|
3961
|
+
const data = await this.client.rest.post(Routes31.packEmojis(packId), {
|
|
3872
3962
|
body: toEmojiCreateBody(options)
|
|
3873
3963
|
});
|
|
3874
3964
|
return toEmojiPayload(data);
|
|
@@ -3876,7 +3966,7 @@ var PackManager = class {
|
|
|
3876
3966
|
/** Bulk-create emojis in a pack. */
|
|
3877
3967
|
async createEmojisBulk(packId, emojis) {
|
|
3878
3968
|
const data = await this.client.rest.post(
|
|
3879
|
-
|
|
3969
|
+
Routes31.packEmojisBulk(packId),
|
|
3880
3970
|
{ body: { emojis: emojis.map(toEmojiCreateBody) } }
|
|
3881
3971
|
);
|
|
3882
3972
|
return {
|
|
@@ -3886,23 +3976,23 @@ var PackManager = class {
|
|
|
3886
3976
|
}
|
|
3887
3977
|
/** Edit an emoji in a pack. */
|
|
3888
3978
|
async editEmoji(packId, emojiId, options) {
|
|
3889
|
-
const data = await this.client.rest.patch(
|
|
3979
|
+
const data = await this.client.rest.patch(Routes31.packEmoji(packId, emojiId), {
|
|
3890
3980
|
body: toEmojiEditBody(options)
|
|
3891
3981
|
});
|
|
3892
3982
|
return toEmojiPayload(data);
|
|
3893
3983
|
}
|
|
3894
3984
|
/** Delete an emoji from a pack. */
|
|
3895
3985
|
async deleteEmoji(packId, emojiId) {
|
|
3896
|
-
await this.client.rest.delete(
|
|
3986
|
+
await this.client.rest.delete(Routes31.packEmoji(packId, emojiId));
|
|
3897
3987
|
}
|
|
3898
3988
|
/** List stickers in a pack. */
|
|
3899
3989
|
async listStickers(packId) {
|
|
3900
|
-
const data = await this.client.rest.get(
|
|
3990
|
+
const data = await this.client.rest.get(Routes31.packStickers(packId));
|
|
3901
3991
|
return data.map(toStickerPayload);
|
|
3902
3992
|
}
|
|
3903
3993
|
/** Create a sticker in a pack. */
|
|
3904
3994
|
async createSticker(packId, options) {
|
|
3905
|
-
const data = await this.client.rest.post(
|
|
3995
|
+
const data = await this.client.rest.post(Routes31.packStickers(packId), {
|
|
3906
3996
|
body: toStickerCreateBody(options)
|
|
3907
3997
|
});
|
|
3908
3998
|
return toStickerPayload(data);
|
|
@@ -3910,7 +4000,7 @@ var PackManager = class {
|
|
|
3910
4000
|
/** Bulk-create stickers in a pack. */
|
|
3911
4001
|
async createStickersBulk(packId, stickers) {
|
|
3912
4002
|
const data = await this.client.rest.post(
|
|
3913
|
-
|
|
4003
|
+
Routes31.packStickersBulk(packId),
|
|
3914
4004
|
{ body: { stickers: stickers.map(toStickerCreateBody) } }
|
|
3915
4005
|
);
|
|
3916
4006
|
return {
|
|
@@ -3920,14 +4010,14 @@ var PackManager = class {
|
|
|
3920
4010
|
}
|
|
3921
4011
|
/** Edit a sticker in a pack. */
|
|
3922
4012
|
async editSticker(packId, stickerId, options) {
|
|
3923
|
-
const data = await this.client.rest.patch(
|
|
4013
|
+
const data = await this.client.rest.patch(Routes31.packSticker(packId, stickerId), {
|
|
3924
4014
|
body: toStickerEditBody(options)
|
|
3925
4015
|
});
|
|
3926
4016
|
return toStickerPayload(data);
|
|
3927
4017
|
}
|
|
3928
4018
|
/** Delete a sticker from a pack. */
|
|
3929
4019
|
async deleteSticker(packId, stickerId) {
|
|
3930
|
-
await this.client.rest.delete(
|
|
4020
|
+
await this.client.rest.delete(Routes31.packSticker(packId, stickerId));
|
|
3931
4021
|
}
|
|
3932
4022
|
};
|
|
3933
4023
|
|
|
@@ -3946,10 +4036,10 @@ function createEventMethods(client) {
|
|
|
3946
4036
|
|
|
3947
4037
|
// src/client/clientEmoji.ts
|
|
3948
4038
|
import { Collection as Collection11 } from "@fluxerjs/collection";
|
|
3949
|
-
import { Routes as
|
|
4039
|
+
import { Routes as Routes32 } from "@fluxerjs/types";
|
|
3950
4040
|
import { formatEmoji, getUnicodeFromShortcode, parseEmoji } from "@fluxerjs/util";
|
|
3951
4041
|
async function assertEmojiInGuild(client, emojiId, guildId) {
|
|
3952
|
-
const emojis = await client.rest.get(
|
|
4042
|
+
const emojis = await client.rest.get(Routes32.guildEmojis(guildId));
|
|
3953
4043
|
if (!emojis.some((e) => e.id === emojiId)) {
|
|
3954
4044
|
throw new FluxerError("Custom emoji is from another server. Use an emoji from this server.", {
|
|
3955
4045
|
code: ErrorCodes.EmojiNotInGuild
|
|
@@ -3975,7 +4065,7 @@ async function resolveClientEmoji(client, emoji, guildId) {
|
|
|
3975
4065
|
const unicodeFromShortcode = getUnicodeFromShortcode(parsed.name);
|
|
3976
4066
|
if (unicodeFromShortcode) return unicodeFromShortcode;
|
|
3977
4067
|
if (guildId) {
|
|
3978
|
-
const emojis = await client.rest.get(
|
|
4068
|
+
const emojis = await client.rest.get(Routes32.guildEmojis(guildId));
|
|
3979
4069
|
const found = emojis.find((e) => e.name && e.name.toLowerCase() === parsed.name.toLowerCase());
|
|
3980
4070
|
if (found) return formatEmoji({ ...parsed, id: found.id, animated: found.animated });
|
|
3981
4071
|
throw new FluxerError(
|
|
@@ -3992,28 +4082,28 @@ async function resolveClientEmoji(client, emoji, guildId) {
|
|
|
3992
4082
|
return parsed.name;
|
|
3993
4083
|
}
|
|
3994
4084
|
async function fetchInstance(client) {
|
|
3995
|
-
const raw = await client.rest.get(
|
|
4085
|
+
const raw = await client.rest.get(Routes32.instanceDiscovery(), { auth: false });
|
|
3996
4086
|
return parseInstanceDiscovery(raw);
|
|
3997
4087
|
}
|
|
3998
4088
|
function fetchGatewayInfo(client) {
|
|
3999
|
-
return client.rest.get(
|
|
4089
|
+
return client.rest.get(Routes32.gatewayBot());
|
|
4000
4090
|
}
|
|
4001
4091
|
function fetchEmojiMetadata(client, emojiId) {
|
|
4002
|
-
return client.rest.get(
|
|
4092
|
+
return client.rest.get(Routes32.emojiMetadata(emojiId), { auth: true });
|
|
4003
4093
|
}
|
|
4004
4094
|
function fetchStickerMetadata(client, stickerId) {
|
|
4005
|
-
return client.rest.get(
|
|
4095
|
+
return client.rest.get(Routes32.stickerMetadata(stickerId), { auth: true });
|
|
4006
4096
|
}
|
|
4007
4097
|
function fetchApplication(client) {
|
|
4008
|
-
return client.rest.get(
|
|
4098
|
+
return client.rest.get(Routes32.applicationsMe(), { auth: true });
|
|
4009
4099
|
}
|
|
4010
4100
|
async function fetchOAuthApplications(client) {
|
|
4011
|
-
const data = await client.rest.get(
|
|
4101
|
+
const data = await client.rest.get(Routes32.oauth2ApplicationsMe(), { auth: true });
|
|
4012
4102
|
return Array.isArray(data) ? data : data.applications ?? [];
|
|
4013
4103
|
}
|
|
4014
4104
|
function checkUsernameTag(client, username, discriminator) {
|
|
4015
4105
|
const params = new URLSearchParams({ username, discriminator });
|
|
4016
|
-
return client.rest.get(`${
|
|
4106
|
+
return client.rest.get(`${Routes32.checkUsernameTag()}?${params}`, { auth: true });
|
|
4017
4107
|
}
|
|
4018
4108
|
function assertChannelIdBatch(name, channelIds) {
|
|
4019
4109
|
if (channelIds.length < 1 || channelIds.length > 100) {
|
|
@@ -4024,14 +4114,14 @@ function assertChannelIdBatch(name, channelIds) {
|
|
|
4024
4114
|
}
|
|
4025
4115
|
function preloadMessages(client, channelIds) {
|
|
4026
4116
|
assertChannelIdBatch("preloadMessages", channelIds);
|
|
4027
|
-
return client.rest.post(
|
|
4117
|
+
return client.rest.post(Routes32.preloadMessages(), {
|
|
4028
4118
|
body: { channels: channelIds },
|
|
4029
4119
|
auth: true
|
|
4030
4120
|
});
|
|
4031
4121
|
}
|
|
4032
4122
|
function preloadMessagesAlt(client, channelIds) {
|
|
4033
4123
|
assertChannelIdBatch("preloadMessagesAlt", channelIds);
|
|
4034
|
-
return client.rest.post(
|
|
4124
|
+
return client.rest.post(Routes32.preloadMessagesAlt(), {
|
|
4035
4125
|
body: { channels: channelIds },
|
|
4036
4126
|
auth: true
|
|
4037
4127
|
});
|
|
@@ -4039,7 +4129,7 @@ function preloadMessagesAlt(client, channelIds) {
|
|
|
4039
4129
|
async function bulkFetchMessages(client, requests, options = {}) {
|
|
4040
4130
|
validateBulkMessageFetchRequests(requests);
|
|
4041
4131
|
const wire = toBulkFetchWire(requests);
|
|
4042
|
-
const data = await client.rest.post(
|
|
4132
|
+
const data = await client.rest.post(Routes32.channelsMessagesBulk(), {
|
|
4043
4133
|
body: { requests: wire },
|
|
4044
4134
|
auth: true
|
|
4045
4135
|
});
|
|
@@ -4126,62 +4216,6 @@ function buildRegistry(...maps) {
|
|
|
4126
4216
|
return registry;
|
|
4127
4217
|
}
|
|
4128
4218
|
|
|
4129
|
-
// src/structures/MessageReaction.ts
|
|
4130
|
-
import { Routes as Routes32 } from "@fluxerjs/types";
|
|
4131
|
-
import { FluxerAPIError as FluxerAPIError5, RateLimitError as RateLimitError4 } from "@fluxerjs/rest";
|
|
4132
|
-
var MessageReaction = class extends Base {
|
|
4133
|
-
client;
|
|
4134
|
-
messageId;
|
|
4135
|
-
channelId;
|
|
4136
|
-
guildId;
|
|
4137
|
-
emoji;
|
|
4138
|
-
/** Raw gateway payload for low-level access. */
|
|
4139
|
-
_data;
|
|
4140
|
-
constructor(client, data) {
|
|
4141
|
-
super();
|
|
4142
|
-
this.client = client;
|
|
4143
|
-
this._data = data;
|
|
4144
|
-
this.messageId = data.message_id;
|
|
4145
|
-
this.channelId = data.channel_id;
|
|
4146
|
-
this.guildId = data.guild_id ?? null;
|
|
4147
|
-
this.emoji = {
|
|
4148
|
-
name: data.emoji.name,
|
|
4149
|
-
...data.emoji.id !== void 0 ? { id: data.emoji.id } : {},
|
|
4150
|
-
...data.emoji.animated !== void 0 ? { animated: data.emoji.animated } : {}
|
|
4151
|
-
};
|
|
4152
|
-
}
|
|
4153
|
-
/** Emoji as a string: unicode or "name:id" for custom. */
|
|
4154
|
-
get emojiIdentifier() {
|
|
4155
|
-
return this.emoji.id ? `${this.emoji.name}:${this.emoji.id}` : this.emoji.name;
|
|
4156
|
-
}
|
|
4157
|
-
/** Guild where this reaction was added. Resolved from cache; null for DMs or if not cached. */
|
|
4158
|
-
get guild() {
|
|
4159
|
-
return this.guildId ? this.client.guilds.get(this.guildId) ?? null : null;
|
|
4160
|
-
}
|
|
4161
|
-
/**
|
|
4162
|
-
* Fetch the message this reaction belongs to.
|
|
4163
|
-
* Use when you need to edit, delete, or otherwise interact with the message.
|
|
4164
|
-
* @throws FluxerError with MESSAGE_NOT_FOUND if the message does not exist
|
|
4165
|
-
*/
|
|
4166
|
-
async fetchMessage() {
|
|
4167
|
-
try {
|
|
4168
|
-
const data = await this.client.rest.get(
|
|
4169
|
-
Routes32.channelMessage(this.channelId, this.messageId)
|
|
4170
|
-
);
|
|
4171
|
-
return new Message(this.client, data);
|
|
4172
|
-
} catch (err) {
|
|
4173
|
-
if (err instanceof RateLimitError4) throw err;
|
|
4174
|
-
if (err instanceof FluxerAPIError5 && err.statusCode === 404) {
|
|
4175
|
-
throw new FluxerError(`Message ${this.messageId} not found in channel ${this.channelId}`, {
|
|
4176
|
-
code: ErrorCodes.MessageNotFound,
|
|
4177
|
-
cause: err
|
|
4178
|
-
});
|
|
4179
|
-
}
|
|
4180
|
-
throw err instanceof FluxerError ? err : new FluxerError(String(err), { cause: err });
|
|
4181
|
-
}
|
|
4182
|
-
}
|
|
4183
|
-
};
|
|
4184
|
-
|
|
4185
4219
|
// src/client/eventHandlers/helpers.ts
|
|
4186
4220
|
function unknownUser(id) {
|
|
4187
4221
|
return { id, username: "Unknown", discriminator: "0" };
|