bakit 3.1.0 → 3.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +542 -189
- package/dist/index.d.cts +560 -135
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +560 -135
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +535 -190
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -129,6 +129,188 @@ var User = class extends BaseStructure {
|
|
|
129
129
|
}
|
|
130
130
|
};
|
|
131
131
|
|
|
132
|
+
//#endregion
|
|
133
|
+
//#region src/lib/structures/Message.ts
|
|
134
|
+
var Message = class extends BaseStructure {
|
|
135
|
+
#cachedAuthor;
|
|
136
|
+
constructor(client, data) {
|
|
137
|
+
super(client);
|
|
138
|
+
this.data = data;
|
|
139
|
+
this.#ensureChannelCache();
|
|
140
|
+
}
|
|
141
|
+
get partial() {
|
|
142
|
+
return typeof this.data.content !== "string" || typeof this.data.author !== "object" || this.channel === void 0;
|
|
143
|
+
}
|
|
144
|
+
get content() {
|
|
145
|
+
return this.data.content;
|
|
146
|
+
}
|
|
147
|
+
get id() {
|
|
148
|
+
return this.data.id;
|
|
149
|
+
}
|
|
150
|
+
get channelId() {
|
|
151
|
+
return this.data.channel_id;
|
|
152
|
+
}
|
|
153
|
+
get channel() {
|
|
154
|
+
return this.#ensureChannelCache();
|
|
155
|
+
}
|
|
156
|
+
get guildId() {
|
|
157
|
+
return "guild_id" in this.data ? this.data.guild_id : void 0;
|
|
158
|
+
}
|
|
159
|
+
get guild() {
|
|
160
|
+
return this.guildId ? this.client.cache.guilds.get(this.guildId) : void 0;
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* The author of this message.
|
|
164
|
+
*
|
|
165
|
+
* **Note:** This property returns the cached `User` synchronously.
|
|
166
|
+
* It may be stale if the users cache has short lifetime or uses an asynchronous remote store.
|
|
167
|
+
* To ensure the author is up-to-date, use the `fetchAuthor()` method instead.
|
|
168
|
+
*/
|
|
169
|
+
get author() {
|
|
170
|
+
let author = this.#cachedAuthor;
|
|
171
|
+
if (!author && this.client.cache.isModuleEnabled("users")) author = this.client.cache.resolveLocal(this.client.cache.users.local, this.data.author.id, () => new User(this.client, this.data.author), (user) => user._patch(this.data.author));
|
|
172
|
+
if (!author) author = new User(this.client, this.data.author);
|
|
173
|
+
this.#cachedAuthor = author;
|
|
174
|
+
return this.#cachedAuthor;
|
|
175
|
+
}
|
|
176
|
+
get createdAt() {
|
|
177
|
+
return new Date(this.data.timestamp);
|
|
178
|
+
}
|
|
179
|
+
get editedAt() {
|
|
180
|
+
return this.data.edited_timestamp ? new Date(this.data.edited_timestamp) : void 0;
|
|
181
|
+
}
|
|
182
|
+
get createdTimestamp() {
|
|
183
|
+
return this.createdAt.getTime();
|
|
184
|
+
}
|
|
185
|
+
get editedTimestamp() {
|
|
186
|
+
return this.editedAt?.getTime();
|
|
187
|
+
}
|
|
188
|
+
get url() {
|
|
189
|
+
return `https://discord.com/channels/${this.guildId ?? "@me"}/${this.channelId}/${this.id}`;
|
|
190
|
+
}
|
|
191
|
+
inGuild() {
|
|
192
|
+
return this.guild !== void 0;
|
|
193
|
+
}
|
|
194
|
+
async fetch() {
|
|
195
|
+
const message = await this.client.helper.fetchMessage(this.channelId, this.id);
|
|
196
|
+
this.data = message.data;
|
|
197
|
+
this.#cachedAuthor = await this.client.cache.resolve(this.client.cache.users, message.data.author.id, () => new User(this.client, message.data.author));
|
|
198
|
+
return this;
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* Fetches the author of this message from cache or Discord API.
|
|
202
|
+
*
|
|
203
|
+
* **Note:** It is recommended to use this method instead of the `author` property
|
|
204
|
+
* if the users cache has short lifetime or is backed by an asynchronous remote cache.
|
|
205
|
+
*
|
|
206
|
+
* @param force - Whether to bypass the cache and force a request to the API.
|
|
207
|
+
* @returns A promise that resolves to the `User` who authored this message.
|
|
208
|
+
*/
|
|
209
|
+
async fetchAuthor(force = false) {
|
|
210
|
+
if (!force && this.client.cache.isModuleEnabled("users")) return this.client.cache.resolve(this.client.cache.users, this.data.author.id, () => new User(this.client, this.data.author), (user) => user._patch(this.data.author));
|
|
211
|
+
return this.client.helper.fetchUser(this.data.author.id, force);
|
|
212
|
+
}
|
|
213
|
+
async reply(options) {
|
|
214
|
+
return this.client.channels.replyMessage(this.channelId, this.id, options);
|
|
215
|
+
}
|
|
216
|
+
async edit(options) {
|
|
217
|
+
return this.client.channels.editMessage(this.channelId, this.id, options);
|
|
218
|
+
}
|
|
219
|
+
async _patch(data) {
|
|
220
|
+
this.data = {
|
|
221
|
+
...this.data,
|
|
222
|
+
...data
|
|
223
|
+
};
|
|
224
|
+
if (data.author && this.client.cache.isModuleEnabled("users")) if (this.client.cache.isModuleEnabled("users")) this.#cachedAuthor = await this.client.cache.resolve(this.client.cache.users, data.author.id, () => new User(this.client, data.author));
|
|
225
|
+
else this.#cachedAuthor?._patch(data.author);
|
|
226
|
+
}
|
|
227
|
+
#ensureChannelCache() {
|
|
228
|
+
const { client } = this;
|
|
229
|
+
let channel = client.cache.channels.get(this.channelId) ?? this.guild?.channels.get(this.channelId);
|
|
230
|
+
if (!channel) {
|
|
231
|
+
if (this.guildId) channel = this.client.channels.resolve({
|
|
232
|
+
id: this.channelId,
|
|
233
|
+
type: ChannelType.GuildText
|
|
234
|
+
});
|
|
235
|
+
else channel = this.client.channels.resolve({
|
|
236
|
+
id: this.channelId,
|
|
237
|
+
type: ChannelType.DM,
|
|
238
|
+
name: null,
|
|
239
|
+
recipients: [this.data.author]
|
|
240
|
+
});
|
|
241
|
+
if (!channel) throw new Error("Channel not found");
|
|
242
|
+
client.cache.channels.set(this.channelId, channel);
|
|
243
|
+
}
|
|
244
|
+
return channel;
|
|
245
|
+
}
|
|
246
|
+
toJSON() {
|
|
247
|
+
return this.data;
|
|
248
|
+
}
|
|
249
|
+
toString() {
|
|
250
|
+
return this.data.content;
|
|
251
|
+
}
|
|
252
|
+
};
|
|
253
|
+
|
|
254
|
+
//#endregion
|
|
255
|
+
//#region src/lib/structures/Typing.ts
|
|
256
|
+
var Typing = class extends BaseStructure {
|
|
257
|
+
constructor(client, data) {
|
|
258
|
+
super(client);
|
|
259
|
+
this.data = data;
|
|
260
|
+
}
|
|
261
|
+
get channelId() {
|
|
262
|
+
return this.data.channel_id;
|
|
263
|
+
}
|
|
264
|
+
get guildId() {
|
|
265
|
+
return this.data.guild_id;
|
|
266
|
+
}
|
|
267
|
+
get userId() {
|
|
268
|
+
return this.data.user_id;
|
|
269
|
+
}
|
|
270
|
+
get timestamp() {
|
|
271
|
+
return this.data.timestamp;
|
|
272
|
+
}
|
|
273
|
+
get member() {
|
|
274
|
+
return this.data.member;
|
|
275
|
+
}
|
|
276
|
+
get channel() {
|
|
277
|
+
return this.guild?.channels.get(this.channelId) ?? this.client.cache.channels.get(this.channelId);
|
|
278
|
+
}
|
|
279
|
+
get guild() {
|
|
280
|
+
if (this.data.guild_id) return this.client.cache.guilds.get(this.data.guild_id);
|
|
281
|
+
}
|
|
282
|
+
};
|
|
283
|
+
|
|
284
|
+
//#endregion
|
|
285
|
+
//#region src/lib/structures/Tag.ts
|
|
286
|
+
var Tag = class extends BaseStructure {
|
|
287
|
+
constructor(client, data) {
|
|
288
|
+
super(client);
|
|
289
|
+
this.data = data;
|
|
290
|
+
}
|
|
291
|
+
get id() {
|
|
292
|
+
return this.data.id;
|
|
293
|
+
}
|
|
294
|
+
get name() {
|
|
295
|
+
return this.data.name;
|
|
296
|
+
}
|
|
297
|
+
get moderated() {
|
|
298
|
+
return this.data.moderated ?? false;
|
|
299
|
+
}
|
|
300
|
+
get emojiId() {
|
|
301
|
+
return this.data.emoji_id ?? void 0;
|
|
302
|
+
}
|
|
303
|
+
get emojiName() {
|
|
304
|
+
return this.data.emoji_name ?? void 0;
|
|
305
|
+
}
|
|
306
|
+
_patch(data) {
|
|
307
|
+
this.data = {
|
|
308
|
+
...this.data,
|
|
309
|
+
...data
|
|
310
|
+
};
|
|
311
|
+
}
|
|
312
|
+
};
|
|
313
|
+
|
|
132
314
|
//#endregion
|
|
133
315
|
//#region src/lib/structures/channel/BaseChannel.ts
|
|
134
316
|
var BaseChannel = class extends BaseStructure {
|
|
@@ -136,6 +318,9 @@ var BaseChannel = class extends BaseStructure {
|
|
|
136
318
|
super(client);
|
|
137
319
|
this.data = data;
|
|
138
320
|
}
|
|
321
|
+
get partial() {
|
|
322
|
+
return Object.keys(this.data).length <= 2;
|
|
323
|
+
}
|
|
139
324
|
get id() {
|
|
140
325
|
return this.data.id;
|
|
141
326
|
}
|
|
@@ -157,11 +342,28 @@ var BaseChannel = class extends BaseStructure {
|
|
|
157
342
|
isDM() {
|
|
158
343
|
return this.type === ChannelType.DM;
|
|
159
344
|
}
|
|
345
|
+
isThread() {
|
|
346
|
+
return this.type === ChannelType.AnnouncementThread || this.type === ChannelType.PublicThread || this.type === ChannelType.PrivateThread;
|
|
347
|
+
}
|
|
348
|
+
isPublicThread() {
|
|
349
|
+
return this.type === ChannelType.PublicThread;
|
|
350
|
+
}
|
|
351
|
+
isPrivateThread() {
|
|
352
|
+
return this.type === ChannelType.PrivateThread;
|
|
353
|
+
}
|
|
354
|
+
isAnnouncementThread() {
|
|
355
|
+
return this.type === ChannelType.AnnouncementThread;
|
|
356
|
+
}
|
|
357
|
+
isCategory() {
|
|
358
|
+
return this.type === ChannelType.GuildCategory;
|
|
359
|
+
}
|
|
160
360
|
inGuild() {
|
|
161
361
|
return "guild_id" in this.data;
|
|
162
362
|
}
|
|
163
|
-
fetch() {
|
|
164
|
-
|
|
363
|
+
async fetch() {
|
|
364
|
+
const channel = await this.client.channels.fetch(this.id, true);
|
|
365
|
+
if (!channel) throw new Error("Channel not found");
|
|
366
|
+
return channel;
|
|
165
367
|
}
|
|
166
368
|
_patch(data) {
|
|
167
369
|
this.data = {
|
|
@@ -175,8 +377,14 @@ var BaseChannel = class extends BaseStructure {
|
|
|
175
377
|
//#region src/lib/mixins/ChannelMixin.ts
|
|
176
378
|
const TextBasedChannelMixin = createMixin((base) => {
|
|
177
379
|
class TextBasedChannel extends base {
|
|
380
|
+
get lastMessageId() {
|
|
381
|
+
return this.data.last_message_id ?? void 0;
|
|
382
|
+
}
|
|
383
|
+
get rateLimitPerUser() {
|
|
384
|
+
return this.data.rate_limit_per_user;
|
|
385
|
+
}
|
|
178
386
|
send(options) {
|
|
179
|
-
return this.client.
|
|
387
|
+
return this.client.channels.createMessage(this.id, options);
|
|
180
388
|
}
|
|
181
389
|
}
|
|
182
390
|
return TextBasedChannel;
|
|
@@ -187,6 +395,12 @@ const VoiceBasedChannelMixin = createMixin((base) => {
|
|
|
187
395
|
});
|
|
188
396
|
const GuildChannelMixin = createMixin((base) => {
|
|
189
397
|
class GuildChannel extends base {
|
|
398
|
+
get parentId() {
|
|
399
|
+
return this.data.parent_id ?? void 0;
|
|
400
|
+
}
|
|
401
|
+
get parent() {
|
|
402
|
+
return this.parentId ? this.client.cache.channels.get(this.parentId) : void 0;
|
|
403
|
+
}
|
|
190
404
|
get guildId() {
|
|
191
405
|
if (!this.data.guild_id) throw new Error("This channel is not a guild channel");
|
|
192
406
|
return this.data.guild_id;
|
|
@@ -198,6 +412,86 @@ const GuildChannelMixin = createMixin((base) => {
|
|
|
198
412
|
return GuildChannel;
|
|
199
413
|
});
|
|
200
414
|
|
|
415
|
+
//#endregion
|
|
416
|
+
//#region src/lib/structures/channel/GuildTextChannel.ts
|
|
417
|
+
var GuildTextChannel = class extends applyMixins(BaseChannel, [GuildChannelMixin, TextBasedChannelMixin]) {};
|
|
418
|
+
|
|
419
|
+
//#endregion
|
|
420
|
+
//#region src/lib/structures/channel/GuildVoiceChannel.ts
|
|
421
|
+
var GuildVoiceChannel = class extends applyMixins(BaseChannel, [
|
|
422
|
+
GuildChannelMixin,
|
|
423
|
+
TextBasedChannelMixin,
|
|
424
|
+
VoiceBasedChannelMixin
|
|
425
|
+
]) {};
|
|
426
|
+
|
|
427
|
+
//#endregion
|
|
428
|
+
//#region src/lib/structures/channel/GuildStageVoiceChannel.ts
|
|
429
|
+
var GuildStageVoiceChannel = class extends applyMixins(BaseChannel, [
|
|
430
|
+
GuildChannelMixin,
|
|
431
|
+
TextBasedChannelMixin,
|
|
432
|
+
VoiceBasedChannelMixin
|
|
433
|
+
]) {};
|
|
434
|
+
|
|
435
|
+
//#endregion
|
|
436
|
+
//#region src/lib/structures/channel/GuildAnnouncementChannel.ts
|
|
437
|
+
var GuildAnnouncementChannel = class extends applyMixins(BaseChannel, [GuildChannelMixin, TextBasedChannelMixin]) {
|
|
438
|
+
crosspost(messageId) {
|
|
439
|
+
return this.client.channels.crosspost(this.id, messageId);
|
|
440
|
+
}
|
|
441
|
+
};
|
|
442
|
+
|
|
443
|
+
//#endregion
|
|
444
|
+
//#region src/lib/structures/channel/GuildForumChannel.ts
|
|
445
|
+
var GuildForumChannel = class extends applyMixins(BaseChannel, [GuildChannelMixin]) {
|
|
446
|
+
#cachedTags;
|
|
447
|
+
constructor(client, data) {
|
|
448
|
+
super(client, data);
|
|
449
|
+
}
|
|
450
|
+
get topic() {
|
|
451
|
+
return this.data.topic ?? void 0;
|
|
452
|
+
}
|
|
453
|
+
get defaultAutoArchiveDuration() {
|
|
454
|
+
return this.data.default_auto_archive_duration;
|
|
455
|
+
}
|
|
456
|
+
get defaultSortOrder() {
|
|
457
|
+
return this.data.default_sort_order;
|
|
458
|
+
}
|
|
459
|
+
get defaultForumLayout() {
|
|
460
|
+
return this.data.default_forum_layout;
|
|
461
|
+
}
|
|
462
|
+
get defaultThreadRateLimitPerUser() {
|
|
463
|
+
return this.data.default_thread_rate_limit_per_user;
|
|
464
|
+
}
|
|
465
|
+
get nsfw() {
|
|
466
|
+
return this.data.nsfw ?? false;
|
|
467
|
+
}
|
|
468
|
+
get tags() {
|
|
469
|
+
if (!this.#cachedTags) {
|
|
470
|
+
this.#cachedTags = new Collection();
|
|
471
|
+
for (const tagData of this.data.available_tags ?? []) {
|
|
472
|
+
const tag = new Tag(this.client, tagData);
|
|
473
|
+
this.#cachedTags.set(tag.id, tag);
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
return this.#cachedTags;
|
|
477
|
+
}
|
|
478
|
+
_patch(data) {
|
|
479
|
+
super._patch(data);
|
|
480
|
+
this.#cachedTags = void 0;
|
|
481
|
+
}
|
|
482
|
+
};
|
|
483
|
+
|
|
484
|
+
//#endregion
|
|
485
|
+
//#region src/lib/structures/channel/GuildCategory.ts
|
|
486
|
+
var GuildCategory = class extends applyMixins(BaseChannel, [GuildChannelMixin]) {
|
|
487
|
+
constructor(client, data) {
|
|
488
|
+
super(client, data);
|
|
489
|
+
}
|
|
490
|
+
get children() {
|
|
491
|
+
return this.guild?.channels.filter((channel) => channel.inGuild() && channel.parentId === this.id);
|
|
492
|
+
}
|
|
493
|
+
};
|
|
494
|
+
|
|
201
495
|
//#endregion
|
|
202
496
|
//#region src/lib/structures/channel/DMChannel.ts
|
|
203
497
|
var DMChannel = class extends applyMixins(BaseChannel, [TextBasedChannelMixin]) {
|
|
@@ -260,151 +554,153 @@ var DMChannel = class extends applyMixins(BaseChannel, [TextBasedChannelMixin])
|
|
|
260
554
|
};
|
|
261
555
|
|
|
262
556
|
//#endregion
|
|
263
|
-
//#region src/lib/structures/
|
|
264
|
-
var
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
super(client);
|
|
268
|
-
this.data = data;
|
|
269
|
-
this.#ensureChannelCache();
|
|
557
|
+
//#region src/lib/structures/channel/ThreadChannel.ts
|
|
558
|
+
var ThreadChannel = class extends applyMixins(BaseChannel, [GuildChannelMixin, TextBasedChannelMixin]) {
|
|
559
|
+
get ownerId() {
|
|
560
|
+
return this.data.owner_id;
|
|
270
561
|
}
|
|
271
|
-
get
|
|
272
|
-
return
|
|
562
|
+
get archived() {
|
|
563
|
+
return this.data.thread_metadata?.archived ?? false;
|
|
273
564
|
}
|
|
274
|
-
get
|
|
275
|
-
return this.data.
|
|
565
|
+
get locked() {
|
|
566
|
+
return this.data.thread_metadata?.locked ?? false;
|
|
276
567
|
}
|
|
277
|
-
get
|
|
278
|
-
return this.data.
|
|
568
|
+
get autoArchiveDuration() {
|
|
569
|
+
return this.data.thread_metadata?.auto_archive_duration;
|
|
279
570
|
}
|
|
280
|
-
get
|
|
281
|
-
return this.data.
|
|
571
|
+
get archiveTimestamp() {
|
|
572
|
+
return this.data.thread_metadata?.archive_timestamp;
|
|
282
573
|
}
|
|
283
|
-
get
|
|
284
|
-
return this
|
|
574
|
+
get invitable() {
|
|
575
|
+
return this.data.thread_metadata?.invitable;
|
|
285
576
|
}
|
|
286
|
-
get
|
|
287
|
-
return
|
|
577
|
+
get memberCount() {
|
|
578
|
+
return this.data.member_count;
|
|
288
579
|
}
|
|
289
|
-
get
|
|
290
|
-
return this.
|
|
580
|
+
get messageCount() {
|
|
581
|
+
return this.data.message_count;
|
|
291
582
|
}
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
*
|
|
295
|
-
* **Note:** This property returns the cached `User` synchronously.
|
|
296
|
-
* It may be stale if the users cache has short lifetime or uses an asynchronous remote store.
|
|
297
|
-
* To ensure the author is up-to-date, use the `fetchAuthor()` method instead.
|
|
298
|
-
*/
|
|
299
|
-
get author() {
|
|
300
|
-
let author = this.#cachedAuthor;
|
|
301
|
-
if (!author && this.client.cache.isModuleEnabled("users")) author = this.client.cache.resolveLocal(this.client.cache.users.local, this.data.author.id, () => new User(this.client, this.data.author), (user) => user._patch(this.data.author));
|
|
302
|
-
if (!author) author = new User(this.client, this.data.author);
|
|
303
|
-
this.#cachedAuthor = author;
|
|
304
|
-
return this.#cachedAuthor;
|
|
305
|
-
}
|
|
306
|
-
get createdAt() {
|
|
307
|
-
return new Date(this.data.timestamp);
|
|
308
|
-
}
|
|
309
|
-
get editedAt() {
|
|
310
|
-
return this.data.edited_timestamp ? new Date(this.data.edited_timestamp) : void 0;
|
|
311
|
-
}
|
|
312
|
-
get createdTimestamp() {
|
|
313
|
-
return this.createdAt.getTime();
|
|
583
|
+
get totalMessageSent() {
|
|
584
|
+
return this.data.total_message_sent;
|
|
314
585
|
}
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
586
|
+
};
|
|
587
|
+
|
|
588
|
+
//#endregion
|
|
589
|
+
//#region src/lib/managers/client/ClientChannelManager.ts
|
|
590
|
+
var ClientChannelManager = class ClientChannelManager {
|
|
591
|
+
constructor(client) {
|
|
592
|
+
Object.defineProperty(this, "client", {
|
|
593
|
+
value: client,
|
|
594
|
+
enumerable: false,
|
|
595
|
+
writable: false
|
|
596
|
+
});
|
|
320
597
|
}
|
|
321
|
-
|
|
322
|
-
|
|
598
|
+
async fetch(id, force = false) {
|
|
599
|
+
if (!force) {
|
|
600
|
+
const cached = this.client.cache.channels.get(id);
|
|
601
|
+
if (cached) return cached;
|
|
602
|
+
}
|
|
603
|
+
const data = await this.client.rest.get(Routes.channel(id)).catch(() => void 0);
|
|
604
|
+
if (!data) return;
|
|
605
|
+
const existing = this.client.cache.channels.get(id);
|
|
606
|
+
if (existing && existing.type === data.type) {
|
|
607
|
+
existing._patch(data);
|
|
608
|
+
return existing;
|
|
609
|
+
}
|
|
610
|
+
const newChannel = ClientChannelManager.create(this.client, data);
|
|
611
|
+
this.client.cache.channels.set(id, newChannel);
|
|
612
|
+
return newChannel;
|
|
613
|
+
}
|
|
614
|
+
async delete(id, force = false) {
|
|
615
|
+
const channel = this.client.cache.channels.get(id);
|
|
616
|
+
if (!channel && !force) return;
|
|
617
|
+
await this.client.rest.delete(Routes.channel(id));
|
|
618
|
+
if (channel) {
|
|
619
|
+
this.client.cache.channels.delete(id);
|
|
620
|
+
if (channel.inGuild()) channel.guild.channels.delete(id);
|
|
621
|
+
}
|
|
622
|
+
return channel;
|
|
323
623
|
}
|
|
324
|
-
async
|
|
325
|
-
const
|
|
326
|
-
|
|
327
|
-
this
|
|
328
|
-
|
|
624
|
+
async create(guildId, payload) {
|
|
625
|
+
const data = await this.client.rest.post(Routes.guildChannels(guildId), { body: payload });
|
|
626
|
+
const channel = ClientChannelManager.create(this.client, data);
|
|
627
|
+
this.client.cache.channels.set(channel.id, channel);
|
|
628
|
+
if (channel.inGuild()) channel.guild.channels.set(channel.id, channel);
|
|
629
|
+
return channel;
|
|
329
630
|
}
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
*
|
|
336
|
-
* @param force - Whether to bypass the cache and force a request to the API.
|
|
337
|
-
* @returns A promise that resolves to the `User` who authored this message.
|
|
338
|
-
*/
|
|
339
|
-
async fetchAuthor(force = false) {
|
|
340
|
-
if (!force && this.client.cache.isModuleEnabled("users")) return this.client.cache.resolve(this.client.cache.users, this.data.author.id, () => new User(this.client, this.data.author), (user) => user._patch(this.data.author));
|
|
341
|
-
return this.client.helper.fetchUser(this.data.author.id, force);
|
|
631
|
+
async crosspost(channelId, messageId) {
|
|
632
|
+
const data = await this.client.rest.post(Routes.channelMessageCrosspost(channelId, messageId));
|
|
633
|
+
const message = new Message(this.client, data);
|
|
634
|
+
if (this.client.cache.isModuleEnabled("messages")) await this.client.cache.messages.set(message.id, message);
|
|
635
|
+
return message;
|
|
342
636
|
}
|
|
343
|
-
async
|
|
344
|
-
|
|
637
|
+
async createMessage(channelId, options) {
|
|
638
|
+
if (typeof options === "string") options = { content: options };
|
|
639
|
+
const data = this.client.rest.post(Routes.channelMessages(channelId), { body: ClientChannelManager.createMessagePayload(options) });
|
|
640
|
+
const message = new Message(this.client, await data);
|
|
641
|
+
if (this.client.cache.isModuleEnabled("messages")) await this.client.cache.messages.set(message.id, message);
|
|
642
|
+
return message;
|
|
345
643
|
}
|
|
346
|
-
async
|
|
347
|
-
|
|
644
|
+
async editMessage(channelId, messageId, options) {
|
|
645
|
+
if (typeof options === "string") options = { content: options };
|
|
646
|
+
const data = await this.client.rest.patch(Routes.channelMessage(channelId, messageId), { body: ClientChannelManager.createMessagePayload(options) });
|
|
647
|
+
let message;
|
|
648
|
+
if (this.client.cache.isModuleEnabled("messages")) message = await this.client.cache.resolve(this.client.cache.messages, messageId, () => new Message(this.client, data), (m) => m._patch(data));
|
|
649
|
+
else message = new Message(this.client, data);
|
|
650
|
+
return message;
|
|
348
651
|
}
|
|
349
|
-
async
|
|
350
|
-
|
|
652
|
+
async deleteMessage(channelId, messageId, force = false) {
|
|
653
|
+
let message;
|
|
654
|
+
if (!force && this.client.cache.isModuleEnabled("messages")) {
|
|
655
|
+
message = await this.client.cache.messages.get(messageId);
|
|
656
|
+
if (!message) return;
|
|
657
|
+
}
|
|
658
|
+
await this.client.rest.delete(Routes.channelMessage(channelId, messageId));
|
|
659
|
+
if (this.client.cache.isModuleEnabled("messages")) await this.client.cache.messages.delete(messageId);
|
|
660
|
+
return message;
|
|
351
661
|
}
|
|
352
|
-
async
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
...
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
662
|
+
async replyMessage(channelId, messageId, options) {
|
|
663
|
+
if (typeof options === "string") options = { content: options };
|
|
664
|
+
return this.createMessage(channelId, {
|
|
665
|
+
...options,
|
|
666
|
+
messageReference: {
|
|
667
|
+
channel_id: channelId,
|
|
668
|
+
message_id: messageId
|
|
669
|
+
}
|
|
670
|
+
});
|
|
359
671
|
}
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
672
|
+
resolve(data) {
|
|
673
|
+
return this.client.cache.resolveLocal(this.client.cache.channels, data.id, () => ClientChannelManager.create(this.client, data), (c) => c?._patch(data));
|
|
674
|
+
}
|
|
675
|
+
static create(client, data) {
|
|
676
|
+
switch (data.type) {
|
|
677
|
+
case ChannelType.GuildText: return new GuildTextChannel(client, data);
|
|
678
|
+
case ChannelType.GuildVoice: return new GuildVoiceChannel(client, data);
|
|
679
|
+
case ChannelType.GuildStageVoice: return new GuildStageVoiceChannel(client, data);
|
|
680
|
+
case ChannelType.GuildAnnouncement: return new GuildAnnouncementChannel(client, data);
|
|
681
|
+
case ChannelType.DM: return new DMChannel(client, data);
|
|
682
|
+
case ChannelType.GuildForum: return new GuildForumChannel(client, data);
|
|
683
|
+
case ChannelType.PublicThread:
|
|
684
|
+
case ChannelType.PrivateThread:
|
|
685
|
+
case ChannelType.AnnouncementThread: return new ThreadChannel(client, data);
|
|
372
686
|
}
|
|
373
|
-
|
|
374
|
-
client.cache.channels.set(this.channelId, channel);
|
|
375
|
-
return channel;
|
|
687
|
+
return new BaseChannel(client, data);
|
|
376
688
|
}
|
|
377
|
-
|
|
378
|
-
return this.
|
|
689
|
+
joinThread(threadId) {
|
|
690
|
+
return this.client.rest.post(Routes.threadMembers(threadId));
|
|
379
691
|
}
|
|
380
|
-
|
|
381
|
-
return
|
|
692
|
+
static createMessagePayload(options) {
|
|
693
|
+
return {
|
|
694
|
+
content: options.content,
|
|
695
|
+
tts: options.tts,
|
|
696
|
+
embeds: options.embeds,
|
|
697
|
+
allowed_mentions: options.allowedMentions,
|
|
698
|
+
message_reference: options.messageReference,
|
|
699
|
+
flags: options.flags
|
|
700
|
+
};
|
|
382
701
|
}
|
|
383
702
|
};
|
|
384
703
|
|
|
385
|
-
//#endregion
|
|
386
|
-
//#region src/lib/structures/channel/GuildTextChannel.ts
|
|
387
|
-
var GuildTextChannel = class extends applyMixins(BaseChannel, [GuildChannelMixin, TextBasedChannelMixin]) {};
|
|
388
|
-
|
|
389
|
-
//#endregion
|
|
390
|
-
//#region src/lib/structures/channel/GuildVoiceChannel.ts
|
|
391
|
-
var GuildVoiceChannel = class extends applyMixins(BaseChannel, [
|
|
392
|
-
GuildChannelMixin,
|
|
393
|
-
TextBasedChannelMixin,
|
|
394
|
-
VoiceBasedChannelMixin
|
|
395
|
-
]) {};
|
|
396
|
-
|
|
397
|
-
//#endregion
|
|
398
|
-
//#region src/lib/utils/channel.ts
|
|
399
|
-
function createChannel(client, data) {
|
|
400
|
-
switch (data.type) {
|
|
401
|
-
case ChannelType.GuildText: return new GuildTextChannel(client, data);
|
|
402
|
-
case ChannelType.GuildVoice: return new GuildVoiceChannel(client, data);
|
|
403
|
-
case ChannelType.DM: return new DMChannel(client, data);
|
|
404
|
-
default: return null;
|
|
405
|
-
}
|
|
406
|
-
}
|
|
407
|
-
|
|
408
704
|
//#endregion
|
|
409
705
|
//#region src/lib/structures/Guild.ts
|
|
410
706
|
var Guild = class extends BaseStructure {
|
|
@@ -447,7 +743,7 @@ var Guild = class extends BaseStructure {
|
|
|
447
743
|
for (const id of this.channels.keys()) this.client.cache.channels.delete(id);
|
|
448
744
|
this.channels.clear();
|
|
449
745
|
for (const channelData of this.data.channels) {
|
|
450
|
-
const channel =
|
|
746
|
+
const channel = ClientChannelManager.create(this.client, channelData);
|
|
451
747
|
if (channel) {
|
|
452
748
|
this.channels.set(channel.id, channel);
|
|
453
749
|
this.client.cache.channels.set(channel.id, channel);
|
|
@@ -458,7 +754,7 @@ var Guild = class extends BaseStructure {
|
|
|
458
754
|
|
|
459
755
|
//#endregion
|
|
460
756
|
//#region src/lib/client/ClientHelper.ts
|
|
461
|
-
var ClientHelper = class
|
|
757
|
+
var ClientHelper = class {
|
|
462
758
|
constructor(client) {
|
|
463
759
|
Object.defineProperty(this, "client", {
|
|
464
760
|
value: client,
|
|
@@ -501,30 +797,6 @@ var ClientHelper = class ClientHelper {
|
|
|
501
797
|
await this.client.rest.delete(Routes.channelMessage(channelId, messageId));
|
|
502
798
|
if (this.client.cache.isModuleEnabled("messages")) await this.client.cache.messages.delete(messageId);
|
|
503
799
|
}
|
|
504
|
-
async createMessage(channelId, options) {
|
|
505
|
-
if (typeof options === "string") options = { content: options };
|
|
506
|
-
const data = this.client.rest.post(Routes.channelMessages(channelId), { body: ClientHelper.toAPICreateMessagePayload(options) });
|
|
507
|
-
const message = new Message(this.client, await data);
|
|
508
|
-
if (this.client.cache.isModuleEnabled("messages")) await this.client.cache.messages.set(message.id, message);
|
|
509
|
-
return message;
|
|
510
|
-
}
|
|
511
|
-
async editMessage(channelId, messageId, options) {
|
|
512
|
-
if (typeof options === "string") options = { content: options };
|
|
513
|
-
const data = await this.client.rest.patch(Routes.channelMessage(channelId, messageId), { body: ClientHelper.toAPICreateMessagePayload(options) });
|
|
514
|
-
let message;
|
|
515
|
-
if (this.client.cache.isModuleEnabled("messages")) message = await this.client.cache.resolve(this.client.cache.messages, messageId, () => new Message(this.client, data), (m) => m._patch(data));
|
|
516
|
-
else message = new Message(this.client, data);
|
|
517
|
-
return message;
|
|
518
|
-
}
|
|
519
|
-
async replyMessage(channelId, messageId, options) {
|
|
520
|
-
return this.createMessage(channelId, {
|
|
521
|
-
...options,
|
|
522
|
-
messageReference: {
|
|
523
|
-
channel_id: channelId,
|
|
524
|
-
message_id: messageId
|
|
525
|
-
}
|
|
526
|
-
});
|
|
527
|
-
}
|
|
528
800
|
async fetchGuild(guildId, force = false) {
|
|
529
801
|
let guild = this.client.cache.guilds.get(guildId);
|
|
530
802
|
if (!guild || force) {
|
|
@@ -534,26 +806,14 @@ var ClientHelper = class ClientHelper {
|
|
|
534
806
|
}
|
|
535
807
|
return guild;
|
|
536
808
|
}
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
if (!channel || force) {
|
|
540
|
-
const data = await this.client.rest.get(Routes.channel(channelId));
|
|
541
|
-
channel = createChannel(this.client, data) ?? void 0;
|
|
542
|
-
if (!channel) throw new Error(`Channel not found: ${channelId}`);
|
|
543
|
-
this.client.cache.channels.set(channelId, channel);
|
|
544
|
-
if (channel.inGuild()) channel.guild.channels.set(channelId, channel);
|
|
545
|
-
}
|
|
546
|
-
return channel;
|
|
809
|
+
fetchChannel(channelId, force = false) {
|
|
810
|
+
return this.client.channels.fetch(channelId, force);
|
|
547
811
|
}
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
allowed_mentions: options.allowedMentions,
|
|
554
|
-
message_reference: options.messageReference,
|
|
555
|
-
flags: options.flags
|
|
556
|
-
};
|
|
812
|
+
async crosspostMessage(channelId, messageId) {
|
|
813
|
+
const data = await this.client.rest.post(Routes.channelMessageCrosspost(channelId, messageId));
|
|
814
|
+
const message = new Message(this.client, data);
|
|
815
|
+
if (this.client.cache.isModuleEnabled("messages")) await this.client.cache.messages.set(message.id, message);
|
|
816
|
+
return message;
|
|
557
817
|
}
|
|
558
818
|
};
|
|
559
819
|
|
|
@@ -562,6 +822,7 @@ var ClientHelper = class ClientHelper {
|
|
|
562
822
|
let Partial = /* @__PURE__ */ function(Partial) {
|
|
563
823
|
Partial[Partial["Message"] = 0] = "Message";
|
|
564
824
|
Partial[Partial["User"] = 1] = "User";
|
|
825
|
+
Partial[Partial["Channel"] = 2] = "Channel";
|
|
565
826
|
return Partial;
|
|
566
827
|
}({});
|
|
567
828
|
|
|
@@ -636,6 +897,12 @@ var LocalCacheAdapter = class extends BaseCacheAdapter {
|
|
|
636
897
|
find(filter) {
|
|
637
898
|
for (const entry of this.collection.values()) if (filter(entry.value)) return entry.value;
|
|
638
899
|
}
|
|
900
|
+
forEach(callback) {
|
|
901
|
+
for (const [key, entry] of this.collection) callback(entry.value, key);
|
|
902
|
+
}
|
|
903
|
+
map(callback) {
|
|
904
|
+
return this.collection.map((entry, key) => callback(entry.value, key));
|
|
905
|
+
}
|
|
639
906
|
sweep(filter) {
|
|
640
907
|
for (const [key, entry] of this.collection) if (filter(entry.value)) this.delete(key);
|
|
641
908
|
}
|
|
@@ -690,7 +957,7 @@ var HybridCache = class {
|
|
|
690
957
|
};
|
|
691
958
|
|
|
692
959
|
//#endregion
|
|
693
|
-
//#region src/lib/client/ClientCacheManager.ts
|
|
960
|
+
//#region src/lib/managers/client/ClientCacheManager.ts
|
|
694
961
|
var ClientCacheManager = class {
|
|
695
962
|
channels = new LocalCacheAdapter();
|
|
696
963
|
guilds = new LocalCacheAdapter();
|
|
@@ -751,31 +1018,49 @@ function registerHandler(event, handler) {
|
|
|
751
1018
|
|
|
752
1019
|
//#endregion
|
|
753
1020
|
//#region src/lib/client/dispatches/handlers/message.ts
|
|
754
|
-
async function
|
|
1021
|
+
async function ensureMessageCache(client, payload) {
|
|
755
1022
|
let message;
|
|
756
1023
|
if (client.cache.isModuleEnabled("messages")) message = await client.cache.resolve(client.cache.messages, payload.d.id, () => new Message(client, payload.d), (m) => m._patch(payload.d));
|
|
757
1024
|
else message = new Message(client, payload.d);
|
|
758
|
-
|
|
759
|
-
client.emit(payload.t === GatewayDispatchEvents.MessageUpdate ? "messageUpdate" : "messageCreate", message);
|
|
1025
|
+
return message;
|
|
760
1026
|
}
|
|
761
|
-
registerHandler(GatewayDispatchEvents.MessageCreate,
|
|
762
|
-
|
|
1027
|
+
registerHandler(GatewayDispatchEvents.MessageCreate, async (client, payload) => {
|
|
1028
|
+
const message = await ensureMessageCache(client, payload);
|
|
1029
|
+
message.channel.data.last_message_id = message.id;
|
|
1030
|
+
if (message.channel.isThread()) {
|
|
1031
|
+
message.channel.data.message_count = (message.channel.data.message_count ?? 0) + 1;
|
|
1032
|
+
message.channel.data.total_message_sent = (message.channel.data.total_message_sent ?? 0) + 1;
|
|
1033
|
+
}
|
|
1034
|
+
if (message.partial && !client.options.partials.has(Partial.Message)) return;
|
|
1035
|
+
if (message.channel.partial && !client.options.partials.has(Partial.Channel)) return;
|
|
1036
|
+
client.emit("messageCreate", message);
|
|
1037
|
+
});
|
|
1038
|
+
registerHandler(GatewayDispatchEvents.MessageUpdate, async (client, payload) => {
|
|
1039
|
+
const message = await ensureMessageCache(client, payload);
|
|
1040
|
+
if (message.partial && !client.options.partials.has(Partial.Message)) return;
|
|
1041
|
+
if (message.channel.partial && !client.options.partials.has(Partial.Channel)) return;
|
|
1042
|
+
client.emit("messageUpdate", message);
|
|
1043
|
+
});
|
|
763
1044
|
registerHandler(GatewayDispatchEvents.MessageDelete, async (client, payload) => {
|
|
764
1045
|
let message;
|
|
765
1046
|
if (client.cache.isModuleEnabled("messages")) message = await client.cache.messages.get(payload.d.id);
|
|
766
1047
|
if (!message) message = new Message(client, payload.d);
|
|
1048
|
+
if (message.channel.isThread()) message.channel.data.message_count = Math.min((message.channel.data.message_count ?? 0) - 1, 0);
|
|
767
1049
|
client.emit("messageDelete", message);
|
|
768
1050
|
});
|
|
769
1051
|
|
|
770
1052
|
//#endregion
|
|
771
1053
|
//#region src/lib/client/dispatches/handlers/guild.ts
|
|
772
|
-
|
|
773
|
-
const guild =
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
registerHandler(GatewayDispatchEvents.GuildUpdate,
|
|
1054
|
+
registerHandler(GatewayDispatchEvents.GuildCreate, (client, payload) => {
|
|
1055
|
+
const guild = client.cache.resolveLocal(client.cache.guilds, payload.d.id, () => new Guild(client, payload.d), (g) => g._patch(payload.d));
|
|
1056
|
+
for (const data of payload.d.channels) client.channels.resolve(data);
|
|
1057
|
+
for (const thread of payload.d.threads) client.channels.resolve(thread);
|
|
1058
|
+
client.emit(payload.d.unavailable ? "guildCreate" : "guildAvailable", guild);
|
|
1059
|
+
});
|
|
1060
|
+
registerHandler(GatewayDispatchEvents.GuildUpdate, (client, payload) => {
|
|
1061
|
+
const guild = client.cache.resolveLocal(client.cache.guilds, payload.d.id, () => new Guild(client, payload.d), (g) => g._patch(payload.d));
|
|
1062
|
+
client.emit("guildUpdate", guild);
|
|
1063
|
+
});
|
|
779
1064
|
registerHandler(GatewayDispatchEvents.GuildDelete, async (client, payload) => {
|
|
780
1065
|
const guild = client.cache.guilds.get(payload.d.id);
|
|
781
1066
|
if (!guild) return;
|
|
@@ -787,20 +1072,28 @@ registerHandler(GatewayDispatchEvents.GuildDelete, async (client, payload) => {
|
|
|
787
1072
|
//#endregion
|
|
788
1073
|
//#region src/lib/client/dispatches/handlers/channel.ts
|
|
789
1074
|
async function onCreateOrUpdate(client, payload) {
|
|
790
|
-
|
|
791
|
-
if (
|
|
1075
|
+
let channel = client.cache.channels.get(payload.d.id);
|
|
1076
|
+
if (channel && channel.type === payload.d.type) channel._patch(payload.d);
|
|
1077
|
+
else {
|
|
1078
|
+
channel = ClientChannelManager.create(client, payload.d);
|
|
1079
|
+
client.cache.channels.set(payload.d.id, channel);
|
|
1080
|
+
}
|
|
792
1081
|
if (channel.inGuild() && !channel.guild.channels.has(channel.id)) channel.guild.channels.set(channel.id, channel);
|
|
1082
|
+
if (channel.partial && !client.options.partials.has(Partial.Channel)) return;
|
|
793
1083
|
client.emit(payload.t === GatewayDispatchEvents.ChannelCreate ? "channelCreate" : "channelUpdate", channel);
|
|
794
1084
|
}
|
|
795
1085
|
registerHandler(GatewayDispatchEvents.ChannelCreate, onCreateOrUpdate);
|
|
796
1086
|
registerHandler(GatewayDispatchEvents.ChannelUpdate, onCreateOrUpdate);
|
|
797
|
-
registerHandler(GatewayDispatchEvents.ChannelDelete, (client, payload) => {
|
|
798
|
-
const channel = client.
|
|
1087
|
+
registerHandler(GatewayDispatchEvents.ChannelDelete, async (client, payload) => {
|
|
1088
|
+
const channel = client.channels.resolve(payload.d);
|
|
799
1089
|
const guild = client.cache.guilds.get(payload.d.guild_id);
|
|
800
1090
|
if (guild) guild.channels.delete(payload.d.id);
|
|
801
|
-
if (!channel) return;
|
|
802
1091
|
client.cache.channels.delete(payload.d.id);
|
|
803
|
-
client.emit("channelDelete", channel);
|
|
1092
|
+
if (!channel.partial || client.options.partials.has(Partial.Channel)) client.emit("channelDelete", channel);
|
|
1093
|
+
if (client.cache.isModuleEnabled("messages")) await Promise.all(client.cache.messages.local.map((message) => {
|
|
1094
|
+
if (message.channelId !== payload.d.id) return;
|
|
1095
|
+
return client.cache.messages.delete(message.id);
|
|
1096
|
+
}));
|
|
804
1097
|
});
|
|
805
1098
|
|
|
806
1099
|
//#endregion
|
|
@@ -813,14 +1106,65 @@ registerHandler(GatewayDispatchEvents.UserUpdate, async (client, payload) => {
|
|
|
813
1106
|
client.emit("userUpdate", user);
|
|
814
1107
|
});
|
|
815
1108
|
|
|
1109
|
+
//#endregion
|
|
1110
|
+
//#region src/lib/client/dispatches/handlers/thread.ts
|
|
1111
|
+
function resolveThread(client, payload) {
|
|
1112
|
+
let thread = client.cache.channels.get(payload.id);
|
|
1113
|
+
if (!thread?.isThread()) {
|
|
1114
|
+
thread = ClientChannelManager.create(client, payload);
|
|
1115
|
+
client.cache.channels.set(payload.id, thread);
|
|
1116
|
+
thread.guild.channels.set(payload.id, thread);
|
|
1117
|
+
} else thread._patch(payload);
|
|
1118
|
+
if ("member" in payload) {}
|
|
1119
|
+
return thread;
|
|
1120
|
+
}
|
|
1121
|
+
registerHandler(GatewayDispatchEvents.ThreadCreate, (client, payload) => {
|
|
1122
|
+
const thread = resolveThread(client, payload.d);
|
|
1123
|
+
if (thread.partial && !client.options.partials.has(Partial.Channel)) return;
|
|
1124
|
+
client.emit("threadCreate", thread);
|
|
1125
|
+
});
|
|
1126
|
+
registerHandler(GatewayDispatchEvents.ThreadUpdate, (client, payload) => {
|
|
1127
|
+
const thread = resolveThread(client, payload.d);
|
|
1128
|
+
if (thread.partial && !client.options.partials.has(Partial.Channel)) return;
|
|
1129
|
+
client.emit("threadUpdate", thread);
|
|
1130
|
+
});
|
|
1131
|
+
registerHandler(GatewayDispatchEvents.ThreadDelete, (client, payload) => {
|
|
1132
|
+
let thread = client.cache.channels.get(payload.d.id);
|
|
1133
|
+
if (thread) client.cache.channels.delete(payload.d.id);
|
|
1134
|
+
else thread = ClientChannelManager.create(client, {
|
|
1135
|
+
id: payload.d.id,
|
|
1136
|
+
guild_id: payload.d.guild_id,
|
|
1137
|
+
parent_id: payload.d.parent_id,
|
|
1138
|
+
type: payload.d.type
|
|
1139
|
+
});
|
|
1140
|
+
if (!thread.isThread()) return;
|
|
1141
|
+
if (thread.partial && !client.options.partials.has(Partial.Channel)) return;
|
|
1142
|
+
client.emit("threadDelete", thread);
|
|
1143
|
+
});
|
|
1144
|
+
registerHandler(GatewayDispatchEvents.ThreadListSync, (client, payload) => {
|
|
1145
|
+
for (const thread of payload.d.threads) resolveThread(client, thread);
|
|
1146
|
+
});
|
|
1147
|
+
|
|
1148
|
+
//#endregion
|
|
1149
|
+
//#region src/lib/client/dispatches/handlers/member.ts
|
|
1150
|
+
registerHandler(GatewayDispatchEvents.TypingStart, async (client, payload) => {
|
|
1151
|
+
const typing = new Typing(client, payload.d);
|
|
1152
|
+
client.emit("typingStart", typing);
|
|
1153
|
+
});
|
|
1154
|
+
|
|
816
1155
|
//#endregion
|
|
817
1156
|
//#region src/lib/client/Client.ts
|
|
818
1157
|
var Client = class extends EventEmitter {
|
|
819
1158
|
options;
|
|
820
1159
|
shards;
|
|
821
1160
|
rest;
|
|
1161
|
+
/**
|
|
1162
|
+
* @private
|
|
1163
|
+
* @deprecated
|
|
1164
|
+
*/
|
|
822
1165
|
helper;
|
|
823
1166
|
cache;
|
|
1167
|
+
channels;
|
|
824
1168
|
#user;
|
|
825
1169
|
#ready = false;
|
|
826
1170
|
constructor(options, rest) {
|
|
@@ -844,6 +1188,7 @@ var Client = class extends EventEmitter {
|
|
|
844
1188
|
intents: this.options.intents.toBigInt()
|
|
845
1189
|
}, rest);
|
|
846
1190
|
this.cache = new ClientCacheManager(this.options.cache);
|
|
1191
|
+
this.channels = new ClientChannelManager(this);
|
|
847
1192
|
this.helper = new ClientHelper(this);
|
|
848
1193
|
this.#setupShardsListeners();
|
|
849
1194
|
}
|
|
@@ -904,5 +1249,5 @@ function createClient(options) {
|
|
|
904
1249
|
}
|
|
905
1250
|
|
|
906
1251
|
//#endregion
|
|
907
|
-
export { BaseCacheAdapter, BaseChannel, Client, ClientHelper, Cluster, DEFAULT_REST_OPTIONS, DiscordAPIV10, DiscordHTTPError, Guild, GuildTextChannel, GuildVoiceChannel, HybridCache, Intent, IntentsBitField, LocalCacheAdapter, Message, Partial, REST, RESTAdapter, RESTMethod, Service, ServiceDriver, ServiceProcess, ServiceState, Shard, ShardState, ShardStrategy, ShardingManager, TransportClient, TransportServer, User, capitalize, createClient, createREST, createRESTAdapter, createService, createTransportClient, createTransportServer, instanceToObject, isCommonJS, isESM, isPlainObject, isPromiseLike, promisify, sleep };
|
|
1252
|
+
export { BaseCacheAdapter, BaseChannel, Client, ClientHelper, Cluster, DEFAULT_REST_OPTIONS, DMChannel, DiscordAPIV10, DiscordHTTPError, Guild, GuildAnnouncementChannel, GuildCategory, GuildForumChannel, GuildStageVoiceChannel, GuildTextChannel, GuildVoiceChannel, HybridCache, Intent, IntentsBitField, LocalCacheAdapter, Message, Partial, REST, RESTAdapter, RESTMethod, Service, ServiceDriver, ServiceProcess, ServiceState, Shard, ShardState, ShardStrategy, ShardingManager, Tag, ThreadChannel, TransportClient, TransportServer, Typing, User, capitalize, createClient, createREST, createRESTAdapter, createService, createTransportClient, createTransportServer, instanceToObject, isCommonJS, isESM, isPlainObject, isPromiseLike, promisify, sleep };
|
|
908
1253
|
//# sourceMappingURL=index.mjs.map
|