lunibee 0.1.5 → 0.1.7
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 +13 -24
- package/dist/builders/commands.d.ts +37 -0
- package/dist/builders/components.d.ts +127 -12
- package/dist/builders/embed.d.ts +3 -1
- package/dist/builders/index.d.ts +2 -2
- package/dist/builders/index.js +319 -16
- package/dist/builders/index.js.map +8 -7
- package/dist/collection/index.d.ts +36 -0
- package/dist/collection/index.js +110 -6
- package/dist/collection/index.js.map +4 -4
- package/dist/core/events.d.ts +69 -3
- package/dist/core/index.d.ts +158 -90
- package/dist/core/index.js +1543 -1169
- package/dist/core/index.js.map +24 -23
- package/dist/core/permissions.d.ts +112 -53
- package/dist/formatters/index.d.ts +43 -3
- package/dist/formatters/index.js +64 -1
- package/dist/formatters/index.js.map +3 -3
- package/dist/handlers/index.js.map +2 -2
- package/dist/index.d.ts +5 -4
- package/dist/index.js +3882 -1588
- package/dist/index.js.map +43 -35
- package/dist/managers/emoji.d.ts +38 -0
- package/dist/managers/guild.d.ts +141 -0
- package/dist/managers/index.d.ts +86 -75
- package/dist/managers/index.js +1084 -67
- package/dist/managers/index.js.map +21 -16
- package/dist/managers/message.d.ts +7 -12
- package/dist/managers/user.d.ts +20 -0
- package/dist/rest/index.d.ts +173 -1
- package/dist/rest/index.js +343 -47
- package/dist/rest/index.js.map +8 -6
- package/dist/rest/redis.d.ts +37 -0
- package/dist/rest/routes.d.ts +26 -1
- package/dist/rest/store.d.ts +38 -0
- package/dist/rest/webhook.d.ts +2 -2
- package/dist/sharding/cluster.d.ts +61 -0
- package/dist/sharding/index.d.ts +8 -0
- package/dist/sharding/index.js +289 -18
- package/dist/sharding/index.js.map +8 -7
- package/dist/structures/audit-log.d.ts +26 -0
- package/dist/structures/base.d.ts +131 -48
- package/dist/structures/embed.d.ts +65 -0
- package/dist/structures/index.d.ts +74 -26
- package/dist/structures/index.js +1528 -59
- package/dist/structures/index.js.map +14 -8
- package/dist/structures/interactions.d.ts +72 -17
- package/dist/structures/resources.d.ts +199 -7
- package/dist/types/index.d.ts +605 -84
- package/dist/types/index.js +71 -1
- package/dist/types/index.js.map +3 -3
- package/dist/utils/index.js.map +2 -2
- package/dist/voice/index.d.ts +88 -0
- package/dist/voice/index.js +204 -5
- package/dist/voice/index.js.map +3 -3
- package/dist/ws/index.d.ts +40 -1
- package/dist/ws/index.js +105 -18
- package/dist/ws/index.js.map +4 -4
- package/package.json +16 -16
- package/dist/structures/permissions.d.ts +0 -73
package/dist/structures/index.js
CHANGED
|
@@ -10,6 +10,16 @@ class BaseStructure {
|
|
|
10
10
|
toString() {
|
|
11
11
|
return this.id;
|
|
12
12
|
}
|
|
13
|
+
get createdAt() {
|
|
14
|
+
return new Date(Number((BigInt(this.id) >> 22n) + 1420070400000n));
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
var CDN_BASE = "https://cdn.discordapp.com";
|
|
18
|
+
function cdnURL(path, hash, options = {}) {
|
|
19
|
+
const isAnimated = hash.startsWith("a_") && !options.forceStatic;
|
|
20
|
+
const ext = options.extension ?? (isAnimated ? "gif" : "png");
|
|
21
|
+
const size = options.size ? `?size=${options.size}` : "";
|
|
22
|
+
return `${CDN_BASE}${path}/${hash}.${ext}${size}`;
|
|
13
23
|
}
|
|
14
24
|
|
|
15
25
|
class User extends BaseStructure {
|
|
@@ -19,6 +29,7 @@ class User extends BaseStructure {
|
|
|
19
29
|
bot;
|
|
20
30
|
system;
|
|
21
31
|
flags;
|
|
32
|
+
discriminator;
|
|
22
33
|
constructor(data) {
|
|
23
34
|
super(data.id);
|
|
24
35
|
if (!data.username)
|
|
@@ -29,6 +40,7 @@ class User extends BaseStructure {
|
|
|
29
40
|
this.bot = data.bot ?? false;
|
|
30
41
|
this.system = data.system ?? false;
|
|
31
42
|
this.flags = data.public_flags ?? 0;
|
|
43
|
+
this.discriminator = data.discriminator && data.discriminator !== "0" ? data.discriminator : null;
|
|
32
44
|
}
|
|
33
45
|
get displayName() {
|
|
34
46
|
return this.globalName ?? this.username;
|
|
@@ -36,21 +48,29 @@ class User extends BaseStructure {
|
|
|
36
48
|
avatarURL(options = {}) {
|
|
37
49
|
if (!this.avatar)
|
|
38
50
|
return null;
|
|
39
|
-
|
|
40
|
-
return `https://cdn.discordapp.com/avatars/${this.id}/${this.avatar}.${extension}${options.size ? `?size=${options.size}` : ""}`;
|
|
51
|
+
return cdnURL(`/avatars/${this.id}`, this.avatar, options);
|
|
41
52
|
}
|
|
42
53
|
defaultAvatarURL() {
|
|
43
|
-
|
|
54
|
+
const index = this.discriminator ? Number(this.discriminator) % 5 : Number((BigInt(this.id) >> 22n) % 6n);
|
|
55
|
+
return `${CDN_BASE}/embed/avatars/${index}.png`;
|
|
44
56
|
}
|
|
45
57
|
displayAvatarURL(options = {}) {
|
|
46
58
|
return this.avatarURL(options) ?? this.defaultAvatarURL();
|
|
47
59
|
}
|
|
60
|
+
toString() {
|
|
61
|
+
return `<@${this.id}>`;
|
|
62
|
+
}
|
|
48
63
|
}
|
|
49
64
|
|
|
50
65
|
class Channel extends BaseStructure {
|
|
51
66
|
type;
|
|
52
67
|
name;
|
|
53
68
|
guildId;
|
|
69
|
+
topic;
|
|
70
|
+
parentId;
|
|
71
|
+
nsfw;
|
|
72
|
+
rateLimitPerUser;
|
|
73
|
+
position;
|
|
54
74
|
#context;
|
|
55
75
|
constructor(data, context) {
|
|
56
76
|
super(data.id);
|
|
@@ -59,6 +79,11 @@ class Channel extends BaseStructure {
|
|
|
59
79
|
this.type = data.type;
|
|
60
80
|
this.name = data.name;
|
|
61
81
|
this.guildId = data.guild_id;
|
|
82
|
+
this.topic = data.topic;
|
|
83
|
+
this.parentId = data.parent_id;
|
|
84
|
+
this.nsfw = data.nsfw;
|
|
85
|
+
this.rateLimitPerUser = data.rate_limit_per_user;
|
|
86
|
+
this.position = data.position;
|
|
62
87
|
this.#context = context;
|
|
63
88
|
}
|
|
64
89
|
sendMessage(options) {
|
|
@@ -66,22 +91,196 @@ class Channel extends BaseStructure {
|
|
|
66
91
|
throw new Error("This channel is not attached to a client.");
|
|
67
92
|
return this.#context.sendMessage(this.id, options);
|
|
68
93
|
}
|
|
94
|
+
send(options) {
|
|
95
|
+
return this.sendMessage(options);
|
|
96
|
+
}
|
|
97
|
+
edit(options) {
|
|
98
|
+
if (!this.#context?.editChannel)
|
|
99
|
+
throw new Error("This channel is not attached to a client.");
|
|
100
|
+
return this.#context.editChannel(this.id, options);
|
|
101
|
+
}
|
|
102
|
+
editName(name) {
|
|
103
|
+
if (!name.trim())
|
|
104
|
+
throw new TypeError("Channel name cannot be empty.");
|
|
105
|
+
return this.edit({ name });
|
|
106
|
+
}
|
|
107
|
+
editTopic(topic) {
|
|
108
|
+
return this.edit({ topic });
|
|
109
|
+
}
|
|
110
|
+
editParent(parentId) {
|
|
111
|
+
return this.edit({ parent_id: parentId });
|
|
112
|
+
}
|
|
113
|
+
delete() {
|
|
114
|
+
if (!this.#context?.deleteChannel)
|
|
115
|
+
throw new Error("This channel is not attached to a client.");
|
|
116
|
+
return this.#context.deleteChannel(this.id);
|
|
117
|
+
}
|
|
118
|
+
update(options) {
|
|
119
|
+
return this.edit(options);
|
|
120
|
+
}
|
|
121
|
+
toString() {
|
|
122
|
+
return `<#${this.id}>`;
|
|
123
|
+
}
|
|
69
124
|
}
|
|
70
125
|
|
|
71
126
|
class Guild extends BaseStructure {
|
|
72
127
|
name;
|
|
128
|
+
icon;
|
|
129
|
+
splash;
|
|
130
|
+
banner;
|
|
131
|
+
description;
|
|
73
132
|
preferredLocale;
|
|
74
133
|
ownerId;
|
|
134
|
+
features;
|
|
135
|
+
verificationLevel;
|
|
136
|
+
premiumTier;
|
|
137
|
+
premiumSubscriptionCount;
|
|
138
|
+
memberCount;
|
|
139
|
+
approximateMemberCount;
|
|
140
|
+
approximatePresenceCount;
|
|
141
|
+
vanityUrlCode;
|
|
142
|
+
nsfwLevel;
|
|
143
|
+
discoverySplash;
|
|
144
|
+
rulesChannelId;
|
|
145
|
+
systemChannelId;
|
|
146
|
+
systemChannelFlags;
|
|
147
|
+
maxMembers;
|
|
148
|
+
mfaLevel;
|
|
149
|
+
explicitContentFilter;
|
|
150
|
+
defaultMessageNotifications;
|
|
75
151
|
constructor(data) {
|
|
76
152
|
super(data.id);
|
|
77
153
|
if (!data.name)
|
|
78
154
|
throw new TypeError("A Discord guild requires a name.");
|
|
79
155
|
this.name = data.name;
|
|
80
|
-
this.
|
|
156
|
+
this.icon = data.icon ?? null;
|
|
157
|
+
this.splash = data.splash ?? null;
|
|
158
|
+
this.banner = data.banner ?? null;
|
|
159
|
+
this.description = data.description ?? null;
|
|
160
|
+
this.preferredLocale = data.preferred_locale ?? "en-US";
|
|
81
161
|
this.ownerId = data.owner_id;
|
|
162
|
+
this.features = data.features ?? [];
|
|
163
|
+
this.verificationLevel = data.verification_level ?? 0;
|
|
164
|
+
this.premiumTier = data.premium_tier ?? 0;
|
|
165
|
+
this.premiumSubscriptionCount = data.premium_subscription_count ?? 0;
|
|
166
|
+
this.memberCount = data.member_count ?? data.approximate_member_count;
|
|
167
|
+
this.approximateMemberCount = data.approximate_member_count;
|
|
168
|
+
this.approximatePresenceCount = data.approximate_presence_count;
|
|
169
|
+
this.vanityUrlCode = data.vanity_url_code ?? null;
|
|
170
|
+
this.nsfwLevel = data.nsfw_level ?? 0;
|
|
171
|
+
this.discoverySplash = data.discovery_splash ?? null;
|
|
172
|
+
const d = data;
|
|
173
|
+
this.rulesChannelId = d.rules_channel_id ?? null;
|
|
174
|
+
this.systemChannelId = d.system_channel_id ?? null;
|
|
175
|
+
this.systemChannelFlags = d.system_channel_flags ?? 0;
|
|
176
|
+
this.maxMembers = d.max_members ?? 0;
|
|
177
|
+
this.mfaLevel = d.mfa_level ?? 0;
|
|
178
|
+
this.explicitContentFilter = d.explicit_content_filter ?? 0;
|
|
179
|
+
this.defaultMessageNotifications = d.default_message_notifications ?? 0;
|
|
180
|
+
}
|
|
181
|
+
iconURL(options = {}) {
|
|
182
|
+
if (!this.icon)
|
|
183
|
+
return null;
|
|
184
|
+
return cdnURL(`/icons/${this.id}`, this.icon, options);
|
|
185
|
+
}
|
|
186
|
+
splashURL(options = {}) {
|
|
187
|
+
if (!this.splash)
|
|
188
|
+
return null;
|
|
189
|
+
return cdnURL(`/splashes/${this.id}`, this.splash, options);
|
|
190
|
+
}
|
|
191
|
+
bannerURL(options = {}) {
|
|
192
|
+
if (!this.banner)
|
|
193
|
+
return null;
|
|
194
|
+
return cdnURL(`/banners/${this.id}`, this.banner, options);
|
|
195
|
+
}
|
|
196
|
+
discoverySplashURL(options = {}) {
|
|
197
|
+
if (!this.discoverySplash)
|
|
198
|
+
return null;
|
|
199
|
+
return cdnURL(`/discovery-splashes/${this.id}`, this.discoverySplash, options);
|
|
200
|
+
}
|
|
201
|
+
widgetImageURL(style = "shield") {
|
|
202
|
+
return `https://discord.com/api/guilds/${this.id}/widget.png?style=${style}`;
|
|
203
|
+
}
|
|
204
|
+
hasFeature(feature) {
|
|
205
|
+
return this.features.includes(feature);
|
|
206
|
+
}
|
|
207
|
+
get isCommunity() {
|
|
208
|
+
return this.hasFeature("COMMUNITY");
|
|
209
|
+
}
|
|
210
|
+
get isPartnered() {
|
|
211
|
+
return this.hasFeature("PARTNERED");
|
|
212
|
+
}
|
|
213
|
+
get isVerified() {
|
|
214
|
+
return this.hasFeature("VERIFIED");
|
|
215
|
+
}
|
|
216
|
+
get isBoosted() {
|
|
217
|
+
return this.premiumSubscriptionCount > 0;
|
|
218
|
+
}
|
|
219
|
+
get boostLevel() {
|
|
220
|
+
return this.premiumTier;
|
|
221
|
+
}
|
|
222
|
+
get hasVanityUrl() {
|
|
223
|
+
return this.vanityUrlCode !== null;
|
|
224
|
+
}
|
|
225
|
+
get vanityURL() {
|
|
226
|
+
return this.vanityUrlCode ? `https://discord.gg/${this.vanityUrlCode}` : null;
|
|
227
|
+
}
|
|
228
|
+
toString() {
|
|
229
|
+
return this.name;
|
|
82
230
|
}
|
|
83
231
|
}
|
|
84
|
-
// packages/
|
|
232
|
+
// packages/core/src/permissions.ts
|
|
233
|
+
var Permission = {
|
|
234
|
+
createInstantInvite: 1n << 0n,
|
|
235
|
+
kickMembers: 1n << 1n,
|
|
236
|
+
banMembers: 1n << 2n,
|
|
237
|
+
administrator: 1n << 3n,
|
|
238
|
+
manageChannels: 1n << 4n,
|
|
239
|
+
manageGuild: 1n << 5n,
|
|
240
|
+
addReactions: 1n << 6n,
|
|
241
|
+
viewAuditLog: 1n << 7n,
|
|
242
|
+
prioritySpeaker: 1n << 8n,
|
|
243
|
+
stream: 1n << 9n,
|
|
244
|
+
viewChannel: 1n << 10n,
|
|
245
|
+
sendMessages: 1n << 11n,
|
|
246
|
+
sendTTSMessages: 1n << 12n,
|
|
247
|
+
manageMessages: 1n << 13n,
|
|
248
|
+
embedLinks: 1n << 14n,
|
|
249
|
+
attachFiles: 1n << 15n,
|
|
250
|
+
readMessageHistory: 1n << 16n,
|
|
251
|
+
mentionEveryone: 1n << 17n,
|
|
252
|
+
useExternalEmojis: 1n << 18n,
|
|
253
|
+
viewGuildInsights: 1n << 19n,
|
|
254
|
+
connect: 1n << 20n,
|
|
255
|
+
speak: 1n << 21n,
|
|
256
|
+
muteMembers: 1n << 22n,
|
|
257
|
+
deafenMembers: 1n << 23n,
|
|
258
|
+
moveMembers: 1n << 24n,
|
|
259
|
+
useVAD: 1n << 25n,
|
|
260
|
+
changeNickname: 1n << 26n,
|
|
261
|
+
manageNicknames: 1n << 27n,
|
|
262
|
+
manageRoles: 1n << 28n,
|
|
263
|
+
manageWebhooks: 1n << 29n,
|
|
264
|
+
manageGuildExpressions: 1n << 30n,
|
|
265
|
+
useApplicationCommands: 1n << 31n,
|
|
266
|
+
requestToSpeak: 1n << 32n,
|
|
267
|
+
manageEvents: 1n << 33n,
|
|
268
|
+
manageThreads: 1n << 34n,
|
|
269
|
+
createPublicThreads: 1n << 35n,
|
|
270
|
+
createPrivateThreads: 1n << 36n,
|
|
271
|
+
useExternalStickers: 1n << 37n,
|
|
272
|
+
sendMessagesInThreads: 1n << 38n,
|
|
273
|
+
useEmbeddedActivities: 1n << 39n,
|
|
274
|
+
moderateMembers: 1n << 40n,
|
|
275
|
+
viewCreatorMonetizationAnalytics: 1n << 41n,
|
|
276
|
+
useSoundboard: 1n << 42n,
|
|
277
|
+
createGuildExpressions: 1n << 43n,
|
|
278
|
+
createEvents: 1n << 44n,
|
|
279
|
+
useExternalSounds: 1n << 45n,
|
|
280
|
+
sendVoiceMessages: 1n << 46n,
|
|
281
|
+
sendPolls: 1n << 49n,
|
|
282
|
+
useExternalApps: 1n << 50n
|
|
283
|
+
};
|
|
85
284
|
var Permissions = {
|
|
86
285
|
CreateInstantInvite: 1n << 0n,
|
|
87
286
|
KickMembers: 1n << 1n,
|
|
@@ -133,6 +332,57 @@ var Permissions = {
|
|
|
133
332
|
SendPolls: 1n << 49n,
|
|
134
333
|
UseExternalApps: 1n << 50n
|
|
135
334
|
};
|
|
335
|
+
var PermissionFlagsBits = {
|
|
336
|
+
CreateInstantInvite: 1n << 0n,
|
|
337
|
+
KickMembers: 1n << 1n,
|
|
338
|
+
BanMembers: 1n << 2n,
|
|
339
|
+
Administrator: 1n << 3n,
|
|
340
|
+
ManageChannels: 1n << 4n,
|
|
341
|
+
ManageGuild: 1n << 5n,
|
|
342
|
+
AddReactions: 1n << 6n,
|
|
343
|
+
ViewAuditLog: 1n << 7n,
|
|
344
|
+
PrioritySpeaker: 1n << 8n,
|
|
345
|
+
Stream: 1n << 9n,
|
|
346
|
+
ViewChannel: 1n << 10n,
|
|
347
|
+
SendMessages: 1n << 11n,
|
|
348
|
+
SendTTSMessages: 1n << 12n,
|
|
349
|
+
ManageMessages: 1n << 13n,
|
|
350
|
+
EmbedLinks: 1n << 14n,
|
|
351
|
+
AttachFiles: 1n << 15n,
|
|
352
|
+
ReadMessageHistory: 1n << 16n,
|
|
353
|
+
MentionEveryone: 1n << 17n,
|
|
354
|
+
UseExternalEmojis: 1n << 18n,
|
|
355
|
+
ViewGuildInsights: 1n << 19n,
|
|
356
|
+
Connect: 1n << 20n,
|
|
357
|
+
Speak: 1n << 21n,
|
|
358
|
+
MuteMembers: 1n << 22n,
|
|
359
|
+
DeafenMembers: 1n << 23n,
|
|
360
|
+
MoveMembers: 1n << 24n,
|
|
361
|
+
UseVAD: 1n << 25n,
|
|
362
|
+
ChangeNickname: 1n << 26n,
|
|
363
|
+
ManageNicknames: 1n << 27n,
|
|
364
|
+
ManageRoles: 1n << 28n,
|
|
365
|
+
ManageWebhooks: 1n << 29n,
|
|
366
|
+
ManageGuildExpressions: 1n << 30n,
|
|
367
|
+
UseApplicationCommands: 1n << 31n,
|
|
368
|
+
RequestToSpeak: 1n << 32n,
|
|
369
|
+
ManageEvents: 1n << 33n,
|
|
370
|
+
ManageThreads: 1n << 34n,
|
|
371
|
+
CreatePublicThreads: 1n << 35n,
|
|
372
|
+
CreatePrivateThreads: 1n << 36n,
|
|
373
|
+
UseExternalStickers: 1n << 37n,
|
|
374
|
+
SendMessagesInThreads: 1n << 38n,
|
|
375
|
+
UseEmbeddedActivities: 1n << 39n,
|
|
376
|
+
ModerateMembers: 1n << 40n,
|
|
377
|
+
ViewCreatorMonetizationAnalytics: 1n << 41n,
|
|
378
|
+
UseSoundboard: 1n << 42n,
|
|
379
|
+
CreateGuildExpressions: 1n << 43n,
|
|
380
|
+
CreateEvents: 1n << 44n,
|
|
381
|
+
UseExternalSounds: 1n << 45n,
|
|
382
|
+
SendVoiceMessages: 1n << 46n,
|
|
383
|
+
SendPolls: 1n << 49n,
|
|
384
|
+
UseExternalApps: 1n << 50n
|
|
385
|
+
};
|
|
136
386
|
|
|
137
387
|
class PermissionSet {
|
|
138
388
|
bitfield;
|
|
@@ -140,8 +390,9 @@ class PermissionSet {
|
|
|
140
390
|
try {
|
|
141
391
|
if (Array.isArray(value)) {
|
|
142
392
|
let bit = 0n;
|
|
143
|
-
for (const item of value)
|
|
393
|
+
for (const item of value) {
|
|
144
394
|
bit |= this.#resolve(item);
|
|
395
|
+
}
|
|
145
396
|
this.bitfield = bit;
|
|
146
397
|
} else if (value instanceof PermissionSet) {
|
|
147
398
|
this.bitfield = value.bitfield;
|
|
@@ -157,22 +408,195 @@ class PermissionSet {
|
|
|
157
408
|
throw new TypeError("Permission bitfield must be a valid non-negative integer.", { cause: error });
|
|
158
409
|
}
|
|
159
410
|
}
|
|
411
|
+
get createInstantInvite() {
|
|
412
|
+
return (this.bitfield & Permission.createInstantInvite) === Permission.createInstantInvite;
|
|
413
|
+
}
|
|
414
|
+
get kickMembers() {
|
|
415
|
+
return (this.bitfield & Permission.kickMembers) === Permission.kickMembers;
|
|
416
|
+
}
|
|
417
|
+
get banMembers() {
|
|
418
|
+
return (this.bitfield & Permission.banMembers) === Permission.banMembers;
|
|
419
|
+
}
|
|
420
|
+
get administrator() {
|
|
421
|
+
return (this.bitfield & Permission.administrator) === Permission.administrator;
|
|
422
|
+
}
|
|
423
|
+
get manageChannels() {
|
|
424
|
+
return (this.bitfield & Permission.manageChannels) === Permission.manageChannels;
|
|
425
|
+
}
|
|
426
|
+
get manageGuild() {
|
|
427
|
+
return (this.bitfield & Permission.manageGuild) === Permission.manageGuild;
|
|
428
|
+
}
|
|
429
|
+
get addReactions() {
|
|
430
|
+
return (this.bitfield & Permission.addReactions) === Permission.addReactions;
|
|
431
|
+
}
|
|
432
|
+
get viewAuditLog() {
|
|
433
|
+
return (this.bitfield & Permission.viewAuditLog) === Permission.viewAuditLog;
|
|
434
|
+
}
|
|
435
|
+
get prioritySpeaker() {
|
|
436
|
+
return (this.bitfield & Permission.prioritySpeaker) === Permission.prioritySpeaker;
|
|
437
|
+
}
|
|
438
|
+
get stream() {
|
|
439
|
+
return (this.bitfield & Permission.stream) === Permission.stream;
|
|
440
|
+
}
|
|
441
|
+
get viewChannel() {
|
|
442
|
+
return (this.bitfield & Permission.viewChannel) === Permission.viewChannel;
|
|
443
|
+
}
|
|
444
|
+
get sendMessages() {
|
|
445
|
+
return (this.bitfield & Permission.sendMessages) === Permission.sendMessages;
|
|
446
|
+
}
|
|
447
|
+
get sendTTSMessages() {
|
|
448
|
+
return (this.bitfield & Permission.sendTTSMessages) === Permission.sendTTSMessages;
|
|
449
|
+
}
|
|
450
|
+
get manageMessages() {
|
|
451
|
+
return (this.bitfield & Permission.manageMessages) === Permission.manageMessages;
|
|
452
|
+
}
|
|
453
|
+
get embedLinks() {
|
|
454
|
+
return (this.bitfield & Permission.embedLinks) === Permission.embedLinks;
|
|
455
|
+
}
|
|
456
|
+
get attachFiles() {
|
|
457
|
+
return (this.bitfield & Permission.attachFiles) === Permission.attachFiles;
|
|
458
|
+
}
|
|
459
|
+
get readMessageHistory() {
|
|
460
|
+
return (this.bitfield & Permission.readMessageHistory) === Permission.readMessageHistory;
|
|
461
|
+
}
|
|
462
|
+
get mentionEveryone() {
|
|
463
|
+
return (this.bitfield & Permission.mentionEveryone) === Permission.mentionEveryone;
|
|
464
|
+
}
|
|
465
|
+
get useExternalEmojis() {
|
|
466
|
+
return (this.bitfield & Permission.useExternalEmojis) === Permission.useExternalEmojis;
|
|
467
|
+
}
|
|
468
|
+
get viewGuildInsights() {
|
|
469
|
+
return (this.bitfield & Permission.viewGuildInsights) === Permission.viewGuildInsights;
|
|
470
|
+
}
|
|
471
|
+
get connect() {
|
|
472
|
+
return (this.bitfield & Permission.connect) === Permission.connect;
|
|
473
|
+
}
|
|
474
|
+
get speak() {
|
|
475
|
+
return (this.bitfield & Permission.speak) === Permission.speak;
|
|
476
|
+
}
|
|
477
|
+
get muteMembers() {
|
|
478
|
+
return (this.bitfield & Permission.muteMembers) === Permission.muteMembers;
|
|
479
|
+
}
|
|
480
|
+
get deafenMembers() {
|
|
481
|
+
return (this.bitfield & Permission.deafenMembers) === Permission.deafenMembers;
|
|
482
|
+
}
|
|
483
|
+
get moveMembers() {
|
|
484
|
+
return (this.bitfield & Permission.moveMembers) === Permission.moveMembers;
|
|
485
|
+
}
|
|
486
|
+
get useVAD() {
|
|
487
|
+
return (this.bitfield & Permission.useVAD) === Permission.useVAD;
|
|
488
|
+
}
|
|
489
|
+
get changeNickname() {
|
|
490
|
+
return (this.bitfield & Permission.changeNickname) === Permission.changeNickname;
|
|
491
|
+
}
|
|
492
|
+
get manageNicknames() {
|
|
493
|
+
return (this.bitfield & Permission.manageNicknames) === Permission.manageNicknames;
|
|
494
|
+
}
|
|
495
|
+
get manageRoles() {
|
|
496
|
+
return (this.bitfield & Permission.manageRoles) === Permission.manageRoles;
|
|
497
|
+
}
|
|
498
|
+
get manageWebhooks() {
|
|
499
|
+
return (this.bitfield & Permission.manageWebhooks) === Permission.manageWebhooks;
|
|
500
|
+
}
|
|
501
|
+
get manageGuildExpressions() {
|
|
502
|
+
return (this.bitfield & Permission.manageGuildExpressions) === Permission.manageGuildExpressions;
|
|
503
|
+
}
|
|
504
|
+
get useApplicationCommands() {
|
|
505
|
+
return (this.bitfield & Permission.useApplicationCommands) === Permission.useApplicationCommands;
|
|
506
|
+
}
|
|
507
|
+
get requestToSpeak() {
|
|
508
|
+
return (this.bitfield & Permission.requestToSpeak) === Permission.requestToSpeak;
|
|
509
|
+
}
|
|
510
|
+
get manageEvents() {
|
|
511
|
+
return (this.bitfield & Permission.manageEvents) === Permission.manageEvents;
|
|
512
|
+
}
|
|
513
|
+
get manageThreads() {
|
|
514
|
+
return (this.bitfield & Permission.manageThreads) === Permission.manageThreads;
|
|
515
|
+
}
|
|
516
|
+
get createPublicThreads() {
|
|
517
|
+
return (this.bitfield & Permission.createPublicThreads) === Permission.createPublicThreads;
|
|
518
|
+
}
|
|
519
|
+
get createPrivateThreads() {
|
|
520
|
+
return (this.bitfield & Permission.createPrivateThreads) === Permission.createPrivateThreads;
|
|
521
|
+
}
|
|
522
|
+
get useExternalStickers() {
|
|
523
|
+
return (this.bitfield & Permission.useExternalStickers) === Permission.useExternalStickers;
|
|
524
|
+
}
|
|
525
|
+
get sendMessagesInThreads() {
|
|
526
|
+
return (this.bitfield & Permission.sendMessagesInThreads) === Permission.sendMessagesInThreads;
|
|
527
|
+
}
|
|
528
|
+
get useEmbeddedActivities() {
|
|
529
|
+
return (this.bitfield & Permission.useEmbeddedActivities) === Permission.useEmbeddedActivities;
|
|
530
|
+
}
|
|
531
|
+
get moderateMembers() {
|
|
532
|
+
return (this.bitfield & Permission.moderateMembers) === Permission.moderateMembers;
|
|
533
|
+
}
|
|
534
|
+
get viewCreatorMonetizationAnalytics() {
|
|
535
|
+
return (this.bitfield & Permission.viewCreatorMonetizationAnalytics) === Permission.viewCreatorMonetizationAnalytics;
|
|
536
|
+
}
|
|
537
|
+
get useSoundboard() {
|
|
538
|
+
return (this.bitfield & Permission.useSoundboard) === Permission.useSoundboard;
|
|
539
|
+
}
|
|
540
|
+
get createGuildExpressions() {
|
|
541
|
+
return (this.bitfield & Permission.createGuildExpressions) === Permission.createGuildExpressions;
|
|
542
|
+
}
|
|
543
|
+
get createEvents() {
|
|
544
|
+
return (this.bitfield & Permission.createEvents) === Permission.createEvents;
|
|
545
|
+
}
|
|
546
|
+
get useExternalSounds() {
|
|
547
|
+
return (this.bitfield & Permission.useExternalSounds) === Permission.useExternalSounds;
|
|
548
|
+
}
|
|
549
|
+
get sendVoiceMessages() {
|
|
550
|
+
return (this.bitfield & Permission.sendVoiceMessages) === Permission.sendVoiceMessages;
|
|
551
|
+
}
|
|
552
|
+
get sendPolls() {
|
|
553
|
+
return (this.bitfield & Permission.sendPolls) === Permission.sendPolls;
|
|
554
|
+
}
|
|
555
|
+
get useExternalApps() {
|
|
556
|
+
return (this.bitfield & Permission.useExternalApps) === Permission.useExternalApps;
|
|
557
|
+
}
|
|
160
558
|
has(...permissions) {
|
|
161
|
-
|
|
559
|
+
if (permissions.length === 1) {
|
|
560
|
+
const p = permissions[0];
|
|
561
|
+
const bit = typeof p === "bigint" ? p : this.#resolve(p);
|
|
562
|
+
return (this.bitfield & bit) === bit;
|
|
563
|
+
}
|
|
564
|
+
for (let i = 0;i < permissions.length; i++) {
|
|
565
|
+
const p = permissions[i];
|
|
566
|
+
const bit = typeof p === "bigint" ? p : this.#resolve(p);
|
|
567
|
+
if ((this.bitfield & bit) !== bit)
|
|
568
|
+
return false;
|
|
569
|
+
}
|
|
570
|
+
return true;
|
|
162
571
|
}
|
|
163
572
|
any(...permissions) {
|
|
164
|
-
|
|
573
|
+
if (permissions.length === 1) {
|
|
574
|
+
const p = permissions[0];
|
|
575
|
+
const bit = typeof p === "bigint" ? p : this.#resolve(p);
|
|
576
|
+
return (this.bitfield & bit) !== 0n;
|
|
577
|
+
}
|
|
578
|
+
for (let i = 0;i < permissions.length; i++) {
|
|
579
|
+
const p = permissions[i];
|
|
580
|
+
const bit = typeof p === "bigint" ? p : this.#resolve(p);
|
|
581
|
+
if ((this.bitfield & bit) !== 0n)
|
|
582
|
+
return true;
|
|
583
|
+
}
|
|
584
|
+
return false;
|
|
165
585
|
}
|
|
166
586
|
add(...permissions) {
|
|
167
587
|
let bitfield = this.bitfield;
|
|
168
|
-
for (
|
|
169
|
-
|
|
588
|
+
for (let i = 0;i < permissions.length; i++) {
|
|
589
|
+
const p = permissions[i];
|
|
590
|
+
bitfield |= typeof p === "bigint" ? p : this.#resolve(p);
|
|
591
|
+
}
|
|
170
592
|
return new PermissionSet(bitfield);
|
|
171
593
|
}
|
|
172
594
|
remove(...permissions) {
|
|
173
595
|
let bitfield = this.bitfield;
|
|
174
|
-
for (
|
|
175
|
-
|
|
596
|
+
for (let i = 0;i < permissions.length; i++) {
|
|
597
|
+
const p = permissions[i];
|
|
598
|
+
bitfield &= ~(typeof p === "bigint" ? p : this.#resolve(p));
|
|
599
|
+
}
|
|
176
600
|
return new PermissionSet(bitfield);
|
|
177
601
|
}
|
|
178
602
|
equals(other) {
|
|
@@ -182,27 +606,31 @@ class PermissionSet {
|
|
|
182
606
|
return this.bitfield.toString();
|
|
183
607
|
}
|
|
184
608
|
toArray() {
|
|
185
|
-
return Object.keys(
|
|
609
|
+
return Object.keys(Permission).filter((permission) => this.has(permission));
|
|
186
610
|
}
|
|
187
611
|
#resolve(permission) {
|
|
188
|
-
if (permission instanceof PermissionSet)
|
|
189
|
-
return permission.bitfield;
|
|
190
612
|
if (typeof permission === "bigint")
|
|
191
613
|
return permission;
|
|
192
614
|
if (typeof permission === "number")
|
|
193
615
|
return BigInt(permission);
|
|
616
|
+
if (permission instanceof PermissionSet)
|
|
617
|
+
return permission.bitfield;
|
|
194
618
|
if (Array.isArray(permission)) {
|
|
195
619
|
let bit = 0n;
|
|
196
|
-
for (
|
|
197
|
-
bit |= this.#resolve(
|
|
620
|
+
for (let i = 0;i < permission.length; i++)
|
|
621
|
+
bit |= this.#resolve(permission[i]);
|
|
198
622
|
return bit;
|
|
199
623
|
}
|
|
200
624
|
if (typeof permission === "string") {
|
|
625
|
+
if (permission in Permission)
|
|
626
|
+
return Permission[permission];
|
|
201
627
|
if (permission in Permissions)
|
|
202
628
|
return Permissions[permission];
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
629
|
+
if (permission in PermissionFlagsBits)
|
|
630
|
+
return PermissionFlagsBits[permission];
|
|
631
|
+
const lower = permission.charAt(0).toLowerCase() + permission.slice(1);
|
|
632
|
+
if (lower in Permission)
|
|
633
|
+
return Permission[lower];
|
|
206
634
|
return BigInt(permission);
|
|
207
635
|
}
|
|
208
636
|
return 0n;
|
|
@@ -210,12 +638,357 @@ class PermissionSet {
|
|
|
210
638
|
}
|
|
211
639
|
|
|
212
640
|
class PermissionsBitField extends PermissionSet {
|
|
641
|
+
static Flags = PermissionFlagsBits;
|
|
642
|
+
static All = Permission;
|
|
213
643
|
constructor(value = 0n) {
|
|
214
644
|
super(value);
|
|
215
645
|
}
|
|
216
646
|
}
|
|
647
|
+
// packages/types/src/index.ts
|
|
648
|
+
var GatewayIntentBits = {
|
|
649
|
+
Guilds: 1 << 0,
|
|
650
|
+
GuildMembers: 1 << 1,
|
|
651
|
+
GuildModeration: 1 << 2,
|
|
652
|
+
GuildExpressions: 1 << 3,
|
|
653
|
+
GuildIntegrations: 1 << 4,
|
|
654
|
+
GuildWebhooks: 1 << 5,
|
|
655
|
+
GuildInvites: 1 << 6,
|
|
656
|
+
GuildVoiceStates: 1 << 7,
|
|
657
|
+
GuildPresences: 1 << 8,
|
|
658
|
+
GuildMessages: 1 << 9,
|
|
659
|
+
GuildMessageReactions: 1 << 10,
|
|
660
|
+
GuildMessageTyping: 1 << 11,
|
|
661
|
+
DirectMessages: 1 << 12,
|
|
662
|
+
DirectMessageReactions: 1 << 13,
|
|
663
|
+
DirectMessageTyping: 1 << 14,
|
|
664
|
+
MessageContent: 1 << 15,
|
|
665
|
+
GuildScheduledEvents: 1 << 16,
|
|
666
|
+
AutoModerationConfiguration: 1 << 20,
|
|
667
|
+
AutoModerationExecution: 1 << 21,
|
|
668
|
+
GuildMessagePolls: 1 << 24,
|
|
669
|
+
DirectMessagePolls: 1 << 25
|
|
670
|
+
};
|
|
671
|
+
var IntentBits = {
|
|
672
|
+
guild: 1 << 0,
|
|
673
|
+
guilds: 1 << 0,
|
|
674
|
+
guildMembers: 1 << 1,
|
|
675
|
+
guildModeration: 1 << 2,
|
|
676
|
+
guildBans: 1 << 2,
|
|
677
|
+
guildExpressions: 1 << 3,
|
|
678
|
+
guildEmojis: 1 << 3,
|
|
679
|
+
guildEmojisAndStickers: 1 << 3,
|
|
680
|
+
guildIntegrations: 1 << 4,
|
|
681
|
+
guildWebhooks: 1 << 5,
|
|
682
|
+
guildInvites: 1 << 6,
|
|
683
|
+
guildVoiceStates: 1 << 7,
|
|
684
|
+
guildPresences: 1 << 8,
|
|
685
|
+
guildMessages: 1 << 9,
|
|
686
|
+
guildMessage: 1 << 9,
|
|
687
|
+
guildMessageReactions: 1 << 10,
|
|
688
|
+
guildMessageTyping: 1 << 11,
|
|
689
|
+
directMessages: 1 << 12,
|
|
690
|
+
directMessageReactions: 1 << 13,
|
|
691
|
+
directMessageTyping: 1 << 14,
|
|
692
|
+
messageContent: 1 << 15,
|
|
693
|
+
guildScheduledEvents: 1 << 16,
|
|
694
|
+
autoModerationConfiguration: 1 << 20,
|
|
695
|
+
autoModerationExecution: 1 << 21,
|
|
696
|
+
guildMessagePolls: 1 << 24,
|
|
697
|
+
directMessagePolls: 1 << 25
|
|
698
|
+
};
|
|
699
|
+
var InteractionResponseType = {
|
|
700
|
+
Pong: 1,
|
|
701
|
+
ChannelMessage: 4,
|
|
702
|
+
DeferredChannelMessage: 5,
|
|
703
|
+
DeferredMessageUpdate: 6,
|
|
704
|
+
MessageUpdate: 7,
|
|
705
|
+
Autocomplete: 8,
|
|
706
|
+
Modal: 9
|
|
707
|
+
};
|
|
708
|
+
// packages/collection/src/index.ts
|
|
709
|
+
class Collection extends Map {
|
|
710
|
+
first() {
|
|
711
|
+
for (const value of this.values())
|
|
712
|
+
return value;
|
|
713
|
+
return;
|
|
714
|
+
}
|
|
715
|
+
firstKey() {
|
|
716
|
+
for (const key of this.keys())
|
|
717
|
+
return key;
|
|
718
|
+
return;
|
|
719
|
+
}
|
|
720
|
+
last() {
|
|
721
|
+
let value;
|
|
722
|
+
for (const item of this.values())
|
|
723
|
+
value = item;
|
|
724
|
+
return value;
|
|
725
|
+
}
|
|
726
|
+
lastKey() {
|
|
727
|
+
let key;
|
|
728
|
+
for (const item of this.keys())
|
|
729
|
+
key = item;
|
|
730
|
+
return key;
|
|
731
|
+
}
|
|
732
|
+
find(predicate) {
|
|
733
|
+
for (const [key, value] of this) {
|
|
734
|
+
if (predicate(value, key, this))
|
|
735
|
+
return value;
|
|
736
|
+
}
|
|
737
|
+
return;
|
|
738
|
+
}
|
|
739
|
+
filter(predicate) {
|
|
740
|
+
const result = new Collection;
|
|
741
|
+
for (const [key, value] of this) {
|
|
742
|
+
if (predicate(value, key, this))
|
|
743
|
+
result.set(key, value);
|
|
744
|
+
}
|
|
745
|
+
return result;
|
|
746
|
+
}
|
|
747
|
+
map(transform) {
|
|
748
|
+
const result = [];
|
|
749
|
+
for (const [key, value] of this) {
|
|
750
|
+
result.push(transform(value, key, this));
|
|
751
|
+
}
|
|
752
|
+
return result;
|
|
753
|
+
}
|
|
754
|
+
some(predicate) {
|
|
755
|
+
for (const [key, value] of this) {
|
|
756
|
+
if (predicate(value, key, this))
|
|
757
|
+
return true;
|
|
758
|
+
}
|
|
759
|
+
return false;
|
|
760
|
+
}
|
|
761
|
+
every(predicate) {
|
|
762
|
+
for (const [key, value] of this) {
|
|
763
|
+
if (!predicate(value, key, this))
|
|
764
|
+
return false;
|
|
765
|
+
}
|
|
766
|
+
return true;
|
|
767
|
+
}
|
|
768
|
+
each(callback) {
|
|
769
|
+
for (const [key, value] of this) {
|
|
770
|
+
callback(value, key, this);
|
|
771
|
+
}
|
|
772
|
+
return this;
|
|
773
|
+
}
|
|
774
|
+
array() {
|
|
775
|
+
return [...this.values()];
|
|
776
|
+
}
|
|
777
|
+
keyArray() {
|
|
778
|
+
return [...this.keys()];
|
|
779
|
+
}
|
|
780
|
+
entriesArray() {
|
|
781
|
+
return [...this.entries()];
|
|
782
|
+
}
|
|
783
|
+
clone() {
|
|
784
|
+
const copy = new Collection;
|
|
785
|
+
for (const [key, value] of this)
|
|
786
|
+
copy.set(key, value);
|
|
787
|
+
return copy;
|
|
788
|
+
}
|
|
789
|
+
hasAll(...keys) {
|
|
790
|
+
for (let i = 0;i < keys.length; i++) {
|
|
791
|
+
if (!this.has(keys[i]))
|
|
792
|
+
return false;
|
|
793
|
+
}
|
|
794
|
+
return true;
|
|
795
|
+
}
|
|
796
|
+
hasAny(...keys) {
|
|
797
|
+
for (let i = 0;i < keys.length; i++) {
|
|
798
|
+
if (this.has(keys[i]))
|
|
799
|
+
return true;
|
|
800
|
+
}
|
|
801
|
+
return false;
|
|
802
|
+
}
|
|
803
|
+
findKey(predicate) {
|
|
804
|
+
for (const [key, value] of this) {
|
|
805
|
+
if (predicate(value, key, this))
|
|
806
|
+
return key;
|
|
807
|
+
}
|
|
808
|
+
return;
|
|
809
|
+
}
|
|
810
|
+
someEntry(predicate) {
|
|
811
|
+
return this.some(predicate);
|
|
812
|
+
}
|
|
813
|
+
sweep(predicate) {
|
|
814
|
+
let removed = 0;
|
|
815
|
+
for (const [key, value] of this) {
|
|
816
|
+
if (predicate(value, key, this) && this.delete(key))
|
|
817
|
+
removed++;
|
|
818
|
+
}
|
|
819
|
+
return removed;
|
|
820
|
+
}
|
|
821
|
+
firstEntry() {
|
|
822
|
+
for (const [key, value] of this)
|
|
823
|
+
return [key, value];
|
|
824
|
+
return;
|
|
825
|
+
}
|
|
826
|
+
lastEntry() {
|
|
827
|
+
let entry;
|
|
828
|
+
for (const item of this)
|
|
829
|
+
entry = [item[0], item[1]];
|
|
830
|
+
return entry;
|
|
831
|
+
}
|
|
832
|
+
union(other) {
|
|
833
|
+
const result = this.clone();
|
|
834
|
+
for (const [key, value] of other)
|
|
835
|
+
result.set(key, value);
|
|
836
|
+
return result;
|
|
837
|
+
}
|
|
838
|
+
intersection(other) {
|
|
839
|
+
const result = new Collection;
|
|
840
|
+
for (const [key, value] of this) {
|
|
841
|
+
if (other.has(key))
|
|
842
|
+
result.set(key, value);
|
|
843
|
+
}
|
|
844
|
+
return result;
|
|
845
|
+
}
|
|
846
|
+
difference(other) {
|
|
847
|
+
const result = new Collection;
|
|
848
|
+
for (const [key, value] of this) {
|
|
849
|
+
if (!other.has(key))
|
|
850
|
+
result.set(key, value);
|
|
851
|
+
}
|
|
852
|
+
return result;
|
|
853
|
+
}
|
|
854
|
+
partition(predicate) {
|
|
855
|
+
const pass = new Collection;
|
|
856
|
+
const fail = new Collection;
|
|
857
|
+
for (const [key, value] of this) {
|
|
858
|
+
if (predicate(value, key, this))
|
|
859
|
+
pass.set(key, value);
|
|
860
|
+
else
|
|
861
|
+
fail.set(key, value);
|
|
862
|
+
}
|
|
863
|
+
return [pass, fail];
|
|
864
|
+
}
|
|
865
|
+
tap(fn) {
|
|
866
|
+
fn(this);
|
|
867
|
+
return this;
|
|
868
|
+
}
|
|
869
|
+
flatMap(transform) {
|
|
870
|
+
const result = [];
|
|
871
|
+
for (const [key, value] of this) {
|
|
872
|
+
for (const item of transform(value, key, this))
|
|
873
|
+
result.push(item);
|
|
874
|
+
}
|
|
875
|
+
return result;
|
|
876
|
+
}
|
|
877
|
+
reduce(fn, initialValue) {
|
|
878
|
+
let acc = initialValue;
|
|
879
|
+
for (const [key, value] of this)
|
|
880
|
+
acc = fn(acc, value, key, this);
|
|
881
|
+
return acc;
|
|
882
|
+
}
|
|
883
|
+
sorted(comparator) {
|
|
884
|
+
const decorated = [...this.entries()].map((entry, index) => ({
|
|
885
|
+
entry,
|
|
886
|
+
index
|
|
887
|
+
}));
|
|
888
|
+
if (comparator)
|
|
889
|
+
decorated.sort((x, y) => {
|
|
890
|
+
const comparison = comparator(x.entry[1], y.entry[1], x.entry[0], y.entry[0]);
|
|
891
|
+
return comparison !== 0 ? comparison : x.index - y.index;
|
|
892
|
+
});
|
|
893
|
+
const result = new Collection;
|
|
894
|
+
for (const { entry } of decorated)
|
|
895
|
+
result.set(entry[0], entry[1]);
|
|
896
|
+
return result;
|
|
897
|
+
}
|
|
898
|
+
random() {
|
|
899
|
+
const arr = [...this.values()];
|
|
900
|
+
if (!arr.length)
|
|
901
|
+
return;
|
|
902
|
+
return arr[Math.floor(Math.random() * arr.length)];
|
|
903
|
+
}
|
|
904
|
+
randomKey() {
|
|
905
|
+
const arr = [...this.keys()];
|
|
906
|
+
if (!arr.length)
|
|
907
|
+
return;
|
|
908
|
+
return arr[Math.floor(Math.random() * arr.length)];
|
|
909
|
+
}
|
|
910
|
+
at(index) {
|
|
911
|
+
const arr = [...this.values()];
|
|
912
|
+
const i = index < 0 ? arr.length + index : index;
|
|
913
|
+
return arr[i];
|
|
914
|
+
}
|
|
915
|
+
keyAt(index) {
|
|
916
|
+
const arr = [...this.keys()];
|
|
917
|
+
const i = index < 0 ? arr.length + index : index;
|
|
918
|
+
return arr[i];
|
|
919
|
+
}
|
|
920
|
+
toJSON() {
|
|
921
|
+
return [...this.entries()];
|
|
922
|
+
}
|
|
923
|
+
}
|
|
217
924
|
|
|
925
|
+
// packages/managers/src/base.ts
|
|
926
|
+
class Manager {
|
|
927
|
+
cache = new Collection;
|
|
928
|
+
get(id) {
|
|
929
|
+
return this.cache.get(id);
|
|
930
|
+
}
|
|
931
|
+
has(id) {
|
|
932
|
+
return this.cache.has(id);
|
|
933
|
+
}
|
|
934
|
+
set(id, value) {
|
|
935
|
+
this.cache.set(id, value);
|
|
936
|
+
return this;
|
|
937
|
+
}
|
|
938
|
+
delete(id) {
|
|
939
|
+
return this.cache.delete(id);
|
|
940
|
+
}
|
|
941
|
+
clear() {
|
|
942
|
+
this.cache.clear();
|
|
943
|
+
}
|
|
944
|
+
get size() {
|
|
945
|
+
return this.cache.size;
|
|
946
|
+
}
|
|
947
|
+
first() {
|
|
948
|
+
return this.cache.first();
|
|
949
|
+
}
|
|
950
|
+
values() {
|
|
951
|
+
return this.cache.array();
|
|
952
|
+
}
|
|
953
|
+
find(predicate) {
|
|
954
|
+
return this.cache.find(predicate);
|
|
955
|
+
}
|
|
956
|
+
[Symbol.iterator]() {
|
|
957
|
+
return this.cache[Symbol.iterator]();
|
|
958
|
+
}
|
|
959
|
+
}
|
|
960
|
+
// packages/rest/package.json
|
|
961
|
+
var package_default = {
|
|
962
|
+
name: "@lunibee/rest",
|
|
963
|
+
version: "0.1.7",
|
|
964
|
+
type: "module",
|
|
965
|
+
module: "./src/index.ts",
|
|
966
|
+
types: "./src/index.ts",
|
|
967
|
+
exports: {
|
|
968
|
+
".": "./src/index.ts"
|
|
969
|
+
}
|
|
970
|
+
};
|
|
971
|
+
// packages/rest/src/index.ts
|
|
972
|
+
var LIBRARY_VERSION = package_default.version;
|
|
973
|
+
var LIBRARY_URL = "https://github.com/Ekretos/lunibee";
|
|
974
|
+
var USER_AGENT = `DiscordBot (${LIBRARY_URL}, ${package_default.version})`;
|
|
975
|
+
var REQUEST_DATA_KEYS = new Set([
|
|
976
|
+
"body",
|
|
977
|
+
"files",
|
|
978
|
+
"query",
|
|
979
|
+
"headers",
|
|
980
|
+
"reason",
|
|
981
|
+
"auth",
|
|
982
|
+
"signal"
|
|
983
|
+
]);
|
|
218
984
|
// packages/structures/src/resources.ts
|
|
985
|
+
function toDateOrNull(value) {
|
|
986
|
+
if (!value)
|
|
987
|
+
return null;
|
|
988
|
+
const date = new Date(value);
|
|
989
|
+
return Number.isNaN(date.getTime()) ? null : date;
|
|
990
|
+
}
|
|
991
|
+
|
|
219
992
|
class GuildMember {
|
|
220
993
|
user;
|
|
221
994
|
guildId;
|
|
@@ -224,6 +997,10 @@ class GuildMember {
|
|
|
224
997
|
pending;
|
|
225
998
|
joinedAt;
|
|
226
999
|
permissions;
|
|
1000
|
+
avatarHash;
|
|
1001
|
+
premiumSince;
|
|
1002
|
+
timedOutUntil;
|
|
1003
|
+
flags;
|
|
227
1004
|
constructor(data) {
|
|
228
1005
|
this.user = new User(data.user);
|
|
229
1006
|
if (!/^\d{1,20}$/.test(data.guild_id))
|
|
@@ -236,10 +1013,28 @@ class GuildMember {
|
|
|
236
1013
|
if (this.joinedAt?.toString() === "Invalid Date")
|
|
237
1014
|
throw new RangeError("Member joined_at must be a valid date.");
|
|
238
1015
|
this.permissions = new PermissionsBitField(data.permissions ?? 0n);
|
|
1016
|
+
this.avatarHash = data.avatar ?? null;
|
|
1017
|
+
this.premiumSince = toDateOrNull(data.premium_since);
|
|
1018
|
+
this.timedOutUntil = toDateOrNull(data.communication_disabled_until);
|
|
1019
|
+
this.flags = data.flags ?? 0;
|
|
239
1020
|
}
|
|
240
1021
|
get displayName() {
|
|
241
1022
|
return this.nickname ?? this.user.displayName;
|
|
242
1023
|
}
|
|
1024
|
+
get isTimedOut() {
|
|
1025
|
+
return this.timedOutUntil !== null && this.timedOutUntil > new Date;
|
|
1026
|
+
}
|
|
1027
|
+
avatarURL(options = {}) {
|
|
1028
|
+
if (this.avatarHash)
|
|
1029
|
+
return cdnURL(`/guilds/${this.guildId}/users/${this.user.id}/avatars`, this.avatarHash, options);
|
|
1030
|
+
return this.user.avatarURL(options);
|
|
1031
|
+
}
|
|
1032
|
+
displayAvatarURL(options = {}) {
|
|
1033
|
+
return this.avatarURL(options) ?? this.user.displayAvatarURL(options);
|
|
1034
|
+
}
|
|
1035
|
+
toString() {
|
|
1036
|
+
return this.user.toString();
|
|
1037
|
+
}
|
|
243
1038
|
}
|
|
244
1039
|
|
|
245
1040
|
class Role extends BaseStructure {
|
|
@@ -249,6 +1044,10 @@ class Role extends BaseStructure {
|
|
|
249
1044
|
permissions;
|
|
250
1045
|
managed;
|
|
251
1046
|
mentionable;
|
|
1047
|
+
position;
|
|
1048
|
+
unicodeEmoji;
|
|
1049
|
+
iconHash;
|
|
1050
|
+
tags;
|
|
252
1051
|
constructor(data) {
|
|
253
1052
|
super(data.id);
|
|
254
1053
|
if (!data.name)
|
|
@@ -259,6 +1058,21 @@ class Role extends BaseStructure {
|
|
|
259
1058
|
this.permissions = new PermissionsBitField(data.permissions ?? 0n);
|
|
260
1059
|
this.managed = data.managed ?? false;
|
|
261
1060
|
this.mentionable = data.mentionable ?? false;
|
|
1061
|
+
this.position = data.position ?? 0;
|
|
1062
|
+
this.unicodeEmoji = data.unicode_emoji ?? null;
|
|
1063
|
+
this.iconHash = data.icon ?? null;
|
|
1064
|
+
this.tags = data.tags ?? null;
|
|
1065
|
+
}
|
|
1066
|
+
get colorHex() {
|
|
1067
|
+
return `#${this.color.toString(16).padStart(6, "0").toUpperCase()}`;
|
|
1068
|
+
}
|
|
1069
|
+
iconURL(options = {}) {
|
|
1070
|
+
if (!this.iconHash)
|
|
1071
|
+
return null;
|
|
1072
|
+
return cdnURL(`/role-icons/${this.id}`, this.iconHash, options);
|
|
1073
|
+
}
|
|
1074
|
+
isEveryone(guildId) {
|
|
1075
|
+
return this.id === guildId;
|
|
262
1076
|
}
|
|
263
1077
|
toString() {
|
|
264
1078
|
return `<@&${this.id}>`;
|
|
@@ -266,15 +1080,225 @@ class Role extends BaseStructure {
|
|
|
266
1080
|
}
|
|
267
1081
|
|
|
268
1082
|
class TextChannel extends Channel {
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
super(data);
|
|
272
|
-
this.parentId = data.parent_id;
|
|
1083
|
+
constructor(data, context) {
|
|
1084
|
+
super(data, context);
|
|
273
1085
|
}
|
|
274
1086
|
toString() {
|
|
275
1087
|
return `<#${this.id}>`;
|
|
276
1088
|
}
|
|
277
1089
|
}
|
|
1090
|
+
|
|
1091
|
+
class Invite {
|
|
1092
|
+
code;
|
|
1093
|
+
guildId;
|
|
1094
|
+
channelId;
|
|
1095
|
+
inviter;
|
|
1096
|
+
uses;
|
|
1097
|
+
maxUses;
|
|
1098
|
+
maxAge;
|
|
1099
|
+
temporary;
|
|
1100
|
+
createdAt;
|
|
1101
|
+
expiresAt;
|
|
1102
|
+
constructor(data) {
|
|
1103
|
+
if (!data.code)
|
|
1104
|
+
throw new TypeError("An invite requires a code.");
|
|
1105
|
+
this.code = data.code;
|
|
1106
|
+
this.guildId = data.guild?.id ?? null;
|
|
1107
|
+
this.channelId = data.channel?.id ?? null;
|
|
1108
|
+
this.inviter = data.inviter ? new User(data.inviter) : null;
|
|
1109
|
+
this.uses = data.uses ?? 0;
|
|
1110
|
+
this.maxUses = data.max_uses ?? 0;
|
|
1111
|
+
this.maxAge = data.max_age ?? 0;
|
|
1112
|
+
this.temporary = data.temporary ?? false;
|
|
1113
|
+
this.createdAt = data.created_at ? new Date(data.created_at) : null;
|
|
1114
|
+
this.expiresAt = data.expires_at ? new Date(data.expires_at) : null;
|
|
1115
|
+
}
|
|
1116
|
+
get url() {
|
|
1117
|
+
return `https://discord.gg/${this.code}`;
|
|
1118
|
+
}
|
|
1119
|
+
toString() {
|
|
1120
|
+
return this.url;
|
|
1121
|
+
}
|
|
1122
|
+
}
|
|
1123
|
+
var WebhookType = {
|
|
1124
|
+
Incoming: 1,
|
|
1125
|
+
ChannelFollower: 2,
|
|
1126
|
+
Application: 3
|
|
1127
|
+
};
|
|
1128
|
+
|
|
1129
|
+
class Webhook extends BaseStructure {
|
|
1130
|
+
type;
|
|
1131
|
+
name;
|
|
1132
|
+
avatarHash;
|
|
1133
|
+
channelId;
|
|
1134
|
+
guildId;
|
|
1135
|
+
applicationId;
|
|
1136
|
+
token;
|
|
1137
|
+
constructor(data) {
|
|
1138
|
+
super(data.id);
|
|
1139
|
+
this.type = data.type ?? WebhookType.Incoming;
|
|
1140
|
+
this.name = data.name ?? null;
|
|
1141
|
+
this.avatarHash = data.avatar ?? null;
|
|
1142
|
+
this.channelId = data.channel_id ?? null;
|
|
1143
|
+
this.guildId = data.guild_id ?? null;
|
|
1144
|
+
this.applicationId = data.application_id ?? null;
|
|
1145
|
+
this.token = data.token ?? null;
|
|
1146
|
+
}
|
|
1147
|
+
avatarURL(options = {}) {
|
|
1148
|
+
if (!this.avatarHash)
|
|
1149
|
+
return null;
|
|
1150
|
+
return cdnURL(`/avatars/${this.id}`, this.avatarHash, options);
|
|
1151
|
+
}
|
|
1152
|
+
get url() {
|
|
1153
|
+
return this.token ? `https://discord.com/api/webhooks/${this.id}/${this.token}` : null;
|
|
1154
|
+
}
|
|
1155
|
+
toString() {
|
|
1156
|
+
return this.url ?? this.id;
|
|
1157
|
+
}
|
|
1158
|
+
}
|
|
1159
|
+
|
|
1160
|
+
class Emoji extends BaseStructure {
|
|
1161
|
+
name;
|
|
1162
|
+
roleIds;
|
|
1163
|
+
user;
|
|
1164
|
+
requireColons;
|
|
1165
|
+
managed;
|
|
1166
|
+
animated;
|
|
1167
|
+
available;
|
|
1168
|
+
constructor(data) {
|
|
1169
|
+
super(data.id ?? "unicode");
|
|
1170
|
+
this.name = data.name;
|
|
1171
|
+
this.roleIds = data.roles ?? [];
|
|
1172
|
+
this.user = data.user ? new User(data.user) : null;
|
|
1173
|
+
this.requireColons = data.require_colons ?? false;
|
|
1174
|
+
this.managed = data.managed ?? false;
|
|
1175
|
+
this.animated = data.animated ?? false;
|
|
1176
|
+
this.available = data.available ?? true;
|
|
1177
|
+
}
|
|
1178
|
+
url(options = {}) {
|
|
1179
|
+
if (!this.id || this.id === "unicode")
|
|
1180
|
+
return null;
|
|
1181
|
+
const ext = options.extension ?? (this.animated ? "gif" : "png");
|
|
1182
|
+
const size = options.size ? `?size=${options.size}` : "";
|
|
1183
|
+
return `${CDN_BASE}/emojis/${this.id}.${ext}${size}`;
|
|
1184
|
+
}
|
|
1185
|
+
toString() {
|
|
1186
|
+
return this.id !== "unicode" ? `<${this.animated ? "a" : ""}:${this.name}:${this.id}>` : this.name ?? "";
|
|
1187
|
+
}
|
|
1188
|
+
}
|
|
1189
|
+
|
|
1190
|
+
class AutoModerationRule extends BaseStructure {
|
|
1191
|
+
guildId;
|
|
1192
|
+
name;
|
|
1193
|
+
creatorId;
|
|
1194
|
+
eventType;
|
|
1195
|
+
triggerType;
|
|
1196
|
+
triggerMetadata;
|
|
1197
|
+
actions;
|
|
1198
|
+
enabled;
|
|
1199
|
+
exemptRoles;
|
|
1200
|
+
exemptChannels;
|
|
1201
|
+
constructor(data) {
|
|
1202
|
+
super(data.id);
|
|
1203
|
+
if (!/^\d{1,20}$/.test(data.guild_id))
|
|
1204
|
+
throw new TypeError("AutoModerationRule guild_id must be a valid snowflake.");
|
|
1205
|
+
this.guildId = data.guild_id;
|
|
1206
|
+
this.name = data.name;
|
|
1207
|
+
this.creatorId = data.creator_id;
|
|
1208
|
+
this.eventType = data.event_type;
|
|
1209
|
+
this.triggerType = data.trigger_type;
|
|
1210
|
+
this.triggerMetadata = data.trigger_metadata;
|
|
1211
|
+
this.actions = data.actions;
|
|
1212
|
+
this.enabled = data.enabled;
|
|
1213
|
+
this.exemptRoles = data.exempt_roles;
|
|
1214
|
+
this.exemptChannels = data.exempt_channels;
|
|
1215
|
+
}
|
|
1216
|
+
toJSON() {
|
|
1217
|
+
return {
|
|
1218
|
+
id: this.id,
|
|
1219
|
+
guildId: this.guildId,
|
|
1220
|
+
name: this.name,
|
|
1221
|
+
creatorId: this.creatorId,
|
|
1222
|
+
eventType: this.eventType,
|
|
1223
|
+
triggerType: this.triggerType,
|
|
1224
|
+
triggerMetadata: this.triggerMetadata,
|
|
1225
|
+
actions: this.actions,
|
|
1226
|
+
enabled: this.enabled,
|
|
1227
|
+
exemptRoles: this.exemptRoles,
|
|
1228
|
+
exemptChannels: this.exemptChannels
|
|
1229
|
+
};
|
|
1230
|
+
}
|
|
1231
|
+
}
|
|
1232
|
+
|
|
1233
|
+
class WelcomeScreenChannel {
|
|
1234
|
+
channelId;
|
|
1235
|
+
description;
|
|
1236
|
+
emojiId;
|
|
1237
|
+
emojiName;
|
|
1238
|
+
constructor(data) {
|
|
1239
|
+
this.channelId = data.channel_id;
|
|
1240
|
+
this.description = data.description;
|
|
1241
|
+
this.emojiId = data.emoji_id;
|
|
1242
|
+
this.emojiName = data.emoji_name;
|
|
1243
|
+
}
|
|
1244
|
+
}
|
|
1245
|
+
|
|
1246
|
+
class GuildWelcomeScreen2 {
|
|
1247
|
+
description;
|
|
1248
|
+
channels;
|
|
1249
|
+
constructor(data) {
|
|
1250
|
+
this.description = data.description;
|
|
1251
|
+
this.channels = data.welcome_channels.map((c) => new WelcomeScreenChannel(c));
|
|
1252
|
+
}
|
|
1253
|
+
}
|
|
1254
|
+
|
|
1255
|
+
class OnboardingPromptOption extends BaseStructure {
|
|
1256
|
+
channelIds;
|
|
1257
|
+
roleIds;
|
|
1258
|
+
emoji;
|
|
1259
|
+
title;
|
|
1260
|
+
description;
|
|
1261
|
+
constructor(data) {
|
|
1262
|
+
super(data.id);
|
|
1263
|
+
this.channelIds = data.channel_ids;
|
|
1264
|
+
this.roleIds = data.role_ids;
|
|
1265
|
+
this.emoji = data.emoji;
|
|
1266
|
+
this.title = data.title;
|
|
1267
|
+
this.description = data.description;
|
|
1268
|
+
}
|
|
1269
|
+
}
|
|
1270
|
+
|
|
1271
|
+
class OnboardingPrompt extends BaseStructure {
|
|
1272
|
+
type;
|
|
1273
|
+
options;
|
|
1274
|
+
title;
|
|
1275
|
+
singleSelect;
|
|
1276
|
+
required;
|
|
1277
|
+
inOnboarding;
|
|
1278
|
+
constructor(data) {
|
|
1279
|
+
super(data.id);
|
|
1280
|
+
this.type = data.type;
|
|
1281
|
+
this.options = data.options.map((o) => new OnboardingPromptOption(o));
|
|
1282
|
+
this.title = data.title;
|
|
1283
|
+
this.singleSelect = data.single_select;
|
|
1284
|
+
this.required = data.required;
|
|
1285
|
+
this.inOnboarding = data.in_onboarding;
|
|
1286
|
+
}
|
|
1287
|
+
}
|
|
1288
|
+
|
|
1289
|
+
class GuildOnboarding2 extends BaseStructure {
|
|
1290
|
+
prompts;
|
|
1291
|
+
defaultChannelIds;
|
|
1292
|
+
enabled;
|
|
1293
|
+
mode;
|
|
1294
|
+
constructor(data) {
|
|
1295
|
+
super(data.guild_id);
|
|
1296
|
+
this.prompts = data.prompts.map((p) => new OnboardingPrompt(p));
|
|
1297
|
+
this.defaultChannelIds = data.default_channel_ids;
|
|
1298
|
+
this.enabled = data.enabled;
|
|
1299
|
+
this.mode = data.mode;
|
|
1300
|
+
}
|
|
1301
|
+
}
|
|
278
1302
|
// packages/structures/src/interactions.ts
|
|
279
1303
|
var InteractionType = {
|
|
280
1304
|
Ping: 1,
|
|
@@ -283,16 +1307,167 @@ var InteractionType = {
|
|
|
283
1307
|
ApplicationCommandAutocomplete: 4,
|
|
284
1308
|
ModalSubmit: 5
|
|
285
1309
|
};
|
|
286
|
-
var
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
1310
|
+
var OptionType = {
|
|
1311
|
+
SubCommand: 1,
|
|
1312
|
+
SubCommandGroup: 2,
|
|
1313
|
+
String: 3,
|
|
1314
|
+
Integer: 4,
|
|
1315
|
+
Boolean: 5,
|
|
1316
|
+
User: 6,
|
|
1317
|
+
Channel: 7,
|
|
1318
|
+
Role: 8,
|
|
1319
|
+
Mentionable: 9,
|
|
1320
|
+
Number: 10,
|
|
1321
|
+
Attachment: 11
|
|
294
1322
|
};
|
|
295
1323
|
|
|
1324
|
+
class CommandOptions {
|
|
1325
|
+
#options;
|
|
1326
|
+
#resolved;
|
|
1327
|
+
constructor(options, resolved = {}) {
|
|
1328
|
+
let currentOptions = options;
|
|
1329
|
+
let group = null;
|
|
1330
|
+
let sub = null;
|
|
1331
|
+
while (currentOptions.length === 1) {
|
|
1332
|
+
const opt = currentOptions[0];
|
|
1333
|
+
if (opt.type === OptionType.SubCommandGroup) {
|
|
1334
|
+
group = opt.name;
|
|
1335
|
+
currentOptions = opt.options ?? [];
|
|
1336
|
+
} else if (opt.type === OptionType.SubCommand) {
|
|
1337
|
+
sub = opt.name;
|
|
1338
|
+
currentOptions = opt.options ?? [];
|
|
1339
|
+
} else {
|
|
1340
|
+
break;
|
|
1341
|
+
}
|
|
1342
|
+
}
|
|
1343
|
+
this.#options = currentOptions;
|
|
1344
|
+
this.#resolved = resolved;
|
|
1345
|
+
this.#subcommandGroup = group;
|
|
1346
|
+
this.#subcommand = sub;
|
|
1347
|
+
}
|
|
1348
|
+
#subcommandGroup;
|
|
1349
|
+
#subcommand;
|
|
1350
|
+
#get(name) {
|
|
1351
|
+
return this.#options.find((o) => o.name.toLowerCase() === name.toLowerCase());
|
|
1352
|
+
}
|
|
1353
|
+
getSubcommand(required = false) {
|
|
1354
|
+
if (!this.#subcommand && required) {
|
|
1355
|
+
throw new TypeError("No subcommand was provided.");
|
|
1356
|
+
}
|
|
1357
|
+
return this.#subcommand;
|
|
1358
|
+
}
|
|
1359
|
+
getSubcommandGroup(required = false) {
|
|
1360
|
+
if (!this.#subcommandGroup && required) {
|
|
1361
|
+
throw new TypeError("No subcommand group was provided.");
|
|
1362
|
+
}
|
|
1363
|
+
return this.#subcommandGroup;
|
|
1364
|
+
}
|
|
1365
|
+
getString(name, required = false) {
|
|
1366
|
+
const opt = this.#get(name);
|
|
1367
|
+
if (!opt || opt.type !== OptionType.String) {
|
|
1368
|
+
if (required)
|
|
1369
|
+
throw new TypeError(`Required option "${name}" (string) is missing.`);
|
|
1370
|
+
return null;
|
|
1371
|
+
}
|
|
1372
|
+
return typeof opt.value === "string" ? opt.value : null;
|
|
1373
|
+
}
|
|
1374
|
+
getInteger(name, required = false) {
|
|
1375
|
+
const opt = this.#get(name);
|
|
1376
|
+
if (!opt || opt.type !== OptionType.Integer) {
|
|
1377
|
+
if (required)
|
|
1378
|
+
throw new TypeError(`Required option "${name}" (integer) is missing.`);
|
|
1379
|
+
return null;
|
|
1380
|
+
}
|
|
1381
|
+
return typeof opt.value === "number" ? Math.trunc(opt.value) : null;
|
|
1382
|
+
}
|
|
1383
|
+
getNumber(name, required = false) {
|
|
1384
|
+
const opt = this.#get(name);
|
|
1385
|
+
if (!opt || opt.type !== OptionType.Number) {
|
|
1386
|
+
if (required)
|
|
1387
|
+
throw new TypeError(`Required option "${name}" (number) is missing.`);
|
|
1388
|
+
return null;
|
|
1389
|
+
}
|
|
1390
|
+
return typeof opt.value === "number" ? opt.value : null;
|
|
1391
|
+
}
|
|
1392
|
+
getBoolean(name, required = false) {
|
|
1393
|
+
const opt = this.#get(name);
|
|
1394
|
+
if (!opt || opt.type !== OptionType.Boolean) {
|
|
1395
|
+
if (required)
|
|
1396
|
+
throw new TypeError(`Required option "${name}" (boolean) is missing.`);
|
|
1397
|
+
return null;
|
|
1398
|
+
}
|
|
1399
|
+
return typeof opt.value === "boolean" ? opt.value : null;
|
|
1400
|
+
}
|
|
1401
|
+
getUser(name, required = false) {
|
|
1402
|
+
const opt = this.#get(name);
|
|
1403
|
+
if (!opt || opt.type !== OptionType.User) {
|
|
1404
|
+
if (required)
|
|
1405
|
+
throw new TypeError(`Required option "${name}" (user) is missing.`);
|
|
1406
|
+
return null;
|
|
1407
|
+
}
|
|
1408
|
+
const userId = String(opt.value);
|
|
1409
|
+
const resolved = this.#resolved?.users?.[userId] ?? null;
|
|
1410
|
+
if (!resolved && required)
|
|
1411
|
+
throw new TypeError(`Resolved user for option "${name}" is missing.`);
|
|
1412
|
+
return resolved;
|
|
1413
|
+
}
|
|
1414
|
+
getChannel(name, required = false) {
|
|
1415
|
+
const opt = this.#get(name);
|
|
1416
|
+
if (!opt || opt.type !== OptionType.Channel) {
|
|
1417
|
+
if (required)
|
|
1418
|
+
throw new TypeError(`Required option "${name}" (channel) is missing.`);
|
|
1419
|
+
return null;
|
|
1420
|
+
}
|
|
1421
|
+
const channelId = String(opt.value);
|
|
1422
|
+
const resolved = this.#resolved?.channels?.[channelId] ?? null;
|
|
1423
|
+
if (!resolved && required)
|
|
1424
|
+
throw new TypeError(`Resolved channel for option "${name}" is missing.`);
|
|
1425
|
+
return resolved;
|
|
1426
|
+
}
|
|
1427
|
+
getRole(name, required = false) {
|
|
1428
|
+
const opt = this.#get(name);
|
|
1429
|
+
if (!opt || opt.type !== OptionType.Role) {
|
|
1430
|
+
if (required)
|
|
1431
|
+
throw new TypeError(`Required option "${name}" (role) is missing.`);
|
|
1432
|
+
return null;
|
|
1433
|
+
}
|
|
1434
|
+
const roleId = String(opt.value);
|
|
1435
|
+
const resolved = this.#resolved?.roles?.[roleId] ?? null;
|
|
1436
|
+
if (!resolved && required)
|
|
1437
|
+
throw new TypeError(`Resolved role for option "${name}" is missing.`);
|
|
1438
|
+
return resolved;
|
|
1439
|
+
}
|
|
1440
|
+
getMentionable(name, required = false) {
|
|
1441
|
+
const opt = this.#get(name);
|
|
1442
|
+
if (!opt || opt.type !== OptionType.Mentionable) {
|
|
1443
|
+
if (required)
|
|
1444
|
+
throw new TypeError(`Required option "${name}" (mentionable) is missing.`);
|
|
1445
|
+
return null;
|
|
1446
|
+
}
|
|
1447
|
+
const id = String(opt.value);
|
|
1448
|
+
const resolved = this.#resolved?.users?.[id] ?? this.#resolved?.roles?.[id] ?? null;
|
|
1449
|
+
if (!resolved && required)
|
|
1450
|
+
throw new TypeError(`Resolved mentionable for option "${name}" is missing.`);
|
|
1451
|
+
return resolved;
|
|
1452
|
+
}
|
|
1453
|
+
getAttachment(name, required = false) {
|
|
1454
|
+
const opt = this.#get(name);
|
|
1455
|
+
if (!opt || opt.type !== OptionType.Attachment) {
|
|
1456
|
+
if (required)
|
|
1457
|
+
throw new TypeError(`Required option "${name}" (attachment) is missing.`);
|
|
1458
|
+
return null;
|
|
1459
|
+
}
|
|
1460
|
+
const attachmentId = String(opt.value);
|
|
1461
|
+
const resolved = this.#resolved?.attachments?.[attachmentId] ?? null;
|
|
1462
|
+
if (!resolved && required)
|
|
1463
|
+
throw new TypeError(`Resolved attachment for option "${name}" is missing.`);
|
|
1464
|
+
return resolved;
|
|
1465
|
+
}
|
|
1466
|
+
get raw() {
|
|
1467
|
+
return this.#options;
|
|
1468
|
+
}
|
|
1469
|
+
}
|
|
1470
|
+
|
|
296
1471
|
class InteractionResponse {
|
|
297
1472
|
type;
|
|
298
1473
|
data;
|
|
@@ -320,7 +1495,7 @@ class InteractionResponse {
|
|
|
320
1495
|
}
|
|
321
1496
|
}
|
|
322
1497
|
|
|
323
|
-
class
|
|
1498
|
+
class Interaction2 {
|
|
324
1499
|
id;
|
|
325
1500
|
applicationId;
|
|
326
1501
|
token;
|
|
@@ -405,13 +1580,20 @@ class Interaction {
|
|
|
405
1580
|
}
|
|
406
1581
|
}
|
|
407
1582
|
|
|
408
|
-
class CommandInteraction extends
|
|
1583
|
+
class CommandInteraction extends Interaction2 {
|
|
1584
|
+
options;
|
|
409
1585
|
get commandName() {
|
|
410
1586
|
return typeof this.data.data?.name === "string" ? this.data.data.name : "";
|
|
411
1587
|
}
|
|
1588
|
+
constructor(client, data) {
|
|
1589
|
+
super(client, data);
|
|
1590
|
+
const rawOptions = data.data?.options ?? [];
|
|
1591
|
+
const resolved = data.data?.resolved ?? {};
|
|
1592
|
+
this.options = new CommandOptions(rawOptions, resolved);
|
|
1593
|
+
}
|
|
412
1594
|
}
|
|
413
1595
|
|
|
414
|
-
class ComponentInteraction extends
|
|
1596
|
+
class ComponentInteraction extends Interaction2 {
|
|
415
1597
|
get customId() {
|
|
416
1598
|
return this.data?.data?.custom_id ?? "";
|
|
417
1599
|
}
|
|
@@ -434,20 +1616,8 @@ class ComponentInteraction extends Interaction {
|
|
|
434
1616
|
return result;
|
|
435
1617
|
}
|
|
436
1618
|
}
|
|
437
|
-
function createInteraction(client, data) {
|
|
438
|
-
switch (data.type) {
|
|
439
|
-
case InteractionType.ApplicationCommand:
|
|
440
|
-
case InteractionType.ApplicationCommandAutocomplete:
|
|
441
|
-
return new CommandInteraction(client, data);
|
|
442
|
-
case InteractionType.MessageComponent:
|
|
443
|
-
case InteractionType.ModalSubmit:
|
|
444
|
-
return new ComponentInteraction(client, data);
|
|
445
|
-
default:
|
|
446
|
-
return new Interaction(client, data);
|
|
447
|
-
}
|
|
448
|
-
}
|
|
449
1619
|
|
|
450
|
-
class ModalSubmitInteraction extends
|
|
1620
|
+
class ModalSubmitInteraction extends Interaction2 {
|
|
451
1621
|
get customId() {
|
|
452
1622
|
return this.data?.data?.custom_id ?? "";
|
|
453
1623
|
}
|
|
@@ -461,23 +1631,226 @@ class ModalSubmitInteraction extends Interaction {
|
|
|
461
1631
|
}
|
|
462
1632
|
return;
|
|
463
1633
|
}
|
|
1634
|
+
getRequiredInputValue(customId) {
|
|
1635
|
+
const value = this.getInputValue(customId);
|
|
1636
|
+
if (value === undefined)
|
|
1637
|
+
throw new TypeError(`Modal input "${customId}" was not found in the submission.`);
|
|
1638
|
+
return value;
|
|
1639
|
+
}
|
|
464
1640
|
}
|
|
465
1641
|
|
|
466
|
-
class AutocompleteInteraction extends
|
|
1642
|
+
class AutocompleteInteraction extends Interaction2 {
|
|
467
1643
|
get commandName() {
|
|
468
1644
|
return this.data?.data?.name ?? "";
|
|
469
1645
|
}
|
|
470
1646
|
get focusedOption() {
|
|
471
1647
|
const options = this.data?.data?.options ?? [];
|
|
472
|
-
return options
|
|
1648
|
+
return findFocused(options);
|
|
473
1649
|
}
|
|
474
1650
|
async respond(choices) {
|
|
1651
|
+
if (!Array.isArray(choices))
|
|
1652
|
+
throw new TypeError("Autocomplete choices must be an array.");
|
|
475
1653
|
const response = new InteractionResponse(InteractionResponseType.Autocomplete, { choices });
|
|
476
1654
|
await this.postResponse(response);
|
|
1655
|
+
this.replied = true;
|
|
1656
|
+
}
|
|
1657
|
+
}
|
|
1658
|
+
function findFocused(options) {
|
|
1659
|
+
for (const opt of options) {
|
|
1660
|
+
if (opt.focused)
|
|
1661
|
+
return { name: opt.name, value: opt.value, type: opt.type };
|
|
1662
|
+
if (Array.isArray(opt.options)) {
|
|
1663
|
+
const found = findFocused(opt.options);
|
|
1664
|
+
if (found)
|
|
1665
|
+
return found;
|
|
1666
|
+
}
|
|
1667
|
+
}
|
|
1668
|
+
return;
|
|
1669
|
+
}
|
|
1670
|
+
function createInteraction(client, data) {
|
|
1671
|
+
switch (data.type) {
|
|
1672
|
+
case InteractionType.ApplicationCommand:
|
|
1673
|
+
return new CommandInteraction(client, data);
|
|
1674
|
+
case InteractionType.ApplicationCommandAutocomplete:
|
|
1675
|
+
return new AutocompleteInteraction(client, data);
|
|
1676
|
+
case InteractionType.MessageComponent:
|
|
1677
|
+
return new ComponentInteraction(client, data);
|
|
1678
|
+
case InteractionType.ModalSubmit:
|
|
1679
|
+
return new ModalSubmitInteraction(client, data);
|
|
1680
|
+
default:
|
|
1681
|
+
return new Interaction2(client, data);
|
|
1682
|
+
}
|
|
1683
|
+
}
|
|
1684
|
+
// packages/structures/src/embed.ts
|
|
1685
|
+
class Embed {
|
|
1686
|
+
#data;
|
|
1687
|
+
constructor(data = {}) {
|
|
1688
|
+
this.#data = { ...data };
|
|
1689
|
+
if (this.#data.fields)
|
|
1690
|
+
this.#data.fields = [...this.#data.fields];
|
|
1691
|
+
}
|
|
1692
|
+
get title() {
|
|
1693
|
+
return this.#data.title;
|
|
1694
|
+
}
|
|
1695
|
+
get description() {
|
|
1696
|
+
return this.#data.description;
|
|
1697
|
+
}
|
|
1698
|
+
get url() {
|
|
1699
|
+
return this.#data.url;
|
|
1700
|
+
}
|
|
1701
|
+
get color() {
|
|
1702
|
+
return this.#data.color;
|
|
1703
|
+
}
|
|
1704
|
+
get timestamp() {
|
|
1705
|
+
return this.#data.timestamp;
|
|
1706
|
+
}
|
|
1707
|
+
get createdAt() {
|
|
1708
|
+
return this.#data.timestamp ? new Date(this.#data.timestamp) : undefined;
|
|
1709
|
+
}
|
|
1710
|
+
get footer() {
|
|
1711
|
+
return this.#data.footer;
|
|
1712
|
+
}
|
|
1713
|
+
get image() {
|
|
1714
|
+
return this.#data.image;
|
|
1715
|
+
}
|
|
1716
|
+
get thumbnail() {
|
|
1717
|
+
return this.#data.thumbnail;
|
|
1718
|
+
}
|
|
1719
|
+
get video() {
|
|
1720
|
+
return this.#data.video;
|
|
1721
|
+
}
|
|
1722
|
+
get author() {
|
|
1723
|
+
return this.#data.author;
|
|
1724
|
+
}
|
|
1725
|
+
get fields() {
|
|
1726
|
+
return this.#data.fields ?? [];
|
|
1727
|
+
}
|
|
1728
|
+
setTitle(title) {
|
|
1729
|
+
if (title.length > 256)
|
|
1730
|
+
throw new TypeError("Embed title must not exceed 256 characters.");
|
|
1731
|
+
this.#data.title = title;
|
|
1732
|
+
return this;
|
|
1733
|
+
}
|
|
1734
|
+
setDescription(description) {
|
|
1735
|
+
if (description.length > 4096)
|
|
1736
|
+
throw new TypeError("Embed description must not exceed 4096 characters.");
|
|
1737
|
+
this.#data.description = description;
|
|
1738
|
+
return this;
|
|
1739
|
+
}
|
|
1740
|
+
setURL(url) {
|
|
1741
|
+
this.#data.url = url;
|
|
1742
|
+
return this;
|
|
1743
|
+
}
|
|
1744
|
+
setColor(color) {
|
|
1745
|
+
if (typeof color === "string") {
|
|
1746
|
+
const hex = color.replace(/^#/, "");
|
|
1747
|
+
this.#data.color = parseInt(hex, 16);
|
|
1748
|
+
} else {
|
|
1749
|
+
this.#data.color = color;
|
|
1750
|
+
}
|
|
1751
|
+
return this;
|
|
1752
|
+
}
|
|
1753
|
+
setTimestamp(timestamp = Date.now()) {
|
|
1754
|
+
this.#data.timestamp = new Date(timestamp).toISOString();
|
|
1755
|
+
return this;
|
|
1756
|
+
}
|
|
1757
|
+
setFooter(text, iconURL) {
|
|
1758
|
+
if (text.length > 2048)
|
|
1759
|
+
throw new TypeError("Embed footer text must not exceed 2048 characters.");
|
|
1760
|
+
this.#data.footer = iconURL ? { text, icon_url: iconURL } : { text };
|
|
1761
|
+
return this;
|
|
1762
|
+
}
|
|
1763
|
+
setImage(url) {
|
|
1764
|
+
this.#data.image = { url };
|
|
1765
|
+
return this;
|
|
1766
|
+
}
|
|
1767
|
+
setThumbnail(url) {
|
|
1768
|
+
this.#data.thumbnail = { url };
|
|
1769
|
+
return this;
|
|
1770
|
+
}
|
|
1771
|
+
setAuthor(name, options = {}) {
|
|
1772
|
+
if (name.length > 256)
|
|
1773
|
+
throw new TypeError("Embed author name must not exceed 256 characters.");
|
|
1774
|
+
this.#data.author = {
|
|
1775
|
+
name,
|
|
1776
|
+
url: options.url,
|
|
1777
|
+
icon_url: options.iconURL
|
|
1778
|
+
};
|
|
1779
|
+
return this;
|
|
1780
|
+
}
|
|
1781
|
+
addFields(...fields) {
|
|
1782
|
+
const existing = this.#data.fields ?? [];
|
|
1783
|
+
if (existing.length + fields.length > 25)
|
|
1784
|
+
throw new TypeError("Embeds cannot have more than 25 fields.");
|
|
1785
|
+
for (const field of fields) {
|
|
1786
|
+
if (field.name.length > 256)
|
|
1787
|
+
throw new TypeError("Embed field name must not exceed 256 characters.");
|
|
1788
|
+
if (field.value.length > 1024)
|
|
1789
|
+
throw new TypeError("Embed field value must not exceed 1024 characters.");
|
|
1790
|
+
}
|
|
1791
|
+
this.#data.fields = [...existing, ...fields];
|
|
1792
|
+
return this;
|
|
1793
|
+
}
|
|
1794
|
+
clearFields() {
|
|
1795
|
+
this.#data.fields = [];
|
|
1796
|
+
return this;
|
|
1797
|
+
}
|
|
1798
|
+
spliceFields(index, deleteCount, ...fields) {
|
|
1799
|
+
const next = [...this.#data.fields ?? []];
|
|
1800
|
+
next.splice(index, deleteCount, ...fields);
|
|
1801
|
+
if (next.length > 25)
|
|
1802
|
+
throw new TypeError("Embeds cannot have more than 25 fields.");
|
|
1803
|
+
for (const field of fields) {
|
|
1804
|
+
if (field.name.length > 256)
|
|
1805
|
+
throw new TypeError("Embed field name must not exceed 256 characters.");
|
|
1806
|
+
if (field.value.length > 1024)
|
|
1807
|
+
throw new TypeError("Embed field value must not exceed 1024 characters.");
|
|
1808
|
+
}
|
|
1809
|
+
this.#data.fields = next;
|
|
1810
|
+
return this;
|
|
1811
|
+
}
|
|
1812
|
+
toJSON() {
|
|
1813
|
+
const json = { ...this.#data };
|
|
1814
|
+
if (json.fields)
|
|
1815
|
+
json.fields = [...json.fields];
|
|
1816
|
+
return json;
|
|
1817
|
+
}
|
|
1818
|
+
static from(data) {
|
|
1819
|
+
return new Embed(data);
|
|
1820
|
+
}
|
|
1821
|
+
}
|
|
1822
|
+
// packages/structures/src/audit-log.ts
|
|
1823
|
+
class AuditLogEntry extends BaseStructure {
|
|
1824
|
+
targetId;
|
|
1825
|
+
userId;
|
|
1826
|
+
actionType;
|
|
1827
|
+
changes;
|
|
1828
|
+
options;
|
|
1829
|
+
reason;
|
|
1830
|
+
constructor(data) {
|
|
1831
|
+
super(data.id);
|
|
1832
|
+
this.targetId = data.target_id;
|
|
1833
|
+
this.userId = data.user_id;
|
|
1834
|
+
this.actionType = data.action_type;
|
|
1835
|
+
this.changes = data.changes ?? [];
|
|
1836
|
+
this.options = data.options ?? null;
|
|
1837
|
+
this.reason = data.reason ?? null;
|
|
1838
|
+
}
|
|
1839
|
+
}
|
|
1840
|
+
|
|
1841
|
+
class AuditLog {
|
|
1842
|
+
entries;
|
|
1843
|
+
constructor(data) {
|
|
1844
|
+
this.entries = new Map;
|
|
1845
|
+
for (const entryData of data.audit_log_entries) {
|
|
1846
|
+
this.entries.set(entryData.id, new AuditLogEntry(entryData));
|
|
1847
|
+
}
|
|
477
1848
|
}
|
|
478
1849
|
}
|
|
479
1850
|
|
|
480
1851
|
// packages/structures/src/index.ts
|
|
1852
|
+
var NON_SYSTEM_MESSAGE_TYPES = new Set([0, 19, 20, 23]);
|
|
1853
|
+
|
|
481
1854
|
class Message extends BaseStructure {
|
|
482
1855
|
content;
|
|
483
1856
|
author;
|
|
@@ -485,7 +1858,7 @@ class Message extends BaseStructure {
|
|
|
485
1858
|
channel;
|
|
486
1859
|
guildId;
|
|
487
1860
|
flags;
|
|
488
|
-
|
|
1861
|
+
timestamp;
|
|
489
1862
|
attachments;
|
|
490
1863
|
embeds;
|
|
491
1864
|
mentions;
|
|
@@ -494,6 +1867,7 @@ class Message extends BaseStructure {
|
|
|
494
1867
|
mentionEveryone;
|
|
495
1868
|
type;
|
|
496
1869
|
reference;
|
|
1870
|
+
components;
|
|
497
1871
|
referencedMessage;
|
|
498
1872
|
#context;
|
|
499
1873
|
constructor(data, context) {
|
|
@@ -505,9 +1879,10 @@ class Message extends BaseStructure {
|
|
|
505
1879
|
this.channelId = data.channel_id;
|
|
506
1880
|
this.guildId = data.guild_id;
|
|
507
1881
|
this.flags = data.flags ?? 0;
|
|
508
|
-
this.
|
|
1882
|
+
this.timestamp = new Date(data.timestamp ?? Number((BigInt(this.id) >> 22n) + 1420070400000n));
|
|
509
1883
|
this.attachments = data.attachments ?? [];
|
|
510
1884
|
this.embeds = data.embeds ?? [];
|
|
1885
|
+
this.components = data.components ?? [];
|
|
511
1886
|
this.mentions = (data.mentions ?? []).map((user) => new User(user));
|
|
512
1887
|
this.mentionRoles = data.mention_roles ?? [];
|
|
513
1888
|
this.pinned = data.pinned ?? false;
|
|
@@ -521,21 +1896,25 @@ class Message extends BaseStructure {
|
|
|
521
1896
|
get embedsSuppressed() {
|
|
522
1897
|
return (this.flags & 4) !== 0;
|
|
523
1898
|
}
|
|
1899
|
+
get createdTimestamp() {
|
|
1900
|
+
return this.timestamp.getTime();
|
|
1901
|
+
}
|
|
1902
|
+
get createdAt() {
|
|
1903
|
+
return this.timestamp;
|
|
1904
|
+
}
|
|
524
1905
|
edit(options) {
|
|
525
1906
|
if (!this.#context)
|
|
526
1907
|
throw new Error("This message is not attached to a client.");
|
|
527
1908
|
return this.#context.editMessage(this.channelId, this.id, options);
|
|
528
1909
|
}
|
|
1910
|
+
update(options) {
|
|
1911
|
+
return this.edit(options);
|
|
1912
|
+
}
|
|
529
1913
|
delete() {
|
|
530
1914
|
if (!this.#context)
|
|
531
1915
|
throw new Error("This message is not attached to a client.");
|
|
532
1916
|
return this.#context.deleteMessage(this.channelId, this.id);
|
|
533
1917
|
}
|
|
534
|
-
crosspost() {
|
|
535
|
-
if (!this.#context)
|
|
536
|
-
throw new Error("This message is not attached to a client.");
|
|
537
|
-
return this.#context.crosspostMessage(this.channelId, this.id);
|
|
538
|
-
}
|
|
539
1918
|
reply(options) {
|
|
540
1919
|
if (!this.#context)
|
|
541
1920
|
throw new Error("This message is not attached to a client.");
|
|
@@ -547,25 +1926,115 @@ class Message extends BaseStructure {
|
|
|
547
1926
|
};
|
|
548
1927
|
return this.#context.sendMessage(this.channelId, payload);
|
|
549
1928
|
}
|
|
1929
|
+
crosspost() {
|
|
1930
|
+
if (!this.#context)
|
|
1931
|
+
throw new Error("This message is not attached to a client.");
|
|
1932
|
+
return this.#context.crosspostMessage(this.channelId, this.id);
|
|
1933
|
+
}
|
|
1934
|
+
react(emoji) {
|
|
1935
|
+
if (!this.#context?.addReaction)
|
|
1936
|
+
throw new Error("This message is not attached to a client.");
|
|
1937
|
+
return this.#context.addReaction(this.channelId, this.id, emoji);
|
|
1938
|
+
}
|
|
1939
|
+
removeReaction(emoji, userId) {
|
|
1940
|
+
if (!this.#context)
|
|
1941
|
+
throw new Error("This message is not attached to a client.");
|
|
1942
|
+
return userId ? this.#context.removeReaction?.(this.channelId, this.id, emoji, userId) ?? Promise.reject(new Error("Reaction operations are unavailable.")) : this.#context.removeOwnReaction?.(this.channelId, this.id, emoji) ?? Promise.reject(new Error("Reaction operations are unavailable."));
|
|
1943
|
+
}
|
|
1944
|
+
removeAllReactions() {
|
|
1945
|
+
if (!this.#context?.removeAllReactions)
|
|
1946
|
+
throw new Error("This message is not attached to a client.");
|
|
1947
|
+
return this.#context.removeAllReactions(this.channelId, this.id);
|
|
1948
|
+
}
|
|
1949
|
+
pin() {
|
|
1950
|
+
if (!this.#context?.pinMessage)
|
|
1951
|
+
throw new Error("This message is not attached to a client.");
|
|
1952
|
+
return this.#context.pinMessage(this.channelId, this.id);
|
|
1953
|
+
}
|
|
1954
|
+
unpin() {
|
|
1955
|
+
if (!this.#context?.unpinMessage)
|
|
1956
|
+
throw new Error("This message is not attached to a client.");
|
|
1957
|
+
return this.#context.unpinMessage(this.channelId, this.id);
|
|
1958
|
+
}
|
|
1959
|
+
get isEphemeral() {
|
|
1960
|
+
return (this.flags & 64) !== 0;
|
|
1961
|
+
}
|
|
1962
|
+
get isPinned() {
|
|
1963
|
+
return this.pinned;
|
|
1964
|
+
}
|
|
1965
|
+
get isSystemMessage() {
|
|
1966
|
+
return !NON_SYSTEM_MESSAGE_TYPES.has(this.type);
|
|
1967
|
+
}
|
|
1968
|
+
get isCrosspost() {
|
|
1969
|
+
return (this.flags & 2) !== 0;
|
|
1970
|
+
}
|
|
1971
|
+
get hasAttachments() {
|
|
1972
|
+
return this.attachments.length > 0;
|
|
1973
|
+
}
|
|
1974
|
+
get hasEmbeds() {
|
|
1975
|
+
return this.embeds.length > 0;
|
|
1976
|
+
}
|
|
1977
|
+
get hasComponents() {
|
|
1978
|
+
return this.components.length > 0;
|
|
1979
|
+
}
|
|
1980
|
+
suppressEmbeds() {
|
|
1981
|
+
return this.edit({ flags: this.flags | 4 });
|
|
1982
|
+
}
|
|
1983
|
+
toJSON() {
|
|
1984
|
+
return {
|
|
1985
|
+
id: this.id,
|
|
1986
|
+
content: this.content,
|
|
1987
|
+
channelId: this.channelId,
|
|
1988
|
+
guildId: this.guildId,
|
|
1989
|
+
flags: this.flags,
|
|
1990
|
+
pinned: this.pinned,
|
|
1991
|
+
mentionEveryone: this.mentionEveryone,
|
|
1992
|
+
type: this.type,
|
|
1993
|
+
timestamp: this.timestamp.toISOString(),
|
|
1994
|
+
author: { id: this.author.id, username: this.author.username },
|
|
1995
|
+
attachments: [...this.attachments],
|
|
1996
|
+
embeds: [...this.embeds],
|
|
1997
|
+
components: [...this.components],
|
|
1998
|
+
mentions: this.mentions.map((u) => u.id),
|
|
1999
|
+
mentionRoles: [...this.mentionRoles],
|
|
2000
|
+
reference: this.reference,
|
|
2001
|
+
referencedMessage: this.referencedMessage ? this.referencedMessage.id : this.referencedMessage
|
|
2002
|
+
};
|
|
2003
|
+
}
|
|
550
2004
|
}
|
|
551
2005
|
export {
|
|
2006
|
+
AuditLog,
|
|
2007
|
+
AuditLogEntry,
|
|
2008
|
+
AutoModerationRule,
|
|
552
2009
|
AutocompleteInteraction,
|
|
553
2010
|
BaseStructure,
|
|
554
2011
|
Channel,
|
|
555
2012
|
CommandInteraction,
|
|
2013
|
+
CommandOptions,
|
|
556
2014
|
ComponentInteraction,
|
|
2015
|
+
Embed,
|
|
2016
|
+
Emoji,
|
|
557
2017
|
Guild,
|
|
558
2018
|
GuildMember,
|
|
559
|
-
|
|
2019
|
+
GuildOnboarding2 as GuildOnboarding,
|
|
2020
|
+
GuildWelcomeScreen2 as GuildWelcomeScreen,
|
|
2021
|
+
Interaction2 as Interaction,
|
|
560
2022
|
InteractionResponse,
|
|
561
2023
|
InteractionResponseType,
|
|
562
2024
|
InteractionType,
|
|
2025
|
+
Invite,
|
|
563
2026
|
Message,
|
|
564
2027
|
ModalSubmitInteraction,
|
|
2028
|
+
OnboardingPrompt,
|
|
2029
|
+
OnboardingPromptOption,
|
|
2030
|
+
PermissionsBitField,
|
|
565
2031
|
Role,
|
|
566
2032
|
TextChannel,
|
|
567
2033
|
User,
|
|
2034
|
+
Webhook,
|
|
2035
|
+
WebhookType,
|
|
2036
|
+
WelcomeScreenChannel,
|
|
568
2037
|
createInteraction
|
|
569
2038
|
};
|
|
570
2039
|
|
|
571
|
-
//# debugId=
|
|
2040
|
+
//# debugId=889BE16B7674B4BA64756E2164756E21
|