lunibee 0.2.1 → 0.2.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/README.md +6 -6
- package/dist/builders/attachment.d.ts +5 -1
- package/dist/builders/commands.d.ts +136 -47
- package/dist/builders/components.d.ts +164 -45
- package/dist/builders/embed.d.ts +5 -1
- package/dist/builders/index.d.ts +9 -4
- package/dist/builders/index.js +206 -105
- package/dist/builders/index.js.map +8 -8
- package/dist/core/events.d.ts +28 -12
- package/dist/core/index.d.ts +2 -1
- package/dist/core/index.js +377 -150
- package/dist/core/index.js.map +25 -25
- package/dist/core/permissions.d.ts +6 -2
- package/dist/index.d.ts +5 -4
- package/dist/index.js +662 -268
- package/dist/index.js.map +33 -32
- package/dist/managers/base.d.ts +4 -0
- package/dist/managers/emoji.d.ts +7 -1
- package/dist/managers/guild-resources.d.ts +11 -3
- package/dist/managers/guild.d.ts +13 -5
- package/dist/managers/index.d.ts +31 -14
- package/dist/managers/index.js +167 -80
- package/dist/managers/index.js.map +18 -18
- package/dist/managers/member.d.ts +5 -3
- package/dist/managers/message.d.ts +7 -3
- package/dist/managers/role.d.ts +13 -1
- package/dist/rest/error-codes.d.ts +48 -0
- package/dist/rest/errors.d.ts +1 -0
- package/dist/rest/index.d.ts +1 -0
- package/dist/rest/index.js +53 -3
- package/dist/rest/index.js.map +7 -6
- package/dist/rest/routes.d.ts +4 -2
- package/dist/sharding/index.js +7 -6
- package/dist/sharding/index.js.map +6 -6
- package/dist/structures/base.d.ts +18 -9
- package/dist/structures/index.d.ts +15 -9
- package/dist/structures/index.js +198 -68
- package/dist/structures/index.js.map +12 -12
- package/dist/structures/interactions.d.ts +85 -11
- package/dist/structures/resources.d.ts +11 -1
- package/dist/types/gateway.d.ts +14 -0
- package/dist/types/index.d.ts +204 -16
- package/dist/types/index.js +37 -10
- package/dist/types/index.js.map +4 -4
- package/dist/voice/index.js +4 -3
- package/dist/voice/index.js.map +3 -3
- package/dist/ws/index.js +2 -1
- package/dist/ws/index.js.map +5 -5
- package/package.json +15 -15
package/dist/index.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
// packages/core/src/permissions.ts
|
|
3
|
-
var
|
|
4
|
-
((
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
})(
|
|
3
|
+
var PermissionOverwriteEnum;
|
|
4
|
+
((PermissionOverwriteEnum) => {
|
|
5
|
+
PermissionOverwriteEnum[PermissionOverwriteEnum["Role"] = 0] = "Role";
|
|
6
|
+
PermissionOverwriteEnum[PermissionOverwriteEnum["Member"] = 1] = "Member";
|
|
7
|
+
})(PermissionOverwriteEnum ||= {});
|
|
8
|
+
var PermissionOverwriteType = PermissionOverwriteEnum;
|
|
8
9
|
var Permission = {
|
|
9
10
|
createInstantInvite: 1n << 0n,
|
|
10
11
|
kickMembers: 1n << 1n,
|
|
@@ -814,7 +815,7 @@ var MessageFlags = {
|
|
|
814
815
|
Loading: 128,
|
|
815
816
|
IsComponentsV2: 32768
|
|
816
817
|
};
|
|
817
|
-
var
|
|
818
|
+
var ChannelEnum = {
|
|
818
819
|
GuildText: 0,
|
|
819
820
|
DM: 1,
|
|
820
821
|
GuildVoice: 2,
|
|
@@ -829,7 +830,7 @@ var ChannelType = {
|
|
|
829
830
|
GuildForum: 15,
|
|
830
831
|
GuildMedia: 16
|
|
831
832
|
};
|
|
832
|
-
var
|
|
833
|
+
var ButtonType = {
|
|
833
834
|
Primary: 1,
|
|
834
835
|
Secondary: 2,
|
|
835
836
|
Success: 3,
|
|
@@ -837,7 +838,7 @@ var ButtonStyle = {
|
|
|
837
838
|
Link: 5,
|
|
838
839
|
Premium: 6
|
|
839
840
|
};
|
|
840
|
-
var
|
|
841
|
+
var InteractionResponseEnum = {
|
|
841
842
|
Pong: 1,
|
|
842
843
|
ChannelMessage: 4,
|
|
843
844
|
DeferredChannelMessage: 5,
|
|
@@ -846,13 +847,13 @@ var InteractionResponseType = {
|
|
|
846
847
|
Autocomplete: 8,
|
|
847
848
|
Modal: 9
|
|
848
849
|
};
|
|
849
|
-
var
|
|
850
|
+
var StickerFormatEnum = {
|
|
850
851
|
PNG: 1,
|
|
851
852
|
APNG: 2,
|
|
852
853
|
Lottie: 3,
|
|
853
854
|
GIF: 4
|
|
854
855
|
};
|
|
855
|
-
var
|
|
856
|
+
var StickerEnum = {
|
|
856
857
|
Standard: 1,
|
|
857
858
|
Guild: 2
|
|
858
859
|
};
|
|
@@ -869,7 +870,15 @@ var PremiumTier = {
|
|
|
869
870
|
Tier2: 2,
|
|
870
871
|
Tier3: 3
|
|
871
872
|
};
|
|
872
|
-
var
|
|
873
|
+
var ActivityEnum = {
|
|
874
|
+
Playing: 0,
|
|
875
|
+
Streaming: 1,
|
|
876
|
+
Listening: 2,
|
|
877
|
+
Watching: 3,
|
|
878
|
+
Custom: 4,
|
|
879
|
+
Competing: 5
|
|
880
|
+
};
|
|
881
|
+
var ApplicationCommandOptionEnum = {
|
|
873
882
|
SubCommand: 1,
|
|
874
883
|
SubCommandGroup: 2,
|
|
875
884
|
String: 3,
|
|
@@ -882,11 +891,17 @@ var ApplicationCommandOptionType = {
|
|
|
882
891
|
Number: 10,
|
|
883
892
|
Attachment: 11
|
|
884
893
|
};
|
|
885
|
-
var
|
|
894
|
+
var ApplicationCommandEnum = {
|
|
886
895
|
ChatInput: 1,
|
|
887
896
|
User: 2,
|
|
888
897
|
Message: 3
|
|
889
898
|
};
|
|
899
|
+
var ChannelType = ChannelEnum;
|
|
900
|
+
var InteractionResponseType = InteractionResponseEnum;
|
|
901
|
+
var ApplicationCommandType = ApplicationCommandEnum;
|
|
902
|
+
var ApplicationCommandOptionType = ApplicationCommandOptionEnum;
|
|
903
|
+
var StickerType = StickerEnum;
|
|
904
|
+
var StickerFormatType = StickerFormatEnum;
|
|
890
905
|
// packages/collection/src/cache.ts
|
|
891
906
|
class Cache {
|
|
892
907
|
#entries = new Collection;
|
|
@@ -1534,6 +1549,11 @@ class Collection extends Map {
|
|
|
1534
1549
|
}
|
|
1535
1550
|
|
|
1536
1551
|
// packages/managers/src/base.ts
|
|
1552
|
+
function splitReason(options) {
|
|
1553
|
+
const { reason, ...payload } = options;
|
|
1554
|
+
return [payload, reason];
|
|
1555
|
+
}
|
|
1556
|
+
|
|
1537
1557
|
class Manager {
|
|
1538
1558
|
cache = new Collection;
|
|
1539
1559
|
get(id) {
|
|
@@ -1635,12 +1655,15 @@ class ResourceManager extends Manager {
|
|
|
1635
1655
|
// packages/rest/package.json
|
|
1636
1656
|
var package_default = {
|
|
1637
1657
|
name: "@lunibee/rest",
|
|
1638
|
-
version: "0.2.
|
|
1658
|
+
version: "0.2.3",
|
|
1639
1659
|
type: "module",
|
|
1640
1660
|
module: "./src/index.ts",
|
|
1641
1661
|
types: "./src/index.ts",
|
|
1642
1662
|
exports: {
|
|
1643
1663
|
".": "./src/index.ts"
|
|
1664
|
+
},
|
|
1665
|
+
dependencies: {
|
|
1666
|
+
"@lunibee/types": "workspace:*"
|
|
1644
1667
|
}
|
|
1645
1668
|
};
|
|
1646
1669
|
|
|
@@ -1715,6 +1738,10 @@ function kindFromStatus(status) {
|
|
|
1715
1738
|
function redactPath(path) {
|
|
1716
1739
|
return path.replace(/^(\/webhooks\/[^/?]+\/)[^/?]+/, "$1:token").replace(/^(\/interactions\/[^/?]+\/)[^/?]+/, "$1:token");
|
|
1717
1740
|
}
|
|
1741
|
+
var HINTS = {
|
|
1742
|
+
50001: "The bot cannot see this resource: check that it is in the guild and has View Channel there.",
|
|
1743
|
+
50013: "The bot lacks a permission for this action, or the target role or member is at or above the bot's highest role."
|
|
1744
|
+
};
|
|
1718
1745
|
|
|
1719
1746
|
class RESTError extends Error {
|
|
1720
1747
|
kind;
|
|
@@ -1723,12 +1750,14 @@ class RESTError extends Error {
|
|
|
1723
1750
|
errors;
|
|
1724
1751
|
method;
|
|
1725
1752
|
path;
|
|
1753
|
+
hint;
|
|
1726
1754
|
constructor(message, status, code, errors, options = {}) {
|
|
1727
1755
|
super(message, options.cause === undefined ? undefined : { cause: options.cause });
|
|
1728
1756
|
this.name = "RESTError";
|
|
1729
1757
|
this.status = status;
|
|
1730
1758
|
this.kind = options.kind ?? kindFromStatus(status);
|
|
1731
1759
|
this.code = code;
|
|
1760
|
+
this.hint = code === undefined ? undefined : HINTS[code];
|
|
1732
1761
|
this.errors = errors;
|
|
1733
1762
|
this.method = options.method;
|
|
1734
1763
|
this.path = options.path === undefined ? undefined : redactPath(options.path);
|
|
@@ -2037,6 +2066,8 @@ var Routes = {
|
|
|
2037
2066
|
crosspostMessage: (channelId, messageId) => `${Routes.message(channelId, messageId)}/crosspost`,
|
|
2038
2067
|
messageReactions: (channelId, messageId, emoji) => `${Routes.message(channelId, messageId)}/reactions/${encodeURIComponent(emoji)}`,
|
|
2039
2068
|
messageReactionsAll: (channelId, messageId) => `${Routes.message(channelId, messageId)}/reactions`,
|
|
2069
|
+
channelMessagesPins: (channelId) => `/channels/${snowflake(channelId, "Channel ID")}/messages/pins`,
|
|
2070
|
+
channelMessagesPin: (channelId, messageId) => `/channels/${snowflake(channelId, "Channel ID")}/messages/pins/${snowflake(messageId, "Message ID")}`,
|
|
2040
2071
|
channelPins: (channelId) => `/channels/${snowflake(channelId, "Channel ID")}/pins`,
|
|
2041
2072
|
channelPin: (channelId, messageId) => `/channels/${snowflake(channelId, "Channel ID")}/pins/${snowflake(messageId, "Message ID")}`,
|
|
2042
2073
|
messageThread: (channelId, messageId) => `${Routes.message(channelId, messageId)}/threads`,
|
|
@@ -2095,6 +2126,44 @@ function snowflake(value, field) {
|
|
|
2095
2126
|
throw new TypeError(`${field} must be a valid Discord snowflake.`);
|
|
2096
2127
|
return value;
|
|
2097
2128
|
}
|
|
2129
|
+
// packages/rest/src/error-codes.ts
|
|
2130
|
+
var RESTErrorCode = {
|
|
2131
|
+
UnknownAccount: 10001,
|
|
2132
|
+
UnknownChannel: 10003,
|
|
2133
|
+
UnknownGuild: 10004,
|
|
2134
|
+
UnknownInvite: 10006,
|
|
2135
|
+
UnknownMember: 10007,
|
|
2136
|
+
UnknownMessage: 10008,
|
|
2137
|
+
UnknownPermissionOverwrite: 10009,
|
|
2138
|
+
UnknownRole: 10011,
|
|
2139
|
+
UnknownUser: 10013,
|
|
2140
|
+
UnknownEmoji: 10014,
|
|
2141
|
+
UnknownWebhook: 10015,
|
|
2142
|
+
UnknownBan: 10026,
|
|
2143
|
+
UnknownSticker: 10060,
|
|
2144
|
+
UnknownInteraction: 10062,
|
|
2145
|
+
UnknownScheduledEvent: 10070,
|
|
2146
|
+
BotsCannotUseEndpoint: 20001,
|
|
2147
|
+
MaxGuilds: 30001,
|
|
2148
|
+
MaxPins: 30003,
|
|
2149
|
+
MaxRoles: 30005,
|
|
2150
|
+
MaxWebhooks: 30007,
|
|
2151
|
+
MaxEmojis: 30008,
|
|
2152
|
+
MaxReactions: 30010,
|
|
2153
|
+
MaxChannels: 30013,
|
|
2154
|
+
InteractionAlreadyAcknowledged: 40060,
|
|
2155
|
+
MissingAccess: 50001,
|
|
2156
|
+
CannotExecuteInDM: 50003,
|
|
2157
|
+
CannotEditOthersMessage: 50005,
|
|
2158
|
+
CannotSendEmptyMessage: 50006,
|
|
2159
|
+
CannotSendMessagesToUser: 50007,
|
|
2160
|
+
MissingPermissions: 50013,
|
|
2161
|
+
InvalidToken: 50014,
|
|
2162
|
+
MessageTooOldToBulkDelete: 50034,
|
|
2163
|
+
InvalidFormBody: 50035,
|
|
2164
|
+
ThreadArchived: 50083,
|
|
2165
|
+
CannotReplyWithoutReadHistory: 160002
|
|
2166
|
+
};
|
|
2098
2167
|
// packages/rest/src/redis.ts
|
|
2099
2168
|
var RESERVE_SCRIPT = `
|
|
2100
2169
|
local raw = redis.call('GET', KEYS[1])
|
|
@@ -2276,7 +2345,7 @@ class WebhookClient {
|
|
|
2276
2345
|
// packages/rest/src/index.ts
|
|
2277
2346
|
var LIBRARY_VERSION = package_default.version;
|
|
2278
2347
|
var LIBRARY_URL = "https://github.com/Ekretos/lunibee";
|
|
2279
|
-
var USER_AGENT = `DiscordBot (${LIBRARY_URL}, ${
|
|
2348
|
+
var USER_AGENT = `DiscordBot (${LIBRARY_URL}, ${LIBRARY_VERSION})`;
|
|
2280
2349
|
var REQUEST_DATA_KEYS = new Set([
|
|
2281
2350
|
"body",
|
|
2282
2351
|
"files",
|
|
@@ -2599,13 +2668,13 @@ class Channel extends BaseStructure {
|
|
|
2599
2668
|
this.permissionOverwrites = (data.permission_overwrites ?? []).map((overwrite) => ({ ...overwrite }));
|
|
2600
2669
|
this.#context = context;
|
|
2601
2670
|
}
|
|
2602
|
-
|
|
2671
|
+
send(options) {
|
|
2603
2672
|
if (!this.#context)
|
|
2604
2673
|
throw new Error("This channel is not attached to a client.");
|
|
2605
2674
|
return this.#context.sendMessage(this.id, options);
|
|
2606
2675
|
}
|
|
2607
|
-
|
|
2608
|
-
return this.
|
|
2676
|
+
sendMessage(options) {
|
|
2677
|
+
return this.send(options);
|
|
2609
2678
|
}
|
|
2610
2679
|
edit(options) {
|
|
2611
2680
|
if (!this.#context?.editChannel)
|
|
@@ -2628,10 +2697,10 @@ class Channel extends BaseStructure {
|
|
|
2628
2697
|
editParent(parentId) {
|
|
2629
2698
|
return this.edit({ parent_id: parentId });
|
|
2630
2699
|
}
|
|
2631
|
-
delete() {
|
|
2700
|
+
delete(reason) {
|
|
2632
2701
|
if (!this.#context?.deleteChannel)
|
|
2633
2702
|
throw new Error("This channel is not attached to a client.");
|
|
2634
|
-
return this.#context.deleteChannel(this.id);
|
|
2703
|
+
return this.#context.deleteChannel(this.id, reason);
|
|
2635
2704
|
}
|
|
2636
2705
|
update(options) {
|
|
2637
2706
|
return this.edit(options);
|
|
@@ -2678,6 +2747,15 @@ class Guild extends BaseStructure {
|
|
|
2678
2747
|
mfaLevel;
|
|
2679
2748
|
explicitContentFilter;
|
|
2680
2749
|
defaultMessageNotifications;
|
|
2750
|
+
afkChannelId;
|
|
2751
|
+
afkTimeout;
|
|
2752
|
+
widgetEnabled;
|
|
2753
|
+
widgetChannelId;
|
|
2754
|
+
applicationId;
|
|
2755
|
+
publicUpdatesChannelId;
|
|
2756
|
+
safetyAlertsChannelId;
|
|
2757
|
+
maxPresences;
|
|
2758
|
+
maxVideoChannelUsers;
|
|
2681
2759
|
constructor(data) {
|
|
2682
2760
|
super(data.id);
|
|
2683
2761
|
if (!data.name)
|
|
@@ -2699,14 +2777,22 @@ class Guild extends BaseStructure {
|
|
|
2699
2777
|
this.vanityUrlCode = data.vanity_url_code ?? null;
|
|
2700
2778
|
this.nsfwLevel = data.nsfw_level ?? 0;
|
|
2701
2779
|
this.discoverySplash = data.discovery_splash ?? null;
|
|
2702
|
-
|
|
2703
|
-
this.
|
|
2704
|
-
this.
|
|
2705
|
-
this.
|
|
2706
|
-
this.
|
|
2707
|
-
this.
|
|
2708
|
-
this.
|
|
2709
|
-
this.
|
|
2780
|
+
this.rulesChannelId = data.rules_channel_id ?? null;
|
|
2781
|
+
this.systemChannelId = data.system_channel_id ?? null;
|
|
2782
|
+
this.systemChannelFlags = data.system_channel_flags ?? 0;
|
|
2783
|
+
this.maxMembers = data.max_members ?? 0;
|
|
2784
|
+
this.mfaLevel = data.mfa_level ?? 0;
|
|
2785
|
+
this.explicitContentFilter = data.explicit_content_filter ?? 0;
|
|
2786
|
+
this.defaultMessageNotifications = data.default_message_notifications ?? 0;
|
|
2787
|
+
this.afkChannelId = data.afk_channel_id ?? null;
|
|
2788
|
+
this.afkTimeout = data.afk_timeout;
|
|
2789
|
+
this.widgetEnabled = data.widget_enabled ?? false;
|
|
2790
|
+
this.widgetChannelId = data.widget_channel_id ?? null;
|
|
2791
|
+
this.applicationId = data.application_id ?? null;
|
|
2792
|
+
this.publicUpdatesChannelId = data.public_updates_channel_id ?? null;
|
|
2793
|
+
this.safetyAlertsChannelId = data.safety_alerts_channel_id ?? null;
|
|
2794
|
+
this.maxPresences = data.max_presences ?? null;
|
|
2795
|
+
this.maxVideoChannelUsers = data.max_video_channel_users;
|
|
2710
2796
|
}
|
|
2711
2797
|
iconURL(options = {}) {
|
|
2712
2798
|
if (!this.icon)
|
|
@@ -2942,7 +3028,7 @@ class Invite {
|
|
|
2942
3028
|
return this.url;
|
|
2943
3029
|
}
|
|
2944
3030
|
}
|
|
2945
|
-
var
|
|
3031
|
+
var WebhookEnum = {
|
|
2946
3032
|
Incoming: 1,
|
|
2947
3033
|
ChannelFollower: 2,
|
|
2948
3034
|
Application: 3
|
|
@@ -2958,7 +3044,7 @@ class Webhook extends BaseStructure {
|
|
|
2958
3044
|
token;
|
|
2959
3045
|
constructor(data) {
|
|
2960
3046
|
super(data.id);
|
|
2961
|
-
this.type = data.type ??
|
|
3047
|
+
this.type = data.type ?? WebhookEnum.Incoming;
|
|
2962
3048
|
this.name = data.name ?? null;
|
|
2963
3049
|
this.avatarHash = data.avatar ?? null;
|
|
2964
3050
|
this.channelId = data.channel_id ?? null;
|
|
@@ -3123,6 +3209,7 @@ class GuildOnboarding extends BaseStructure {
|
|
|
3123
3209
|
this.mode = data.mode;
|
|
3124
3210
|
}
|
|
3125
3211
|
}
|
|
3212
|
+
var WebhookType = WebhookEnum;
|
|
3126
3213
|
// packages/structures/src/channels.ts
|
|
3127
3214
|
class NewsChannel extends TextChannel {
|
|
3128
3215
|
}
|
|
@@ -3241,6 +3328,13 @@ var OptionType = {
|
|
|
3241
3328
|
class CommandOptions {
|
|
3242
3329
|
#options;
|
|
3243
3330
|
#resolved;
|
|
3331
|
+
#lookup(kind, id) {
|
|
3332
|
+
const group = this.#resolved?.[kind];
|
|
3333
|
+
if (typeof group !== "object" || group === null)
|
|
3334
|
+
return;
|
|
3335
|
+
const entry = group[id];
|
|
3336
|
+
return typeof entry === "object" && entry !== null ? entry : undefined;
|
|
3337
|
+
}
|
|
3244
3338
|
constructor(options, resolved = {}) {
|
|
3245
3339
|
let currentOptions = options;
|
|
3246
3340
|
let group = null;
|
|
@@ -3329,7 +3423,7 @@ class CommandOptions {
|
|
|
3329
3423
|
return null;
|
|
3330
3424
|
}
|
|
3331
3425
|
const userId = String(opt.value);
|
|
3332
|
-
const resolved = this.#
|
|
3426
|
+
const resolved = this.#lookup("users", userId) ?? null;
|
|
3333
3427
|
if (!resolved && required)
|
|
3334
3428
|
throw new TypeError(`Resolved user for option "${name}" is missing.`);
|
|
3335
3429
|
return resolved;
|
|
@@ -3342,7 +3436,7 @@ class CommandOptions {
|
|
|
3342
3436
|
return null;
|
|
3343
3437
|
}
|
|
3344
3438
|
const channelId = String(opt.value);
|
|
3345
|
-
const resolved = this.#
|
|
3439
|
+
const resolved = this.#lookup("channels", channelId) ?? null;
|
|
3346
3440
|
if (!resolved && required)
|
|
3347
3441
|
throw new TypeError(`Resolved channel for option "${name}" is missing.`);
|
|
3348
3442
|
return resolved;
|
|
@@ -3355,7 +3449,7 @@ class CommandOptions {
|
|
|
3355
3449
|
return null;
|
|
3356
3450
|
}
|
|
3357
3451
|
const roleId = String(opt.value);
|
|
3358
|
-
const resolved = this.#
|
|
3452
|
+
const resolved = this.#lookup("roles", roleId) ?? null;
|
|
3359
3453
|
if (!resolved && required)
|
|
3360
3454
|
throw new TypeError(`Resolved role for option "${name}" is missing.`);
|
|
3361
3455
|
return resolved;
|
|
@@ -3368,7 +3462,7 @@ class CommandOptions {
|
|
|
3368
3462
|
return null;
|
|
3369
3463
|
}
|
|
3370
3464
|
const id = String(opt.value);
|
|
3371
|
-
const resolved = this.#
|
|
3465
|
+
const resolved = this.#lookup("users", id) ?? this.#lookup("roles", id) ?? null;
|
|
3372
3466
|
if (!resolved && required)
|
|
3373
3467
|
throw new TypeError(`Resolved mentionable for option "${name}" is missing.`);
|
|
3374
3468
|
return resolved;
|
|
@@ -3378,9 +3472,9 @@ class CommandOptions {
|
|
|
3378
3472
|
if (!opt || opt.type !== OptionType.Mentionable)
|
|
3379
3473
|
return null;
|
|
3380
3474
|
const id = String(opt.value);
|
|
3381
|
-
if (this.#
|
|
3475
|
+
if (this.#lookup("users", id))
|
|
3382
3476
|
return "user";
|
|
3383
|
-
if (this.#
|
|
3477
|
+
if (this.#lookup("roles", id))
|
|
3384
3478
|
return "role";
|
|
3385
3479
|
return null;
|
|
3386
3480
|
}
|
|
@@ -3392,7 +3486,7 @@ class CommandOptions {
|
|
|
3392
3486
|
return null;
|
|
3393
3487
|
}
|
|
3394
3488
|
const attachmentId = String(opt.value);
|
|
3395
|
-
const resolved = this.#
|
|
3489
|
+
const resolved = this.#lookup("attachments", attachmentId) ?? null;
|
|
3396
3490
|
if (!resolved && required)
|
|
3397
3491
|
throw new TypeError(`Resolved attachment for option "${name}" is missing.`);
|
|
3398
3492
|
return resolved;
|
|
@@ -3402,7 +3496,7 @@ class CommandOptions {
|
|
|
3402
3496
|
}
|
|
3403
3497
|
}
|
|
3404
3498
|
// packages/structures/src/interactions.ts
|
|
3405
|
-
var
|
|
3499
|
+
var InteractionEnum = {
|
|
3406
3500
|
Ping: 1,
|
|
3407
3501
|
ApplicationCommand: 2,
|
|
3408
3502
|
MessageComponent: 3,
|
|
@@ -3410,8 +3504,17 @@ var InteractionType = {
|
|
|
3410
3504
|
ModalSubmit: 5
|
|
3411
3505
|
};
|
|
3412
3506
|
var EPHEMERAL = 64;
|
|
3507
|
+
var COMMAND_CHAT_INPUT = 1;
|
|
3508
|
+
var COMMAND_USER = 2;
|
|
3509
|
+
var COMMAND_MESSAGE = 3;
|
|
3413
3510
|
var TOKEN_LIFETIME_MS = 15 * 60000;
|
|
3414
3511
|
var DISCORD_EPOCH = 1420070400000n;
|
|
3512
|
+
function splitWithResponse(options) {
|
|
3513
|
+
if (typeof options === "string")
|
|
3514
|
+
return { withResponse: false, rest: options };
|
|
3515
|
+
const { withResponse, ...rest } = options;
|
|
3516
|
+
return { withResponse: withResponse === true, rest };
|
|
3517
|
+
}
|
|
3415
3518
|
function toMessageData(options) {
|
|
3416
3519
|
if (typeof options === "string")
|
|
3417
3520
|
return { content: options };
|
|
@@ -3424,6 +3527,7 @@ function toMessageData(options) {
|
|
|
3424
3527
|
class InteractionResponse {
|
|
3425
3528
|
type;
|
|
3426
3529
|
data;
|
|
3530
|
+
withResponse = false;
|
|
3427
3531
|
constructor(type, data) {
|
|
3428
3532
|
if (!Number.isFinite(type))
|
|
3429
3533
|
throw new TypeError("Interaction response type must be finite.");
|
|
@@ -3434,13 +3538,13 @@ class InteractionResponse {
|
|
|
3434
3538
|
return this.data === undefined ? { type: this.type } : { type: this.type, data: this.data };
|
|
3435
3539
|
}
|
|
3436
3540
|
static message(options) {
|
|
3437
|
-
return new InteractionResponse(
|
|
3541
|
+
return new InteractionResponse(InteractionResponseEnum.ChannelMessage, toMessageData(options));
|
|
3438
3542
|
}
|
|
3439
3543
|
static defer(ephemeral = false) {
|
|
3440
|
-
return new InteractionResponse(
|
|
3544
|
+
return new InteractionResponse(InteractionResponseEnum.DeferredChannelMessage, ephemeral ? { flags: EPHEMERAL } : undefined);
|
|
3441
3545
|
}
|
|
3442
3546
|
static pong() {
|
|
3443
|
-
return new InteractionResponse(
|
|
3547
|
+
return new InteractionResponse(InteractionResponseEnum.Pong);
|
|
3444
3548
|
}
|
|
3445
3549
|
}
|
|
3446
3550
|
|
|
@@ -3468,8 +3572,30 @@ class Interaction {
|
|
|
3468
3572
|
this.type = data.type;
|
|
3469
3573
|
this.data = data;
|
|
3470
3574
|
}
|
|
3575
|
+
#commandType() {
|
|
3576
|
+
if (this.type !== InteractionEnum.ApplicationCommand)
|
|
3577
|
+
return 0;
|
|
3578
|
+
const type = this.data.data?.type;
|
|
3579
|
+
return typeof type === "number" ? type : COMMAND_CHAT_INPUT;
|
|
3580
|
+
}
|
|
3581
|
+
isCommand() {
|
|
3582
|
+
return this.type === InteractionEnum.ApplicationCommand;
|
|
3583
|
+
}
|
|
3471
3584
|
isChatInputCommand() {
|
|
3472
|
-
return this
|
|
3585
|
+
return this.#commandType() === COMMAND_CHAT_INPUT;
|
|
3586
|
+
}
|
|
3587
|
+
isContextMenuCommand() {
|
|
3588
|
+
const type = this.#commandType();
|
|
3589
|
+
return type === COMMAND_USER || type === COMMAND_MESSAGE;
|
|
3590
|
+
}
|
|
3591
|
+
isUserContextMenuCommand() {
|
|
3592
|
+
return this.#commandType() === COMMAND_USER;
|
|
3593
|
+
}
|
|
3594
|
+
isMessageContextMenuCommand() {
|
|
3595
|
+
return this.#commandType() === COMMAND_MESSAGE;
|
|
3596
|
+
}
|
|
3597
|
+
get resourceContext() {
|
|
3598
|
+
return this.#client.resourceContext;
|
|
3473
3599
|
}
|
|
3474
3600
|
awaitModalSubmit(options) {
|
|
3475
3601
|
const collect = this.#client.resourceContext?.collectInteractions;
|
|
@@ -3486,13 +3612,13 @@ class Interaction {
|
|
|
3486
3612
|
return collector.next();
|
|
3487
3613
|
}
|
|
3488
3614
|
isMessageComponent() {
|
|
3489
|
-
return this.type ===
|
|
3615
|
+
return this.type === InteractionEnum.MessageComponent;
|
|
3490
3616
|
}
|
|
3491
3617
|
isModalSubmit() {
|
|
3492
|
-
return this.type ===
|
|
3618
|
+
return this.type === InteractionEnum.ModalSubmit;
|
|
3493
3619
|
}
|
|
3494
3620
|
isAutocomplete() {
|
|
3495
|
-
return this.type ===
|
|
3621
|
+
return this.type === InteractionEnum.ApplicationCommandAutocomplete;
|
|
3496
3622
|
}
|
|
3497
3623
|
#componentType() {
|
|
3498
3624
|
return this.isMessageComponent() ? this.data.data?.component_type ?? 0 : 0;
|
|
@@ -3577,12 +3703,24 @@ class Interaction {
|
|
|
3577
3703
|
postResponse(response) {
|
|
3578
3704
|
return this.#client.postInteractionResponse(this.id, this.token, response);
|
|
3579
3705
|
}
|
|
3706
|
+
async acknowledgeWith(response, state, withResponse) {
|
|
3707
|
+
response.withResponse = withResponse;
|
|
3708
|
+
const result = await this.acknowledge(response, state);
|
|
3709
|
+
if (!withResponse)
|
|
3710
|
+
return result;
|
|
3711
|
+
const message = result?.resource?.message;
|
|
3712
|
+
return message ? new Message(message, this.#client.resourceContext) : null;
|
|
3713
|
+
}
|
|
3580
3714
|
async reply(options) {
|
|
3581
|
-
|
|
3715
|
+
const { withResponse, rest } = splitWithResponse(options);
|
|
3716
|
+
return this.acknowledgeWith(InteractionResponse.message(toMessageData(rest)), "replied", withResponse);
|
|
3582
3717
|
}
|
|
3583
3718
|
async deferReply(options = false) {
|
|
3584
3719
|
const ephemeral = typeof options === "boolean" ? options : options.ephemeral === true;
|
|
3585
|
-
|
|
3720
|
+
const withResponse = typeof options === "object" && options.withResponse === true;
|
|
3721
|
+
const result = await this.acknowledgeWith(InteractionResponse.defer(ephemeral), "deferred", withResponse);
|
|
3722
|
+
if (withResponse)
|
|
3723
|
+
return result;
|
|
3586
3724
|
}
|
|
3587
3725
|
editReply(options) {
|
|
3588
3726
|
this.assertAcknowledged();
|
|
@@ -3596,11 +3734,12 @@ class Interaction {
|
|
|
3596
3734
|
return this.#client.followUpInteraction(this.token, toMessageData(options));
|
|
3597
3735
|
}
|
|
3598
3736
|
async update(options) {
|
|
3599
|
-
|
|
3737
|
+
const { withResponse, rest } = splitWithResponse(options);
|
|
3738
|
+
return this.acknowledgeWith(new InteractionResponse(InteractionResponseEnum.MessageUpdate, toMessageData(rest)), "replied", withResponse);
|
|
3600
3739
|
}
|
|
3601
3740
|
async showModal(modal) {
|
|
3602
3741
|
const data = "toJSON" in modal && typeof modal.toJSON === "function" ? modal.toJSON() : modal;
|
|
3603
|
-
return this.acknowledge(new InteractionResponse(
|
|
3742
|
+
return this.acknowledge(new InteractionResponse(InteractionResponseEnum.Modal, data), "replied");
|
|
3604
3743
|
}
|
|
3605
3744
|
}
|
|
3606
3745
|
|
|
@@ -3617,33 +3756,69 @@ class CommandInteraction extends Interaction {
|
|
|
3617
3756
|
}
|
|
3618
3757
|
}
|
|
3619
3758
|
|
|
3759
|
+
class ContextMenuCommandInteraction extends CommandInteraction {
|
|
3760
|
+
#resolved() {
|
|
3761
|
+
return this.data.data?.resolved ?? {};
|
|
3762
|
+
}
|
|
3763
|
+
get targetId() {
|
|
3764
|
+
const id = this.data.data?.target_id;
|
|
3765
|
+
return typeof id === "string" ? id : null;
|
|
3766
|
+
}
|
|
3767
|
+
get targetUser() {
|
|
3768
|
+
const id = this.targetId;
|
|
3769
|
+
const raw = id ? this.#resolved().users?.[id] : undefined;
|
|
3770
|
+
return raw ? new User(raw) : null;
|
|
3771
|
+
}
|
|
3772
|
+
get targetMember() {
|
|
3773
|
+
const id = this.targetId;
|
|
3774
|
+
const raw = id ? this.#resolved().members?.[id] : undefined;
|
|
3775
|
+
const user = id ? this.#resolved().users?.[id] : undefined;
|
|
3776
|
+
if (!raw || !user || !this.guildId)
|
|
3777
|
+
return null;
|
|
3778
|
+
return new GuildMember({
|
|
3779
|
+
...raw,
|
|
3780
|
+
user,
|
|
3781
|
+
guild_id: this.guildId
|
|
3782
|
+
}, this.resourceContext);
|
|
3783
|
+
}
|
|
3784
|
+
get targetMessage() {
|
|
3785
|
+
const id = this.targetId;
|
|
3786
|
+
const raw = id ? this.#resolved().messages?.[id] : undefined;
|
|
3787
|
+
return raw ? new Message(raw, this.resourceContext) : null;
|
|
3788
|
+
}
|
|
3789
|
+
}
|
|
3790
|
+
|
|
3620
3791
|
class ComponentInteraction extends Interaction {
|
|
3621
3792
|
get customId() {
|
|
3622
|
-
|
|
3793
|
+
const id = this.data.data?.custom_id;
|
|
3794
|
+
return typeof id === "string" ? id : "";
|
|
3623
3795
|
}
|
|
3624
3796
|
get messageId() {
|
|
3625
|
-
return this.data
|
|
3797
|
+
return this.data.message?.id;
|
|
3626
3798
|
}
|
|
3627
3799
|
get componentType() {
|
|
3628
|
-
|
|
3800
|
+
const type = this.data.data?.component_type;
|
|
3801
|
+
return typeof type === "number" ? type : 0;
|
|
3629
3802
|
}
|
|
3630
3803
|
get values() {
|
|
3631
|
-
|
|
3632
|
-
|
|
3633
|
-
async deferUpdate() {
|
|
3634
|
-
await this.acknowledge(new InteractionResponse(InteractionResponseType.DeferredMessageUpdate), "deferred");
|
|
3804
|
+
const values = this.data.data?.values;
|
|
3805
|
+
return Array.isArray(values) ? values : [];
|
|
3635
3806
|
}
|
|
3636
|
-
async
|
|
3637
|
-
|
|
3807
|
+
async deferUpdate(options = {}) {
|
|
3808
|
+
const withResponse = options.withResponse === true;
|
|
3809
|
+
const result = await this.acknowledgeWith(new InteractionResponse(InteractionResponseEnum.DeferredMessageUpdate), "deferred", withResponse);
|
|
3810
|
+
if (withResponse)
|
|
3811
|
+
return result;
|
|
3638
3812
|
}
|
|
3639
3813
|
}
|
|
3640
3814
|
|
|
3641
3815
|
class ModalSubmitInteraction extends Interaction {
|
|
3642
3816
|
get customId() {
|
|
3643
|
-
|
|
3817
|
+
const id = this.data.data?.custom_id;
|
|
3818
|
+
return typeof id === "string" ? id : "";
|
|
3644
3819
|
}
|
|
3645
3820
|
getInputValue(customId) {
|
|
3646
|
-
const rows = this.data
|
|
3821
|
+
const rows = this.data.data?.components ?? [];
|
|
3647
3822
|
for (const row of rows) {
|
|
3648
3823
|
for (const comp of row.components ?? []) {
|
|
3649
3824
|
if (comp.custom_id === customId)
|
|
@@ -3667,16 +3842,17 @@ class AutocompleteInteraction extends Interaction {
|
|
|
3667
3842
|
this.options = new CommandOptions(data.data?.options ?? []);
|
|
3668
3843
|
}
|
|
3669
3844
|
get commandName() {
|
|
3670
|
-
|
|
3845
|
+
const name = this.data.data?.name;
|
|
3846
|
+
return typeof name === "string" ? name : "";
|
|
3671
3847
|
}
|
|
3672
3848
|
get focusedOption() {
|
|
3673
|
-
const options = this.data
|
|
3674
|
-
return findFocused(options);
|
|
3849
|
+
const options = this.data.data?.options;
|
|
3850
|
+
return findFocused(Array.isArray(options) ? options : []);
|
|
3675
3851
|
}
|
|
3676
3852
|
async respond(choices) {
|
|
3677
3853
|
if (!Array.isArray(choices))
|
|
3678
3854
|
throw new TypeError("Autocomplete choices must be an array.");
|
|
3679
|
-
const response = new InteractionResponse(
|
|
3855
|
+
const response = new InteractionResponse(InteractionResponseEnum.Autocomplete, { choices });
|
|
3680
3856
|
await this.acknowledge(response, "replied");
|
|
3681
3857
|
}
|
|
3682
3858
|
}
|
|
@@ -3694,18 +3870,21 @@ function findFocused(options) {
|
|
|
3694
3870
|
}
|
|
3695
3871
|
function createInteraction(client, data) {
|
|
3696
3872
|
switch (data.type) {
|
|
3697
|
-
case
|
|
3698
|
-
|
|
3699
|
-
|
|
3873
|
+
case InteractionEnum.ApplicationCommand: {
|
|
3874
|
+
const commandType = data.data?.type;
|
|
3875
|
+
return commandType === COMMAND_USER || commandType === COMMAND_MESSAGE ? new ContextMenuCommandInteraction(client, data) : new CommandInteraction(client, data);
|
|
3876
|
+
}
|
|
3877
|
+
case InteractionEnum.ApplicationCommandAutocomplete:
|
|
3700
3878
|
return new AutocompleteInteraction(client, data);
|
|
3701
|
-
case
|
|
3879
|
+
case InteractionEnum.MessageComponent:
|
|
3702
3880
|
return new ComponentInteraction(client, data);
|
|
3703
|
-
case
|
|
3881
|
+
case InteractionEnum.ModalSubmit:
|
|
3704
3882
|
return new ModalSubmitInteraction(client, data);
|
|
3705
3883
|
default:
|
|
3706
3884
|
return new Interaction(client, data);
|
|
3707
3885
|
}
|
|
3708
3886
|
}
|
|
3887
|
+
var InteractionType = InteractionEnum;
|
|
3709
3888
|
// packages/structures/src/embed.ts
|
|
3710
3889
|
class Embed {
|
|
3711
3890
|
#data;
|
|
@@ -3895,6 +4074,9 @@ class Message extends BaseStructure {
|
|
|
3895
4074
|
reference;
|
|
3896
4075
|
components;
|
|
3897
4076
|
referencedMessage;
|
|
4077
|
+
stickers;
|
|
4078
|
+
poll;
|
|
4079
|
+
messageSnapshots;
|
|
3898
4080
|
member;
|
|
3899
4081
|
#context;
|
|
3900
4082
|
constructor(data, context) {
|
|
@@ -3916,6 +4098,13 @@ class Message extends BaseStructure {
|
|
|
3916
4098
|
this.mentionEveryone = data.mention_everyone ?? false;
|
|
3917
4099
|
this.type = data.type ?? 0;
|
|
3918
4100
|
this.reference = data.message_reference;
|
|
4101
|
+
this.stickers = data.sticker_items ?? (data.stickers ?? []).map(({ id, name, format_type }) => ({
|
|
4102
|
+
id,
|
|
4103
|
+
name,
|
|
4104
|
+
format_type
|
|
4105
|
+
}));
|
|
4106
|
+
this.poll = data.poll ?? null;
|
|
4107
|
+
this.messageSnapshots = data.message_snapshots ?? [];
|
|
3919
4108
|
this.referencedMessage = data.referenced_message ? new Message(data.referenced_message, context) : data.referenced_message === null ? null : undefined;
|
|
3920
4109
|
this.#context = context;
|
|
3921
4110
|
this.member = data.member && data.guild_id ? new GuildMember({
|
|
@@ -3942,10 +4131,10 @@ class Message extends BaseStructure {
|
|
|
3942
4131
|
update(options) {
|
|
3943
4132
|
return this.edit(options);
|
|
3944
4133
|
}
|
|
3945
|
-
delete() {
|
|
4134
|
+
delete(reason) {
|
|
3946
4135
|
if (!this.#context)
|
|
3947
4136
|
throw new Error("This message is not attached to a client.");
|
|
3948
|
-
return this.#context.deleteMessage(this.channelId, this.id);
|
|
4137
|
+
return this.#context.deleteMessage(this.channelId, this.id, reason);
|
|
3949
4138
|
}
|
|
3950
4139
|
reply(options) {
|
|
3951
4140
|
if (!this.#context)
|
|
@@ -3992,15 +4181,15 @@ class Message extends BaseStructure {
|
|
|
3992
4181
|
throw new Error("This message is not attached to a client.");
|
|
3993
4182
|
return this.#context.removeAllReactions(this.channelId, this.id);
|
|
3994
4183
|
}
|
|
3995
|
-
pin() {
|
|
4184
|
+
pin(reason) {
|
|
3996
4185
|
if (!this.#context?.pinMessage)
|
|
3997
4186
|
throw new Error("This message is not attached to a client.");
|
|
3998
|
-
return this.#context.pinMessage(this.channelId, this.id);
|
|
4187
|
+
return this.#context.pinMessage(this.channelId, this.id, reason);
|
|
3999
4188
|
}
|
|
4000
|
-
unpin() {
|
|
4189
|
+
unpin(reason) {
|
|
4001
4190
|
if (!this.#context?.unpinMessage)
|
|
4002
4191
|
throw new Error("This message is not attached to a client.");
|
|
4003
|
-
return this.#context.unpinMessage(this.channelId, this.id);
|
|
4192
|
+
return this.#context.unpinMessage(this.channelId, this.id, reason);
|
|
4004
4193
|
}
|
|
4005
4194
|
get isEphemeral() {
|
|
4006
4195
|
return (this.flags & 64) !== 0;
|
|
@@ -4050,8 +4239,10 @@ class Message extends BaseStructure {
|
|
|
4050
4239
|
}
|
|
4051
4240
|
|
|
4052
4241
|
// packages/managers/src/message.ts
|
|
4053
|
-
function toRequest(options) {
|
|
4242
|
+
function toRequest(options, allowedMentions) {
|
|
4054
4243
|
const { files, ...body } = options;
|
|
4244
|
+
if (allowedMentions !== undefined && body.allowed_mentions === undefined)
|
|
4245
|
+
body.allowed_mentions = allowedMentions;
|
|
4055
4246
|
if (!files?.length)
|
|
4056
4247
|
return body;
|
|
4057
4248
|
return {
|
|
@@ -4070,9 +4261,11 @@ class MessageManager {
|
|
|
4070
4261
|
#rest;
|
|
4071
4262
|
#context;
|
|
4072
4263
|
#channelId;
|
|
4073
|
-
|
|
4264
|
+
#allowedMentions;
|
|
4265
|
+
constructor(rest, context, channelId, cache, allowedMentions) {
|
|
4074
4266
|
if (!channelId)
|
|
4075
4267
|
throw new TypeError("Channel ID is required.");
|
|
4268
|
+
this.#allowedMentions = allowedMentions;
|
|
4076
4269
|
this.#rest = rest;
|
|
4077
4270
|
this.#context = context;
|
|
4078
4271
|
this.#channelId = channelId;
|
|
@@ -4086,7 +4279,7 @@ class MessageManager {
|
|
|
4086
4279
|
return this.cache.get(messageId) ?? this.fetch(messageId);
|
|
4087
4280
|
}
|
|
4088
4281
|
async send(options) {
|
|
4089
|
-
const data = await this.#rest.post(Routes.channelMessages(this.#channelId), toRequest(options));
|
|
4282
|
+
const data = await this.#rest.post(Routes.channelMessages(this.#channelId), toRequest(options, this.#allowedMentions));
|
|
4090
4283
|
return this.upsert(data);
|
|
4091
4284
|
}
|
|
4092
4285
|
async fetch(messageId) {
|
|
@@ -4175,15 +4368,22 @@ class EmojiManager extends Manager {
|
|
|
4175
4368
|
return data.map((item) => this.upsert(item));
|
|
4176
4369
|
}
|
|
4177
4370
|
async create(options) {
|
|
4178
|
-
|
|
4371
|
+
const [payload, reason] = splitReason(options);
|
|
4372
|
+
return this.upsert(await this.#rest.post(Routes.guildEmoji(this.#guildId), payload, { reason }));
|
|
4179
4373
|
}
|
|
4180
4374
|
async edit(emojiId, options) {
|
|
4181
|
-
|
|
4375
|
+
const [payload, reason] = splitReason(options);
|
|
4376
|
+
return this.upsert(await this.#rest.patch(Routes.guildEmoji(this.#guildId, emojiId), payload, { reason }));
|
|
4182
4377
|
}
|
|
4183
|
-
async
|
|
4184
|
-
await this.#rest.delete(Routes.guildEmoji(this.#guildId, emojiId)
|
|
4378
|
+
async remove(emojiId, reason) {
|
|
4379
|
+
await this.#rest.delete(Routes.guildEmoji(this.#guildId, emojiId), {
|
|
4380
|
+
reason
|
|
4381
|
+
});
|
|
4185
4382
|
this.delete(emojiId);
|
|
4186
4383
|
}
|
|
4384
|
+
deleteEmoji(emojiId) {
|
|
4385
|
+
return this.remove(emojiId);
|
|
4386
|
+
}
|
|
4187
4387
|
upsert(data) {
|
|
4188
4388
|
const key = data.id != null ? data.id : `unicode:${data.name ?? ""}`;
|
|
4189
4389
|
return this.#merge(key, new Emoji(data));
|
|
@@ -4387,11 +4587,16 @@ class GuildMemberManager extends ResourceManager {
|
|
|
4387
4587
|
await this.#rest.put(Routes.guildBan(this.guildId, userId), { delete_message_seconds: options.deleteMessageSeconds }, { reason: options.reason });
|
|
4388
4588
|
this.delete(userId);
|
|
4389
4589
|
}
|
|
4390
|
-
async unban(userId) {
|
|
4391
|
-
await this.#rest.delete(Routes.guildBan(this.guildId, userId)
|
|
4590
|
+
async unban(userId, reason) {
|
|
4591
|
+
await this.#rest.delete(Routes.guildBan(this.guildId, userId), {
|
|
4592
|
+
reason
|
|
4593
|
+
});
|
|
4392
4594
|
}
|
|
4393
4595
|
async edit(userId, options, reason) {
|
|
4394
|
-
const
|
|
4596
|
+
const [payload, optionsReason] = splitReason(options);
|
|
4597
|
+
const data = await this.#rest.patch(Routes.guildMember(this.guildId, userId), payload, {
|
|
4598
|
+
reason: optionsReason ?? reason
|
|
4599
|
+
});
|
|
4395
4600
|
const member = new GuildMember({ ...data, guild_id: this.guildId }, this.#context());
|
|
4396
4601
|
this.set(member.user.id, member);
|
|
4397
4602
|
return member;
|
|
@@ -4430,7 +4635,7 @@ class RoleManager extends ResourceManager {
|
|
|
4430
4635
|
const data = await this.#rest.post(Routes.guildRoles(this.guildId), {
|
|
4431
4636
|
...payload,
|
|
4432
4637
|
permissions: payload.permissions !== undefined ? String(payload.permissions) : undefined
|
|
4433
|
-
});
|
|
4638
|
+
}, { reason });
|
|
4434
4639
|
const role = new Role(data);
|
|
4435
4640
|
this.set(role.id, role);
|
|
4436
4641
|
return role;
|
|
@@ -4440,15 +4645,28 @@ class RoleManager extends ResourceManager {
|
|
|
4440
4645
|
const data = await this.#rest.patch(Routes.guildRole(this.guildId, roleId), {
|
|
4441
4646
|
...payload,
|
|
4442
4647
|
permissions: payload.permissions !== undefined ? String(payload.permissions) : undefined
|
|
4443
|
-
});
|
|
4648
|
+
}, { reason });
|
|
4444
4649
|
const role = new Role(data);
|
|
4445
4650
|
this.set(role.id, role);
|
|
4446
4651
|
return role;
|
|
4447
4652
|
}
|
|
4448
|
-
async
|
|
4449
|
-
await this.#rest.delete(Routes.guildRole(this.guildId, roleId)
|
|
4653
|
+
async remove(roleId, reason) {
|
|
4654
|
+
await this.#rest.delete(Routes.guildRole(this.guildId, roleId), {
|
|
4655
|
+
reason
|
|
4656
|
+
});
|
|
4450
4657
|
this.delete(roleId);
|
|
4451
4658
|
}
|
|
4659
|
+
async setPositions(positions, reason) {
|
|
4660
|
+
const data = await this.#rest.patch(Routes.guildRoles(this.guildId), positions.map(({ id, position }) => ({ id, position })), { reason });
|
|
4661
|
+
return data.map((item) => {
|
|
4662
|
+
const role = new Role(item);
|
|
4663
|
+
this.set(role.id, role);
|
|
4664
|
+
return role;
|
|
4665
|
+
});
|
|
4666
|
+
}
|
|
4667
|
+
deleteRole(roleId) {
|
|
4668
|
+
return this.remove(roleId);
|
|
4669
|
+
}
|
|
4452
4670
|
}
|
|
4453
4671
|
|
|
4454
4672
|
// packages/managers/src/guild-resources.ts
|
|
@@ -4520,13 +4738,15 @@ class GuildScheduledEventManager extends Manager {
|
|
|
4520
4738
|
return events.map((event) => this.#store(event));
|
|
4521
4739
|
}
|
|
4522
4740
|
async create(options, reason) {
|
|
4523
|
-
|
|
4741
|
+
const [payload, optionsReason] = splitReason(options);
|
|
4742
|
+
return this.#store(await this.#rest.post(Routes.guildScheduledEvents(this.guildId), payload, { reason: optionsReason ?? reason }));
|
|
4524
4743
|
}
|
|
4525
4744
|
async edit(eventId, options, reason) {
|
|
4526
|
-
|
|
4745
|
+
const [payload, optionsReason] = splitReason(options);
|
|
4746
|
+
return this.#store(await this.#rest.patch(Routes.guildScheduledEvent(this.guildId, eventId), payload, { reason: optionsReason ?? reason }));
|
|
4527
4747
|
}
|
|
4528
|
-
async remove(eventId) {
|
|
4529
|
-
await this.#rest.delete(Routes.guildScheduledEvent(this.guildId, eventId));
|
|
4748
|
+
async remove(eventId, reason) {
|
|
4749
|
+
await this.#rest.delete(Routes.guildScheduledEvent(this.guildId, eventId), { reason });
|
|
4530
4750
|
this.delete(eventId);
|
|
4531
4751
|
}
|
|
4532
4752
|
async fetchSubscribers(eventId, options = {}) {
|
|
@@ -4557,13 +4777,13 @@ class StageInstanceManager extends Manager {
|
|
|
4557
4777
|
privacy_level: options.privacyLevel,
|
|
4558
4778
|
send_start_notification: options.sendStartNotification,
|
|
4559
4779
|
guild_scheduled_event_id: options.guildScheduledEventId
|
|
4560
|
-
}, { reason }));
|
|
4780
|
+
}, { reason: options.reason ?? reason }));
|
|
4561
4781
|
}
|
|
4562
4782
|
async fetch(channelId) {
|
|
4563
4783
|
return this.#store(await this.#rest.get(Routes.stageInstanceByChannel(channelId)));
|
|
4564
4784
|
}
|
|
4565
4785
|
async edit(channelId, options, reason) {
|
|
4566
|
-
return this.#store(await this.#rest.patch(Routes.stageInstanceByChannel(channelId), { topic: options.topic, privacy_level: options.privacyLevel }, { reason }));
|
|
4786
|
+
return this.#store(await this.#rest.patch(Routes.stageInstanceByChannel(channelId), { topic: options.topic, privacy_level: options.privacyLevel }, { reason: options.reason ?? reason }));
|
|
4567
4787
|
}
|
|
4568
4788
|
async remove(channelId, reason) {
|
|
4569
4789
|
await this.#rest.delete(Routes.stageInstanceByChannel(channelId), {
|
|
@@ -4600,7 +4820,7 @@ class PermissionOverwriteManager {
|
|
|
4600
4820
|
type: options.type,
|
|
4601
4821
|
allow: BigInt(options.allow ?? 0).toString(),
|
|
4602
4822
|
deny: BigInt(options.deny ?? 0).toString()
|
|
4603
|
-
}, { reason });
|
|
4823
|
+
}, { reason: options.reason ?? reason });
|
|
4604
4824
|
}
|
|
4605
4825
|
async remove(overwriteId, reason) {
|
|
4606
4826
|
await this.#rest.delete(Routes.channelPermission(this.channelId, overwriteId), { reason });
|
|
@@ -4718,12 +4938,16 @@ class GuildManager extends ResourceManager {
|
|
|
4718
4938
|
return this.upsert(new Guild(data));
|
|
4719
4939
|
}
|
|
4720
4940
|
async edit(id, options) {
|
|
4721
|
-
const
|
|
4941
|
+
const [payload, reason] = splitReason(options);
|
|
4942
|
+
const data = await this.#rest.patch(Routes.guild(id), payload, { reason });
|
|
4722
4943
|
return this.upsert(new Guild(data));
|
|
4723
4944
|
}
|
|
4724
|
-
async
|
|
4945
|
+
async remove(id) {
|
|
4725
4946
|
await this.#rest.delete(Routes.guild(id));
|
|
4726
4947
|
}
|
|
4948
|
+
deleteGuild(id) {
|
|
4949
|
+
return this.remove(id);
|
|
4950
|
+
}
|
|
4727
4951
|
async fetchPreview(id) {
|
|
4728
4952
|
return this.#rest.get(Routes.guildPreview(id));
|
|
4729
4953
|
}
|
|
@@ -4767,15 +4991,17 @@ class GuildManager extends ResourceManager {
|
|
|
4767
4991
|
return new AutoModerationRule(rule);
|
|
4768
4992
|
}
|
|
4769
4993
|
async createAutoModerationRule(guildId, options) {
|
|
4770
|
-
const
|
|
4994
|
+
const [payload, reason] = splitReason(options);
|
|
4995
|
+
const rule = await this.#rest.post(Routes.guildAutoModerationRules(guildId), payload, { reason });
|
|
4771
4996
|
return new AutoModerationRule(rule);
|
|
4772
4997
|
}
|
|
4773
4998
|
async editAutoModerationRule(guildId, ruleId, options) {
|
|
4774
|
-
const
|
|
4999
|
+
const [payload, reason] = splitReason(options);
|
|
5000
|
+
const rule = await this.#rest.patch(Routes.guildAutoModerationRule(guildId, ruleId), payload, { reason });
|
|
4775
5001
|
return new AutoModerationRule(rule);
|
|
4776
5002
|
}
|
|
4777
|
-
async deleteAutoModerationRule(guildId, ruleId) {
|
|
4778
|
-
await this.#rest.delete(Routes.guildAutoModerationRule(guildId, ruleId));
|
|
5003
|
+
async deleteAutoModerationRule(guildId, ruleId, reason) {
|
|
5004
|
+
await this.#rest.delete(Routes.guildAutoModerationRule(guildId, ruleId), { reason });
|
|
4779
5005
|
}
|
|
4780
5006
|
}
|
|
4781
5007
|
var AuditLogEvent = {
|
|
@@ -4882,29 +5108,31 @@ class ChannelManager extends Manager {
|
|
|
4882
5108
|
#context;
|
|
4883
5109
|
#messageManagers = new Map;
|
|
4884
5110
|
#messageCache;
|
|
5111
|
+
#allowedMentions;
|
|
4885
5112
|
constructor(rest, options = {}) {
|
|
4886
5113
|
super();
|
|
4887
5114
|
this.#rest = rest;
|
|
4888
5115
|
this.#messageCache = options.messageCache;
|
|
5116
|
+
this.#allowedMentions = options.allowedMentions;
|
|
4889
5117
|
this.#context = {
|
|
4890
5118
|
sendMessage: (channelId, options) => this.send(channelId, options),
|
|
4891
5119
|
editMessage: (channelId, messageId, options) => this.editMessage(channelId, messageId, options),
|
|
4892
|
-
deleteMessage: (channelId, messageId) => this.deleteMessage(channelId, messageId),
|
|
5120
|
+
deleteMessage: (channelId, messageId, reason) => this.deleteMessage(channelId, messageId, reason),
|
|
4893
5121
|
crosspostMessage: (channelId, messageId) => this.crosspostMessage(channelId, messageId),
|
|
4894
5122
|
editChannel: (channelId, options) => this.edit(channelId, options),
|
|
4895
|
-
deleteChannel: (channelId) => this.
|
|
5123
|
+
deleteChannel: (channelId, reason) => this.remove(channelId, reason),
|
|
4896
5124
|
addReaction: (channelId, messageId, emoji) => this.addReaction(channelId, messageId, emoji),
|
|
4897
5125
|
removeOwnReaction: (channelId, messageId, emoji) => this.removeOwnReaction(channelId, messageId, emoji),
|
|
4898
5126
|
removeReaction: (channelId, messageId, emoji, userId) => this.removeReaction(channelId, messageId, emoji, userId),
|
|
4899
5127
|
removeAllReactions: (channelId, messageId) => this.removeAllReactions(channelId, messageId),
|
|
4900
|
-
pinMessage: (channelId, messageId) => this.pinMessage(channelId, messageId),
|
|
4901
|
-
unpinMessage: (channelId, messageId) => this.unpinMessage(channelId, messageId)
|
|
5128
|
+
pinMessage: (channelId, messageId, reason) => this.pinMessage(channelId, messageId, reason),
|
|
5129
|
+
unpinMessage: (channelId, messageId, reason) => this.unpinMessage(channelId, messageId, reason)
|
|
4902
5130
|
};
|
|
4903
5131
|
}
|
|
4904
5132
|
messages(channelId) {
|
|
4905
5133
|
let manager = this.#messageManagers.get(channelId);
|
|
4906
5134
|
if (!manager) {
|
|
4907
|
-
manager = new MessageManager(this.#rest, this.#context, channelId, this.#messageCache);
|
|
5135
|
+
manager = new MessageManager(this.#rest, this.#context, channelId, this.#messageCache, this.#allowedMentions);
|
|
4908
5136
|
this.#messageManagers.set(channelId, manager);
|
|
4909
5137
|
}
|
|
4910
5138
|
return manager;
|
|
@@ -4968,15 +5196,20 @@ class ChannelManager extends Manager {
|
|
|
4968
5196
|
return this.#messageManagers.get(channelId);
|
|
4969
5197
|
}
|
|
4970
5198
|
async create(guildId, options) {
|
|
4971
|
-
|
|
5199
|
+
const [payload, reason] = splitReason(options);
|
|
5200
|
+
return this.upsert(await this.#rest.post(Routes.guildChannels(guildId), payload, { reason }));
|
|
4972
5201
|
}
|
|
4973
5202
|
async edit(channelId, options) {
|
|
4974
|
-
|
|
5203
|
+
const [payload, reason] = splitReason(options);
|
|
5204
|
+
return this.upsert(await this.#rest.patch(Routes.channel(channelId), payload, { reason }));
|
|
4975
5205
|
}
|
|
4976
|
-
async
|
|
4977
|
-
await this.#rest.delete(Routes.channel(channelId));
|
|
5206
|
+
async remove(channelId, reason) {
|
|
5207
|
+
await this.#rest.delete(Routes.channel(channelId), { reason });
|
|
4978
5208
|
this.delete(channelId);
|
|
4979
5209
|
}
|
|
5210
|
+
deleteChannel(channelId) {
|
|
5211
|
+
return this.remove(channelId);
|
|
5212
|
+
}
|
|
4980
5213
|
delete(channelId) {
|
|
4981
5214
|
this.#messageManagers.delete(channelId);
|
|
4982
5215
|
return super.delete(channelId);
|
|
@@ -5010,10 +5243,12 @@ class ChannelManager extends Manager {
|
|
|
5010
5243
|
return this.messages(data.channel_id).upsert(data);
|
|
5011
5244
|
}
|
|
5012
5245
|
async editMessage(channelId, messageId, options) {
|
|
5013
|
-
return this.messages(channelId).upsert(await this.#rest.patch(Routes.message(channelId, messageId), toRequest(options)));
|
|
5246
|
+
return this.messages(channelId).upsert(await this.#rest.patch(Routes.message(channelId, messageId), toRequest(options, this.#allowedMentions)));
|
|
5014
5247
|
}
|
|
5015
|
-
async deleteMessage(channelId, messageId) {
|
|
5016
|
-
await this.#rest.delete(Routes.message(channelId, messageId)
|
|
5248
|
+
async deleteMessage(channelId, messageId, reason) {
|
|
5249
|
+
await this.#rest.delete(Routes.message(channelId, messageId), {
|
|
5250
|
+
reason
|
|
5251
|
+
});
|
|
5017
5252
|
this.messages(channelId).delete(messageId);
|
|
5018
5253
|
}
|
|
5019
5254
|
deleteCachedMessage(channelId, messageId) {
|
|
@@ -5022,19 +5257,17 @@ class ChannelManager extends Manager {
|
|
|
5022
5257
|
async crosspostMessage(channelId, messageId) {
|
|
5023
5258
|
return this.messages(channelId).upsert(await this.#rest.post(Routes.crosspostMessage(channelId, messageId)));
|
|
5024
5259
|
}
|
|
5025
|
-
async bulkDeleteMessages(channelId, messageIds) {
|
|
5260
|
+
async bulkDeleteMessages(channelId, messageIds, reason) {
|
|
5026
5261
|
const ids = [...new Set(messageIds)];
|
|
5027
5262
|
if (ids.length < 1 || ids.length > 100)
|
|
5028
5263
|
throw new RangeError("bulkDelete requires between 1 and 100 message IDs.");
|
|
5029
5264
|
if (ids.length === 1)
|
|
5030
|
-
return this.deleteMessage(channelId, ids[0]);
|
|
5265
|
+
return this.deleteMessage(channelId, ids[0], reason);
|
|
5031
5266
|
const cutoff = Date.now() - BULK_DELETE_MAX_AGE_MS;
|
|
5032
5267
|
const tooOld = ids.filter((id) => snowflakeTime(id) < cutoff);
|
|
5033
5268
|
if (tooOld.length)
|
|
5034
5269
|
throw new RangeError(`bulkDelete cannot delete messages older than 14 days: ${tooOld.join(", ")}`);
|
|
5035
|
-
await this.#rest.post(Routes.channelBulkDelete(channelId), {
|
|
5036
|
-
messages: ids
|
|
5037
|
-
});
|
|
5270
|
+
await this.#rest.post(Routes.channelBulkDelete(channelId), { messages: ids }, { reason });
|
|
5038
5271
|
for (const id of ids)
|
|
5039
5272
|
this.messages(channelId).delete(id);
|
|
5040
5273
|
}
|
|
@@ -5077,14 +5310,20 @@ class ChannelManager extends Manager {
|
|
|
5077
5310
|
await this.#rest.delete(Routes.messageReactionsAll(channelId, messageId));
|
|
5078
5311
|
}
|
|
5079
5312
|
async fetchPinnedMessages(channelId) {
|
|
5080
|
-
const data = await this.#rest.get(Routes.
|
|
5081
|
-
return data.map((item) => this.messages(channelId).upsert(item));
|
|
5313
|
+
const data = await this.#rest.get(Routes.channelMessagesPins(channelId));
|
|
5314
|
+
return data.items.map((item) => this.messages(channelId).upsert(item.message));
|
|
5315
|
+
}
|
|
5316
|
+
async pinMessage(channelId, messageId, reason) {
|
|
5317
|
+
await this.#rest.put(Routes.channelMessagesPin(channelId, messageId), undefined, { reason });
|
|
5082
5318
|
}
|
|
5083
|
-
async
|
|
5084
|
-
await this.#rest.
|
|
5319
|
+
async unpinMessage(channelId, messageId, reason) {
|
|
5320
|
+
await this.#rest.delete(Routes.channelMessagesPin(channelId, messageId), { reason });
|
|
5085
5321
|
}
|
|
5086
|
-
async
|
|
5087
|
-
|
|
5322
|
+
async createWebhook(channelId, options) {
|
|
5323
|
+
const [payload, reason] = splitReason(options);
|
|
5324
|
+
return this.#rest.post(Routes.channelWebhooks(channelId), payload, {
|
|
5325
|
+
reason
|
|
5326
|
+
});
|
|
5088
5327
|
}
|
|
5089
5328
|
createThreadFromMessage(channelId, messageId, options) {
|
|
5090
5329
|
return this.threads(channelId).createFromMessage(messageId, options);
|
|
@@ -5102,7 +5341,7 @@ class ChannelManager extends Manager {
|
|
|
5102
5341
|
hasMore: messages.length === limit
|
|
5103
5342
|
};
|
|
5104
5343
|
}
|
|
5105
|
-
|
|
5344
|
+
bulkDelete(channelId, messageIds) {
|
|
5106
5345
|
return this.bulkDeleteMessages(channelId, messageIds);
|
|
5107
5346
|
}
|
|
5108
5347
|
clear() {
|
|
@@ -6059,6 +6298,7 @@ class Gateway {
|
|
|
6059
6298
|
#message(raw, token) {
|
|
6060
6299
|
if (!this.#session.owns(token))
|
|
6061
6300
|
return;
|
|
6301
|
+
this.#heartbeat.receivedMessage();
|
|
6062
6302
|
const { sequence, action } = classifyFrame(raw);
|
|
6063
6303
|
if (sequence !== null)
|
|
6064
6304
|
this.#session.recordSequence(sequence, token);
|
|
@@ -6256,18 +6496,31 @@ class EventEmitter2 {
|
|
|
6256
6496
|
return true;
|
|
6257
6497
|
}
|
|
6258
6498
|
#handleError(event, error) {
|
|
6259
|
-
if (event === "error" /* Error */)
|
|
6260
|
-
return;
|
|
6261
6499
|
const normalized = error instanceof Error ? error : new Error(String(error), { cause: error });
|
|
6262
|
-
|
|
6500
|
+
const listeners = event === "error" /* Error */ ? [] : [
|
|
6263
6501
|
...this.#listeners.get("error" /* Error */) ?? []
|
|
6264
|
-
]
|
|
6502
|
+
];
|
|
6503
|
+
if (listeners.length === 0)
|
|
6504
|
+
return warnListenerError(event, normalized);
|
|
6505
|
+
for (const listener of listeners) {
|
|
6265
6506
|
try {
|
|
6266
|
-
listener(normalized);
|
|
6267
|
-
|
|
6507
|
+
const result = listener(normalized);
|
|
6508
|
+
if (result && typeof result.then === "function")
|
|
6509
|
+
Promise.resolve(result).catch((failure) => warnListenerError("error" /* Error */, failure));
|
|
6510
|
+
} catch (failure) {
|
|
6511
|
+
warnListenerError("error" /* Error */, failure);
|
|
6512
|
+
}
|
|
6268
6513
|
}
|
|
6269
6514
|
}
|
|
6270
6515
|
}
|
|
6516
|
+
function warnListenerError(event, error) {
|
|
6517
|
+
const failure = error instanceof Error ? error : new Error(String(error));
|
|
6518
|
+
process.emitWarning(`A "${String(event)}" listener threw and no error listener handled it: ${failure.message}`, {
|
|
6519
|
+
type: "LunibeeWarning",
|
|
6520
|
+
code: "LUNIBEE_UNHANDLED_LISTENER_ERROR",
|
|
6521
|
+
detail: failure.stack
|
|
6522
|
+
});
|
|
6523
|
+
}
|
|
6271
6524
|
|
|
6272
6525
|
class Client extends EventEmitter2 {
|
|
6273
6526
|
options;
|
|
@@ -6327,7 +6580,8 @@ class Client extends EventEmitter2 {
|
|
|
6327
6580
|
this.users = new UserManager(this.rest);
|
|
6328
6581
|
this.guilds = new GuildManager(this.rest);
|
|
6329
6582
|
this.channels = new ChannelManager(this.rest, {
|
|
6330
|
-
messageCache: options.messageCache
|
|
6583
|
+
messageCache: options.messageCache,
|
|
6584
|
+
allowedMentions: options.allowedMentions
|
|
6331
6585
|
});
|
|
6332
6586
|
this.stageInstances = new StageInstanceManager(this.rest);
|
|
6333
6587
|
const placeholderAppCommands = new ApplicationCommandManager(this.rest, "0");
|
|
@@ -6335,16 +6589,16 @@ class Client extends EventEmitter2 {
|
|
|
6335
6589
|
this.#resourceContext = {
|
|
6336
6590
|
sendMessage: (channelId, options) => this.channels.send(channelId, options),
|
|
6337
6591
|
editMessage: (channelId, messageId, options) => this.channels.editMessage(channelId, messageId, options),
|
|
6338
|
-
deleteMessage: (channelId, messageId) => this.channels.deleteMessage(channelId, messageId),
|
|
6592
|
+
deleteMessage: (channelId, messageId, reason) => this.channels.deleteMessage(channelId, messageId, reason),
|
|
6339
6593
|
crosspostMessage: (channelId, messageId) => this.channels.crosspostMessage(channelId, messageId),
|
|
6340
6594
|
editChannel: (channelId, options) => this.channels.edit(channelId, options),
|
|
6341
|
-
deleteChannel: (channelId) => this.channels.
|
|
6595
|
+
deleteChannel: (channelId, reason) => this.channels.remove(channelId, reason),
|
|
6342
6596
|
addReaction: (channelId, messageId, emoji) => this.channels.addReaction(channelId, messageId, emoji),
|
|
6343
6597
|
removeOwnReaction: (channelId, messageId, emoji) => this.channels.removeOwnReaction(channelId, messageId, emoji),
|
|
6344
6598
|
removeReaction: (channelId, messageId, emoji, userId) => this.channels.removeReaction(channelId, messageId, emoji, userId),
|
|
6345
6599
|
removeAllReactions: (channelId, messageId) => this.channels.removeAllReactions(channelId, messageId),
|
|
6346
|
-
pinMessage: (channelId, messageId) => this.channels.pinMessage(channelId, messageId),
|
|
6347
|
-
unpinMessage: (channelId, messageId) => this.channels.unpinMessage(channelId, messageId),
|
|
6600
|
+
pinMessage: (channelId, messageId, reason) => this.channels.pinMessage(channelId, messageId, reason),
|
|
6601
|
+
unpinMessage: (channelId, messageId, reason) => this.channels.unpinMessage(channelId, messageId, reason),
|
|
6348
6602
|
collectInteractions: (options) => this.createCollector("interactionCreate" /* InteractionCreate */, options),
|
|
6349
6603
|
memberPermissions: (guildId, memberId, roleIds, channelId) => this.#memberPermissions(guildId, memberId, roleIds, channelId),
|
|
6350
6604
|
kickMember: (guildId, userId, reason) => this.guilds.members(guildId).kick(userId, reason),
|
|
@@ -6474,8 +6728,11 @@ class Client extends EventEmitter2 {
|
|
|
6474
6728
|
this.emit(wasCached ? "guildAvailable" /* GuildAvailable */ : "guildCreate" /* GuildCreate */, payload);
|
|
6475
6729
|
});
|
|
6476
6730
|
this.#gateway.on("GUILD_UPDATE", (data) => {
|
|
6477
|
-
|
|
6478
|
-
this.
|
|
6731
|
+
const payload = data;
|
|
6732
|
+
const cached = this.guilds.get(payload.id);
|
|
6733
|
+
const previous = cached ? this.#snapshot(cached) : null;
|
|
6734
|
+
this.guilds.patch(payload);
|
|
6735
|
+
this.emit("guildUpdate" /* GuildUpdate */, payload, previous);
|
|
6479
6736
|
});
|
|
6480
6737
|
this.#gateway.on("GUILD_DELETE", (data) => {
|
|
6481
6738
|
const payload = data;
|
|
@@ -6494,8 +6751,10 @@ class Client extends EventEmitter2 {
|
|
|
6494
6751
|
});
|
|
6495
6752
|
this.#gateway.on("GUILD_MEMBER_UPDATE", (data) => {
|
|
6496
6753
|
const member = data;
|
|
6754
|
+
const cached = this.#cache.members ? this.guilds.members(member.guild_id).get(member.user.id) : undefined;
|
|
6755
|
+
const previous = cached ? this.#snapshot(cached, new GuildMember({ user: member.user, guild_id: member.guild_id }, this.#resourceContext)) : null;
|
|
6497
6756
|
this.#upsertMember(member.guild_id, member);
|
|
6498
|
-
this.emit("guildMemberUpdate" /* GuildMemberUpdate */, member);
|
|
6757
|
+
this.emit("guildMemberUpdate" /* GuildMemberUpdate */, member, previous);
|
|
6499
6758
|
});
|
|
6500
6759
|
this.#gateway.on("GUILD_MEMBER_REMOVE", (data) => {
|
|
6501
6760
|
const member = data;
|
|
@@ -6530,18 +6789,24 @@ class Client extends EventEmitter2 {
|
|
|
6530
6789
|
});
|
|
6531
6790
|
this.#gateway.on("GUILD_ROLE_UPDATE", (data) => {
|
|
6532
6791
|
const event = data;
|
|
6792
|
+
const cached = this.#cache.roles ? this.guilds.roles(event.guild_id).get(event.role.id) : undefined;
|
|
6793
|
+
const previous = cached ? this.#snapshot(cached) : null;
|
|
6533
6794
|
this.#upsertRole(event.guild_id, event.role);
|
|
6534
|
-
this.emit("guildRoleUpdate" /* GuildRoleUpdate */, event);
|
|
6795
|
+
this.emit("guildRoleUpdate" /* GuildRoleUpdate */, event, previous);
|
|
6535
6796
|
});
|
|
6536
6797
|
this.#gateway.on("GUILD_ROLE_DELETE", (data) => {
|
|
6537
6798
|
const event = data;
|
|
6538
|
-
this.guilds.roles(event.guild_id)
|
|
6539
|
-
|
|
6799
|
+
const roles = this.guilds.roles(event.guild_id);
|
|
6800
|
+
const removed = roles.get(event.role_id) ?? null;
|
|
6801
|
+
roles.delete(event.role_id);
|
|
6802
|
+
this.emit("guildRoleDelete" /* GuildRoleDelete */, event, removed);
|
|
6540
6803
|
});
|
|
6541
6804
|
this.#gateway.on("GUILD_EMOJIS_UPDATE", (data) => {
|
|
6542
6805
|
const event = data;
|
|
6806
|
+
let previous = null;
|
|
6543
6807
|
if (this.#cache.emojis) {
|
|
6544
6808
|
const emojis = this.guilds.emojis(event.guild_id);
|
|
6809
|
+
previous = [...emojis.cache.values()].map((emoji) => this.#snapshot(emoji));
|
|
6545
6810
|
const current = new Set(event.emojis.map((emoji) => emoji.id));
|
|
6546
6811
|
for (const id of [...emojis.cache.keys()])
|
|
6547
6812
|
if (!current.has(id))
|
|
@@ -6549,12 +6814,14 @@ class Client extends EventEmitter2 {
|
|
|
6549
6814
|
for (const emoji of event.emojis)
|
|
6550
6815
|
emojis.upsert(emoji);
|
|
6551
6816
|
}
|
|
6552
|
-
this.emit("guildEmojisUpdate" /* GuildEmojisUpdate */, event);
|
|
6817
|
+
this.emit("guildEmojisUpdate" /* GuildEmojisUpdate */, event, previous);
|
|
6553
6818
|
});
|
|
6554
6819
|
this.#gateway.on("GUILD_STICKERS_UPDATE", (data) => {
|
|
6555
6820
|
const event = data;
|
|
6556
|
-
this.guilds.stickers(event.guild_id)
|
|
6557
|
-
|
|
6821
|
+
const stickers = this.guilds.stickers(event.guild_id);
|
|
6822
|
+
const previous = [...stickers.cache.values()];
|
|
6823
|
+
stickers.sync(event.stickers);
|
|
6824
|
+
this.emit("guildStickersUpdate" /* GuildStickersUpdate */, event, previous);
|
|
6558
6825
|
});
|
|
6559
6826
|
this.#gateway.on("GUILD_SOUNDBOARD_SOUND_CREATE", (data) => {
|
|
6560
6827
|
const sound = data;
|
|
@@ -6635,13 +6902,15 @@ class Client extends EventEmitter2 {
|
|
|
6635
6902
|
this.emit("channelCreate" /* ChannelCreate */, channel);
|
|
6636
6903
|
});
|
|
6637
6904
|
this.#gateway.on("CHANNEL_UPDATE", (data) => {
|
|
6905
|
+
const previous = this.#previousChannel(data);
|
|
6638
6906
|
const channel = this.channels.upsert(data);
|
|
6639
|
-
this.emit("channelUpdate" /* ChannelUpdate */, channel);
|
|
6907
|
+
this.emit("channelUpdate" /* ChannelUpdate */, channel, previous);
|
|
6640
6908
|
});
|
|
6641
6909
|
this.#gateway.on("CHANNEL_DELETE", (data) => {
|
|
6642
6910
|
const payload = data;
|
|
6911
|
+
const removed = this.channels.get(payload.id) ?? null;
|
|
6643
6912
|
this.channels.delete(payload.id);
|
|
6644
|
-
this.emit("channelDelete" /* ChannelDelete */, payload);
|
|
6913
|
+
this.emit("channelDelete" /* ChannelDelete */, payload, removed);
|
|
6645
6914
|
});
|
|
6646
6915
|
this.#gateway.on("CHANNEL_PINS_UPDATE", (data) => this.emit("channelPinsUpdate" /* ChannelPinsUpdate */, data));
|
|
6647
6916
|
this.#gateway.on("THREAD_CREATE", (data) => {
|
|
@@ -6649,13 +6918,15 @@ class Client extends EventEmitter2 {
|
|
|
6649
6918
|
this.emit("threadCreate" /* ThreadCreate */, channel);
|
|
6650
6919
|
});
|
|
6651
6920
|
this.#gateway.on("THREAD_UPDATE", (data) => {
|
|
6921
|
+
const previous = this.#previousChannel(data);
|
|
6652
6922
|
const channel = this.channels.upsert(data);
|
|
6653
|
-
this.emit("threadUpdate" /* ThreadUpdate */, channel);
|
|
6923
|
+
this.emit("threadUpdate" /* ThreadUpdate */, channel, previous);
|
|
6654
6924
|
});
|
|
6655
6925
|
this.#gateway.on("THREAD_DELETE", (data) => {
|
|
6656
6926
|
const payload = data;
|
|
6927
|
+
const removed = this.channels.get(payload.id) ?? null;
|
|
6657
6928
|
this.channels.delete(payload.id);
|
|
6658
|
-
this.emit("threadDelete" /* ThreadDelete */, payload);
|
|
6929
|
+
this.emit("threadDelete" /* ThreadDelete */, payload, removed);
|
|
6659
6930
|
});
|
|
6660
6931
|
this.#gateway.on("THREAD_LIST_SYNC", (data) => {
|
|
6661
6932
|
const sync = data;
|
|
@@ -6732,6 +7003,15 @@ class Client extends EventEmitter2 {
|
|
|
6732
7003
|
return new Role(data);
|
|
6733
7004
|
return this.#merge(this.guilds.roles(guildId), data.id, new Role(data));
|
|
6734
7005
|
}
|
|
7006
|
+
#snapshot(cached, blank = Object.create(Object.getPrototypeOf(cached))) {
|
|
7007
|
+
return Object.assign(blank, cached);
|
|
7008
|
+
}
|
|
7009
|
+
#previousChannel(data) {
|
|
7010
|
+
const cached = this.channels.get(data.id);
|
|
7011
|
+
if (!cached)
|
|
7012
|
+
return null;
|
|
7013
|
+
return this.#snapshot(cached, createChannel({ id: cached.id, type: cached.type, guild_id: cached.guildId }, this.#resourceContext));
|
|
7014
|
+
}
|
|
6735
7015
|
#merge(manager, id, next) {
|
|
6736
7016
|
const existing = manager.get(id);
|
|
6737
7017
|
if (!existing) {
|
|
@@ -6823,20 +7103,22 @@ class Client extends EventEmitter2 {
|
|
|
6823
7103
|
}
|
|
6824
7104
|
postInteractionResponse(id, token, response) {
|
|
6825
7105
|
const json = response.toJSON();
|
|
6826
|
-
const
|
|
7106
|
+
const callback = response.withResponse ? `${Routes.interactionCallback(id, token)}?with_response=true` : Routes.interactionCallback(id, token);
|
|
7107
|
+
const carriesMessage = json.type === 4 || json.type === 7;
|
|
7108
|
+
const upload = json.data ? toRequest(json.data, carriesMessage ? this.options.allowedMentions : undefined) : undefined;
|
|
6827
7109
|
if (upload && typeof upload === "object" && "files" in upload) {
|
|
6828
7110
|
const { body, files } = upload;
|
|
6829
|
-
return this.rest.post(
|
|
7111
|
+
return this.rest.post(callback, {
|
|
6830
7112
|
body: { ...json, data: body },
|
|
6831
7113
|
files
|
|
6832
7114
|
});
|
|
6833
7115
|
}
|
|
6834
|
-
return this.rest.post(
|
|
7116
|
+
return this.rest.post(callback, upload === undefined ? json : { ...json, data: upload });
|
|
6835
7117
|
}
|
|
6836
7118
|
editInteractionReply(token, data) {
|
|
6837
7119
|
if (!this.user)
|
|
6838
7120
|
return Promise.reject(new Error("Client is unauthenticated."));
|
|
6839
|
-
return this.rest.patch(Routes.interactionOriginalResponse(this.user.id, token), toRequest(data));
|
|
7121
|
+
return this.rest.patch(Routes.interactionOriginalResponse(this.user.id, token), toRequest(data, this.options.allowedMentions));
|
|
6840
7122
|
}
|
|
6841
7123
|
deleteInteractionReply(token) {
|
|
6842
7124
|
if (!this.user)
|
|
@@ -6846,14 +7128,14 @@ class Client extends EventEmitter2 {
|
|
|
6846
7128
|
followUpInteraction(token, data) {
|
|
6847
7129
|
if (!this.user)
|
|
6848
7130
|
return Promise.reject(new Error("Client is unauthenticated."));
|
|
6849
|
-
return this.rest.post(`/webhooks/${this.user.id}/${token}`, toRequest(data));
|
|
7131
|
+
return this.rest.post(`/webhooks/${this.user.id}/${token}`, toRequest(data, this.options.allowedMentions));
|
|
6850
7132
|
}
|
|
6851
7133
|
interactionWebhookMessage(method, applicationId, token, messageId, data) {
|
|
6852
7134
|
const path = messageId === "@original" ? Routes.interactionOriginalResponse(applicationId, token) : Routes.webhookMessage(applicationId, token, messageId);
|
|
6853
7135
|
if (method === "GET")
|
|
6854
7136
|
return this.rest.get(path);
|
|
6855
7137
|
if (method === "PATCH")
|
|
6856
|
-
return this.rest.patch(path, data);
|
|
7138
|
+
return this.rest.patch(path, data ? toRequest(data, this.options.allowedMentions) : data);
|
|
6857
7139
|
return this.rest.delete(path);
|
|
6858
7140
|
}
|
|
6859
7141
|
fetchWebhook(id, token) {
|
|
@@ -6869,8 +7151,6 @@ class Client extends EventEmitter2 {
|
|
|
6869
7151
|
const query = new URLSearchParams;
|
|
6870
7152
|
if (options?.withCounts)
|
|
6871
7153
|
query.set("with_counts", "true");
|
|
6872
|
-
if (options?.withExpiration)
|
|
6873
|
-
query.set("with_expiration", "true");
|
|
6874
7154
|
if (options?.guildScheduledEventId)
|
|
6875
7155
|
query.set("guild_scheduled_event_id", options.guildScheduledEventId);
|
|
6876
7156
|
const qs = query.toString();
|
|
@@ -7014,7 +7294,7 @@ class HandlerRegistry {
|
|
|
7014
7294
|
// packages/sharding/package.json
|
|
7015
7295
|
var package_default2 = {
|
|
7016
7296
|
name: "@lunibee/sharding",
|
|
7017
|
-
version: "0.2.
|
|
7297
|
+
version: "0.2.3",
|
|
7018
7298
|
type: "module",
|
|
7019
7299
|
module: "./src/index.ts",
|
|
7020
7300
|
types: "./src/index.ts",
|
|
@@ -7227,12 +7507,12 @@ class ClusterManager {
|
|
|
7227
7507
|
const clusterCount = this.#options.clusterCount ?? cpus().length;
|
|
7228
7508
|
const chunks = Array.from({ length: clusterCount }, () => []);
|
|
7229
7509
|
for (let i = 0;i < count; i++) {
|
|
7230
|
-
chunks[i % clusterCount]
|
|
7510
|
+
chunks[i % clusterCount]?.push(i);
|
|
7231
7511
|
}
|
|
7232
|
-
for (
|
|
7233
|
-
if (
|
|
7512
|
+
for (const [i, chunk] of chunks.entries()) {
|
|
7513
|
+
if (chunk.length === 0)
|
|
7234
7514
|
continue;
|
|
7235
|
-
this.#launch(i,
|
|
7515
|
+
this.#launch(i, chunk, count);
|
|
7236
7516
|
await sleep2(500);
|
|
7237
7517
|
}
|
|
7238
7518
|
if (this.#options.autoScaleInterval && this.#options.autoScaleInterval > 0) {
|
|
@@ -8082,9 +8362,10 @@ class VoiceReceiver {
|
|
|
8082
8362
|
const controllers = this.#streams.get(userId);
|
|
8083
8363
|
if (!controllers || controllers.size === 0)
|
|
8084
8364
|
return;
|
|
8085
|
-
const
|
|
8365
|
+
const first = view.getUint8(0);
|
|
8366
|
+
const csrcCount = first & 15;
|
|
8086
8367
|
let offset = 12 + csrcCount * 4;
|
|
8087
|
-
const hasExtension = (
|
|
8368
|
+
const hasExtension = (first & 16) !== 0;
|
|
8088
8369
|
if (hasExtension) {
|
|
8089
8370
|
if (packet.length < offset + 4)
|
|
8090
8371
|
return;
|
|
@@ -8148,7 +8429,7 @@ function entersState(target, status, timeoutMs) {
|
|
|
8148
8429
|
});
|
|
8149
8430
|
}
|
|
8150
8431
|
// packages/builders/src/embed.ts
|
|
8151
|
-
class
|
|
8432
|
+
class CreateEmbed {
|
|
8152
8433
|
#data = {};
|
|
8153
8434
|
setTitle(value) {
|
|
8154
8435
|
if (value === null)
|
|
@@ -8279,8 +8560,9 @@ function url(value, field) {
|
|
|
8279
8560
|
throw new TypeError(`${field} must be a valid URL.`, { cause: error });
|
|
8280
8561
|
}
|
|
8281
8562
|
}
|
|
8563
|
+
var EmbedBuilder = CreateEmbed;
|
|
8282
8564
|
// packages/builders/src/components.ts
|
|
8283
|
-
var
|
|
8565
|
+
var ComponentEnum = {
|
|
8284
8566
|
ActionRow: 1,
|
|
8285
8567
|
Button: 2,
|
|
8286
8568
|
StringSelect: 3,
|
|
@@ -8298,9 +8580,9 @@ var ComponentType = {
|
|
|
8298
8580
|
ContentInventoryEntry: 16,
|
|
8299
8581
|
Container: 17
|
|
8300
8582
|
};
|
|
8301
|
-
var
|
|
8583
|
+
var TextInputType = { Short: 1, Paragraph: 2 };
|
|
8302
8584
|
|
|
8303
|
-
class
|
|
8585
|
+
class CreateActionRow {
|
|
8304
8586
|
#components = [];
|
|
8305
8587
|
addComponents(...components) {
|
|
8306
8588
|
if (!components.length)
|
|
@@ -8319,15 +8601,15 @@ class ActionRowBuilder {
|
|
|
8319
8601
|
if (components.length === 0)
|
|
8320
8602
|
throw new RangeError("An action row needs at least one component.");
|
|
8321
8603
|
const types = components.map((component) => component.type);
|
|
8322
|
-
if (types.some((type) => type !==
|
|
8604
|
+
if (types.some((type) => type !== ComponentEnum.Button) && components.length > 1)
|
|
8323
8605
|
throw new RangeError("A select menu or text input must be alone in its action row.");
|
|
8324
|
-
return { type:
|
|
8606
|
+
return { type: ComponentEnum.ActionRow, components };
|
|
8325
8607
|
}
|
|
8326
8608
|
}
|
|
8327
8609
|
|
|
8328
|
-
class
|
|
8610
|
+
class CreateStringSelect {
|
|
8329
8611
|
#data = {
|
|
8330
|
-
type:
|
|
8612
|
+
type: ComponentEnum.StringSelect
|
|
8331
8613
|
};
|
|
8332
8614
|
setCustomId(value) {
|
|
8333
8615
|
validateText(value, 100, "Component custom ID");
|
|
@@ -8386,18 +8668,18 @@ class StringSelectBuilder {
|
|
|
8386
8668
|
}
|
|
8387
8669
|
}
|
|
8388
8670
|
|
|
8389
|
-
class
|
|
8671
|
+
class CreateButton {
|
|
8390
8672
|
#data = {
|
|
8391
|
-
type:
|
|
8392
|
-
style:
|
|
8673
|
+
type: ComponentEnum.Button,
|
|
8674
|
+
style: ButtonType.Secondary
|
|
8393
8675
|
};
|
|
8394
8676
|
setStyle(style) {
|
|
8395
8677
|
const data = this.#data;
|
|
8396
8678
|
data.style = style;
|
|
8397
|
-
if (style ===
|
|
8679
|
+
if (style === ButtonType.Link) {
|
|
8398
8680
|
delete data.custom_id;
|
|
8399
8681
|
delete data.sku_id;
|
|
8400
|
-
} else if (style ===
|
|
8682
|
+
} else if (style === ButtonType.Premium) {
|
|
8401
8683
|
delete data.custom_id;
|
|
8402
8684
|
delete data.url;
|
|
8403
8685
|
delete data.label;
|
|
@@ -8410,7 +8692,7 @@ class ButtonBuilder {
|
|
|
8410
8692
|
}
|
|
8411
8693
|
setCustomId(value) {
|
|
8412
8694
|
validateText(value, 100, "Button custom ID");
|
|
8413
|
-
if (this.#data.style ===
|
|
8695
|
+
if (this.#data.style === ButtonType.Link)
|
|
8414
8696
|
throw new TypeError("Link buttons cannot use custom IDs.");
|
|
8415
8697
|
this.#data.custom_id = value;
|
|
8416
8698
|
return this;
|
|
@@ -8430,13 +8712,13 @@ class ButtonBuilder {
|
|
|
8430
8712
|
cause: error
|
|
8431
8713
|
});
|
|
8432
8714
|
}
|
|
8433
|
-
this.setStyle(
|
|
8715
|
+
this.setStyle(ButtonType.Link);
|
|
8434
8716
|
this.#data.url = url.toString();
|
|
8435
8717
|
return this;
|
|
8436
8718
|
}
|
|
8437
8719
|
setSKUId(skuId) {
|
|
8438
8720
|
validateText(skuId, 20, "Button SKU ID");
|
|
8439
|
-
this.setStyle(
|
|
8721
|
+
this.setStyle(ButtonType.Premium);
|
|
8440
8722
|
this.#data.sku_id = skuId;
|
|
8441
8723
|
return this;
|
|
8442
8724
|
}
|
|
@@ -8450,12 +8732,12 @@ class ButtonBuilder {
|
|
|
8450
8732
|
}
|
|
8451
8733
|
toJSON() {
|
|
8452
8734
|
const data = this.#data;
|
|
8453
|
-
if (data.style ===
|
|
8735
|
+
if (data.style === ButtonType.Link) {
|
|
8454
8736
|
if (!data.url)
|
|
8455
8737
|
throw new TypeError("Link buttons require a URL.");
|
|
8456
8738
|
if (data.custom_id || data.sku_id)
|
|
8457
8739
|
throw new TypeError("Link buttons cannot have a custom ID or SKU ID.");
|
|
8458
|
-
} else if (data.style ===
|
|
8740
|
+
} else if (data.style === ButtonType.Premium) {
|
|
8459
8741
|
if (!data.sku_id)
|
|
8460
8742
|
throw new TypeError("Premium buttons require a SKU ID.");
|
|
8461
8743
|
if (data.custom_id || data.url || data.label || data.emoji)
|
|
@@ -8466,16 +8748,16 @@ class ButtonBuilder {
|
|
|
8466
8748
|
if (data.url || data.sku_id)
|
|
8467
8749
|
throw new TypeError("Only link buttons have a URL and only premium buttons have a SKU ID.");
|
|
8468
8750
|
}
|
|
8469
|
-
if (data.style !==
|
|
8751
|
+
if (data.style !== ButtonType.Premium && !data.label && !data.emoji)
|
|
8470
8752
|
throw new TypeError("Buttons require a label or an emoji.");
|
|
8471
8753
|
return structuredClone(data);
|
|
8472
8754
|
}
|
|
8473
8755
|
}
|
|
8474
8756
|
|
|
8475
|
-
class
|
|
8757
|
+
class CreateEntitySelect {
|
|
8476
8758
|
#data;
|
|
8477
8759
|
constructor(type) {
|
|
8478
|
-
if (type !==
|
|
8760
|
+
if (type !== ComponentEnum.UserSelect && type !== ComponentEnum.RoleSelect && type !== ComponentEnum.MentionableSelect && type !== ComponentEnum.ChannelSelect)
|
|
8479
8761
|
throw new TypeError("Invalid select component type.");
|
|
8480
8762
|
this.#data = { type };
|
|
8481
8763
|
}
|
|
@@ -8517,7 +8799,7 @@ class EntitySelectBuilder {
|
|
|
8517
8799
|
}
|
|
8518
8800
|
}
|
|
8519
8801
|
|
|
8520
|
-
class
|
|
8802
|
+
class CreateModal {
|
|
8521
8803
|
#components = [];
|
|
8522
8804
|
#custom_id;
|
|
8523
8805
|
#title;
|
|
@@ -8540,7 +8822,7 @@ class ModalBuilder {
|
|
|
8540
8822
|
return this;
|
|
8541
8823
|
}
|
|
8542
8824
|
addTextInputs(...inputs) {
|
|
8543
|
-
return this.addComponents(...inputs.map((input) => new
|
|
8825
|
+
return this.addComponents(...inputs.map((input) => new CreateActionRow().addComponents(input)));
|
|
8544
8826
|
}
|
|
8545
8827
|
toJSON() {
|
|
8546
8828
|
if (!this.#custom_id || !this.#title)
|
|
@@ -8556,10 +8838,10 @@ class ModalBuilder {
|
|
|
8556
8838
|
}
|
|
8557
8839
|
}
|
|
8558
8840
|
|
|
8559
|
-
class
|
|
8841
|
+
class CreateTextInput {
|
|
8560
8842
|
#data = {
|
|
8561
|
-
type:
|
|
8562
|
-
style:
|
|
8843
|
+
type: ComponentEnum.TextInput,
|
|
8844
|
+
style: TextInputType.Short
|
|
8563
8845
|
};
|
|
8564
8846
|
setStyle(style) {
|
|
8565
8847
|
this.#data.style = style;
|
|
@@ -8609,7 +8891,7 @@ class TextInputBuilder {
|
|
|
8609
8891
|
}
|
|
8610
8892
|
}
|
|
8611
8893
|
|
|
8612
|
-
class
|
|
8894
|
+
class CreateContainer {
|
|
8613
8895
|
#components = [];
|
|
8614
8896
|
#accentColor;
|
|
8615
8897
|
#spoiler;
|
|
@@ -8632,7 +8914,7 @@ class ContainerBuilder {
|
|
|
8632
8914
|
}
|
|
8633
8915
|
toJSON() {
|
|
8634
8916
|
const data = {
|
|
8635
|
-
type:
|
|
8917
|
+
type: ComponentEnum.Container,
|
|
8636
8918
|
components: this.#components.map((c) => c.toJSON())
|
|
8637
8919
|
};
|
|
8638
8920
|
if (this.#accentColor !== undefined)
|
|
@@ -8643,7 +8925,7 @@ class ContainerBuilder {
|
|
|
8643
8925
|
}
|
|
8644
8926
|
}
|
|
8645
8927
|
|
|
8646
|
-
class
|
|
8928
|
+
class CreateSection {
|
|
8647
8929
|
#components = [];
|
|
8648
8930
|
#accessory;
|
|
8649
8931
|
addComponents(...components) {
|
|
@@ -8658,14 +8940,14 @@ class SectionBuilder {
|
|
|
8658
8940
|
}
|
|
8659
8941
|
toJSON() {
|
|
8660
8942
|
return {
|
|
8661
|
-
type:
|
|
8943
|
+
type: ComponentEnum.Section,
|
|
8662
8944
|
components: this.#components.length ? this.#components.map((c) => c.toJSON()) : undefined,
|
|
8663
8945
|
accessory: this.#accessory?.toJSON()
|
|
8664
8946
|
};
|
|
8665
8947
|
}
|
|
8666
8948
|
}
|
|
8667
8949
|
|
|
8668
|
-
class
|
|
8950
|
+
class CreateTextDisplay {
|
|
8669
8951
|
#content = "";
|
|
8670
8952
|
setContent(content) {
|
|
8671
8953
|
validateText(content, 4000, "Text display content");
|
|
@@ -8674,13 +8956,13 @@ class TextDisplayBuilder {
|
|
|
8674
8956
|
}
|
|
8675
8957
|
toJSON() {
|
|
8676
8958
|
return {
|
|
8677
|
-
type:
|
|
8959
|
+
type: ComponentEnum.TextDisplay,
|
|
8678
8960
|
content: this.#content
|
|
8679
8961
|
};
|
|
8680
8962
|
}
|
|
8681
8963
|
}
|
|
8682
8964
|
|
|
8683
|
-
class
|
|
8965
|
+
class CreateMediaGallery {
|
|
8684
8966
|
#items = [];
|
|
8685
8967
|
addItems(...items) {
|
|
8686
8968
|
if (!items.length) {
|
|
@@ -8694,13 +8976,13 @@ class MediaGalleryBuilder {
|
|
|
8694
8976
|
}
|
|
8695
8977
|
toJSON() {
|
|
8696
8978
|
return {
|
|
8697
|
-
type:
|
|
8979
|
+
type: ComponentEnum.MediaGallery,
|
|
8698
8980
|
items: structuredClone(this.#items)
|
|
8699
8981
|
};
|
|
8700
8982
|
}
|
|
8701
8983
|
}
|
|
8702
8984
|
|
|
8703
|
-
class
|
|
8985
|
+
class CreateFileComponent {
|
|
8704
8986
|
#url = "";
|
|
8705
8987
|
#spoiler;
|
|
8706
8988
|
setUrl(url) {
|
|
@@ -8716,7 +8998,7 @@ class FileComponentBuilder {
|
|
|
8716
8998
|
if (!this.#url)
|
|
8717
8999
|
throw new Error("File component must have a URL.");
|
|
8718
9000
|
const data = {
|
|
8719
|
-
type:
|
|
9001
|
+
type: ComponentEnum.File,
|
|
8720
9002
|
file: { url: this.#url }
|
|
8721
9003
|
};
|
|
8722
9004
|
if (this.#spoiler !== undefined)
|
|
@@ -8725,7 +9007,7 @@ class FileComponentBuilder {
|
|
|
8725
9007
|
}
|
|
8726
9008
|
}
|
|
8727
9009
|
|
|
8728
|
-
class
|
|
9010
|
+
class CreateSeparator {
|
|
8729
9011
|
#spacing;
|
|
8730
9012
|
#divider;
|
|
8731
9013
|
setSpacing(spacing) {
|
|
@@ -8738,7 +9020,7 @@ class SeparatorBuilder {
|
|
|
8738
9020
|
}
|
|
8739
9021
|
toJSON() {
|
|
8740
9022
|
const data = {
|
|
8741
|
-
type:
|
|
9023
|
+
type: ComponentEnum.Separator
|
|
8742
9024
|
};
|
|
8743
9025
|
if (this.#spacing !== undefined)
|
|
8744
9026
|
data.spacing = this.#spacing;
|
|
@@ -8748,7 +9030,7 @@ class SeparatorBuilder {
|
|
|
8748
9030
|
}
|
|
8749
9031
|
}
|
|
8750
9032
|
|
|
8751
|
-
class
|
|
9033
|
+
class CreateThumbnail {
|
|
8752
9034
|
#url = "";
|
|
8753
9035
|
#description;
|
|
8754
9036
|
#spoiler;
|
|
@@ -8768,7 +9050,7 @@ class ThumbnailBuilder {
|
|
|
8768
9050
|
}
|
|
8769
9051
|
toJSON() {
|
|
8770
9052
|
const data = {
|
|
8771
|
-
type:
|
|
9053
|
+
type: ComponentEnum.Thumbnail,
|
|
8772
9054
|
url: this.#url
|
|
8773
9055
|
};
|
|
8774
9056
|
if (this.#description !== undefined)
|
|
@@ -8779,7 +9061,7 @@ class ThumbnailBuilder {
|
|
|
8779
9061
|
}
|
|
8780
9062
|
}
|
|
8781
9063
|
|
|
8782
|
-
class
|
|
9064
|
+
class CreateContentInventoryEntry {
|
|
8783
9065
|
#id = "";
|
|
8784
9066
|
setId(id) {
|
|
8785
9067
|
validateText(id, 100, "Content inventory entry ID");
|
|
@@ -8788,7 +9070,7 @@ class ContentInventoryEntryBuilder {
|
|
|
8788
9070
|
}
|
|
8789
9071
|
toJSON() {
|
|
8790
9072
|
return {
|
|
8791
|
-
type:
|
|
9073
|
+
type: ComponentEnum.ContentInventoryEntry,
|
|
8792
9074
|
id: this.#id
|
|
8793
9075
|
};
|
|
8794
9076
|
}
|
|
@@ -8809,27 +9091,27 @@ function validateLength(value, field, max = 4000) {
|
|
|
8809
9091
|
if (!Number.isInteger(value) || value < 0 || value > max)
|
|
8810
9092
|
throw new RangeError(`${field} must be an integer between 0 and ${max}.`);
|
|
8811
9093
|
}
|
|
8812
|
-
class
|
|
9094
|
+
class CreateUserSelectMenu extends CreateEntitySelect {
|
|
8813
9095
|
constructor() {
|
|
8814
|
-
super(
|
|
9096
|
+
super(ComponentEnum.UserSelect);
|
|
8815
9097
|
}
|
|
8816
9098
|
}
|
|
8817
9099
|
|
|
8818
|
-
class
|
|
9100
|
+
class CreateRoleSelectMenu extends CreateEntitySelect {
|
|
8819
9101
|
constructor() {
|
|
8820
|
-
super(
|
|
9102
|
+
super(ComponentEnum.RoleSelect);
|
|
8821
9103
|
}
|
|
8822
9104
|
}
|
|
8823
9105
|
|
|
8824
|
-
class
|
|
9106
|
+
class CreateMentionableSelectMenu extends CreateEntitySelect {
|
|
8825
9107
|
constructor() {
|
|
8826
|
-
super(
|
|
9108
|
+
super(ComponentEnum.MentionableSelect);
|
|
8827
9109
|
}
|
|
8828
9110
|
}
|
|
8829
9111
|
|
|
8830
|
-
class
|
|
9112
|
+
class CreateChannelSelectMenu extends CreateEntitySelect {
|
|
8831
9113
|
constructor() {
|
|
8832
|
-
super(
|
|
9114
|
+
super(ComponentEnum.ChannelSelect);
|
|
8833
9115
|
}
|
|
8834
9116
|
}
|
|
8835
9117
|
function assertSelect(data) {
|
|
@@ -8849,8 +9131,30 @@ function componentsV2Message(components, options) {
|
|
|
8849
9131
|
flags: (options?.flags ?? 0) | IS_COMPONENTS_V2
|
|
8850
9132
|
};
|
|
8851
9133
|
}
|
|
9134
|
+
var ButtonBuilder = CreateButton;
|
|
9135
|
+
var ChannelSelectMenuBuilder = CreateChannelSelectMenu;
|
|
9136
|
+
var ContainerBuilder = CreateContainer;
|
|
9137
|
+
var ContentInventoryEntryBuilder = CreateContentInventoryEntry;
|
|
9138
|
+
var EntitySelectBuilder = CreateEntitySelect;
|
|
9139
|
+
var FileComponentBuilder = CreateFileComponent;
|
|
9140
|
+
var MediaGalleryBuilder = CreateMediaGallery;
|
|
9141
|
+
var MentionableSelectMenuBuilder = CreateMentionableSelectMenu;
|
|
9142
|
+
var ModalBuilder = CreateModal;
|
|
9143
|
+
var RoleSelectMenuBuilder = CreateRoleSelectMenu;
|
|
9144
|
+
var SectionBuilder = CreateSection;
|
|
9145
|
+
var SeparatorBuilder = CreateSeparator;
|
|
9146
|
+
var StringSelectBuilder = CreateStringSelect;
|
|
9147
|
+
var StringSelectMenuBuilder = CreateStringSelect;
|
|
9148
|
+
var TextDisplayBuilder = CreateTextDisplay;
|
|
9149
|
+
var TextInputBuilder = CreateTextInput;
|
|
9150
|
+
var ThumbnailBuilder = CreateThumbnail;
|
|
9151
|
+
var UserSelectMenuBuilder = CreateUserSelectMenu;
|
|
9152
|
+
var ActionRowBuilder = CreateActionRow;
|
|
9153
|
+
var ButtonStyle = ButtonType;
|
|
9154
|
+
var TextInputStyle = TextInputType;
|
|
9155
|
+
var ComponentType = ComponentEnum;
|
|
8852
9156
|
// packages/builders/src/commands.ts
|
|
8853
|
-
var
|
|
9157
|
+
var ApplicationCommandOptionEnum2 = {
|
|
8854
9158
|
Subcommand: 1,
|
|
8855
9159
|
SubcommandGroup: 2,
|
|
8856
9160
|
String: 3,
|
|
@@ -8863,8 +9167,12 @@ var ApplicationCommandOptionType2 = {
|
|
|
8863
9167
|
Number: 10,
|
|
8864
9168
|
Attachment: 11
|
|
8865
9169
|
};
|
|
9170
|
+
function validateContexts(contexts) {
|
|
9171
|
+
if (contexts.some((context) => context !== 0 && context !== 1 && context !== 2))
|
|
9172
|
+
throw new RangeError("Command contexts must be 0, 1 or 2.");
|
|
9173
|
+
}
|
|
8866
9174
|
|
|
8867
|
-
class
|
|
9175
|
+
class CreateSlashCommand {
|
|
8868
9176
|
#data = { type: 1 };
|
|
8869
9177
|
setName(name) {
|
|
8870
9178
|
validateName(name, "Command name");
|
|
@@ -8876,6 +9184,11 @@ class SlashCommandBuilder {
|
|
|
8876
9184
|
this.#data.description = description;
|
|
8877
9185
|
return this;
|
|
8878
9186
|
}
|
|
9187
|
+
setContexts(...contexts) {
|
|
9188
|
+
validateContexts(contexts);
|
|
9189
|
+
this.#data.contexts = [...contexts];
|
|
9190
|
+
return this;
|
|
9191
|
+
}
|
|
8879
9192
|
setDMPermission(enabled) {
|
|
8880
9193
|
this.#data.dm_permission = enabled;
|
|
8881
9194
|
return this;
|
|
@@ -8896,37 +9209,37 @@ class SlashCommandBuilder {
|
|
|
8896
9209
|
return this;
|
|
8897
9210
|
}
|
|
8898
9211
|
addStringOption(configure) {
|
|
8899
|
-
return this.addOption(configure(new
|
|
9212
|
+
return this.addOption(configure(new CreateStringOption));
|
|
8900
9213
|
}
|
|
8901
9214
|
addIntegerOption(configure) {
|
|
8902
|
-
return this.addOption(configure(new
|
|
9215
|
+
return this.addOption(configure(new CreateIntegerOption));
|
|
8903
9216
|
}
|
|
8904
9217
|
addNumberOption(configure) {
|
|
8905
|
-
return this.addOption(configure(new
|
|
9218
|
+
return this.addOption(configure(new CreateNumberOption));
|
|
8906
9219
|
}
|
|
8907
9220
|
addBooleanOption(configure) {
|
|
8908
|
-
return this.addOption(configure(new
|
|
9221
|
+
return this.addOption(configure(new CreateBooleanOption));
|
|
8909
9222
|
}
|
|
8910
9223
|
addUserOption(configure) {
|
|
8911
|
-
return this.addOption(configure(new
|
|
9224
|
+
return this.addOption(configure(new CreateUserOption));
|
|
8912
9225
|
}
|
|
8913
9226
|
addChannelOption(configure) {
|
|
8914
|
-
return this.addOption(configure(new
|
|
9227
|
+
return this.addOption(configure(new CreateChannelOption));
|
|
8915
9228
|
}
|
|
8916
9229
|
addRoleOption(configure) {
|
|
8917
|
-
return this.addOption(configure(new
|
|
9230
|
+
return this.addOption(configure(new CreateRoleOption));
|
|
8918
9231
|
}
|
|
8919
9232
|
addMentionableOption(configure) {
|
|
8920
|
-
return this.addOption(configure(new
|
|
9233
|
+
return this.addOption(configure(new CreateMentionableOption));
|
|
8921
9234
|
}
|
|
8922
9235
|
addAttachmentOption(configure) {
|
|
8923
|
-
return this.addOption(configure(new
|
|
9236
|
+
return this.addOption(configure(new CreateAttachmentOption));
|
|
8924
9237
|
}
|
|
8925
9238
|
addSubcommand(configure) {
|
|
8926
|
-
return this.addOption(configure(new
|
|
9239
|
+
return this.addOption(configure(new CreateSubcommand));
|
|
8927
9240
|
}
|
|
8928
9241
|
addSubcommandGroup(configure) {
|
|
8929
|
-
return this.addOption(configure(new
|
|
9242
|
+
return this.addOption(configure(new CreateSubcommandGroup));
|
|
8930
9243
|
}
|
|
8931
9244
|
toJSON() {
|
|
8932
9245
|
return structuredClone(this.#data);
|
|
@@ -8946,7 +9259,7 @@ class SlashCommandBuilder {
|
|
|
8946
9259
|
}
|
|
8947
9260
|
}
|
|
8948
9261
|
|
|
8949
|
-
class
|
|
9262
|
+
class CreateCommandOption {
|
|
8950
9263
|
data;
|
|
8951
9264
|
constructor(type) {
|
|
8952
9265
|
this.data = { type };
|
|
@@ -8974,9 +9287,9 @@ class CommandOptionBuilder {
|
|
|
8974
9287
|
}
|
|
8975
9288
|
}
|
|
8976
9289
|
|
|
8977
|
-
class
|
|
9290
|
+
class CreateStringOption extends CreateCommandOption {
|
|
8978
9291
|
constructor() {
|
|
8979
|
-
super(
|
|
9292
|
+
super(ApplicationCommandOptionEnum2.String);
|
|
8980
9293
|
}
|
|
8981
9294
|
addChoices(...choices) {
|
|
8982
9295
|
const current = this.data.choices ?? [];
|
|
@@ -9010,9 +9323,9 @@ class StringOptionBuilder extends CommandOptionBuilder {
|
|
|
9010
9323
|
}
|
|
9011
9324
|
}
|
|
9012
9325
|
|
|
9013
|
-
class
|
|
9326
|
+
class CreateIntegerOption extends CreateCommandOption {
|
|
9014
9327
|
constructor() {
|
|
9015
|
-
super(
|
|
9328
|
+
super(ApplicationCommandOptionEnum2.Integer);
|
|
9016
9329
|
}
|
|
9017
9330
|
setMinValue(value) {
|
|
9018
9331
|
validateNumberRange(value, -9007199254740991, 9007199254740991, "min_value", true);
|
|
@@ -9045,9 +9358,9 @@ class IntegerOptionBuilder extends CommandOptionBuilder {
|
|
|
9045
9358
|
}
|
|
9046
9359
|
}
|
|
9047
9360
|
|
|
9048
|
-
class
|
|
9361
|
+
class CreateNumberOption extends CreateCommandOption {
|
|
9049
9362
|
constructor() {
|
|
9050
|
-
super(
|
|
9363
|
+
super(ApplicationCommandOptionEnum2.Number);
|
|
9051
9364
|
}
|
|
9052
9365
|
setMinValue(value) {
|
|
9053
9366
|
validateNumberRange(value, -9007199254740991, 9007199254740991, "min_value", false);
|
|
@@ -9080,39 +9393,39 @@ class NumberOptionBuilder extends CommandOptionBuilder {
|
|
|
9080
9393
|
}
|
|
9081
9394
|
}
|
|
9082
9395
|
|
|
9083
|
-
class
|
|
9396
|
+
class CreateBooleanOption extends CreateCommandOption {
|
|
9084
9397
|
constructor() {
|
|
9085
|
-
super(
|
|
9398
|
+
super(ApplicationCommandOptionEnum2.Boolean);
|
|
9086
9399
|
}
|
|
9087
9400
|
}
|
|
9088
9401
|
|
|
9089
|
-
class
|
|
9402
|
+
class CreateUserOption extends CreateCommandOption {
|
|
9090
9403
|
constructor() {
|
|
9091
|
-
super(
|
|
9404
|
+
super(ApplicationCommandOptionEnum2.User);
|
|
9092
9405
|
}
|
|
9093
9406
|
}
|
|
9094
9407
|
|
|
9095
|
-
class
|
|
9408
|
+
class CreateRoleOption extends CreateCommandOption {
|
|
9096
9409
|
constructor() {
|
|
9097
|
-
super(
|
|
9410
|
+
super(ApplicationCommandOptionEnum2.Role);
|
|
9098
9411
|
}
|
|
9099
9412
|
}
|
|
9100
9413
|
|
|
9101
|
-
class
|
|
9414
|
+
class CreateMentionableOption extends CreateCommandOption {
|
|
9102
9415
|
constructor() {
|
|
9103
|
-
super(
|
|
9416
|
+
super(ApplicationCommandOptionEnum2.Mentionable);
|
|
9104
9417
|
}
|
|
9105
9418
|
}
|
|
9106
9419
|
|
|
9107
|
-
class
|
|
9420
|
+
class CreateAttachmentOption extends CreateCommandOption {
|
|
9108
9421
|
constructor() {
|
|
9109
|
-
super(
|
|
9422
|
+
super(ApplicationCommandOptionEnum2.Attachment);
|
|
9110
9423
|
}
|
|
9111
9424
|
}
|
|
9112
9425
|
|
|
9113
|
-
class
|
|
9426
|
+
class CreateChannelOption extends CreateCommandOption {
|
|
9114
9427
|
constructor() {
|
|
9115
|
-
super(
|
|
9428
|
+
super(ApplicationCommandOptionEnum2.Channel);
|
|
9116
9429
|
}
|
|
9117
9430
|
addChannelTypes(...types) {
|
|
9118
9431
|
if (types.some((type) => !Number.isInteger(type) || type < 0))
|
|
@@ -9122,36 +9435,36 @@ class ChannelOptionBuilder extends CommandOptionBuilder {
|
|
|
9122
9435
|
}
|
|
9123
9436
|
}
|
|
9124
9437
|
|
|
9125
|
-
class
|
|
9438
|
+
class CreateSubcommand extends CreateCommandOption {
|
|
9126
9439
|
constructor() {
|
|
9127
|
-
super(
|
|
9440
|
+
super(ApplicationCommandOptionEnum2.Subcommand);
|
|
9128
9441
|
}
|
|
9129
9442
|
addStringOption(configure) {
|
|
9130
|
-
return this.addChildOption(configure(new
|
|
9443
|
+
return this.addChildOption(configure(new CreateStringOption));
|
|
9131
9444
|
}
|
|
9132
9445
|
addIntegerOption(configure) {
|
|
9133
|
-
return this.addChildOption(configure(new
|
|
9446
|
+
return this.addChildOption(configure(new CreateIntegerOption));
|
|
9134
9447
|
}
|
|
9135
9448
|
addNumberOption(configure) {
|
|
9136
|
-
return this.addChildOption(configure(new
|
|
9449
|
+
return this.addChildOption(configure(new CreateNumberOption));
|
|
9137
9450
|
}
|
|
9138
9451
|
addBooleanOption(configure) {
|
|
9139
|
-
return this.addChildOption(configure(new
|
|
9452
|
+
return this.addChildOption(configure(new CreateBooleanOption));
|
|
9140
9453
|
}
|
|
9141
9454
|
addUserOption(configure) {
|
|
9142
|
-
return this.addChildOption(configure(new
|
|
9455
|
+
return this.addChildOption(configure(new CreateUserOption));
|
|
9143
9456
|
}
|
|
9144
9457
|
addChannelOption(configure) {
|
|
9145
|
-
return this.addChildOption(configure(new
|
|
9458
|
+
return this.addChildOption(configure(new CreateChannelOption));
|
|
9146
9459
|
}
|
|
9147
9460
|
addRoleOption(configure) {
|
|
9148
|
-
return this.addChildOption(configure(new
|
|
9461
|
+
return this.addChildOption(configure(new CreateRoleOption));
|
|
9149
9462
|
}
|
|
9150
9463
|
addMentionableOption(configure) {
|
|
9151
|
-
return this.addChildOption(configure(new
|
|
9464
|
+
return this.addChildOption(configure(new CreateMentionableOption));
|
|
9152
9465
|
}
|
|
9153
9466
|
addAttachmentOption(configure) {
|
|
9154
|
-
return this.addChildOption(configure(new
|
|
9467
|
+
return this.addChildOption(configure(new CreateAttachmentOption));
|
|
9155
9468
|
}
|
|
9156
9469
|
addChildOption(option) {
|
|
9157
9470
|
const options = this.data.options ?? [];
|
|
@@ -9162,7 +9475,7 @@ class SubcommandBuilder extends CommandOptionBuilder {
|
|
|
9162
9475
|
throw new RangeError(`Duplicate option name: ${String(payload.name)}.`);
|
|
9163
9476
|
if (payload.required === true && options.some((existing) => existing.required !== true))
|
|
9164
9477
|
throw new RangeError("Required subcommand options must be placed before optional options.");
|
|
9165
|
-
if (options.some((existing) => existing.type ===
|
|
9478
|
+
if (options.some((existing) => existing.type === ApplicationCommandOptionEnum2.Subcommand))
|
|
9166
9479
|
throw new RangeError("Subcommands cannot contain nested subcommands.");
|
|
9167
9480
|
options.push(payload);
|
|
9168
9481
|
this.data.options = options;
|
|
@@ -9170,18 +9483,18 @@ class SubcommandBuilder extends CommandOptionBuilder {
|
|
|
9170
9483
|
}
|
|
9171
9484
|
}
|
|
9172
9485
|
|
|
9173
|
-
class
|
|
9486
|
+
class CreateSubcommandGroup extends CreateCommandOption {
|
|
9174
9487
|
constructor() {
|
|
9175
|
-
super(
|
|
9488
|
+
super(ApplicationCommandOptionEnum2.SubcommandGroup);
|
|
9176
9489
|
}
|
|
9177
9490
|
addSubcommand(configure) {
|
|
9178
9491
|
const options = this.data.options ?? [];
|
|
9179
9492
|
if (options.length >= 25)
|
|
9180
9493
|
throw new RangeError("A subcommand group cannot contain more than 25 subcommands.");
|
|
9181
|
-
const payload = configure(new
|
|
9494
|
+
const payload = configure(new CreateSubcommand).toJSON();
|
|
9182
9495
|
if (options.some((existing) => existing.name === payload.name))
|
|
9183
9496
|
throw new RangeError(`Duplicate subcommand name: ${String(payload.name)}.`);
|
|
9184
|
-
if (payload.type !==
|
|
9497
|
+
if (payload.type !== ApplicationCommandOptionEnum2.Subcommand)
|
|
9185
9498
|
throw new TypeError("Subcommand group children must be subcommands.");
|
|
9186
9499
|
options.push(payload);
|
|
9187
9500
|
this.data.options = options;
|
|
@@ -9205,7 +9518,7 @@ function validateNumberRange(value, minimum, maximum, field, integerOnly = true)
|
|
|
9205
9518
|
throw new RangeError(`${field} must be ${integerOnly ? "an integer" : "a number"} between ${minimum} and ${maximum}.`);
|
|
9206
9519
|
}
|
|
9207
9520
|
|
|
9208
|
-
class
|
|
9521
|
+
class CreateContextMenuCommand {
|
|
9209
9522
|
data;
|
|
9210
9523
|
constructor(type = 2) {
|
|
9211
9524
|
this.data = { type };
|
|
@@ -9234,27 +9547,52 @@ class ContextMenuCommandBuilder {
|
|
|
9234
9547
|
this.data.integration_types = [...types];
|
|
9235
9548
|
return this;
|
|
9236
9549
|
}
|
|
9550
|
+
setContexts(...contexts) {
|
|
9551
|
+
validateContexts(contexts);
|
|
9552
|
+
this.data.contexts = [...contexts];
|
|
9553
|
+
return this;
|
|
9554
|
+
}
|
|
9555
|
+
setNameLocalizations(localizations) {
|
|
9556
|
+
this.data.name_localizations = localizations === null ? null : { ...localizations };
|
|
9557
|
+
return this;
|
|
9558
|
+
}
|
|
9237
9559
|
toJSON() {
|
|
9238
9560
|
return structuredClone(this.data);
|
|
9239
9561
|
}
|
|
9240
9562
|
}
|
|
9241
9563
|
|
|
9242
|
-
class
|
|
9564
|
+
class CreateUserCommand extends CreateContextMenuCommand {
|
|
9243
9565
|
constructor() {
|
|
9244
9566
|
super(2);
|
|
9245
9567
|
}
|
|
9246
9568
|
}
|
|
9247
9569
|
|
|
9248
|
-
class
|
|
9570
|
+
class CreateMessageCommand extends CreateContextMenuCommand {
|
|
9249
9571
|
constructor() {
|
|
9250
9572
|
super(3);
|
|
9251
9573
|
}
|
|
9252
9574
|
}
|
|
9575
|
+
var AttachmentOptionBuilder = CreateAttachmentOption;
|
|
9576
|
+
var BooleanOptionBuilder = CreateBooleanOption;
|
|
9577
|
+
var ChannelOptionBuilder = CreateChannelOption;
|
|
9578
|
+
var CommandOptionBuilder = CreateCommandOption;
|
|
9579
|
+
var ContextMenuCommandBuilder = CreateContextMenuCommand;
|
|
9580
|
+
var IntegerOptionBuilder = CreateIntegerOption;
|
|
9581
|
+
var MentionableOptionBuilder = CreateMentionableOption;
|
|
9582
|
+
var MessageCommandBuilder = CreateMessageCommand;
|
|
9583
|
+
var NumberOptionBuilder = CreateNumberOption;
|
|
9584
|
+
var RoleOptionBuilder = CreateRoleOption;
|
|
9585
|
+
var SlashCommandBuilder = CreateSlashCommand;
|
|
9586
|
+
var StringOptionBuilder = CreateStringOption;
|
|
9587
|
+
var SubcommandBuilder = CreateSubcommand;
|
|
9588
|
+
var SubcommandGroupBuilder = CreateSubcommandGroup;
|
|
9589
|
+
var UserCommandBuilder = CreateUserCommand;
|
|
9590
|
+
var UserOptionBuilder = CreateUserOption;
|
|
9253
9591
|
// packages/builders/src/attachment.ts
|
|
9254
9592
|
import { readFile } from "fs/promises";
|
|
9255
9593
|
import { basename } from "path";
|
|
9256
9594
|
|
|
9257
|
-
class
|
|
9595
|
+
class CreateAttachment {
|
|
9258
9596
|
name;
|
|
9259
9597
|
description;
|
|
9260
9598
|
file;
|
|
@@ -9298,9 +9636,13 @@ class AttachmentBuilder {
|
|
|
9298
9636
|
throw new TypeError("Attachment file must be a supported binary value or file path.");
|
|
9299
9637
|
}
|
|
9300
9638
|
}
|
|
9639
|
+
var AttachmentBuilder = CreateAttachment;
|
|
9301
9640
|
export {
|
|
9302
9641
|
ActionRowBuilder,
|
|
9642
|
+
ActivityEnum,
|
|
9643
|
+
ApplicationCommandEnum,
|
|
9303
9644
|
ApplicationCommandManager,
|
|
9645
|
+
ApplicationCommandOptionEnum,
|
|
9304
9646
|
ApplicationCommandOptionType,
|
|
9305
9647
|
ApplicationCommandType,
|
|
9306
9648
|
AttachmentBuilder,
|
|
@@ -9316,10 +9658,13 @@ export {
|
|
|
9316
9658
|
BooleanOptionBuilder,
|
|
9317
9659
|
ButtonBuilder,
|
|
9318
9660
|
ButtonStyle,
|
|
9661
|
+
ButtonType,
|
|
9662
|
+
CDN_BASE,
|
|
9319
9663
|
Cache,
|
|
9320
9664
|
ResourceManager as CachedManager,
|
|
9321
9665
|
CategoryChannel,
|
|
9322
9666
|
Channel,
|
|
9667
|
+
ChannelEnum,
|
|
9323
9668
|
ChannelManager,
|
|
9324
9669
|
ChannelOptionBuilder,
|
|
9325
9670
|
ChannelSelectMenuBuilder,
|
|
@@ -9330,12 +9675,52 @@ export {
|
|
|
9330
9675
|
Collection,
|
|
9331
9676
|
Collector,
|
|
9332
9677
|
CommandInteraction,
|
|
9678
|
+
CommandOptionBuilder,
|
|
9333
9679
|
CommandOptions,
|
|
9680
|
+
ComponentEnum,
|
|
9334
9681
|
ComponentInteraction,
|
|
9335
9682
|
ComponentType,
|
|
9336
9683
|
ContainerBuilder,
|
|
9337
9684
|
ContentInventoryEntryBuilder,
|
|
9338
9685
|
ContextMenuCommandBuilder,
|
|
9686
|
+
ContextMenuCommandInteraction,
|
|
9687
|
+
CreateActionRow,
|
|
9688
|
+
CreateAttachment,
|
|
9689
|
+
CreateAttachmentOption,
|
|
9690
|
+
CreateBooleanOption,
|
|
9691
|
+
CreateButton,
|
|
9692
|
+
CreateChannelOption,
|
|
9693
|
+
CreateChannelSelectMenu,
|
|
9694
|
+
CreateCommandOption,
|
|
9695
|
+
CreateContainer,
|
|
9696
|
+
CreateContentInventoryEntry,
|
|
9697
|
+
CreateContextMenuCommand,
|
|
9698
|
+
CreateEmbed,
|
|
9699
|
+
CreateEntitySelect,
|
|
9700
|
+
CreateFileComponent,
|
|
9701
|
+
CreateIntegerOption,
|
|
9702
|
+
CreateMediaGallery,
|
|
9703
|
+
CreateMentionableOption,
|
|
9704
|
+
CreateMentionableSelectMenu,
|
|
9705
|
+
CreateMessageCommand,
|
|
9706
|
+
CreateModal,
|
|
9707
|
+
CreateNumberOption,
|
|
9708
|
+
CreateRoleOption,
|
|
9709
|
+
CreateRoleSelectMenu,
|
|
9710
|
+
CreateSection,
|
|
9711
|
+
CreateSeparator,
|
|
9712
|
+
CreateSlashCommand,
|
|
9713
|
+
CreateStringOption,
|
|
9714
|
+
CreateStringSelect,
|
|
9715
|
+
CreateStringSelect as CreateStringSelectMenu,
|
|
9716
|
+
CreateSubcommand,
|
|
9717
|
+
CreateSubcommandGroup,
|
|
9718
|
+
CreateTextDisplay,
|
|
9719
|
+
CreateTextInput,
|
|
9720
|
+
CreateThumbnail,
|
|
9721
|
+
CreateUserCommand,
|
|
9722
|
+
CreateUserOption,
|
|
9723
|
+
CreateUserSelectMenu,
|
|
9339
9724
|
DMChannel,
|
|
9340
9725
|
RESTError as DiscordAPIError,
|
|
9341
9726
|
Embed,
|
|
@@ -9374,7 +9759,9 @@ export {
|
|
|
9374
9759
|
Intents,
|
|
9375
9760
|
IntentsBitField,
|
|
9376
9761
|
Interaction,
|
|
9762
|
+
InteractionEnum,
|
|
9377
9763
|
InteractionResponse,
|
|
9764
|
+
InteractionResponseEnum,
|
|
9378
9765
|
InteractionResponseType,
|
|
9379
9766
|
InteractionType,
|
|
9380
9767
|
Invite,
|
|
@@ -9397,6 +9784,7 @@ export {
|
|
|
9397
9784
|
OnboardingPromptOption,
|
|
9398
9785
|
Permission,
|
|
9399
9786
|
PermissionFlagsBits,
|
|
9787
|
+
PermissionOverwriteEnum,
|
|
9400
9788
|
PermissionOverwriteManager,
|
|
9401
9789
|
PermissionOverwriteType,
|
|
9402
9790
|
PermissionSet,
|
|
@@ -9406,6 +9794,7 @@ export {
|
|
|
9406
9794
|
PremiumTier,
|
|
9407
9795
|
REST,
|
|
9408
9796
|
RESTError,
|
|
9797
|
+
RESTErrorCode,
|
|
9409
9798
|
RateLimiter,
|
|
9410
9799
|
RedisRateLimitStore,
|
|
9411
9800
|
RequestScheduler,
|
|
@@ -9426,17 +9815,20 @@ export {
|
|
|
9426
9815
|
StageChannel,
|
|
9427
9816
|
StageInstanceManager,
|
|
9428
9817
|
GatewayState as Status,
|
|
9818
|
+
StickerEnum,
|
|
9819
|
+
StickerFormatEnum,
|
|
9429
9820
|
StickerFormatType,
|
|
9430
9821
|
StickerType,
|
|
9431
9822
|
StringOptionBuilder,
|
|
9432
9823
|
StringSelectBuilder,
|
|
9433
|
-
|
|
9824
|
+
StringSelectMenuBuilder,
|
|
9434
9825
|
SubcommandBuilder,
|
|
9435
9826
|
SubcommandGroupBuilder,
|
|
9436
9827
|
TextChannel,
|
|
9437
9828
|
TextDisplayBuilder,
|
|
9438
9829
|
TextInputBuilder,
|
|
9439
9830
|
TextInputStyle,
|
|
9831
|
+
TextInputType,
|
|
9440
9832
|
ThreadChannel,
|
|
9441
9833
|
ThreadManager,
|
|
9442
9834
|
ThumbnailBuilder,
|
|
@@ -9456,6 +9848,7 @@ export {
|
|
|
9456
9848
|
WebSocketTransport,
|
|
9457
9849
|
Webhook,
|
|
9458
9850
|
WebhookClient,
|
|
9851
|
+
WebhookEnum,
|
|
9459
9852
|
WebhookType,
|
|
9460
9853
|
WelcomeScreenChannel,
|
|
9461
9854
|
ZlibStreamDecoder,
|
|
@@ -9464,6 +9857,7 @@ export {
|
|
|
9464
9857
|
blockQuote,
|
|
9465
9858
|
bold,
|
|
9466
9859
|
bulletList,
|
|
9860
|
+
cdnURL,
|
|
9467
9861
|
channelMention,
|
|
9468
9862
|
classifyCloseCode,
|
|
9469
9863
|
classifyFrame,
|
|
@@ -9516,4 +9910,4 @@ export {
|
|
|
9516
9910
|
userMention
|
|
9517
9911
|
};
|
|
9518
9912
|
|
|
9519
|
-
//# debugId=
|
|
9913
|
+
//# debugId=97695754EB32311964756E2164756E21
|