@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/index.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";
|
|
@@ -201,19 +201,19 @@ async function prepareMessagePostPayload(options, defaults) {
|
|
|
201
201
|
}
|
|
202
202
|
|
|
203
203
|
// src/structures/channel/base.ts
|
|
204
|
-
import { ChannelType, Routes as
|
|
204
|
+
import { ChannelType, Routes as Routes7 } from "@fluxerjs/types";
|
|
205
205
|
|
|
206
206
|
// src/client/MessageManager.ts
|
|
207
|
-
import { Routes as
|
|
207
|
+
import { Routes as Routes5 } from "@fluxerjs/types";
|
|
208
208
|
import { Collection as Collection3 } from "@fluxerjs/collection";
|
|
209
|
-
import { FluxerAPIError, RateLimitError } from "@fluxerjs/rest";
|
|
209
|
+
import { FluxerAPIError as FluxerAPIError2, RateLimitError as RateLimitError2 } from "@fluxerjs/rest";
|
|
210
210
|
|
|
211
211
|
// src/structures/message/Message.ts
|
|
212
212
|
import { Collection as Collection2 } from "@fluxerjs/collection";
|
|
213
213
|
import { EmbedBuilder as EmbedBuilder2 } from "@fluxerjs/builders";
|
|
214
214
|
import {
|
|
215
215
|
MessageType,
|
|
216
|
-
Routes as
|
|
216
|
+
Routes as Routes4
|
|
217
217
|
} from "@fluxerjs/types";
|
|
218
218
|
|
|
219
219
|
// src/client/sdkOptions.ts
|
|
@@ -455,6 +455,68 @@ function toProfilePayload(data) {
|
|
|
455
455
|
import { EventEmitter } from "events";
|
|
456
456
|
import { Collection } from "@fluxerjs/collection";
|
|
457
457
|
|
|
458
|
+
// src/structures/MessageReaction.ts
|
|
459
|
+
import { Routes } from "@fluxerjs/types";
|
|
460
|
+
import { FluxerAPIError, RateLimitError } from "@fluxerjs/rest";
|
|
461
|
+
|
|
462
|
+
// src/structures/Base.ts
|
|
463
|
+
var Base = class {
|
|
464
|
+
};
|
|
465
|
+
|
|
466
|
+
// src/structures/MessageReaction.ts
|
|
467
|
+
var MessageReaction = class extends Base {
|
|
468
|
+
client;
|
|
469
|
+
messageId;
|
|
470
|
+
channelId;
|
|
471
|
+
guildId;
|
|
472
|
+
emoji;
|
|
473
|
+
/** Raw gateway payload for low-level access. */
|
|
474
|
+
_data;
|
|
475
|
+
constructor(client, data) {
|
|
476
|
+
super();
|
|
477
|
+
this.client = client;
|
|
478
|
+
this._data = data;
|
|
479
|
+
this.messageId = data.message_id;
|
|
480
|
+
this.channelId = data.channel_id;
|
|
481
|
+
this.guildId = data.guild_id ?? null;
|
|
482
|
+
this.emoji = {
|
|
483
|
+
name: data.emoji.name,
|
|
484
|
+
...data.emoji.id !== void 0 ? { id: data.emoji.id } : {},
|
|
485
|
+
...data.emoji.animated !== void 0 ? { animated: data.emoji.animated } : {}
|
|
486
|
+
};
|
|
487
|
+
}
|
|
488
|
+
/** Emoji as a string: unicode or "name:id" for custom. */
|
|
489
|
+
get emojiIdentifier() {
|
|
490
|
+
return this.emoji.id ? `${this.emoji.name}:${this.emoji.id}` : this.emoji.name;
|
|
491
|
+
}
|
|
492
|
+
/** Guild where this reaction was added. Resolved from cache; null for DMs or if not cached. */
|
|
493
|
+
get guild() {
|
|
494
|
+
return this.guildId ? this.client.guilds.get(this.guildId) ?? null : null;
|
|
495
|
+
}
|
|
496
|
+
/**
|
|
497
|
+
* Fetch the message this reaction belongs to.
|
|
498
|
+
* Use when you need to edit, delete, or otherwise interact with the message.
|
|
499
|
+
* @throws FluxerError with MESSAGE_NOT_FOUND if the message does not exist
|
|
500
|
+
*/
|
|
501
|
+
async fetchMessage() {
|
|
502
|
+
try {
|
|
503
|
+
const data = await this.client.rest.get(
|
|
504
|
+
Routes.channelMessage(this.channelId, this.messageId)
|
|
505
|
+
);
|
|
506
|
+
return new Message(this.client, data);
|
|
507
|
+
} catch (err) {
|
|
508
|
+
if (err instanceof RateLimitError) throw err;
|
|
509
|
+
if (err instanceof FluxerAPIError && err.statusCode === 404) {
|
|
510
|
+
throw new FluxerError(`Message ${this.messageId} not found in channel ${this.channelId}`, {
|
|
511
|
+
code: ErrorCodes.MessageNotFound,
|
|
512
|
+
cause: err
|
|
513
|
+
});
|
|
514
|
+
}
|
|
515
|
+
throw err instanceof FluxerError ? err : new FluxerError(String(err), { cause: err });
|
|
516
|
+
}
|
|
517
|
+
}
|
|
518
|
+
};
|
|
519
|
+
|
|
458
520
|
// src/util/Events.ts
|
|
459
521
|
var Events = {
|
|
460
522
|
Ready: "ready",
|
|
@@ -518,7 +580,8 @@ var ReactionCollector = class extends EventEmitter {
|
|
|
518
580
|
collected = new Collection();
|
|
519
581
|
_timeout = null;
|
|
520
582
|
_ended = false;
|
|
521
|
-
|
|
583
|
+
_onAdd;
|
|
584
|
+
_onAddMany;
|
|
522
585
|
constructor(client, messageId, channelId, options = {}) {
|
|
523
586
|
super();
|
|
524
587
|
this.client = client;
|
|
@@ -529,27 +592,58 @@ var ReactionCollector = class extends EventEmitter {
|
|
|
529
592
|
time: options.time ?? 0,
|
|
530
593
|
max: options.max ?? 0
|
|
531
594
|
};
|
|
532
|
-
this.
|
|
595
|
+
this._onAdd = (payload) => {
|
|
533
596
|
if (this._ended || payload.reaction.messageId !== this.messageId || payload.channelId !== this.channelId) {
|
|
534
597
|
return;
|
|
535
598
|
}
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
this.
|
|
540
|
-
|
|
541
|
-
|
|
599
|
+
this._collect(payload.reaction, payload.user, payload.userId);
|
|
600
|
+
};
|
|
601
|
+
this._onAddMany = (payload) => {
|
|
602
|
+
if (this._ended || payload.messageId !== this.messageId || payload.channelId !== this.channelId) {
|
|
603
|
+
return;
|
|
604
|
+
}
|
|
605
|
+
for (const entry of payload.reactions) {
|
|
606
|
+
if (this._ended) return;
|
|
607
|
+
const reaction = new MessageReaction(this.client, {
|
|
608
|
+
message_id: payload.messageId,
|
|
609
|
+
channel_id: payload.channelId,
|
|
610
|
+
guild_id: payload.guildId ?? void 0,
|
|
611
|
+
user_id: entry.userId,
|
|
612
|
+
emoji: {
|
|
613
|
+
name: entry.emoji.name,
|
|
614
|
+
...entry.emoji.id !== void 0 ? { id: entry.emoji.id } : {},
|
|
615
|
+
...entry.emoji.animated !== void 0 ? { animated: entry.emoji.animated } : {}
|
|
616
|
+
}
|
|
617
|
+
});
|
|
618
|
+
const user = entry.member?.user ?? this.client.users.get(entry.userId) ?? this.client.getOrCreateUser({
|
|
619
|
+
id: entry.userId,
|
|
620
|
+
username: "Unknown",
|
|
621
|
+
discriminator: "0"
|
|
622
|
+
});
|
|
623
|
+
this._collect(reaction, user, entry.userId);
|
|
542
624
|
}
|
|
543
625
|
};
|
|
544
|
-
this.client.on(Events.MessageReactionAdd, this.
|
|
626
|
+
this.client.on(Events.MessageReactionAdd, this._onAdd);
|
|
627
|
+
this.client.on(Events.MessageReactionAddMany, this._onAddMany);
|
|
545
628
|
if (this.options.time > 0) {
|
|
546
629
|
this._timeout = setTimeout(() => this.stop("time"), this.options.time);
|
|
547
630
|
}
|
|
548
631
|
}
|
|
632
|
+
_collect(reaction, user, userId) {
|
|
633
|
+
if (this._ended) return;
|
|
634
|
+
if (!this.options.filter(reaction, user)) return;
|
|
635
|
+
const key = `${userId}:${reaction.emoji.id ?? reaction.emoji.name}`;
|
|
636
|
+
this.collected.set(key, { reaction, user });
|
|
637
|
+
this.emit("collect", reaction, user);
|
|
638
|
+
if (this.options.max > 0 && this.collected.size >= this.options.max) {
|
|
639
|
+
this.stop("limit");
|
|
640
|
+
}
|
|
641
|
+
}
|
|
549
642
|
stop(reason = "user") {
|
|
550
643
|
if (this._ended) return;
|
|
551
644
|
this._ended = true;
|
|
552
|
-
this.client.off(Events.MessageReactionAdd, this.
|
|
645
|
+
this.client.off(Events.MessageReactionAdd, this._onAdd);
|
|
646
|
+
this.client.off(Events.MessageReactionAddMany, this._onAddMany);
|
|
553
647
|
if (this._timeout) {
|
|
554
648
|
clearTimeout(this._timeout);
|
|
555
649
|
this._timeout = null;
|
|
@@ -564,30 +658,26 @@ var ReactionCollector = class extends EventEmitter {
|
|
|
564
658
|
}
|
|
565
659
|
};
|
|
566
660
|
|
|
567
|
-
// src/structures/Base.ts
|
|
568
|
-
var Base = class {
|
|
569
|
-
};
|
|
570
|
-
|
|
571
661
|
// src/structures/message/reactions.ts
|
|
572
|
-
import { Routes } from "@fluxerjs/types";
|
|
662
|
+
import { Routes as Routes2 } from "@fluxerjs/types";
|
|
573
663
|
async function emojiPath(message, emoji) {
|
|
574
664
|
return message.client.resolveEmoji(emoji, message.guildId);
|
|
575
665
|
}
|
|
576
666
|
async function reactToMessage(message, emoji) {
|
|
577
667
|
const e = await emojiPath(message, emoji);
|
|
578
|
-
await message.client.rest.put(
|
|
668
|
+
await message.client.rest.put(Routes2.channelMessageReactionMe(message.channelId, message.id, e));
|
|
579
669
|
}
|
|
580
670
|
async function removeMessageReaction(message, emoji, userId) {
|
|
581
671
|
const e = await emojiPath(message, emoji);
|
|
582
|
-
const route = userId ?
|
|
672
|
+
const route = userId ? Routes2.channelMessageReactionUser(message.channelId, message.id, e, userId) : Routes2.channelMessageReactionMe(message.channelId, message.id, e);
|
|
583
673
|
await message.client.rest.delete(route);
|
|
584
674
|
}
|
|
585
675
|
async function removeAllMessageReactions(message) {
|
|
586
|
-
await message.client.rest.delete(
|
|
676
|
+
await message.client.rest.delete(Routes2.channelMessageReactions(message.channelId, message.id));
|
|
587
677
|
}
|
|
588
678
|
async function removeMessageReactionEmoji(message, emoji) {
|
|
589
679
|
const e = await emojiPath(message, emoji);
|
|
590
|
-
await message.client.rest.delete(
|
|
680
|
+
await message.client.rest.delete(Routes2.channelMessageReaction(message.channelId, message.id, e));
|
|
591
681
|
}
|
|
592
682
|
async function fetchMessageReactionUsers(message, emoji, options) {
|
|
593
683
|
return (await fetchMessageReactionUsersPage(message, emoji, options)).users;
|
|
@@ -598,7 +688,7 @@ async function fetchMessageReactionUsersPage(message, emoji, options) {
|
|
|
598
688
|
if (options?.limit != null) params.set("limit", String(options.limit));
|
|
599
689
|
if (options?.after) params.set("after", options.after);
|
|
600
690
|
const qs2 = params.toString();
|
|
601
|
-
const route =
|
|
691
|
+
const route = Routes2.channelMessageReactionUsers(message.channelId, message.id, e) + (qs2 ? `?${qs2}` : "");
|
|
602
692
|
const data = await message.client.rest.get(route);
|
|
603
693
|
if (Array.isArray(data)) {
|
|
604
694
|
return {
|
|
@@ -617,7 +707,7 @@ async function fetchMessageReactionUsersPage(message, emoji, options) {
|
|
|
617
707
|
|
|
618
708
|
// src/structures/message/send.ts
|
|
619
709
|
import { MessagePayload as MessagePayloadBuilder } from "@fluxerjs/builders";
|
|
620
|
-
import { Routes as
|
|
710
|
+
import { Routes as Routes3 } from "@fluxerjs/types";
|
|
621
711
|
function toReplyTarget(ref) {
|
|
622
712
|
return {
|
|
623
713
|
channelId: ref.channel_id,
|
|
@@ -651,7 +741,7 @@ function asReplyTarget(value) {
|
|
|
651
741
|
}
|
|
652
742
|
async function sendPrepared(message, payload) {
|
|
653
743
|
const data = await message.client.rest.post(
|
|
654
|
-
|
|
744
|
+
Routes3.channelMessages(message.channelId),
|
|
655
745
|
payload
|
|
656
746
|
);
|
|
657
747
|
message.client._addMessageToCache(message.channelId, data);
|
|
@@ -828,7 +918,7 @@ var Message = class _Message extends Base {
|
|
|
828
918
|
if (options.attachments !== void 0) {
|
|
829
919
|
body.attachments = toMessageAttachmentEditWire(options.attachments);
|
|
830
920
|
}
|
|
831
|
-
const data = await this.client.rest.patch(
|
|
921
|
+
const data = await this.client.rest.patch(Routes4.channelMessage(this.channelId, this.id), {
|
|
832
922
|
body
|
|
833
923
|
});
|
|
834
924
|
const updated = new _Message(this.client, data);
|
|
@@ -845,25 +935,25 @@ var Message = class _Message extends Base {
|
|
|
845
935
|
}
|
|
846
936
|
/** Delete this message. */
|
|
847
937
|
async delete() {
|
|
848
|
-
await this.client.rest.delete(
|
|
938
|
+
await this.client.rest.delete(Routes4.channelMessage(this.channelId, this.id));
|
|
849
939
|
this.client._removeMessageFromCache(this.channelId, this.id);
|
|
850
940
|
}
|
|
851
941
|
/** Delete a specific attachment from this message. */
|
|
852
942
|
async deleteAttachment(attachmentId) {
|
|
853
943
|
await this.client.rest.delete(
|
|
854
|
-
|
|
944
|
+
Routes4.channelMessageAttachment(this.channelId, this.id, attachmentId),
|
|
855
945
|
{ auth: true }
|
|
856
946
|
);
|
|
857
947
|
this.attachments.delete(attachmentId);
|
|
858
948
|
}
|
|
859
949
|
/** Pin this message in the channel. */
|
|
860
950
|
async pin() {
|
|
861
|
-
await this.client.rest.put(
|
|
951
|
+
await this.client.rest.put(Routes4.channelPinMessage(this.channelId, this.id));
|
|
862
952
|
this.pinned = true;
|
|
863
953
|
}
|
|
864
954
|
/** Unpin this message from the channel. */
|
|
865
955
|
async unpin() {
|
|
866
|
-
await this.client.rest.delete(
|
|
956
|
+
await this.client.rest.delete(Routes4.channelPinMessage(this.channelId, this.id));
|
|
867
957
|
this.pinned = false;
|
|
868
958
|
}
|
|
869
959
|
/** React to this message with an emoji. */
|
|
@@ -944,12 +1034,12 @@ var MessageManager = class {
|
|
|
944
1034
|
async fetchOne(messageId) {
|
|
945
1035
|
try {
|
|
946
1036
|
const data = await this.client.rest.get(
|
|
947
|
-
|
|
1037
|
+
Routes5.channelMessage(this.channelId, messageId)
|
|
948
1038
|
);
|
|
949
1039
|
return this.wrap(data);
|
|
950
1040
|
} catch (err) {
|
|
951
|
-
if (err instanceof
|
|
952
|
-
if (err instanceof
|
|
1041
|
+
if (err instanceof RateLimitError2) throw err;
|
|
1042
|
+
if (err instanceof FluxerAPIError2 && err.statusCode === 404) {
|
|
953
1043
|
throw new FluxerError(`Message ${messageId} not found in channel ${this.channelId}`, {
|
|
954
1044
|
code: ErrorCodes.MessageNotFound,
|
|
955
1045
|
cause: err
|
|
@@ -970,7 +1060,7 @@ var MessageManager = class {
|
|
|
970
1060
|
const value = options[key];
|
|
971
1061
|
if (value != null && value !== "") qs2.set(key, String(value));
|
|
972
1062
|
}
|
|
973
|
-
const base =
|
|
1063
|
+
const base = Routes5.channelMessages(this.channelId);
|
|
974
1064
|
const data = await this.client.rest.get(qs2.size > 0 ? `${base}?${qs2}` : base);
|
|
975
1065
|
const collection = new Collection3();
|
|
976
1066
|
for (const msg of data) collection.set(msg.id, this.wrap(msg));
|
|
@@ -979,7 +1069,7 @@ var MessageManager = class {
|
|
|
979
1069
|
};
|
|
980
1070
|
|
|
981
1071
|
// src/structures/channel/attachments.ts
|
|
982
|
-
import { Routes as
|
|
1072
|
+
import { Routes as Routes6 } from "@fluxerjs/types";
|
|
983
1073
|
function asBytes(data) {
|
|
984
1074
|
const src = data instanceof ArrayBuffer ? new Uint8Array(data) : new Uint8Array(data);
|
|
985
1075
|
const out = new Uint8Array(src.byteLength);
|
|
@@ -1000,7 +1090,7 @@ async function putBlob(url, body, contentType) {
|
|
|
1000
1090
|
}
|
|
1001
1091
|
async function uploadAttachmentsForSend(client, channelId, files) {
|
|
1002
1092
|
const plan = await client.rest.post(
|
|
1003
|
-
|
|
1093
|
+
Routes6.channelAttachments(channelId),
|
|
1004
1094
|
{
|
|
1005
1095
|
body: {
|
|
1006
1096
|
attachments: files.map((f) => ({
|
|
@@ -1046,7 +1136,7 @@ async function uploadAttachmentsForSend(client, channelId, files) {
|
|
|
1046
1136
|
});
|
|
1047
1137
|
}
|
|
1048
1138
|
if (multipart.length) {
|
|
1049
|
-
await client.rest.post(
|
|
1139
|
+
await client.rest.post(Routes6.channelAttachmentsComplete(channelId), {
|
|
1050
1140
|
body: { uploads: multipart },
|
|
1051
1141
|
auth: true
|
|
1052
1142
|
});
|
|
@@ -1140,7 +1230,7 @@ var Channel = class extends Base {
|
|
|
1140
1230
|
}
|
|
1141
1231
|
if (ids.length === 0) return [];
|
|
1142
1232
|
if (ids.length === 1) {
|
|
1143
|
-
await this.client.rest.delete(
|
|
1233
|
+
await this.client.rest.delete(Routes7.channelMessage(this.id, ids[0]), { auth: true });
|
|
1144
1234
|
this.client._removeMessageFromCache(this.id, ids[0]);
|
|
1145
1235
|
return ids;
|
|
1146
1236
|
}
|
|
@@ -1149,7 +1239,7 @@ var Channel = class extends Base {
|
|
|
1149
1239
|
code: ErrorCodes.InvalidBulkDelete
|
|
1150
1240
|
});
|
|
1151
1241
|
}
|
|
1152
|
-
await this.client.rest.post(
|
|
1242
|
+
await this.client.rest.post(Routes7.channelBulkDelete(this.id), {
|
|
1153
1243
|
body: { message_ids: ids },
|
|
1154
1244
|
auth: true
|
|
1155
1245
|
});
|
|
@@ -1159,23 +1249,23 @@ var Channel = class extends Base {
|
|
|
1159
1249
|
/** Delete all messages sent by the bot in this channel (user account feature). */
|
|
1160
1250
|
async bulkDeleteMyMessages(options) {
|
|
1161
1251
|
const body = options ? toSudoBody(options) : void 0;
|
|
1162
|
-
await this.client.rest.post(
|
|
1252
|
+
await this.client.rest.post(Routes7.channelBulkDeleteMine(this.id), {
|
|
1163
1253
|
body: body && Object.keys(body).length ? body : void 0,
|
|
1164
1254
|
auth: true
|
|
1165
1255
|
});
|
|
1166
1256
|
}
|
|
1167
1257
|
/** Mark all pinned messages as read in this channel. */
|
|
1168
1258
|
async acknowledgePins() {
|
|
1169
|
-
await this.client.rest.post(
|
|
1259
|
+
await this.client.rest.post(Routes7.channelPinsAck(this.id), { auth: true });
|
|
1170
1260
|
}
|
|
1171
1261
|
/** Clear the read state for this channel. */
|
|
1172
1262
|
async clearReadState() {
|
|
1173
|
-
await this.client.rest.delete(
|
|
1263
|
+
await this.client.rest.delete(Routes7.channelMessagesAck(this.id), { auth: true });
|
|
1174
1264
|
}
|
|
1175
1265
|
/** Request upload URLs for attachments before sending a message. */
|
|
1176
1266
|
async requestAttachmentUploads(attachments) {
|
|
1177
1267
|
const data = await this.client.rest.post(
|
|
1178
|
-
|
|
1268
|
+
Routes7.channelAttachments(this.id),
|
|
1179
1269
|
{
|
|
1180
1270
|
body: toAttachmentUploadPlanBody(attachments),
|
|
1181
1271
|
auth: true
|
|
@@ -1186,7 +1276,7 @@ var Channel = class extends Base {
|
|
|
1186
1276
|
/** Complete the attachment upload flow after uploading to the CDN. */
|
|
1187
1277
|
async completeAttachmentUploads(uploads) {
|
|
1188
1278
|
const data = await this.client.rest.post(
|
|
1189
|
-
|
|
1279
|
+
Routes7.channelAttachmentsComplete(this.id),
|
|
1190
1280
|
{
|
|
1191
1281
|
body: toAttachmentUploadCompleteBody(uploads),
|
|
1192
1282
|
auth: true
|
|
@@ -1202,11 +1292,11 @@ var Channel = class extends Base {
|
|
|
1202
1292
|
}
|
|
1203
1293
|
/** Trigger the typing indicator in this channel. */
|
|
1204
1294
|
async sendTyping() {
|
|
1205
|
-
await this.client.rest.post(
|
|
1295
|
+
await this.client.rest.post(Routes7.channelTyping(this.id), { auth: true });
|
|
1206
1296
|
}
|
|
1207
1297
|
/** Fetch available RTC regions for voice channels. */
|
|
1208
1298
|
async fetchRtcRegions() {
|
|
1209
|
-
const data = await this.client.rest.get(
|
|
1299
|
+
const data = await this.client.rest.get(Routes7.channelRtcRegions(this.id), {
|
|
1210
1300
|
auth: true
|
|
1211
1301
|
});
|
|
1212
1302
|
return data.map((r) => ({ id: r.id, name: r.name, emoji: r.emoji }));
|
|
@@ -1214,7 +1304,7 @@ var Channel = class extends Base {
|
|
|
1214
1304
|
/** Fetch slowmode state for this channel. */
|
|
1215
1305
|
async fetchSlowmode() {
|
|
1216
1306
|
const data = await this.client.rest.get(
|
|
1217
|
-
|
|
1307
|
+
Routes7.channelSlowmode(this.id),
|
|
1218
1308
|
{ auth: true }
|
|
1219
1309
|
);
|
|
1220
1310
|
return {
|
|
@@ -1230,7 +1320,7 @@ var Channel = class extends Base {
|
|
|
1230
1320
|
};
|
|
1231
1321
|
|
|
1232
1322
|
// src/structures/channel/guild.ts
|
|
1233
|
-
import { Routes as
|
|
1323
|
+
import { Routes as Routes11 } from "@fluxerjs/types";
|
|
1234
1324
|
import { PermissionFlags } from "@fluxerjs/util";
|
|
1235
1325
|
|
|
1236
1326
|
// src/structures/Invite.ts
|
|
@@ -1239,7 +1329,7 @@ import {
|
|
|
1239
1329
|
isGroupDmInvite,
|
|
1240
1330
|
isGuildInvite,
|
|
1241
1331
|
isPackInvite,
|
|
1242
|
-
Routes as
|
|
1332
|
+
Routes as Routes8
|
|
1243
1333
|
} from "@fluxerjs/types";
|
|
1244
1334
|
|
|
1245
1335
|
// src/util/Constants.ts
|
|
@@ -1459,19 +1549,19 @@ var Invite = class _Invite extends Base {
|
|
|
1459
1549
|
}
|
|
1460
1550
|
/** Fetch invite metadata by code or URL (does not join). */
|
|
1461
1551
|
static async fetch(client, codeOrUrl) {
|
|
1462
|
-
const data = await client.rest.get(
|
|
1552
|
+
const data = await client.rest.get(Routes8.invite(parseInviteCode(codeOrUrl)));
|
|
1463
1553
|
return new _Invite(client, data);
|
|
1464
1554
|
}
|
|
1465
1555
|
/** Delete this invite. Requires Manage Guild or Create Instant Invite. */
|
|
1466
1556
|
async delete() {
|
|
1467
|
-
await this.client.rest.delete(
|
|
1557
|
+
await this.client.rest.delete(Routes8.invite(this.code), { auth: true });
|
|
1468
1558
|
}
|
|
1469
1559
|
};
|
|
1470
1560
|
|
|
1471
1561
|
// src/structures/Webhook.ts
|
|
1472
1562
|
import { EmbedBuilder as EmbedBuilder3 } from "@fluxerjs/builders";
|
|
1473
1563
|
import {
|
|
1474
|
-
Routes as
|
|
1564
|
+
Routes as Routes9
|
|
1475
1565
|
} from "@fluxerjs/types";
|
|
1476
1566
|
|
|
1477
1567
|
// src/util/cdn.ts
|
|
@@ -1572,10 +1662,10 @@ var Webhook = class _Webhook extends Base {
|
|
|
1572
1662
|
/** Delete this webhook (token auth when available, otherwise bot auth). */
|
|
1573
1663
|
async delete() {
|
|
1574
1664
|
if (this.token) {
|
|
1575
|
-
await this.client.rest.delete(
|
|
1665
|
+
await this.client.rest.delete(Routes9.webhookExecute(this.id, this.token), { auth: false });
|
|
1576
1666
|
return;
|
|
1577
1667
|
}
|
|
1578
|
-
await this.client.rest.delete(
|
|
1668
|
+
await this.client.rest.delete(Routes9.webhook(this.id), { auth: true });
|
|
1579
1669
|
}
|
|
1580
1670
|
/**
|
|
1581
1671
|
* Edit name/avatar. With bot auth (no token), `channelId` may also be set.
|
|
@@ -1587,10 +1677,10 @@ var Webhook = class _Webhook extends Base {
|
|
|
1587
1677
|
if (!this.token && options.channelId !== void 0) {
|
|
1588
1678
|
body.channel_id = options.channelId;
|
|
1589
1679
|
}
|
|
1590
|
-
const data = this.token ? await this.client.rest.patch(
|
|
1680
|
+
const data = this.token ? await this.client.rest.patch(Routes9.webhookExecute(this.id, this.token), {
|
|
1591
1681
|
body,
|
|
1592
1682
|
auth: false
|
|
1593
|
-
}) : await this.client.rest.patch(
|
|
1683
|
+
}) : await this.client.rest.patch(Routes9.webhook(this.id), { body, auth: true });
|
|
1594
1684
|
this.name = data.name ?? this.name;
|
|
1595
1685
|
this.avatar = data.avatar ?? null;
|
|
1596
1686
|
if (!this.token) this.channelId = data.channel_id ?? this.channelId;
|
|
@@ -1611,7 +1701,7 @@ var Webhook = class _Webhook extends Base {
|
|
|
1611
1701
|
if (overrides.avatarUrl !== void 0) {
|
|
1612
1702
|
body.avatar_url = overrides.avatarUrl;
|
|
1613
1703
|
}
|
|
1614
|
-
const route = `${
|
|
1704
|
+
const route = `${Routes9.webhookExecute(this.id, token)}${wait ? "?wait=true" : ""}`;
|
|
1615
1705
|
const data = await this.client.rest.post(route, {
|
|
1616
1706
|
body,
|
|
1617
1707
|
...files?.length ? { files } : {},
|
|
@@ -1652,7 +1742,7 @@ var Webhook = class _Webhook extends Base {
|
|
|
1652
1742
|
}
|
|
1653
1743
|
/** Fetch a webhook by ID (bot auth; no token). */
|
|
1654
1744
|
static async fetch(client, webhookId) {
|
|
1655
|
-
const data = await client.rest.get(
|
|
1745
|
+
const data = await client.rest.get(Routes9.webhook(webhookId));
|
|
1656
1746
|
return new _Webhook(client, data);
|
|
1657
1747
|
}
|
|
1658
1748
|
/** Build a webhook from a stored id + token (e.g. webhook URL). */
|
|
@@ -1677,12 +1767,12 @@ var Webhook = class _Webhook extends Base {
|
|
|
1677
1767
|
return this.token;
|
|
1678
1768
|
}
|
|
1679
1769
|
messageRoute(messageId) {
|
|
1680
|
-
return
|
|
1770
|
+
return Routes9.webhookMessage(this.id, this.requireToken(), messageId);
|
|
1681
1771
|
}
|
|
1682
1772
|
};
|
|
1683
1773
|
|
|
1684
1774
|
// src/structures/channel/textCapable.ts
|
|
1685
|
-
import { Routes as
|
|
1775
|
+
import { Routes as Routes10 } from "@fluxerjs/types";
|
|
1686
1776
|
|
|
1687
1777
|
// src/util/MessageCollector.ts
|
|
1688
1778
|
import { EventEmitter as EventEmitter2 } from "events";
|
|
@@ -1743,7 +1833,7 @@ async function fetchPinnedMessagesPageFor(client, channelId, options) {
|
|
|
1743
1833
|
if (options?.before) params.set("before", options.before);
|
|
1744
1834
|
const qs2 = params.toString();
|
|
1745
1835
|
const data = await client.rest.get(
|
|
1746
|
-
|
|
1836
|
+
Routes10.channelPins(channelId) + (qs2 ? `?${qs2}` : "")
|
|
1747
1837
|
);
|
|
1748
1838
|
const items = data.items ?? [];
|
|
1749
1839
|
return {
|
|
@@ -1759,7 +1849,7 @@ function TextCapable(Base2) {
|
|
|
1759
1849
|
const payload = await prepareMessagePostPayload(options, {
|
|
1760
1850
|
defaultAllowedMentions: this.client.options.defaultAllowedMentions
|
|
1761
1851
|
});
|
|
1762
|
-
const data = await this.client.rest.post(
|
|
1852
|
+
const data = await this.client.rest.post(Routes10.channelMessages(this.id), payload);
|
|
1763
1853
|
this.client._addMessageToCache(this.id, data);
|
|
1764
1854
|
return new Message(this.client, data);
|
|
1765
1855
|
}
|
|
@@ -1816,7 +1906,7 @@ var GuildChannel = class extends Channel {
|
|
|
1816
1906
|
}
|
|
1817
1907
|
/** Create a webhook for this channel. Requires Manage Webhooks. */
|
|
1818
1908
|
async createWebhook(options) {
|
|
1819
|
-
const data = await this.client.rest.post(
|
|
1909
|
+
const data = await this.client.rest.post(Routes11.channelWebhooks(this.id), {
|
|
1820
1910
|
body: options,
|
|
1821
1911
|
auth: true
|
|
1822
1912
|
});
|
|
@@ -1824,13 +1914,13 @@ var GuildChannel = class extends Channel {
|
|
|
1824
1914
|
}
|
|
1825
1915
|
/** Fetch all webhooks in this channel. Requires Manage Webhooks. */
|
|
1826
1916
|
async fetchWebhooks() {
|
|
1827
|
-
const data = await this.client.rest.get(
|
|
1917
|
+
const data = await this.client.rest.get(Routes11.channelWebhooks(this.id));
|
|
1828
1918
|
return data.map((w) => new Webhook(this.client, w));
|
|
1829
1919
|
}
|
|
1830
1920
|
/** Create an invite for this channel. Requires Create Instant Invite. */
|
|
1831
1921
|
async createInvite(options) {
|
|
1832
1922
|
const body = options ? toChannelInviteBody(options) : {};
|
|
1833
|
-
const data = await this.client.rest.post(
|
|
1923
|
+
const data = await this.client.rest.post(Routes11.channelInvites(this.id), {
|
|
1834
1924
|
body: Object.keys(body).length ? body : void 0,
|
|
1835
1925
|
auth: true
|
|
1836
1926
|
});
|
|
@@ -1838,12 +1928,12 @@ var GuildChannel = class extends Channel {
|
|
|
1838
1928
|
}
|
|
1839
1929
|
/** Fetch all invites for this channel. Requires Manage Channels. */
|
|
1840
1930
|
async fetchInvites() {
|
|
1841
|
-
const data = await this.client.rest.get(
|
|
1931
|
+
const data = await this.client.rest.get(Routes11.channelInvites(this.id));
|
|
1842
1932
|
return data.map((i) => new Invite(this.client, i));
|
|
1843
1933
|
}
|
|
1844
1934
|
/** Edit or create a permission overwrite. Requires Manage Roles. */
|
|
1845
1935
|
async editPermission(overwriteId, options) {
|
|
1846
|
-
await this.client.rest.put(
|
|
1936
|
+
await this.client.rest.put(Routes11.channelPermission(this.id, overwriteId), {
|
|
1847
1937
|
body: options,
|
|
1848
1938
|
auth: true
|
|
1849
1939
|
});
|
|
@@ -1859,7 +1949,7 @@ var GuildChannel = class extends Channel {
|
|
|
1859
1949
|
}
|
|
1860
1950
|
/** Delete a permission overwrite. Requires Manage Roles. */
|
|
1861
1951
|
async deletePermission(overwriteId) {
|
|
1862
|
-
await this.client.rest.delete(
|
|
1952
|
+
await this.client.rest.delete(Routes11.channelPermission(this.id, overwriteId), { auth: true });
|
|
1863
1953
|
const idx = this.permissionOverwrites.findIndex((o) => o.id === overwriteId);
|
|
1864
1954
|
if (idx >= 0) this.permissionOverwrites.splice(idx, 1);
|
|
1865
1955
|
}
|
|
@@ -1872,7 +1962,7 @@ var GuildChannel = class extends Channel {
|
|
|
1872
1962
|
}
|
|
1873
1963
|
/** Edit this channel's settings. Requires Manage Channels. */
|
|
1874
1964
|
async edit(options) {
|
|
1875
|
-
const data = await this.client.rest.patch(
|
|
1965
|
+
const data = await this.client.rest.patch(Routes11.channel(this.id), {
|
|
1876
1966
|
body: toChannelEditBody(options),
|
|
1877
1967
|
auth: true
|
|
1878
1968
|
});
|
|
@@ -1892,7 +1982,7 @@ var GuildChannel = class extends Channel {
|
|
|
1892
1982
|
const qs2 = params.toString();
|
|
1893
1983
|
const { silent: _s, deleteMessages: _d, ...sudo } = options ?? {};
|
|
1894
1984
|
const body = Object.keys(sudo).length ? toSudoBody(sudo) : void 0;
|
|
1895
|
-
await this.client.rest.delete(
|
|
1985
|
+
await this.client.rest.delete(Routes11.channel(this.id) + (qs2 ? `?${qs2}` : ""), {
|
|
1896
1986
|
body,
|
|
1897
1987
|
auth: true
|
|
1898
1988
|
});
|
|
@@ -1954,7 +2044,7 @@ var LinkChannel = class extends GuildChannel {
|
|
|
1954
2044
|
};
|
|
1955
2045
|
|
|
1956
2046
|
// src/structures/channel/dm.ts
|
|
1957
|
-
import { ChannelType as ChannelType2, Routes as
|
|
2047
|
+
import { ChannelType as ChannelType2, Routes as Routes12 } from "@fluxerjs/types";
|
|
1958
2048
|
var DMChannel = class extends TextCapable(Channel) {
|
|
1959
2049
|
/** ID of the last message sent in this channel. */
|
|
1960
2050
|
lastMessageId;
|
|
@@ -1980,28 +2070,28 @@ var DMChannel = class extends TextCapable(Channel) {
|
|
|
1980
2070
|
});
|
|
1981
2071
|
}
|
|
1982
2072
|
const data = await this.client.rest.post(
|
|
1983
|
-
|
|
2073
|
+
Routes12.channelMessagesPurge(this.id),
|
|
1984
2074
|
{ auth: true }
|
|
1985
2075
|
);
|
|
1986
2076
|
return data.deleted_count;
|
|
1987
2077
|
}
|
|
1988
2078
|
/** Pin this DM channel to the top of the DM list. */
|
|
1989
2079
|
async pinInList() {
|
|
1990
|
-
await this.client.rest.put(
|
|
2080
|
+
await this.client.rest.put(Routes12.userMeChannelPin(this.id), { auth: true });
|
|
1991
2081
|
}
|
|
1992
2082
|
/** Unpin this DM channel from the DM list. */
|
|
1993
2083
|
async unpinFromList() {
|
|
1994
|
-
await this.client.rest.delete(
|
|
2084
|
+
await this.client.rest.delete(Routes12.userMeChannelPin(this.id), { auth: true });
|
|
1995
2085
|
}
|
|
1996
2086
|
/** Add a user to this group DM. */
|
|
1997
2087
|
async addRecipient(userId) {
|
|
1998
|
-
await this.client.rest.put(
|
|
2088
|
+
await this.client.rest.put(Routes12.channelRecipient(this.id, userId), { auth: true });
|
|
1999
2089
|
const user = this.client.users.get(userId) ?? await this.client.users.fetch(userId);
|
|
2000
2090
|
if (user) this.recipients.push(user);
|
|
2001
2091
|
}
|
|
2002
2092
|
/** Remove a user from this group DM. */
|
|
2003
2093
|
async removeRecipient(userId, options) {
|
|
2004
|
-
const url =
|
|
2094
|
+
const url = Routes12.channelRecipient(this.id, userId) + (options?.silent ? "?silent=true" : "");
|
|
2005
2095
|
await this.client.rest.delete(url, { auth: true });
|
|
2006
2096
|
const idx = this.recipients.findIndex((u) => u.id === userId);
|
|
2007
2097
|
if (idx >= 0) this.recipients.splice(idx, 1);
|
|
@@ -2039,8 +2129,8 @@ Channel.createDM = createDM;
|
|
|
2039
2129
|
|
|
2040
2130
|
// src/client/ChannelManager.ts
|
|
2041
2131
|
function rethrowNotFound(err, message, code) {
|
|
2042
|
-
if (err instanceof
|
|
2043
|
-
if (err instanceof
|
|
2132
|
+
if (err instanceof RateLimitError3) throw err;
|
|
2133
|
+
if (err instanceof FluxerAPIError3 && err.statusCode === 404) {
|
|
2044
2134
|
throw new FluxerError(message, { code, cause: err });
|
|
2045
2135
|
}
|
|
2046
2136
|
throw err instanceof FluxerError ? err : new FluxerError(String(err), { cause: err });
|
|
@@ -2072,7 +2162,7 @@ var ChannelManager = class extends Collection5 {
|
|
|
2072
2162
|
const cached = this.get(channelId);
|
|
2073
2163
|
if (cached) return cached;
|
|
2074
2164
|
try {
|
|
2075
|
-
const data = await this.client.rest.get(
|
|
2165
|
+
const data = await this.client.rest.get(Routes13.channel(channelId));
|
|
2076
2166
|
const channel = Channel.fromOrCreate(this.client, data);
|
|
2077
2167
|
if (!channel) {
|
|
2078
2168
|
throw new FluxerError("Channel data invalid or unsupported type", {
|
|
@@ -2105,7 +2195,7 @@ var ChannelManager = class extends Collection5 {
|
|
|
2105
2195
|
defaultAllowedMentions: this.client.options.defaultAllowedMentions
|
|
2106
2196
|
});
|
|
2107
2197
|
const data = await this.client.rest.post(
|
|
2108
|
-
|
|
2198
|
+
Routes13.channelMessages(channelId),
|
|
2109
2199
|
postPayload
|
|
2110
2200
|
);
|
|
2111
2201
|
this.client._addMessageToCache(channelId, data);
|
|
@@ -2115,8 +2205,8 @@ var ChannelManager = class extends Collection5 {
|
|
|
2115
2205
|
|
|
2116
2206
|
// src/client/GuildManager.ts
|
|
2117
2207
|
import { Collection as Collection9 } from "@fluxerjs/collection";
|
|
2118
|
-
import { Routes as
|
|
2119
|
-
import { FluxerAPIError as
|
|
2208
|
+
import { Routes as Routes28 } from "@fluxerjs/types";
|
|
2209
|
+
import { FluxerAPIError as FluxerAPIError5, RateLimitError as RateLimitError4 } from "@fluxerjs/rest";
|
|
2120
2210
|
|
|
2121
2211
|
// src/structures/guild/Guild.ts
|
|
2122
2212
|
import { Collection as Collection8 } from "@fluxerjs/collection";
|
|
@@ -2124,10 +2214,10 @@ import { GuildNSFWLevel } from "@fluxerjs/types";
|
|
|
2124
2214
|
|
|
2125
2215
|
// src/client/GuildMemberManager.ts
|
|
2126
2216
|
import { Collection as Collection7 } from "@fluxerjs/collection";
|
|
2127
|
-
import { Routes as
|
|
2217
|
+
import { Routes as Routes16 } from "@fluxerjs/types";
|
|
2128
2218
|
|
|
2129
2219
|
// src/structures/GuildMember.ts
|
|
2130
|
-
import { Routes as
|
|
2220
|
+
import { Routes as Routes15 } from "@fluxerjs/types";
|
|
2131
2221
|
import { PermissionsBitField } from "@fluxerjs/util";
|
|
2132
2222
|
|
|
2133
2223
|
// src/util/permissions.ts
|
|
@@ -2148,7 +2238,7 @@ function computePermissions(basePermissions, overwrites, memberRoles, memberId,
|
|
|
2148
2238
|
|
|
2149
2239
|
// src/structures/GuildMemberRoleManager.ts
|
|
2150
2240
|
import { Collection as Collection6 } from "@fluxerjs/collection";
|
|
2151
|
-
import { Routes as
|
|
2241
|
+
import { Routes as Routes14 } from "@fluxerjs/types";
|
|
2152
2242
|
function roleId(roleOrId) {
|
|
2153
2243
|
return typeof roleOrId === "string" ? roleOrId : roleOrId.id;
|
|
2154
2244
|
}
|
|
@@ -2177,7 +2267,7 @@ var GuildMemberRoleManager = class {
|
|
|
2177
2267
|
const id = roleId(roleOrId);
|
|
2178
2268
|
if (this.ids.includes(id)) return;
|
|
2179
2269
|
await this.member.client.rest.put(
|
|
2180
|
-
|
|
2270
|
+
Routes14.guildMemberRole(this.member.guild.id, this.member.id, id)
|
|
2181
2271
|
);
|
|
2182
2272
|
this.ids.push(id);
|
|
2183
2273
|
}
|
|
@@ -2186,13 +2276,13 @@ var GuildMemberRoleManager = class {
|
|
|
2186
2276
|
const idx = this.ids.indexOf(id);
|
|
2187
2277
|
if (idx === -1) return;
|
|
2188
2278
|
await this.member.client.rest.delete(
|
|
2189
|
-
|
|
2279
|
+
Routes14.guildMemberRole(this.member.guild.id, this.member.id, id)
|
|
2190
2280
|
);
|
|
2191
2281
|
this.ids.splice(idx, 1);
|
|
2192
2282
|
}
|
|
2193
2283
|
async set(roleIds) {
|
|
2194
2284
|
const data = await this.member.client.rest.patch(
|
|
2195
|
-
|
|
2285
|
+
Routes14.guildMember(this.member.guild.id, this.member.id),
|
|
2196
2286
|
{ body: { roles: roleIds }, auth: true }
|
|
2197
2287
|
);
|
|
2198
2288
|
this.ids = data.roles ? [...data.roles] : [];
|
|
@@ -2319,7 +2409,7 @@ var GuildMember = class _GuildMember extends Base {
|
|
|
2319
2409
|
/** PATCH member (`/members/@me` when editing the bot). */
|
|
2320
2410
|
async edit(options) {
|
|
2321
2411
|
const isMe = this.client.user?.id === this.id;
|
|
2322
|
-
const route = isMe ?
|
|
2412
|
+
const route = isMe ? Routes15.guildMemberMe(this.guild.id) : Routes15.guildMember(this.guild.id, this.id);
|
|
2323
2413
|
const data = await this.client.rest.patch(route, {
|
|
2324
2414
|
body: toMemberEditBody(options),
|
|
2325
2415
|
auth: true
|
|
@@ -2448,7 +2538,7 @@ var GuildMemberManager = class extends Collection7 {
|
|
|
2448
2538
|
if (options?.limit != null) params.set("limit", String(options.limit));
|
|
2449
2539
|
if (options?.after) params.set("after", options.after);
|
|
2450
2540
|
const qs2 = params.toString();
|
|
2451
|
-
const url =
|
|
2541
|
+
const url = Routes16.guildMembers(this.guild.id) + (qs2 ? `?${qs2}` : "");
|
|
2452
2542
|
const data = await this.guild.client.rest.get(url, { auth: true });
|
|
2453
2543
|
const members = [];
|
|
2454
2544
|
for (const m of data) {
|
|
@@ -2471,7 +2561,7 @@ var GuildMemberManager = class extends Collection7 {
|
|
|
2471
2561
|
*/
|
|
2472
2562
|
async search(options = {}) {
|
|
2473
2563
|
const data = await this.guild.client.rest.post(
|
|
2474
|
-
|
|
2564
|
+
Routes16.guildMembersSearch(this.guild.id),
|
|
2475
2565
|
{ body: toMemberSearchBody(options), auth: true }
|
|
2476
2566
|
);
|
|
2477
2567
|
const offset = options.offset ?? 0;
|
|
@@ -2497,7 +2587,7 @@ var GuildMemberManager = class extends Collection7 {
|
|
|
2497
2587
|
};
|
|
2498
2588
|
|
|
2499
2589
|
// src/structures/Role.ts
|
|
2500
|
-
import { Routes as
|
|
2590
|
+
import { Routes as Routes17 } from "@fluxerjs/types";
|
|
2501
2591
|
import { ALL_PERMISSIONS_BIGINT as ALL_PERMISSIONS_BIGINT2, PermissionFlags as PermissionFlags4, PermissionsBitField as PermissionsBitField2 } from "@fluxerjs/util";
|
|
2502
2592
|
|
|
2503
2593
|
// src/structures/roleOptions.ts
|
|
@@ -2610,7 +2700,7 @@ var Role = class _Role extends Base {
|
|
|
2610
2700
|
*/
|
|
2611
2701
|
async edit(options) {
|
|
2612
2702
|
const body = toRoleRequestBody(options);
|
|
2613
|
-
const data = await this.client.rest.patch(
|
|
2703
|
+
const data = await this.client.rest.patch(Routes17.guildRole(this.guildId, this.id), {
|
|
2614
2704
|
body: Object.keys(body).length ? body : void 0,
|
|
2615
2705
|
auth: true
|
|
2616
2706
|
});
|
|
@@ -2621,18 +2711,18 @@ var Role = class _Role extends Base {
|
|
|
2621
2711
|
* DELETE role. Requires Manage Roles.
|
|
2622
2712
|
*/
|
|
2623
2713
|
async delete() {
|
|
2624
|
-
await this.client.rest.delete(
|
|
2714
|
+
await this.client.rest.delete(Routes17.guildRole(this.guildId, this.id), { auth: true });
|
|
2625
2715
|
this.client.guilds.get(this.guildId)?.roles.delete(this.id);
|
|
2626
2716
|
}
|
|
2627
2717
|
};
|
|
2628
2718
|
|
|
2629
2719
|
// src/structures/guild/admin.ts
|
|
2630
|
-
import { Routes as
|
|
2720
|
+
import { Routes as Routes18 } from "@fluxerjs/types";
|
|
2631
2721
|
|
|
2632
2722
|
// src/structures/guild/http.ts
|
|
2633
|
-
import { FluxerAPIError as
|
|
2723
|
+
import { FluxerAPIError as FluxerAPIError4 } from "@fluxerjs/rest";
|
|
2634
2724
|
function httpStatus(err) {
|
|
2635
|
-
if (err instanceof
|
|
2725
|
+
if (err instanceof FluxerAPIError4) return err.statusCode;
|
|
2636
2726
|
if (typeof err === "object" && err !== null && "statusCode" in err) {
|
|
2637
2727
|
const code = err.statusCode;
|
|
2638
2728
|
return typeof code === "number" ? code : void 0;
|
|
@@ -2732,7 +2822,7 @@ function toVanityPayload(data) {
|
|
|
2732
2822
|
return { code: data.code ?? null, uses: data.uses };
|
|
2733
2823
|
}
|
|
2734
2824
|
async function fetchAuditLogs(guild, options) {
|
|
2735
|
-
const url =
|
|
2825
|
+
const url = Routes18.guildAuditLogs(guild.id) + qs({
|
|
2736
2826
|
limit: options?.limit,
|
|
2737
2827
|
before: options?.before,
|
|
2738
2828
|
after: options?.after,
|
|
@@ -2753,7 +2843,7 @@ async function fetchAuditLogs(guild, options) {
|
|
|
2753
2843
|
};
|
|
2754
2844
|
}
|
|
2755
2845
|
async function editGuild(guild, options) {
|
|
2756
|
-
const data = await guild.client.rest.patch(
|
|
2846
|
+
const data = await guild.client.rest.patch(Routes18.guild(guild.id), {
|
|
2757
2847
|
body: toGuildEditBody(options),
|
|
2758
2848
|
auth: true
|
|
2759
2849
|
});
|
|
@@ -2761,13 +2851,13 @@ async function editGuild(guild, options) {
|
|
|
2761
2851
|
return guild;
|
|
2762
2852
|
}
|
|
2763
2853
|
async function fetchVanityURL(guild) {
|
|
2764
|
-
const data = await guild.client.rest.get(
|
|
2854
|
+
const data = await guild.client.rest.get(Routes18.guildVanityUrl(guild.id), {
|
|
2765
2855
|
auth: true
|
|
2766
2856
|
});
|
|
2767
2857
|
return toVanityPayload(data);
|
|
2768
2858
|
}
|
|
2769
2859
|
async function editVanityURL(guild, code) {
|
|
2770
|
-
const data = await guild.client.rest.patch(
|
|
2860
|
+
const data = await guild.client.rest.patch(Routes18.guildVanityUrl(guild.id), {
|
|
2771
2861
|
body: { code },
|
|
2772
2862
|
auth: true
|
|
2773
2863
|
});
|
|
@@ -2775,14 +2865,14 @@ async function editVanityURL(guild, code) {
|
|
|
2775
2865
|
return toVanityPayload(data);
|
|
2776
2866
|
}
|
|
2777
2867
|
async function fetchDiscoveryStatus(guild) {
|
|
2778
|
-
const data = await guild.client.rest.get(
|
|
2868
|
+
const data = await guild.client.rest.get(Routes18.guildDiscovery(guild.id), {
|
|
2779
2869
|
auth: true
|
|
2780
2870
|
});
|
|
2781
2871
|
return toDiscoveryStatusPayload(data);
|
|
2782
2872
|
}
|
|
2783
2873
|
async function applyForDiscovery(guild, options) {
|
|
2784
2874
|
const data = await guild.client.rest.post(
|
|
2785
|
-
|
|
2875
|
+
Routes18.guildDiscovery(guild.id),
|
|
2786
2876
|
{
|
|
2787
2877
|
body: toDiscoveryBody(options),
|
|
2788
2878
|
auth: true
|
|
@@ -2792,7 +2882,7 @@ async function applyForDiscovery(guild, options) {
|
|
|
2792
2882
|
}
|
|
2793
2883
|
async function editDiscoveryApplication(guild, options) {
|
|
2794
2884
|
const data = await guild.client.rest.patch(
|
|
2795
|
-
|
|
2885
|
+
Routes18.guildDiscovery(guild.id),
|
|
2796
2886
|
{
|
|
2797
2887
|
body: toDiscoveryBody(options),
|
|
2798
2888
|
auth: true
|
|
@@ -2801,28 +2891,28 @@ async function editDiscoveryApplication(guild, options) {
|
|
|
2801
2891
|
return toDiscoveryApplicationPayload(data);
|
|
2802
2892
|
}
|
|
2803
2893
|
async function withdrawDiscoveryApplication(guild) {
|
|
2804
|
-
await guild.client.rest.delete(
|
|
2894
|
+
await guild.client.rest.delete(Routes18.guildDiscovery(guild.id), { auth: true });
|
|
2805
2895
|
}
|
|
2806
2896
|
async function deleteGuild(guild, options) {
|
|
2807
2897
|
const body = options ? toSudoBody(options) : {};
|
|
2808
|
-
await guild.client.rest.post(
|
|
2898
|
+
await guild.client.rest.post(Routes18.guildDelete(guild.id), {
|
|
2809
2899
|
body,
|
|
2810
2900
|
auth: true
|
|
2811
2901
|
});
|
|
2812
2902
|
guild.client.guilds.delete(guild.id);
|
|
2813
2903
|
}
|
|
2814
2904
|
async function transferOwnership(guild, newOwnerId, password) {
|
|
2815
|
-
await guild.client.rest.post(
|
|
2905
|
+
await guild.client.rest.post(Routes18.guildTransferOwnership(guild.id), {
|
|
2816
2906
|
body: { new_owner_id: newOwnerId, ...password != null && { password } },
|
|
2817
2907
|
auth: true
|
|
2818
2908
|
});
|
|
2819
2909
|
}
|
|
2820
2910
|
|
|
2821
2911
|
// src/structures/guild/channels.ts
|
|
2822
|
-
import { Routes as
|
|
2912
|
+
import { Routes as Routes21 } from "@fluxerjs/types";
|
|
2823
2913
|
|
|
2824
2914
|
// src/structures/GuildEmoji.ts
|
|
2825
|
-
import { Routes as
|
|
2915
|
+
import { Routes as Routes19 } from "@fluxerjs/types";
|
|
2826
2916
|
var GuildEmoji = class extends Base {
|
|
2827
2917
|
client;
|
|
2828
2918
|
id;
|
|
@@ -2850,7 +2940,7 @@ var GuildEmoji = class extends Base {
|
|
|
2850
2940
|
}
|
|
2851
2941
|
/** Delete this emoji. Requires Manage Emojis and Stickers permission. */
|
|
2852
2942
|
async delete() {
|
|
2853
|
-
await this.client.rest.delete(
|
|
2943
|
+
await this.client.rest.delete(Routes19.guildEmoji(this.guildId, this.id), {
|
|
2854
2944
|
auth: true
|
|
2855
2945
|
});
|
|
2856
2946
|
const guild = this.client.guilds.get(this.guildId);
|
|
@@ -2861,7 +2951,7 @@ var GuildEmoji = class extends Base {
|
|
|
2861
2951
|
* Requires Manage Emojis and Stickers permission.
|
|
2862
2952
|
*/
|
|
2863
2953
|
async edit(options) {
|
|
2864
|
-
const data = await this.client.rest.patch(
|
|
2954
|
+
const data = await this.client.rest.patch(Routes19.guildEmoji(this.guildId, this.id), {
|
|
2865
2955
|
body: options,
|
|
2866
2956
|
auth: true
|
|
2867
2957
|
});
|
|
@@ -2871,7 +2961,7 @@ var GuildEmoji = class extends Base {
|
|
|
2871
2961
|
};
|
|
2872
2962
|
|
|
2873
2963
|
// src/structures/GuildSticker.ts
|
|
2874
|
-
import { Routes as
|
|
2964
|
+
import { Routes as Routes20 } from "@fluxerjs/types";
|
|
2875
2965
|
var GuildSticker = class extends Base {
|
|
2876
2966
|
client;
|
|
2877
2967
|
id;
|
|
@@ -2902,7 +2992,7 @@ var GuildSticker = class extends Base {
|
|
|
2902
2992
|
}
|
|
2903
2993
|
/** Delete this sticker. Requires Manage Emojis and Stickers permission. */
|
|
2904
2994
|
async delete() {
|
|
2905
|
-
await this.client.rest.delete(
|
|
2995
|
+
await this.client.rest.delete(Routes20.guildSticker(this.guildId, this.id), {
|
|
2906
2996
|
auth: true
|
|
2907
2997
|
});
|
|
2908
2998
|
}
|
|
@@ -2911,7 +3001,7 @@ var GuildSticker = class extends Base {
|
|
|
2911
3001
|
* Requires Manage Emojis and Stickers permission.
|
|
2912
3002
|
*/
|
|
2913
3003
|
async edit(options) {
|
|
2914
|
-
const data = await this.client.rest.patch(
|
|
3004
|
+
const data = await this.client.rest.patch(Routes20.guildSticker(this.guildId, this.id), {
|
|
2915
3005
|
body: options,
|
|
2916
3006
|
auth: true
|
|
2917
3007
|
});
|
|
@@ -2966,14 +3056,14 @@ function cacheSticker(guild, data) {
|
|
|
2966
3056
|
|
|
2967
3057
|
// src/structures/guild/channels.ts
|
|
2968
3058
|
async function createChannel(guild, data) {
|
|
2969
|
-
const created = await guild.client.rest.post(
|
|
3059
|
+
const created = await guild.client.rest.post(Routes21.guildChannels(guild.id), {
|
|
2970
3060
|
body: data,
|
|
2971
3061
|
auth: true
|
|
2972
3062
|
});
|
|
2973
3063
|
return cacheChannel(guild, created);
|
|
2974
3064
|
}
|
|
2975
3065
|
async function fetchChannels(guild) {
|
|
2976
|
-
const data = await guild.client.rest.get(
|
|
3066
|
+
const data = await guild.client.rest.get(Routes21.guildChannels(guild.id));
|
|
2977
3067
|
const channels = [];
|
|
2978
3068
|
for (const ch of data) {
|
|
2979
3069
|
const channel = cacheChannel(guild, ch);
|
|
@@ -2982,17 +3072,17 @@ async function fetchChannels(guild) {
|
|
|
2982
3072
|
return channels;
|
|
2983
3073
|
}
|
|
2984
3074
|
async function setChannelPositions(guild, updates) {
|
|
2985
|
-
await guild.client.rest.patch(
|
|
3075
|
+
await guild.client.rest.patch(Routes21.guildChannels(guild.id), {
|
|
2986
3076
|
body: toChannelPositionBody(updates),
|
|
2987
3077
|
auth: true
|
|
2988
3078
|
});
|
|
2989
3079
|
}
|
|
2990
3080
|
async function fetchWebhooks(guild) {
|
|
2991
|
-
const data = await guild.client.rest.get(
|
|
3081
|
+
const data = await guild.client.rest.get(Routes21.guildWebhooks(guild.id));
|
|
2992
3082
|
return data.map((w) => new Webhook(guild.client, w));
|
|
2993
3083
|
}
|
|
2994
3084
|
async function fetchInvites(guild) {
|
|
2995
|
-
const data = await guild.client.rest.get(
|
|
3085
|
+
const data = await guild.client.rest.get(Routes21.guildInvites(guild.id));
|
|
2996
3086
|
return data.map((invite) => new Invite(guild.client, invite));
|
|
2997
3087
|
}
|
|
2998
3088
|
async function fetchInvite(guild, codeOrUrl) {
|
|
@@ -3000,14 +3090,14 @@ async function fetchInvite(guild, codeOrUrl) {
|
|
|
3000
3090
|
}
|
|
3001
3091
|
|
|
3002
3092
|
// src/structures/guild/emojis.ts
|
|
3003
|
-
import { Routes as
|
|
3093
|
+
import { Routes as Routes22 } from "@fluxerjs/types";
|
|
3004
3094
|
async function fetchEmojis(guild) {
|
|
3005
|
-
const data = await guild.client.rest.get(
|
|
3095
|
+
const data = await guild.client.rest.get(Routes22.guildEmojis(guild.id));
|
|
3006
3096
|
return data.map((e) => cacheEmoji(guild, e));
|
|
3007
3097
|
}
|
|
3008
3098
|
async function fetchEmoji(guild, emojiId) {
|
|
3009
3099
|
try {
|
|
3010
|
-
const data = await guild.client.rest.get(
|
|
3100
|
+
const data = await guild.client.rest.get(Routes22.guildEmoji(guild.id, emojiId));
|
|
3011
3101
|
return cacheEmoji(guild, data);
|
|
3012
3102
|
} catch (err) {
|
|
3013
3103
|
rethrowNotFound2(
|
|
@@ -3018,14 +3108,14 @@ async function fetchEmoji(guild, emojiId) {
|
|
|
3018
3108
|
}
|
|
3019
3109
|
}
|
|
3020
3110
|
async function createEmoji(guild, options) {
|
|
3021
|
-
const data = await guild.client.rest.post(
|
|
3111
|
+
const data = await guild.client.rest.post(Routes22.guildEmojis(guild.id), {
|
|
3022
3112
|
body: options,
|
|
3023
3113
|
auth: true
|
|
3024
3114
|
});
|
|
3025
3115
|
return cacheEmoji(guild, data);
|
|
3026
3116
|
}
|
|
3027
3117
|
async function cloneEmoji(guild, sourceEmojiId) {
|
|
3028
|
-
const data = await guild.client.rest.post(
|
|
3118
|
+
const data = await guild.client.rest.post(Routes22.guildEmojisClone(guild.id), {
|
|
3029
3119
|
body: { source_emoji_id: sourceEmojiId },
|
|
3030
3120
|
auth: true
|
|
3031
3121
|
});
|
|
@@ -3033,18 +3123,18 @@ async function cloneEmoji(guild, sourceEmojiId) {
|
|
|
3033
3123
|
}
|
|
3034
3124
|
async function createEmojisBulk(guild, emojis) {
|
|
3035
3125
|
const data = await guild.client.rest.post(
|
|
3036
|
-
|
|
3126
|
+
Routes22.guildEmojisBulk(guild.id),
|
|
3037
3127
|
{ body: { emojis }, auth: true }
|
|
3038
3128
|
);
|
|
3039
3129
|
return { success: data.success.map((e) => cacheEmoji(guild, e)), failed: data.failed };
|
|
3040
3130
|
}
|
|
3041
3131
|
|
|
3042
3132
|
// src/structures/guild/members.ts
|
|
3043
|
-
import { Routes as
|
|
3133
|
+
import { Routes as Routes23 } from "@fluxerjs/types";
|
|
3044
3134
|
async function fetchMember(guild, userId) {
|
|
3045
3135
|
try {
|
|
3046
3136
|
const data = await guild.client.rest.get(
|
|
3047
|
-
|
|
3137
|
+
Routes23.guildMember(guild.id, userId)
|
|
3048
3138
|
);
|
|
3049
3139
|
return cacheMember(guild, data);
|
|
3050
3140
|
} catch (err) {
|
|
@@ -3057,17 +3147,17 @@ async function fetchMember(guild, userId) {
|
|
|
3057
3147
|
}
|
|
3058
3148
|
async function fetchMe(guild) {
|
|
3059
3149
|
const data = await guild.client.rest.get(
|
|
3060
|
-
|
|
3150
|
+
Routes23.guildMemberMe(guild.id),
|
|
3061
3151
|
{ auth: true }
|
|
3062
3152
|
);
|
|
3063
3153
|
return cacheMember(guild, data);
|
|
3064
3154
|
}
|
|
3065
3155
|
|
|
3066
3156
|
// src/structures/guild/moderation.ts
|
|
3067
|
-
import { Routes as
|
|
3157
|
+
import { Routes as Routes25 } from "@fluxerjs/types";
|
|
3068
3158
|
|
|
3069
3159
|
// src/structures/GuildBan.ts
|
|
3070
|
-
import { Routes as
|
|
3160
|
+
import { Routes as Routes24 } from "@fluxerjs/types";
|
|
3071
3161
|
var GuildBan = class extends Base {
|
|
3072
3162
|
client;
|
|
3073
3163
|
guildId;
|
|
@@ -3089,7 +3179,7 @@ var GuildBan = class extends Base {
|
|
|
3089
3179
|
* Requires Ban Members permission.
|
|
3090
3180
|
*/
|
|
3091
3181
|
async unban() {
|
|
3092
|
-
await this.client.rest.delete(
|
|
3182
|
+
await this.client.rest.delete(Routes24.guildBan(this.guildId, this.user.id), {
|
|
3093
3183
|
auth: true
|
|
3094
3184
|
});
|
|
3095
3185
|
}
|
|
@@ -3098,40 +3188,40 @@ var GuildBan = class extends Base {
|
|
|
3098
3188
|
// src/structures/guild/moderation.ts
|
|
3099
3189
|
async function ban(guild, userId, options) {
|
|
3100
3190
|
const body = options ? toGuildBanBody(options) : {};
|
|
3101
|
-
await guild.client.rest.put(
|
|
3191
|
+
await guild.client.rest.put(Routes25.guildBan(guild.id, userId), {
|
|
3102
3192
|
body: Object.keys(body).length ? body : void 0,
|
|
3103
3193
|
auth: true
|
|
3104
3194
|
});
|
|
3105
3195
|
}
|
|
3106
3196
|
async function fetchBans(guild) {
|
|
3107
|
-
const data = await guild.client.rest.get(
|
|
3197
|
+
const data = await guild.client.rest.get(Routes25.guildBans(guild.id));
|
|
3108
3198
|
return data.map((b) => new GuildBan(guild.client, { ...b, guild_id: guild.id }, guild.id));
|
|
3109
3199
|
}
|
|
3110
3200
|
async function unban(guild, userId) {
|
|
3111
|
-
await guild.client.rest.delete(
|
|
3201
|
+
await guild.client.rest.delete(Routes25.guildBan(guild.id, userId), { auth: true });
|
|
3112
3202
|
}
|
|
3113
3203
|
async function kick(guild, userId) {
|
|
3114
|
-
await guild.client.rest.delete(
|
|
3204
|
+
await guild.client.rest.delete(Routes25.guildMember(guild.id, userId), { auth: true });
|
|
3115
3205
|
}
|
|
3116
3206
|
|
|
3117
3207
|
// src/structures/guild/roles.ts
|
|
3118
|
-
import { Routes as
|
|
3208
|
+
import { Routes as Routes26 } from "@fluxerjs/types";
|
|
3119
3209
|
import { parseRoleMention } from "@fluxerjs/util";
|
|
3120
3210
|
async function createRole(guild, options = {}) {
|
|
3121
3211
|
const body = toRoleRequestBody(options);
|
|
3122
|
-
const data = await guild.client.rest.post(
|
|
3212
|
+
const data = await guild.client.rest.post(Routes26.guildRoles(guild.id), {
|
|
3123
3213
|
body: Object.keys(body).length ? body : void 0,
|
|
3124
3214
|
auth: true
|
|
3125
3215
|
});
|
|
3126
3216
|
return cacheRole(guild, data);
|
|
3127
3217
|
}
|
|
3128
3218
|
async function fetchRoles(guild) {
|
|
3129
|
-
const data = await guild.client.rest.get(
|
|
3219
|
+
const data = await guild.client.rest.get(Routes26.guildRoles(guild.id));
|
|
3130
3220
|
return data.map((r) => cacheRole(guild, r));
|
|
3131
3221
|
}
|
|
3132
3222
|
async function fetchRole(guild, roleId2) {
|
|
3133
3223
|
try {
|
|
3134
|
-
const data = await guild.client.rest.get(
|
|
3224
|
+
const data = await guild.client.rest.get(Routes26.guildRole(guild.id, roleId2));
|
|
3135
3225
|
return cacheRole(guild, data);
|
|
3136
3226
|
} catch (err) {
|
|
3137
3227
|
rethrowNotFound2(
|
|
@@ -3149,7 +3239,7 @@ async function resolveRoleId(guild, arg) {
|
|
|
3149
3239
|
const needle = trimmed.toLowerCase();
|
|
3150
3240
|
const cached = guild.roles.find((r) => r.name?.toLowerCase() === needle);
|
|
3151
3241
|
if (cached) return cached.id;
|
|
3152
|
-
const roles = await guild.client.rest.get(
|
|
3242
|
+
const roles = await guild.client.rest.get(Routes26.guildRoles(guild.id));
|
|
3153
3243
|
const role = roles.find((r) => r.name?.toLowerCase() === needle);
|
|
3154
3244
|
if (!role) return null;
|
|
3155
3245
|
cacheRole(guild, role);
|
|
@@ -3158,7 +3248,7 @@ async function resolveRoleId(guild, arg) {
|
|
|
3158
3248
|
async function setRolePositions(guild, updates) {
|
|
3159
3249
|
return replaceRoles(
|
|
3160
3250
|
guild,
|
|
3161
|
-
await guild.client.rest.patch(
|
|
3251
|
+
await guild.client.rest.patch(Routes26.guildRoles(guild.id), {
|
|
3162
3252
|
body: updates,
|
|
3163
3253
|
auth: true
|
|
3164
3254
|
})
|
|
@@ -3167,7 +3257,7 @@ async function setRolePositions(guild, updates) {
|
|
|
3167
3257
|
async function setRoleHoistPositions(guild, updates) {
|
|
3168
3258
|
return replaceRoles(
|
|
3169
3259
|
guild,
|
|
3170
|
-
await guild.client.rest.patch(
|
|
3260
|
+
await guild.client.rest.patch(Routes26.guildRolesHoistPositions(guild.id), {
|
|
3171
3261
|
body: updates.map((u) => ({
|
|
3172
3262
|
id: u.id,
|
|
3173
3263
|
...u.hoistPosition !== void 0 ? { hoist_position: u.hoistPosition } : {}
|
|
@@ -3179,23 +3269,23 @@ async function setRoleHoistPositions(guild, updates) {
|
|
|
3179
3269
|
async function resetRoleHoistPositions(guild) {
|
|
3180
3270
|
return replaceRoles(
|
|
3181
3271
|
guild,
|
|
3182
|
-
await guild.client.rest.delete(
|
|
3272
|
+
await guild.client.rest.delete(Routes26.guildRolesHoistPositions(guild.id), {
|
|
3183
3273
|
auth: true
|
|
3184
3274
|
})
|
|
3185
3275
|
);
|
|
3186
3276
|
}
|
|
3187
3277
|
|
|
3188
3278
|
// src/structures/guild/stickers.ts
|
|
3189
|
-
import { Routes as
|
|
3279
|
+
import { Routes as Routes27 } from "@fluxerjs/types";
|
|
3190
3280
|
async function createSticker(guild, options) {
|
|
3191
|
-
const data = await guild.client.rest.post(
|
|
3281
|
+
const data = await guild.client.rest.post(Routes27.guildStickers(guild.id), {
|
|
3192
3282
|
body: options,
|
|
3193
3283
|
auth: true
|
|
3194
3284
|
});
|
|
3195
3285
|
return cacheSticker(guild, data);
|
|
3196
3286
|
}
|
|
3197
3287
|
async function cloneSticker(guild, sourceStickerId) {
|
|
3198
|
-
const data = await guild.client.rest.post(
|
|
3288
|
+
const data = await guild.client.rest.post(Routes27.guildStickersClone(guild.id), {
|
|
3199
3289
|
body: { source_sticker_id: sourceStickerId },
|
|
3200
3290
|
auth: true
|
|
3201
3291
|
});
|
|
@@ -3203,17 +3293,17 @@ async function cloneSticker(guild, sourceStickerId) {
|
|
|
3203
3293
|
}
|
|
3204
3294
|
async function createStickersBulk(guild, stickers) {
|
|
3205
3295
|
const data = await guild.client.rest.post(
|
|
3206
|
-
|
|
3296
|
+
Routes27.guildStickersBulk(guild.id),
|
|
3207
3297
|
{ body: { stickers }, auth: true }
|
|
3208
3298
|
);
|
|
3209
3299
|
return { success: data.success.map((s) => cacheSticker(guild, s)), failed: data.failed };
|
|
3210
3300
|
}
|
|
3211
3301
|
async function fetchStickers(guild) {
|
|
3212
|
-
const data = await guild.client.rest.get(
|
|
3302
|
+
const data = await guild.client.rest.get(Routes27.guildStickers(guild.id));
|
|
3213
3303
|
return data.map((s) => cacheSticker(guild, s));
|
|
3214
3304
|
}
|
|
3215
3305
|
async function fetchSticker(guild, stickerId) {
|
|
3216
|
-
const data = await guild.client.rest.get(
|
|
3306
|
+
const data = await guild.client.rest.get(Routes27.guildSticker(guild.id, stickerId));
|
|
3217
3307
|
return cacheSticker(guild, data);
|
|
3218
3308
|
}
|
|
3219
3309
|
|
|
@@ -3560,13 +3650,13 @@ var GuildManager = class extends Collection9 {
|
|
|
3560
3650
|
const cached = this.get(guildId);
|
|
3561
3651
|
if (cached) return cached;
|
|
3562
3652
|
try {
|
|
3563
|
-
const data = await this.client.rest.get(
|
|
3653
|
+
const data = await this.client.rest.get(Routes28.guild(guildId));
|
|
3564
3654
|
const guild = new Guild(this.client, data);
|
|
3565
3655
|
this.set(guild.id, guild);
|
|
3566
3656
|
return guild;
|
|
3567
3657
|
} catch (err) {
|
|
3568
|
-
if (err instanceof
|
|
3569
|
-
if (err instanceof
|
|
3658
|
+
if (err instanceof RateLimitError4) throw err;
|
|
3659
|
+
if (err instanceof FluxerAPIError5 && err.statusCode === 404) {
|
|
3570
3660
|
throw new FluxerError(`Guild ${guildId} not found`, {
|
|
3571
3661
|
code: ErrorCodes.GuildNotFound,
|
|
3572
3662
|
cause: err
|
|
@@ -3587,7 +3677,7 @@ var DEFAULT_CACHE_LIMITS = {
|
|
|
3587
3677
|
};
|
|
3588
3678
|
|
|
3589
3679
|
// src/structures/User.ts
|
|
3590
|
-
import { Routes as
|
|
3680
|
+
import { Routes as Routes29 } from "@fluxerjs/types";
|
|
3591
3681
|
var User = class extends Base {
|
|
3592
3682
|
/** Parent client instance. */
|
|
3593
3683
|
client;
|
|
@@ -3677,7 +3767,7 @@ var User = class extends Base {
|
|
|
3677
3767
|
* @returns DM channel instance (cached if already open)
|
|
3678
3768
|
*/
|
|
3679
3769
|
async createDM() {
|
|
3680
|
-
const data = await this.client.rest.post(
|
|
3770
|
+
const data = await this.client.rest.post(Routes29.userMeChannels(), {
|
|
3681
3771
|
body: { recipient_id: this.id },
|
|
3682
3772
|
auth: true
|
|
3683
3773
|
});
|
|
@@ -3698,7 +3788,7 @@ var User = class extends Base {
|
|
|
3698
3788
|
// src/client/UserManager.ts
|
|
3699
3789
|
import { Collection as Collection10 } from "@fluxerjs/collection";
|
|
3700
3790
|
import {
|
|
3701
|
-
Routes as
|
|
3791
|
+
Routes as Routes30
|
|
3702
3792
|
} from "@fluxerjs/types";
|
|
3703
3793
|
var soft = (p) => p.catch(() => null);
|
|
3704
3794
|
var UserManager = class extends Collection10 {
|
|
@@ -3730,7 +3820,7 @@ var UserManager = class extends Collection10 {
|
|
|
3730
3820
|
}
|
|
3731
3821
|
/** Fetch a user by ID and update cache. */
|
|
3732
3822
|
async fetch(userId) {
|
|
3733
|
-
const data = await this.client.rest.get(
|
|
3823
|
+
const data = await this.client.rest.get(Routes30.user(userId));
|
|
3734
3824
|
return this.client.getOrCreateUser(data);
|
|
3735
3825
|
}
|
|
3736
3826
|
/**
|
|
@@ -3744,10 +3834,10 @@ var UserManager = class extends Collection10 {
|
|
|
3744
3834
|
async fetchWithProfile(userId, options) {
|
|
3745
3835
|
const guildId = options?.guildId ?? void 0;
|
|
3746
3836
|
const [userData, globalProfileRaw, serverProfileRaw, memberData] = await Promise.all([
|
|
3747
|
-
this.client.rest.get(
|
|
3748
|
-
soft(this.client.rest.get(
|
|
3749
|
-
guildId ? soft(this.client.rest.get(
|
|
3750
|
-
guildId ? soft(this.client.rest.get(
|
|
3837
|
+
this.client.rest.get(Routes30.user(userId)),
|
|
3838
|
+
soft(this.client.rest.get(Routes30.userProfile(userId))),
|
|
3839
|
+
guildId ? soft(this.client.rest.get(Routes30.userProfile(userId, guildId))) : null,
|
|
3840
|
+
guildId ? soft(this.client.rest.get(Routes30.guildMember(guildId, userId))) : null
|
|
3751
3841
|
]);
|
|
3752
3842
|
const user = this.client.getOrCreateUser(userData);
|
|
3753
3843
|
let member = null;
|
|
@@ -3777,7 +3867,7 @@ var UserManager = class extends Collection10 {
|
|
|
3777
3867
|
|
|
3778
3868
|
// src/client/PackManager.ts
|
|
3779
3869
|
import {
|
|
3780
|
-
Routes as
|
|
3870
|
+
Routes as Routes31
|
|
3781
3871
|
} from "@fluxerjs/types";
|
|
3782
3872
|
function toPackSummaryPayload(data) {
|
|
3783
3873
|
return {
|
|
@@ -3833,7 +3923,7 @@ var PackManager = class {
|
|
|
3833
3923
|
}
|
|
3834
3924
|
/** Fetch the current user's pack dashboard (camelCase summaries). */
|
|
3835
3925
|
async fetchDashboard() {
|
|
3836
|
-
const data = await this.client.rest.get(
|
|
3926
|
+
const data = await this.client.rest.get(Routes31.packs());
|
|
3837
3927
|
return {
|
|
3838
3928
|
emoji: mapDashboardSection(data.emoji),
|
|
3839
3929
|
sticker: mapDashboardSection(data.sticker)
|
|
@@ -3841,49 +3931,49 @@ var PackManager = class {
|
|
|
3841
3931
|
}
|
|
3842
3932
|
/** Create a pack. */
|
|
3843
3933
|
async create(packType, body) {
|
|
3844
|
-
const data = await this.client.rest.post(
|
|
3934
|
+
const data = await this.client.rest.post(Routes31.packsByType(packType), {
|
|
3845
3935
|
body
|
|
3846
3936
|
});
|
|
3847
3937
|
return toPackSummaryPayload(data);
|
|
3848
3938
|
}
|
|
3849
3939
|
/** Edit a pack. */
|
|
3850
3940
|
async edit(packId, body) {
|
|
3851
|
-
const data = await this.client.rest.patch(
|
|
3941
|
+
const data = await this.client.rest.patch(Routes31.pack(packId), { body });
|
|
3852
3942
|
return toPackSummaryPayload(data);
|
|
3853
3943
|
}
|
|
3854
3944
|
/** Delete a pack. */
|
|
3855
3945
|
async delete(packId) {
|
|
3856
|
-
await this.client.rest.delete(
|
|
3946
|
+
await this.client.rest.delete(Routes31.pack(packId));
|
|
3857
3947
|
}
|
|
3858
3948
|
/** Install a pack for the current user. */
|
|
3859
3949
|
async install(packId) {
|
|
3860
|
-
await this.client.rest.post(
|
|
3950
|
+
await this.client.rest.post(Routes31.packInstall(packId));
|
|
3861
3951
|
}
|
|
3862
3952
|
/** Uninstall a pack for the current user. */
|
|
3863
3953
|
async uninstall(packId) {
|
|
3864
|
-
await this.client.rest.delete(
|
|
3954
|
+
await this.client.rest.delete(Routes31.packInstall(packId));
|
|
3865
3955
|
}
|
|
3866
3956
|
/** List invites for a pack. */
|
|
3867
3957
|
async listInvites(packId) {
|
|
3868
|
-
const data = await this.client.rest.get(
|
|
3958
|
+
const data = await this.client.rest.get(Routes31.packInvites(packId));
|
|
3869
3959
|
return data.map(toInvitePayload);
|
|
3870
3960
|
}
|
|
3871
3961
|
/** Create an invite for a pack. */
|
|
3872
3962
|
async createInvite(packId, options = {}) {
|
|
3873
3963
|
const body = toPackInviteBody(options);
|
|
3874
|
-
const data = await this.client.rest.post(
|
|
3964
|
+
const data = await this.client.rest.post(Routes31.packInvites(packId), {
|
|
3875
3965
|
body: Object.keys(body).length ? body : void 0
|
|
3876
3966
|
});
|
|
3877
3967
|
return toInvitePayload(data);
|
|
3878
3968
|
}
|
|
3879
3969
|
/** List emojis in a pack. */
|
|
3880
3970
|
async listEmojis(packId) {
|
|
3881
|
-
const data = await this.client.rest.get(
|
|
3971
|
+
const data = await this.client.rest.get(Routes31.packEmojis(packId));
|
|
3882
3972
|
return data.map(toEmojiPayload);
|
|
3883
3973
|
}
|
|
3884
3974
|
/** Create an emoji in a pack. */
|
|
3885
3975
|
async createEmoji(packId, options) {
|
|
3886
|
-
const data = await this.client.rest.post(
|
|
3976
|
+
const data = await this.client.rest.post(Routes31.packEmojis(packId), {
|
|
3887
3977
|
body: toEmojiCreateBody(options)
|
|
3888
3978
|
});
|
|
3889
3979
|
return toEmojiPayload(data);
|
|
@@ -3891,7 +3981,7 @@ var PackManager = class {
|
|
|
3891
3981
|
/** Bulk-create emojis in a pack. */
|
|
3892
3982
|
async createEmojisBulk(packId, emojis) {
|
|
3893
3983
|
const data = await this.client.rest.post(
|
|
3894
|
-
|
|
3984
|
+
Routes31.packEmojisBulk(packId),
|
|
3895
3985
|
{ body: { emojis: emojis.map(toEmojiCreateBody) } }
|
|
3896
3986
|
);
|
|
3897
3987
|
return {
|
|
@@ -3901,23 +3991,23 @@ var PackManager = class {
|
|
|
3901
3991
|
}
|
|
3902
3992
|
/** Edit an emoji in a pack. */
|
|
3903
3993
|
async editEmoji(packId, emojiId, options) {
|
|
3904
|
-
const data = await this.client.rest.patch(
|
|
3994
|
+
const data = await this.client.rest.patch(Routes31.packEmoji(packId, emojiId), {
|
|
3905
3995
|
body: toEmojiEditBody(options)
|
|
3906
3996
|
});
|
|
3907
3997
|
return toEmojiPayload(data);
|
|
3908
3998
|
}
|
|
3909
3999
|
/** Delete an emoji from a pack. */
|
|
3910
4000
|
async deleteEmoji(packId, emojiId) {
|
|
3911
|
-
await this.client.rest.delete(
|
|
4001
|
+
await this.client.rest.delete(Routes31.packEmoji(packId, emojiId));
|
|
3912
4002
|
}
|
|
3913
4003
|
/** List stickers in a pack. */
|
|
3914
4004
|
async listStickers(packId) {
|
|
3915
|
-
const data = await this.client.rest.get(
|
|
4005
|
+
const data = await this.client.rest.get(Routes31.packStickers(packId));
|
|
3916
4006
|
return data.map(toStickerPayload);
|
|
3917
4007
|
}
|
|
3918
4008
|
/** Create a sticker in a pack. */
|
|
3919
4009
|
async createSticker(packId, options) {
|
|
3920
|
-
const data = await this.client.rest.post(
|
|
4010
|
+
const data = await this.client.rest.post(Routes31.packStickers(packId), {
|
|
3921
4011
|
body: toStickerCreateBody(options)
|
|
3922
4012
|
});
|
|
3923
4013
|
return toStickerPayload(data);
|
|
@@ -3925,7 +4015,7 @@ var PackManager = class {
|
|
|
3925
4015
|
/** Bulk-create stickers in a pack. */
|
|
3926
4016
|
async createStickersBulk(packId, stickers) {
|
|
3927
4017
|
const data = await this.client.rest.post(
|
|
3928
|
-
|
|
4018
|
+
Routes31.packStickersBulk(packId),
|
|
3929
4019
|
{ body: { stickers: stickers.map(toStickerCreateBody) } }
|
|
3930
4020
|
);
|
|
3931
4021
|
return {
|
|
@@ -3935,14 +4025,14 @@ var PackManager = class {
|
|
|
3935
4025
|
}
|
|
3936
4026
|
/** Edit a sticker in a pack. */
|
|
3937
4027
|
async editSticker(packId, stickerId, options) {
|
|
3938
|
-
const data = await this.client.rest.patch(
|
|
4028
|
+
const data = await this.client.rest.patch(Routes31.packSticker(packId, stickerId), {
|
|
3939
4029
|
body: toStickerEditBody(options)
|
|
3940
4030
|
});
|
|
3941
4031
|
return toStickerPayload(data);
|
|
3942
4032
|
}
|
|
3943
4033
|
/** Delete a sticker from a pack. */
|
|
3944
4034
|
async deleteSticker(packId, stickerId) {
|
|
3945
|
-
await this.client.rest.delete(
|
|
4035
|
+
await this.client.rest.delete(Routes31.packSticker(packId, stickerId));
|
|
3946
4036
|
}
|
|
3947
4037
|
};
|
|
3948
4038
|
|
|
@@ -3961,10 +4051,10 @@ function createEventMethods(client) {
|
|
|
3961
4051
|
|
|
3962
4052
|
// src/client/clientEmoji.ts
|
|
3963
4053
|
import { Collection as Collection11 } from "@fluxerjs/collection";
|
|
3964
|
-
import { Routes as
|
|
4054
|
+
import { Routes as Routes32 } from "@fluxerjs/types";
|
|
3965
4055
|
import { formatEmoji, getUnicodeFromShortcode, parseEmoji } from "@fluxerjs/util";
|
|
3966
4056
|
async function assertEmojiInGuild(client, emojiId, guildId) {
|
|
3967
|
-
const emojis = await client.rest.get(
|
|
4057
|
+
const emojis = await client.rest.get(Routes32.guildEmojis(guildId));
|
|
3968
4058
|
if (!emojis.some((e) => e.id === emojiId)) {
|
|
3969
4059
|
throw new FluxerError("Custom emoji is from another server. Use an emoji from this server.", {
|
|
3970
4060
|
code: ErrorCodes.EmojiNotInGuild
|
|
@@ -3990,7 +4080,7 @@ async function resolveClientEmoji(client, emoji, guildId) {
|
|
|
3990
4080
|
const unicodeFromShortcode = getUnicodeFromShortcode(parsed.name);
|
|
3991
4081
|
if (unicodeFromShortcode) return unicodeFromShortcode;
|
|
3992
4082
|
if (guildId) {
|
|
3993
|
-
const emojis = await client.rest.get(
|
|
4083
|
+
const emojis = await client.rest.get(Routes32.guildEmojis(guildId));
|
|
3994
4084
|
const found = emojis.find((e) => e.name && e.name.toLowerCase() === parsed.name.toLowerCase());
|
|
3995
4085
|
if (found) return formatEmoji({ ...parsed, id: found.id, animated: found.animated });
|
|
3996
4086
|
throw new FluxerError(
|
|
@@ -4007,28 +4097,28 @@ async function resolveClientEmoji(client, emoji, guildId) {
|
|
|
4007
4097
|
return parsed.name;
|
|
4008
4098
|
}
|
|
4009
4099
|
async function fetchInstance(client) {
|
|
4010
|
-
const raw = await client.rest.get(
|
|
4100
|
+
const raw = await client.rest.get(Routes32.instanceDiscovery(), { auth: false });
|
|
4011
4101
|
return parseInstanceDiscovery(raw);
|
|
4012
4102
|
}
|
|
4013
4103
|
function fetchGatewayInfo(client) {
|
|
4014
|
-
return client.rest.get(
|
|
4104
|
+
return client.rest.get(Routes32.gatewayBot());
|
|
4015
4105
|
}
|
|
4016
4106
|
function fetchEmojiMetadata(client, emojiId) {
|
|
4017
|
-
return client.rest.get(
|
|
4107
|
+
return client.rest.get(Routes32.emojiMetadata(emojiId), { auth: true });
|
|
4018
4108
|
}
|
|
4019
4109
|
function fetchStickerMetadata(client, stickerId) {
|
|
4020
|
-
return client.rest.get(
|
|
4110
|
+
return client.rest.get(Routes32.stickerMetadata(stickerId), { auth: true });
|
|
4021
4111
|
}
|
|
4022
4112
|
function fetchApplication(client) {
|
|
4023
|
-
return client.rest.get(
|
|
4113
|
+
return client.rest.get(Routes32.applicationsMe(), { auth: true });
|
|
4024
4114
|
}
|
|
4025
4115
|
async function fetchOAuthApplications(client) {
|
|
4026
|
-
const data = await client.rest.get(
|
|
4116
|
+
const data = await client.rest.get(Routes32.oauth2ApplicationsMe(), { auth: true });
|
|
4027
4117
|
return Array.isArray(data) ? data : data.applications ?? [];
|
|
4028
4118
|
}
|
|
4029
4119
|
function checkUsernameTag(client, username, discriminator) {
|
|
4030
4120
|
const params = new URLSearchParams({ username, discriminator });
|
|
4031
|
-
return client.rest.get(`${
|
|
4121
|
+
return client.rest.get(`${Routes32.checkUsernameTag()}?${params}`, { auth: true });
|
|
4032
4122
|
}
|
|
4033
4123
|
function assertChannelIdBatch(name, channelIds) {
|
|
4034
4124
|
if (channelIds.length < 1 || channelIds.length > 100) {
|
|
@@ -4039,14 +4129,14 @@ function assertChannelIdBatch(name, channelIds) {
|
|
|
4039
4129
|
}
|
|
4040
4130
|
function preloadMessages(client, channelIds) {
|
|
4041
4131
|
assertChannelIdBatch("preloadMessages", channelIds);
|
|
4042
|
-
return client.rest.post(
|
|
4132
|
+
return client.rest.post(Routes32.preloadMessages(), {
|
|
4043
4133
|
body: { channels: channelIds },
|
|
4044
4134
|
auth: true
|
|
4045
4135
|
});
|
|
4046
4136
|
}
|
|
4047
4137
|
function preloadMessagesAlt(client, channelIds) {
|
|
4048
4138
|
assertChannelIdBatch("preloadMessagesAlt", channelIds);
|
|
4049
|
-
return client.rest.post(
|
|
4139
|
+
return client.rest.post(Routes32.preloadMessagesAlt(), {
|
|
4050
4140
|
body: { channels: channelIds },
|
|
4051
4141
|
auth: true
|
|
4052
4142
|
});
|
|
@@ -4054,7 +4144,7 @@ function preloadMessagesAlt(client, channelIds) {
|
|
|
4054
4144
|
async function bulkFetchMessages(client, requests, options = {}) {
|
|
4055
4145
|
validateBulkMessageFetchRequests(requests);
|
|
4056
4146
|
const wire = toBulkFetchWire(requests);
|
|
4057
|
-
const data = await client.rest.post(
|
|
4147
|
+
const data = await client.rest.post(Routes32.channelsMessagesBulk(), {
|
|
4058
4148
|
body: { requests: wire },
|
|
4059
4149
|
auth: true
|
|
4060
4150
|
});
|
|
@@ -4141,62 +4231,6 @@ function buildRegistry(...maps) {
|
|
|
4141
4231
|
return registry;
|
|
4142
4232
|
}
|
|
4143
4233
|
|
|
4144
|
-
// src/structures/MessageReaction.ts
|
|
4145
|
-
import { Routes as Routes32 } from "@fluxerjs/types";
|
|
4146
|
-
import { FluxerAPIError as FluxerAPIError5, RateLimitError as RateLimitError4 } from "@fluxerjs/rest";
|
|
4147
|
-
var MessageReaction = class extends Base {
|
|
4148
|
-
client;
|
|
4149
|
-
messageId;
|
|
4150
|
-
channelId;
|
|
4151
|
-
guildId;
|
|
4152
|
-
emoji;
|
|
4153
|
-
/** Raw gateway payload for low-level access. */
|
|
4154
|
-
_data;
|
|
4155
|
-
constructor(client, data) {
|
|
4156
|
-
super();
|
|
4157
|
-
this.client = client;
|
|
4158
|
-
this._data = data;
|
|
4159
|
-
this.messageId = data.message_id;
|
|
4160
|
-
this.channelId = data.channel_id;
|
|
4161
|
-
this.guildId = data.guild_id ?? null;
|
|
4162
|
-
this.emoji = {
|
|
4163
|
-
name: data.emoji.name,
|
|
4164
|
-
...data.emoji.id !== void 0 ? { id: data.emoji.id } : {},
|
|
4165
|
-
...data.emoji.animated !== void 0 ? { animated: data.emoji.animated } : {}
|
|
4166
|
-
};
|
|
4167
|
-
}
|
|
4168
|
-
/** Emoji as a string: unicode or "name:id" for custom. */
|
|
4169
|
-
get emojiIdentifier() {
|
|
4170
|
-
return this.emoji.id ? `${this.emoji.name}:${this.emoji.id}` : this.emoji.name;
|
|
4171
|
-
}
|
|
4172
|
-
/** Guild where this reaction was added. Resolved from cache; null for DMs or if not cached. */
|
|
4173
|
-
get guild() {
|
|
4174
|
-
return this.guildId ? this.client.guilds.get(this.guildId) ?? null : null;
|
|
4175
|
-
}
|
|
4176
|
-
/**
|
|
4177
|
-
* Fetch the message this reaction belongs to.
|
|
4178
|
-
* Use when you need to edit, delete, or otherwise interact with the message.
|
|
4179
|
-
* @throws FluxerError with MESSAGE_NOT_FOUND if the message does not exist
|
|
4180
|
-
*/
|
|
4181
|
-
async fetchMessage() {
|
|
4182
|
-
try {
|
|
4183
|
-
const data = await this.client.rest.get(
|
|
4184
|
-
Routes32.channelMessage(this.channelId, this.messageId)
|
|
4185
|
-
);
|
|
4186
|
-
return new Message(this.client, data);
|
|
4187
|
-
} catch (err) {
|
|
4188
|
-
if (err instanceof RateLimitError4) throw err;
|
|
4189
|
-
if (err instanceof FluxerAPIError5 && err.statusCode === 404) {
|
|
4190
|
-
throw new FluxerError(`Message ${this.messageId} not found in channel ${this.channelId}`, {
|
|
4191
|
-
code: ErrorCodes.MessageNotFound,
|
|
4192
|
-
cause: err
|
|
4193
|
-
});
|
|
4194
|
-
}
|
|
4195
|
-
throw err instanceof FluxerError ? err : new FluxerError(String(err), { cause: err });
|
|
4196
|
-
}
|
|
4197
|
-
}
|
|
4198
|
-
};
|
|
4199
|
-
|
|
4200
4234
|
// src/client/eventHandlers/helpers.ts
|
|
4201
4235
|
function unknownUser(id) {
|
|
4202
4236
|
return { id, username: "Unknown", discriminator: "0" };
|