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.cjs
CHANGED
|
@@ -158,6 +158,188 @@ var User = class extends BaseStructure {
|
|
|
158
158
|
}
|
|
159
159
|
};
|
|
160
160
|
|
|
161
|
+
//#endregion
|
|
162
|
+
//#region src/lib/structures/Message.ts
|
|
163
|
+
var Message = class extends BaseStructure {
|
|
164
|
+
#cachedAuthor;
|
|
165
|
+
constructor(client, data) {
|
|
166
|
+
super(client);
|
|
167
|
+
this.data = data;
|
|
168
|
+
this.#ensureChannelCache();
|
|
169
|
+
}
|
|
170
|
+
get partial() {
|
|
171
|
+
return typeof this.data.content !== "string" || typeof this.data.author !== "object" || this.channel === void 0;
|
|
172
|
+
}
|
|
173
|
+
get content() {
|
|
174
|
+
return this.data.content;
|
|
175
|
+
}
|
|
176
|
+
get id() {
|
|
177
|
+
return this.data.id;
|
|
178
|
+
}
|
|
179
|
+
get channelId() {
|
|
180
|
+
return this.data.channel_id;
|
|
181
|
+
}
|
|
182
|
+
get channel() {
|
|
183
|
+
return this.#ensureChannelCache();
|
|
184
|
+
}
|
|
185
|
+
get guildId() {
|
|
186
|
+
return "guild_id" in this.data ? this.data.guild_id : void 0;
|
|
187
|
+
}
|
|
188
|
+
get guild() {
|
|
189
|
+
return this.guildId ? this.client.cache.guilds.get(this.guildId) : void 0;
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* The author of this message.
|
|
193
|
+
*
|
|
194
|
+
* **Note:** This property returns the cached `User` synchronously.
|
|
195
|
+
* It may be stale if the users cache has short lifetime or uses an asynchronous remote store.
|
|
196
|
+
* To ensure the author is up-to-date, use the `fetchAuthor()` method instead.
|
|
197
|
+
*/
|
|
198
|
+
get author() {
|
|
199
|
+
let author = this.#cachedAuthor;
|
|
200
|
+
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));
|
|
201
|
+
if (!author) author = new User(this.client, this.data.author);
|
|
202
|
+
this.#cachedAuthor = author;
|
|
203
|
+
return this.#cachedAuthor;
|
|
204
|
+
}
|
|
205
|
+
get createdAt() {
|
|
206
|
+
return new Date(this.data.timestamp);
|
|
207
|
+
}
|
|
208
|
+
get editedAt() {
|
|
209
|
+
return this.data.edited_timestamp ? new Date(this.data.edited_timestamp) : void 0;
|
|
210
|
+
}
|
|
211
|
+
get createdTimestamp() {
|
|
212
|
+
return this.createdAt.getTime();
|
|
213
|
+
}
|
|
214
|
+
get editedTimestamp() {
|
|
215
|
+
return this.editedAt?.getTime();
|
|
216
|
+
}
|
|
217
|
+
get url() {
|
|
218
|
+
return `https://discord.com/channels/${this.guildId ?? "@me"}/${this.channelId}/${this.id}`;
|
|
219
|
+
}
|
|
220
|
+
inGuild() {
|
|
221
|
+
return this.guild !== void 0;
|
|
222
|
+
}
|
|
223
|
+
async fetch() {
|
|
224
|
+
const message = await this.client.helper.fetchMessage(this.channelId, this.id);
|
|
225
|
+
this.data = message.data;
|
|
226
|
+
this.#cachedAuthor = await this.client.cache.resolve(this.client.cache.users, message.data.author.id, () => new User(this.client, message.data.author));
|
|
227
|
+
return this;
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* Fetches the author of this message from cache or Discord API.
|
|
231
|
+
*
|
|
232
|
+
* **Note:** It is recommended to use this method instead of the `author` property
|
|
233
|
+
* if the users cache has short lifetime or is backed by an asynchronous remote cache.
|
|
234
|
+
*
|
|
235
|
+
* @param force - Whether to bypass the cache and force a request to the API.
|
|
236
|
+
* @returns A promise that resolves to the `User` who authored this message.
|
|
237
|
+
*/
|
|
238
|
+
async fetchAuthor(force = false) {
|
|
239
|
+
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));
|
|
240
|
+
return this.client.helper.fetchUser(this.data.author.id, force);
|
|
241
|
+
}
|
|
242
|
+
async reply(options) {
|
|
243
|
+
return this.client.channels.replyMessage(this.channelId, this.id, options);
|
|
244
|
+
}
|
|
245
|
+
async edit(options) {
|
|
246
|
+
return this.client.channels.editMessage(this.channelId, this.id, options);
|
|
247
|
+
}
|
|
248
|
+
async _patch(data) {
|
|
249
|
+
this.data = {
|
|
250
|
+
...this.data,
|
|
251
|
+
...data
|
|
252
|
+
};
|
|
253
|
+
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));
|
|
254
|
+
else this.#cachedAuthor?._patch(data.author);
|
|
255
|
+
}
|
|
256
|
+
#ensureChannelCache() {
|
|
257
|
+
const { client } = this;
|
|
258
|
+
let channel = client.cache.channels.get(this.channelId) ?? this.guild?.channels.get(this.channelId);
|
|
259
|
+
if (!channel) {
|
|
260
|
+
if (this.guildId) channel = this.client.channels.resolve({
|
|
261
|
+
id: this.channelId,
|
|
262
|
+
type: discord_api_types_v10.ChannelType.GuildText
|
|
263
|
+
});
|
|
264
|
+
else channel = this.client.channels.resolve({
|
|
265
|
+
id: this.channelId,
|
|
266
|
+
type: discord_api_types_v10.ChannelType.DM,
|
|
267
|
+
name: null,
|
|
268
|
+
recipients: [this.data.author]
|
|
269
|
+
});
|
|
270
|
+
if (!channel) throw new Error("Channel not found");
|
|
271
|
+
client.cache.channels.set(this.channelId, channel);
|
|
272
|
+
}
|
|
273
|
+
return channel;
|
|
274
|
+
}
|
|
275
|
+
toJSON() {
|
|
276
|
+
return this.data;
|
|
277
|
+
}
|
|
278
|
+
toString() {
|
|
279
|
+
return this.data.content;
|
|
280
|
+
}
|
|
281
|
+
};
|
|
282
|
+
|
|
283
|
+
//#endregion
|
|
284
|
+
//#region src/lib/structures/Typing.ts
|
|
285
|
+
var Typing = class extends BaseStructure {
|
|
286
|
+
constructor(client, data) {
|
|
287
|
+
super(client);
|
|
288
|
+
this.data = data;
|
|
289
|
+
}
|
|
290
|
+
get channelId() {
|
|
291
|
+
return this.data.channel_id;
|
|
292
|
+
}
|
|
293
|
+
get guildId() {
|
|
294
|
+
return this.data.guild_id;
|
|
295
|
+
}
|
|
296
|
+
get userId() {
|
|
297
|
+
return this.data.user_id;
|
|
298
|
+
}
|
|
299
|
+
get timestamp() {
|
|
300
|
+
return this.data.timestamp;
|
|
301
|
+
}
|
|
302
|
+
get member() {
|
|
303
|
+
return this.data.member;
|
|
304
|
+
}
|
|
305
|
+
get channel() {
|
|
306
|
+
return this.guild?.channels.get(this.channelId) ?? this.client.cache.channels.get(this.channelId);
|
|
307
|
+
}
|
|
308
|
+
get guild() {
|
|
309
|
+
if (this.data.guild_id) return this.client.cache.guilds.get(this.data.guild_id);
|
|
310
|
+
}
|
|
311
|
+
};
|
|
312
|
+
|
|
313
|
+
//#endregion
|
|
314
|
+
//#region src/lib/structures/Tag.ts
|
|
315
|
+
var Tag = class extends BaseStructure {
|
|
316
|
+
constructor(client, data) {
|
|
317
|
+
super(client);
|
|
318
|
+
this.data = data;
|
|
319
|
+
}
|
|
320
|
+
get id() {
|
|
321
|
+
return this.data.id;
|
|
322
|
+
}
|
|
323
|
+
get name() {
|
|
324
|
+
return this.data.name;
|
|
325
|
+
}
|
|
326
|
+
get moderated() {
|
|
327
|
+
return this.data.moderated ?? false;
|
|
328
|
+
}
|
|
329
|
+
get emojiId() {
|
|
330
|
+
return this.data.emoji_id ?? void 0;
|
|
331
|
+
}
|
|
332
|
+
get emojiName() {
|
|
333
|
+
return this.data.emoji_name ?? void 0;
|
|
334
|
+
}
|
|
335
|
+
_patch(data) {
|
|
336
|
+
this.data = {
|
|
337
|
+
...this.data,
|
|
338
|
+
...data
|
|
339
|
+
};
|
|
340
|
+
}
|
|
341
|
+
};
|
|
342
|
+
|
|
161
343
|
//#endregion
|
|
162
344
|
//#region src/lib/structures/channel/BaseChannel.ts
|
|
163
345
|
var BaseChannel = class extends BaseStructure {
|
|
@@ -165,6 +347,9 @@ var BaseChannel = class extends BaseStructure {
|
|
|
165
347
|
super(client);
|
|
166
348
|
this.data = data;
|
|
167
349
|
}
|
|
350
|
+
get partial() {
|
|
351
|
+
return Object.keys(this.data).length <= 2;
|
|
352
|
+
}
|
|
168
353
|
get id() {
|
|
169
354
|
return this.data.id;
|
|
170
355
|
}
|
|
@@ -186,11 +371,28 @@ var BaseChannel = class extends BaseStructure {
|
|
|
186
371
|
isDM() {
|
|
187
372
|
return this.type === discord_api_types_v10.ChannelType.DM;
|
|
188
373
|
}
|
|
374
|
+
isThread() {
|
|
375
|
+
return this.type === discord_api_types_v10.ChannelType.AnnouncementThread || this.type === discord_api_types_v10.ChannelType.PublicThread || this.type === discord_api_types_v10.ChannelType.PrivateThread;
|
|
376
|
+
}
|
|
377
|
+
isPublicThread() {
|
|
378
|
+
return this.type === discord_api_types_v10.ChannelType.PublicThread;
|
|
379
|
+
}
|
|
380
|
+
isPrivateThread() {
|
|
381
|
+
return this.type === discord_api_types_v10.ChannelType.PrivateThread;
|
|
382
|
+
}
|
|
383
|
+
isAnnouncementThread() {
|
|
384
|
+
return this.type === discord_api_types_v10.ChannelType.AnnouncementThread;
|
|
385
|
+
}
|
|
386
|
+
isCategory() {
|
|
387
|
+
return this.type === discord_api_types_v10.ChannelType.GuildCategory;
|
|
388
|
+
}
|
|
189
389
|
inGuild() {
|
|
190
390
|
return "guild_id" in this.data;
|
|
191
391
|
}
|
|
192
|
-
fetch() {
|
|
193
|
-
|
|
392
|
+
async fetch() {
|
|
393
|
+
const channel = await this.client.channels.fetch(this.id, true);
|
|
394
|
+
if (!channel) throw new Error("Channel not found");
|
|
395
|
+
return channel;
|
|
194
396
|
}
|
|
195
397
|
_patch(data) {
|
|
196
398
|
this.data = {
|
|
@@ -204,8 +406,14 @@ var BaseChannel = class extends BaseStructure {
|
|
|
204
406
|
//#region src/lib/mixins/ChannelMixin.ts
|
|
205
407
|
const TextBasedChannelMixin = (0, tiny_mixin.createMixin)((base) => {
|
|
206
408
|
class TextBasedChannel extends base {
|
|
409
|
+
get lastMessageId() {
|
|
410
|
+
return this.data.last_message_id ?? void 0;
|
|
411
|
+
}
|
|
412
|
+
get rateLimitPerUser() {
|
|
413
|
+
return this.data.rate_limit_per_user;
|
|
414
|
+
}
|
|
207
415
|
send(options) {
|
|
208
|
-
return this.client.
|
|
416
|
+
return this.client.channels.createMessage(this.id, options);
|
|
209
417
|
}
|
|
210
418
|
}
|
|
211
419
|
return TextBasedChannel;
|
|
@@ -216,6 +424,12 @@ const VoiceBasedChannelMixin = (0, tiny_mixin.createMixin)((base) => {
|
|
|
216
424
|
});
|
|
217
425
|
const GuildChannelMixin = (0, tiny_mixin.createMixin)((base) => {
|
|
218
426
|
class GuildChannel extends base {
|
|
427
|
+
get parentId() {
|
|
428
|
+
return this.data.parent_id ?? void 0;
|
|
429
|
+
}
|
|
430
|
+
get parent() {
|
|
431
|
+
return this.parentId ? this.client.cache.channels.get(this.parentId) : void 0;
|
|
432
|
+
}
|
|
219
433
|
get guildId() {
|
|
220
434
|
if (!this.data.guild_id) throw new Error("This channel is not a guild channel");
|
|
221
435
|
return this.data.guild_id;
|
|
@@ -227,6 +441,86 @@ const GuildChannelMixin = (0, tiny_mixin.createMixin)((base) => {
|
|
|
227
441
|
return GuildChannel;
|
|
228
442
|
});
|
|
229
443
|
|
|
444
|
+
//#endregion
|
|
445
|
+
//#region src/lib/structures/channel/GuildTextChannel.ts
|
|
446
|
+
var GuildTextChannel = class extends (0, tiny_mixin.applyMixins)(BaseChannel, [GuildChannelMixin, TextBasedChannelMixin]) {};
|
|
447
|
+
|
|
448
|
+
//#endregion
|
|
449
|
+
//#region src/lib/structures/channel/GuildVoiceChannel.ts
|
|
450
|
+
var GuildVoiceChannel = class extends (0, tiny_mixin.applyMixins)(BaseChannel, [
|
|
451
|
+
GuildChannelMixin,
|
|
452
|
+
TextBasedChannelMixin,
|
|
453
|
+
VoiceBasedChannelMixin
|
|
454
|
+
]) {};
|
|
455
|
+
|
|
456
|
+
//#endregion
|
|
457
|
+
//#region src/lib/structures/channel/GuildStageVoiceChannel.ts
|
|
458
|
+
var GuildStageVoiceChannel = class extends (0, tiny_mixin.applyMixins)(BaseChannel, [
|
|
459
|
+
GuildChannelMixin,
|
|
460
|
+
TextBasedChannelMixin,
|
|
461
|
+
VoiceBasedChannelMixin
|
|
462
|
+
]) {};
|
|
463
|
+
|
|
464
|
+
//#endregion
|
|
465
|
+
//#region src/lib/structures/channel/GuildAnnouncementChannel.ts
|
|
466
|
+
var GuildAnnouncementChannel = class extends (0, tiny_mixin.applyMixins)(BaseChannel, [GuildChannelMixin, TextBasedChannelMixin]) {
|
|
467
|
+
crosspost(messageId) {
|
|
468
|
+
return this.client.channels.crosspost(this.id, messageId);
|
|
469
|
+
}
|
|
470
|
+
};
|
|
471
|
+
|
|
472
|
+
//#endregion
|
|
473
|
+
//#region src/lib/structures/channel/GuildForumChannel.ts
|
|
474
|
+
var GuildForumChannel = class extends (0, tiny_mixin.applyMixins)(BaseChannel, [GuildChannelMixin]) {
|
|
475
|
+
#cachedTags;
|
|
476
|
+
constructor(client, data) {
|
|
477
|
+
super(client, data);
|
|
478
|
+
}
|
|
479
|
+
get topic() {
|
|
480
|
+
return this.data.topic ?? void 0;
|
|
481
|
+
}
|
|
482
|
+
get defaultAutoArchiveDuration() {
|
|
483
|
+
return this.data.default_auto_archive_duration;
|
|
484
|
+
}
|
|
485
|
+
get defaultSortOrder() {
|
|
486
|
+
return this.data.default_sort_order;
|
|
487
|
+
}
|
|
488
|
+
get defaultForumLayout() {
|
|
489
|
+
return this.data.default_forum_layout;
|
|
490
|
+
}
|
|
491
|
+
get defaultThreadRateLimitPerUser() {
|
|
492
|
+
return this.data.default_thread_rate_limit_per_user;
|
|
493
|
+
}
|
|
494
|
+
get nsfw() {
|
|
495
|
+
return this.data.nsfw ?? false;
|
|
496
|
+
}
|
|
497
|
+
get tags() {
|
|
498
|
+
if (!this.#cachedTags) {
|
|
499
|
+
this.#cachedTags = new _discordjs_collection.Collection();
|
|
500
|
+
for (const tagData of this.data.available_tags ?? []) {
|
|
501
|
+
const tag = new Tag(this.client, tagData);
|
|
502
|
+
this.#cachedTags.set(tag.id, tag);
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
return this.#cachedTags;
|
|
506
|
+
}
|
|
507
|
+
_patch(data) {
|
|
508
|
+
super._patch(data);
|
|
509
|
+
this.#cachedTags = void 0;
|
|
510
|
+
}
|
|
511
|
+
};
|
|
512
|
+
|
|
513
|
+
//#endregion
|
|
514
|
+
//#region src/lib/structures/channel/GuildCategory.ts
|
|
515
|
+
var GuildCategory = class extends (0, tiny_mixin.applyMixins)(BaseChannel, [GuildChannelMixin]) {
|
|
516
|
+
constructor(client, data) {
|
|
517
|
+
super(client, data);
|
|
518
|
+
}
|
|
519
|
+
get children() {
|
|
520
|
+
return this.guild?.channels.filter((channel) => channel.inGuild() && channel.parentId === this.id);
|
|
521
|
+
}
|
|
522
|
+
};
|
|
523
|
+
|
|
230
524
|
//#endregion
|
|
231
525
|
//#region src/lib/structures/channel/DMChannel.ts
|
|
232
526
|
var DMChannel = class extends (0, tiny_mixin.applyMixins)(BaseChannel, [TextBasedChannelMixin]) {
|
|
@@ -289,151 +583,153 @@ var DMChannel = class extends (0, tiny_mixin.applyMixins)(BaseChannel, [TextBase
|
|
|
289
583
|
};
|
|
290
584
|
|
|
291
585
|
//#endregion
|
|
292
|
-
//#region src/lib/structures/
|
|
293
|
-
var
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
super(client);
|
|
297
|
-
this.data = data;
|
|
298
|
-
this.#ensureChannelCache();
|
|
586
|
+
//#region src/lib/structures/channel/ThreadChannel.ts
|
|
587
|
+
var ThreadChannel = class extends (0, tiny_mixin.applyMixins)(BaseChannel, [GuildChannelMixin, TextBasedChannelMixin]) {
|
|
588
|
+
get ownerId() {
|
|
589
|
+
return this.data.owner_id;
|
|
299
590
|
}
|
|
300
|
-
get
|
|
301
|
-
return
|
|
591
|
+
get archived() {
|
|
592
|
+
return this.data.thread_metadata?.archived ?? false;
|
|
302
593
|
}
|
|
303
|
-
get
|
|
304
|
-
return this.data.
|
|
594
|
+
get locked() {
|
|
595
|
+
return this.data.thread_metadata?.locked ?? false;
|
|
305
596
|
}
|
|
306
|
-
get
|
|
307
|
-
return this.data.
|
|
597
|
+
get autoArchiveDuration() {
|
|
598
|
+
return this.data.thread_metadata?.auto_archive_duration;
|
|
308
599
|
}
|
|
309
|
-
get
|
|
310
|
-
return this.data.
|
|
600
|
+
get archiveTimestamp() {
|
|
601
|
+
return this.data.thread_metadata?.archive_timestamp;
|
|
311
602
|
}
|
|
312
|
-
get
|
|
313
|
-
return this
|
|
603
|
+
get invitable() {
|
|
604
|
+
return this.data.thread_metadata?.invitable;
|
|
314
605
|
}
|
|
315
|
-
get
|
|
316
|
-
return
|
|
606
|
+
get memberCount() {
|
|
607
|
+
return this.data.member_count;
|
|
317
608
|
}
|
|
318
|
-
get
|
|
319
|
-
return this.
|
|
609
|
+
get messageCount() {
|
|
610
|
+
return this.data.message_count;
|
|
320
611
|
}
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
*
|
|
324
|
-
* **Note:** This property returns the cached `User` synchronously.
|
|
325
|
-
* It may be stale if the users cache has short lifetime or uses an asynchronous remote store.
|
|
326
|
-
* To ensure the author is up-to-date, use the `fetchAuthor()` method instead.
|
|
327
|
-
*/
|
|
328
|
-
get author() {
|
|
329
|
-
let author = this.#cachedAuthor;
|
|
330
|
-
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));
|
|
331
|
-
if (!author) author = new User(this.client, this.data.author);
|
|
332
|
-
this.#cachedAuthor = author;
|
|
333
|
-
return this.#cachedAuthor;
|
|
334
|
-
}
|
|
335
|
-
get createdAt() {
|
|
336
|
-
return new Date(this.data.timestamp);
|
|
337
|
-
}
|
|
338
|
-
get editedAt() {
|
|
339
|
-
return this.data.edited_timestamp ? new Date(this.data.edited_timestamp) : void 0;
|
|
340
|
-
}
|
|
341
|
-
get createdTimestamp() {
|
|
342
|
-
return this.createdAt.getTime();
|
|
612
|
+
get totalMessageSent() {
|
|
613
|
+
return this.data.total_message_sent;
|
|
343
614
|
}
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
615
|
+
};
|
|
616
|
+
|
|
617
|
+
//#endregion
|
|
618
|
+
//#region src/lib/managers/client/ClientChannelManager.ts
|
|
619
|
+
var ClientChannelManager = class ClientChannelManager {
|
|
620
|
+
constructor(client) {
|
|
621
|
+
Object.defineProperty(this, "client", {
|
|
622
|
+
value: client,
|
|
623
|
+
enumerable: false,
|
|
624
|
+
writable: false
|
|
625
|
+
});
|
|
349
626
|
}
|
|
350
|
-
|
|
351
|
-
|
|
627
|
+
async fetch(id, force = false) {
|
|
628
|
+
if (!force) {
|
|
629
|
+
const cached = this.client.cache.channels.get(id);
|
|
630
|
+
if (cached) return cached;
|
|
631
|
+
}
|
|
632
|
+
const data = await this.client.rest.get(discord_api_types_v10.Routes.channel(id)).catch(() => void 0);
|
|
633
|
+
if (!data) return;
|
|
634
|
+
const existing = this.client.cache.channels.get(id);
|
|
635
|
+
if (existing && existing.type === data.type) {
|
|
636
|
+
existing._patch(data);
|
|
637
|
+
return existing;
|
|
638
|
+
}
|
|
639
|
+
const newChannel = ClientChannelManager.create(this.client, data);
|
|
640
|
+
this.client.cache.channels.set(id, newChannel);
|
|
641
|
+
return newChannel;
|
|
642
|
+
}
|
|
643
|
+
async delete(id, force = false) {
|
|
644
|
+
const channel = this.client.cache.channels.get(id);
|
|
645
|
+
if (!channel && !force) return;
|
|
646
|
+
await this.client.rest.delete(discord_api_types_v10.Routes.channel(id));
|
|
647
|
+
if (channel) {
|
|
648
|
+
this.client.cache.channels.delete(id);
|
|
649
|
+
if (channel.inGuild()) channel.guild.channels.delete(id);
|
|
650
|
+
}
|
|
651
|
+
return channel;
|
|
352
652
|
}
|
|
353
|
-
async
|
|
354
|
-
const
|
|
355
|
-
|
|
356
|
-
this
|
|
357
|
-
|
|
653
|
+
async create(guildId, payload) {
|
|
654
|
+
const data = await this.client.rest.post(discord_api_types_v10.Routes.guildChannels(guildId), { body: payload });
|
|
655
|
+
const channel = ClientChannelManager.create(this.client, data);
|
|
656
|
+
this.client.cache.channels.set(channel.id, channel);
|
|
657
|
+
if (channel.inGuild()) channel.guild.channels.set(channel.id, channel);
|
|
658
|
+
return channel;
|
|
358
659
|
}
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
*
|
|
365
|
-
* @param force - Whether to bypass the cache and force a request to the API.
|
|
366
|
-
* @returns A promise that resolves to the `User` who authored this message.
|
|
367
|
-
*/
|
|
368
|
-
async fetchAuthor(force = false) {
|
|
369
|
-
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));
|
|
370
|
-
return this.client.helper.fetchUser(this.data.author.id, force);
|
|
660
|
+
async crosspost(channelId, messageId) {
|
|
661
|
+
const data = await this.client.rest.post(discord_api_types_v10.Routes.channelMessageCrosspost(channelId, messageId));
|
|
662
|
+
const message = new Message(this.client, data);
|
|
663
|
+
if (this.client.cache.isModuleEnabled("messages")) await this.client.cache.messages.set(message.id, message);
|
|
664
|
+
return message;
|
|
371
665
|
}
|
|
372
|
-
async
|
|
373
|
-
|
|
666
|
+
async createMessage(channelId, options) {
|
|
667
|
+
if (typeof options === "string") options = { content: options };
|
|
668
|
+
const data = this.client.rest.post(discord_api_types_v10.Routes.channelMessages(channelId), { body: ClientChannelManager.createMessagePayload(options) });
|
|
669
|
+
const message = new Message(this.client, await data);
|
|
670
|
+
if (this.client.cache.isModuleEnabled("messages")) await this.client.cache.messages.set(message.id, message);
|
|
671
|
+
return message;
|
|
374
672
|
}
|
|
375
|
-
async
|
|
376
|
-
|
|
673
|
+
async editMessage(channelId, messageId, options) {
|
|
674
|
+
if (typeof options === "string") options = { content: options };
|
|
675
|
+
const data = await this.client.rest.patch(discord_api_types_v10.Routes.channelMessage(channelId, messageId), { body: ClientChannelManager.createMessagePayload(options) });
|
|
676
|
+
let message;
|
|
677
|
+
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));
|
|
678
|
+
else message = new Message(this.client, data);
|
|
679
|
+
return message;
|
|
377
680
|
}
|
|
378
|
-
async
|
|
379
|
-
|
|
681
|
+
async deleteMessage(channelId, messageId, force = false) {
|
|
682
|
+
let message;
|
|
683
|
+
if (!force && this.client.cache.isModuleEnabled("messages")) {
|
|
684
|
+
message = await this.client.cache.messages.get(messageId);
|
|
685
|
+
if (!message) return;
|
|
686
|
+
}
|
|
687
|
+
await this.client.rest.delete(discord_api_types_v10.Routes.channelMessage(channelId, messageId));
|
|
688
|
+
if (this.client.cache.isModuleEnabled("messages")) await this.client.cache.messages.delete(messageId);
|
|
689
|
+
return message;
|
|
380
690
|
}
|
|
381
|
-
async
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
...
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
691
|
+
async replyMessage(channelId, messageId, options) {
|
|
692
|
+
if (typeof options === "string") options = { content: options };
|
|
693
|
+
return this.createMessage(channelId, {
|
|
694
|
+
...options,
|
|
695
|
+
messageReference: {
|
|
696
|
+
channel_id: channelId,
|
|
697
|
+
message_id: messageId
|
|
698
|
+
}
|
|
699
|
+
});
|
|
388
700
|
}
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
701
|
+
resolve(data) {
|
|
702
|
+
return this.client.cache.resolveLocal(this.client.cache.channels, data.id, () => ClientChannelManager.create(this.client, data), (c) => c?._patch(data));
|
|
703
|
+
}
|
|
704
|
+
static create(client, data) {
|
|
705
|
+
switch (data.type) {
|
|
706
|
+
case discord_api_types_v10.ChannelType.GuildText: return new GuildTextChannel(client, data);
|
|
707
|
+
case discord_api_types_v10.ChannelType.GuildVoice: return new GuildVoiceChannel(client, data);
|
|
708
|
+
case discord_api_types_v10.ChannelType.GuildStageVoice: return new GuildStageVoiceChannel(client, data);
|
|
709
|
+
case discord_api_types_v10.ChannelType.GuildAnnouncement: return new GuildAnnouncementChannel(client, data);
|
|
710
|
+
case discord_api_types_v10.ChannelType.DM: return new DMChannel(client, data);
|
|
711
|
+
case discord_api_types_v10.ChannelType.GuildForum: return new GuildForumChannel(client, data);
|
|
712
|
+
case discord_api_types_v10.ChannelType.PublicThread:
|
|
713
|
+
case discord_api_types_v10.ChannelType.PrivateThread:
|
|
714
|
+
case discord_api_types_v10.ChannelType.AnnouncementThread: return new ThreadChannel(client, data);
|
|
401
715
|
}
|
|
402
|
-
|
|
403
|
-
client.cache.channels.set(this.channelId, channel);
|
|
404
|
-
return channel;
|
|
716
|
+
return new BaseChannel(client, data);
|
|
405
717
|
}
|
|
406
|
-
|
|
407
|
-
return this.
|
|
718
|
+
joinThread(threadId) {
|
|
719
|
+
return this.client.rest.post(discord_api_types_v10.Routes.threadMembers(threadId));
|
|
408
720
|
}
|
|
409
|
-
|
|
410
|
-
return
|
|
721
|
+
static createMessagePayload(options) {
|
|
722
|
+
return {
|
|
723
|
+
content: options.content,
|
|
724
|
+
tts: options.tts,
|
|
725
|
+
embeds: options.embeds,
|
|
726
|
+
allowed_mentions: options.allowedMentions,
|
|
727
|
+
message_reference: options.messageReference,
|
|
728
|
+
flags: options.flags
|
|
729
|
+
};
|
|
411
730
|
}
|
|
412
731
|
};
|
|
413
732
|
|
|
414
|
-
//#endregion
|
|
415
|
-
//#region src/lib/structures/channel/GuildTextChannel.ts
|
|
416
|
-
var GuildTextChannel = class extends (0, tiny_mixin.applyMixins)(BaseChannel, [GuildChannelMixin, TextBasedChannelMixin]) {};
|
|
417
|
-
|
|
418
|
-
//#endregion
|
|
419
|
-
//#region src/lib/structures/channel/GuildVoiceChannel.ts
|
|
420
|
-
var GuildVoiceChannel = class extends (0, tiny_mixin.applyMixins)(BaseChannel, [
|
|
421
|
-
GuildChannelMixin,
|
|
422
|
-
TextBasedChannelMixin,
|
|
423
|
-
VoiceBasedChannelMixin
|
|
424
|
-
]) {};
|
|
425
|
-
|
|
426
|
-
//#endregion
|
|
427
|
-
//#region src/lib/utils/channel.ts
|
|
428
|
-
function createChannel(client, data) {
|
|
429
|
-
switch (data.type) {
|
|
430
|
-
case discord_api_types_v10.ChannelType.GuildText: return new GuildTextChannel(client, data);
|
|
431
|
-
case discord_api_types_v10.ChannelType.GuildVoice: return new GuildVoiceChannel(client, data);
|
|
432
|
-
case discord_api_types_v10.ChannelType.DM: return new DMChannel(client, data);
|
|
433
|
-
default: return null;
|
|
434
|
-
}
|
|
435
|
-
}
|
|
436
|
-
|
|
437
733
|
//#endregion
|
|
438
734
|
//#region src/lib/structures/Guild.ts
|
|
439
735
|
var Guild = class extends BaseStructure {
|
|
@@ -476,7 +772,7 @@ var Guild = class extends BaseStructure {
|
|
|
476
772
|
for (const id of this.channels.keys()) this.client.cache.channels.delete(id);
|
|
477
773
|
this.channels.clear();
|
|
478
774
|
for (const channelData of this.data.channels) {
|
|
479
|
-
const channel =
|
|
775
|
+
const channel = ClientChannelManager.create(this.client, channelData);
|
|
480
776
|
if (channel) {
|
|
481
777
|
this.channels.set(channel.id, channel);
|
|
482
778
|
this.client.cache.channels.set(channel.id, channel);
|
|
@@ -487,7 +783,7 @@ var Guild = class extends BaseStructure {
|
|
|
487
783
|
|
|
488
784
|
//#endregion
|
|
489
785
|
//#region src/lib/client/ClientHelper.ts
|
|
490
|
-
var ClientHelper = class
|
|
786
|
+
var ClientHelper = class {
|
|
491
787
|
constructor(client) {
|
|
492
788
|
Object.defineProperty(this, "client", {
|
|
493
789
|
value: client,
|
|
@@ -530,30 +826,6 @@ var ClientHelper = class ClientHelper {
|
|
|
530
826
|
await this.client.rest.delete(discord_api_types_v10.Routes.channelMessage(channelId, messageId));
|
|
531
827
|
if (this.client.cache.isModuleEnabled("messages")) await this.client.cache.messages.delete(messageId);
|
|
532
828
|
}
|
|
533
|
-
async createMessage(channelId, options) {
|
|
534
|
-
if (typeof options === "string") options = { content: options };
|
|
535
|
-
const data = this.client.rest.post(discord_api_types_v10.Routes.channelMessages(channelId), { body: ClientHelper.toAPICreateMessagePayload(options) });
|
|
536
|
-
const message = new Message(this.client, await data);
|
|
537
|
-
if (this.client.cache.isModuleEnabled("messages")) await this.client.cache.messages.set(message.id, message);
|
|
538
|
-
return message;
|
|
539
|
-
}
|
|
540
|
-
async editMessage(channelId, messageId, options) {
|
|
541
|
-
if (typeof options === "string") options = { content: options };
|
|
542
|
-
const data = await this.client.rest.patch(discord_api_types_v10.Routes.channelMessage(channelId, messageId), { body: ClientHelper.toAPICreateMessagePayload(options) });
|
|
543
|
-
let message;
|
|
544
|
-
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));
|
|
545
|
-
else message = new Message(this.client, data);
|
|
546
|
-
return message;
|
|
547
|
-
}
|
|
548
|
-
async replyMessage(channelId, messageId, options) {
|
|
549
|
-
return this.createMessage(channelId, {
|
|
550
|
-
...options,
|
|
551
|
-
messageReference: {
|
|
552
|
-
channel_id: channelId,
|
|
553
|
-
message_id: messageId
|
|
554
|
-
}
|
|
555
|
-
});
|
|
556
|
-
}
|
|
557
829
|
async fetchGuild(guildId, force = false) {
|
|
558
830
|
let guild = this.client.cache.guilds.get(guildId);
|
|
559
831
|
if (!guild || force) {
|
|
@@ -563,26 +835,14 @@ var ClientHelper = class ClientHelper {
|
|
|
563
835
|
}
|
|
564
836
|
return guild;
|
|
565
837
|
}
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
if (!channel || force) {
|
|
569
|
-
const data = await this.client.rest.get(discord_api_types_v10.Routes.channel(channelId));
|
|
570
|
-
channel = createChannel(this.client, data) ?? void 0;
|
|
571
|
-
if (!channel) throw new Error(`Channel not found: ${channelId}`);
|
|
572
|
-
this.client.cache.channels.set(channelId, channel);
|
|
573
|
-
if (channel.inGuild()) channel.guild.channels.set(channelId, channel);
|
|
574
|
-
}
|
|
575
|
-
return channel;
|
|
838
|
+
fetchChannel(channelId, force = false) {
|
|
839
|
+
return this.client.channels.fetch(channelId, force);
|
|
576
840
|
}
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
allowed_mentions: options.allowedMentions,
|
|
583
|
-
message_reference: options.messageReference,
|
|
584
|
-
flags: options.flags
|
|
585
|
-
};
|
|
841
|
+
async crosspostMessage(channelId, messageId) {
|
|
842
|
+
const data = await this.client.rest.post(discord_api_types_v10.Routes.channelMessageCrosspost(channelId, messageId));
|
|
843
|
+
const message = new Message(this.client, data);
|
|
844
|
+
if (this.client.cache.isModuleEnabled("messages")) await this.client.cache.messages.set(message.id, message);
|
|
845
|
+
return message;
|
|
586
846
|
}
|
|
587
847
|
};
|
|
588
848
|
|
|
@@ -591,6 +851,7 @@ var ClientHelper = class ClientHelper {
|
|
|
591
851
|
let Partial = /* @__PURE__ */ function(Partial) {
|
|
592
852
|
Partial[Partial["Message"] = 0] = "Message";
|
|
593
853
|
Partial[Partial["User"] = 1] = "User";
|
|
854
|
+
Partial[Partial["Channel"] = 2] = "Channel";
|
|
594
855
|
return Partial;
|
|
595
856
|
}({});
|
|
596
857
|
|
|
@@ -665,6 +926,12 @@ var LocalCacheAdapter = class extends BaseCacheAdapter {
|
|
|
665
926
|
find(filter) {
|
|
666
927
|
for (const entry of this.collection.values()) if (filter(entry.value)) return entry.value;
|
|
667
928
|
}
|
|
929
|
+
forEach(callback) {
|
|
930
|
+
for (const [key, entry] of this.collection) callback(entry.value, key);
|
|
931
|
+
}
|
|
932
|
+
map(callback) {
|
|
933
|
+
return this.collection.map((entry, key) => callback(entry.value, key));
|
|
934
|
+
}
|
|
668
935
|
sweep(filter) {
|
|
669
936
|
for (const [key, entry] of this.collection) if (filter(entry.value)) this.delete(key);
|
|
670
937
|
}
|
|
@@ -719,7 +986,7 @@ var HybridCache = class {
|
|
|
719
986
|
};
|
|
720
987
|
|
|
721
988
|
//#endregion
|
|
722
|
-
//#region src/lib/client/ClientCacheManager.ts
|
|
989
|
+
//#region src/lib/managers/client/ClientCacheManager.ts
|
|
723
990
|
var ClientCacheManager = class {
|
|
724
991
|
channels = new LocalCacheAdapter();
|
|
725
992
|
guilds = new LocalCacheAdapter();
|
|
@@ -780,31 +1047,49 @@ function registerHandler(event, handler) {
|
|
|
780
1047
|
|
|
781
1048
|
//#endregion
|
|
782
1049
|
//#region src/lib/client/dispatches/handlers/message.ts
|
|
783
|
-
async function
|
|
1050
|
+
async function ensureMessageCache(client, payload) {
|
|
784
1051
|
let message;
|
|
785
1052
|
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));
|
|
786
1053
|
else message = new Message(client, payload.d);
|
|
787
|
-
|
|
788
|
-
client.emit(payload.t === discord_api_types_v10.GatewayDispatchEvents.MessageUpdate ? "messageUpdate" : "messageCreate", message);
|
|
1054
|
+
return message;
|
|
789
1055
|
}
|
|
790
|
-
registerHandler(discord_api_types_v10.GatewayDispatchEvents.MessageCreate,
|
|
791
|
-
|
|
1056
|
+
registerHandler(discord_api_types_v10.GatewayDispatchEvents.MessageCreate, async (client, payload) => {
|
|
1057
|
+
const message = await ensureMessageCache(client, payload);
|
|
1058
|
+
message.channel.data.last_message_id = message.id;
|
|
1059
|
+
if (message.channel.isThread()) {
|
|
1060
|
+
message.channel.data.message_count = (message.channel.data.message_count ?? 0) + 1;
|
|
1061
|
+
message.channel.data.total_message_sent = (message.channel.data.total_message_sent ?? 0) + 1;
|
|
1062
|
+
}
|
|
1063
|
+
if (message.partial && !client.options.partials.has(Partial.Message)) return;
|
|
1064
|
+
if (message.channel.partial && !client.options.partials.has(Partial.Channel)) return;
|
|
1065
|
+
client.emit("messageCreate", message);
|
|
1066
|
+
});
|
|
1067
|
+
registerHandler(discord_api_types_v10.GatewayDispatchEvents.MessageUpdate, async (client, payload) => {
|
|
1068
|
+
const message = await ensureMessageCache(client, payload);
|
|
1069
|
+
if (message.partial && !client.options.partials.has(Partial.Message)) return;
|
|
1070
|
+
if (message.channel.partial && !client.options.partials.has(Partial.Channel)) return;
|
|
1071
|
+
client.emit("messageUpdate", message);
|
|
1072
|
+
});
|
|
792
1073
|
registerHandler(discord_api_types_v10.GatewayDispatchEvents.MessageDelete, async (client, payload) => {
|
|
793
1074
|
let message;
|
|
794
1075
|
if (client.cache.isModuleEnabled("messages")) message = await client.cache.messages.get(payload.d.id);
|
|
795
1076
|
if (!message) message = new Message(client, payload.d);
|
|
1077
|
+
if (message.channel.isThread()) message.channel.data.message_count = Math.min((message.channel.data.message_count ?? 0) - 1, 0);
|
|
796
1078
|
client.emit("messageDelete", message);
|
|
797
1079
|
});
|
|
798
1080
|
|
|
799
1081
|
//#endregion
|
|
800
1082
|
//#region src/lib/client/dispatches/handlers/guild.ts
|
|
801
|
-
|
|
802
|
-
const guild =
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
registerHandler(discord_api_types_v10.GatewayDispatchEvents.GuildUpdate,
|
|
1083
|
+
registerHandler(discord_api_types_v10.GatewayDispatchEvents.GuildCreate, (client, payload) => {
|
|
1084
|
+
const guild = client.cache.resolveLocal(client.cache.guilds, payload.d.id, () => new Guild(client, payload.d), (g) => g._patch(payload.d));
|
|
1085
|
+
for (const data of payload.d.channels) client.channels.resolve(data);
|
|
1086
|
+
for (const thread of payload.d.threads) client.channels.resolve(thread);
|
|
1087
|
+
client.emit(payload.d.unavailable ? "guildCreate" : "guildAvailable", guild);
|
|
1088
|
+
});
|
|
1089
|
+
registerHandler(discord_api_types_v10.GatewayDispatchEvents.GuildUpdate, (client, payload) => {
|
|
1090
|
+
const guild = client.cache.resolveLocal(client.cache.guilds, payload.d.id, () => new Guild(client, payload.d), (g) => g._patch(payload.d));
|
|
1091
|
+
client.emit("guildUpdate", guild);
|
|
1092
|
+
});
|
|
808
1093
|
registerHandler(discord_api_types_v10.GatewayDispatchEvents.GuildDelete, async (client, payload) => {
|
|
809
1094
|
const guild = client.cache.guilds.get(payload.d.id);
|
|
810
1095
|
if (!guild) return;
|
|
@@ -816,20 +1101,28 @@ registerHandler(discord_api_types_v10.GatewayDispatchEvents.GuildDelete, async (
|
|
|
816
1101
|
//#endregion
|
|
817
1102
|
//#region src/lib/client/dispatches/handlers/channel.ts
|
|
818
1103
|
async function onCreateOrUpdate(client, payload) {
|
|
819
|
-
|
|
820
|
-
if (
|
|
1104
|
+
let channel = client.cache.channels.get(payload.d.id);
|
|
1105
|
+
if (channel && channel.type === payload.d.type) channel._patch(payload.d);
|
|
1106
|
+
else {
|
|
1107
|
+
channel = ClientChannelManager.create(client, payload.d);
|
|
1108
|
+
client.cache.channels.set(payload.d.id, channel);
|
|
1109
|
+
}
|
|
821
1110
|
if (channel.inGuild() && !channel.guild.channels.has(channel.id)) channel.guild.channels.set(channel.id, channel);
|
|
1111
|
+
if (channel.partial && !client.options.partials.has(Partial.Channel)) return;
|
|
822
1112
|
client.emit(payload.t === discord_api_types_v10.GatewayDispatchEvents.ChannelCreate ? "channelCreate" : "channelUpdate", channel);
|
|
823
1113
|
}
|
|
824
1114
|
registerHandler(discord_api_types_v10.GatewayDispatchEvents.ChannelCreate, onCreateOrUpdate);
|
|
825
1115
|
registerHandler(discord_api_types_v10.GatewayDispatchEvents.ChannelUpdate, onCreateOrUpdate);
|
|
826
|
-
registerHandler(discord_api_types_v10.GatewayDispatchEvents.ChannelDelete, (client, payload) => {
|
|
827
|
-
const channel = client.
|
|
1116
|
+
registerHandler(discord_api_types_v10.GatewayDispatchEvents.ChannelDelete, async (client, payload) => {
|
|
1117
|
+
const channel = client.channels.resolve(payload.d);
|
|
828
1118
|
const guild = client.cache.guilds.get(payload.d.guild_id);
|
|
829
1119
|
if (guild) guild.channels.delete(payload.d.id);
|
|
830
|
-
if (!channel) return;
|
|
831
1120
|
client.cache.channels.delete(payload.d.id);
|
|
832
|
-
client.emit("channelDelete", channel);
|
|
1121
|
+
if (!channel.partial || client.options.partials.has(Partial.Channel)) client.emit("channelDelete", channel);
|
|
1122
|
+
if (client.cache.isModuleEnabled("messages")) await Promise.all(client.cache.messages.local.map((message) => {
|
|
1123
|
+
if (message.channelId !== payload.d.id) return;
|
|
1124
|
+
return client.cache.messages.delete(message.id);
|
|
1125
|
+
}));
|
|
833
1126
|
});
|
|
834
1127
|
|
|
835
1128
|
//#endregion
|
|
@@ -842,14 +1135,65 @@ registerHandler(discord_api_types_v10.GatewayDispatchEvents.UserUpdate, async (c
|
|
|
842
1135
|
client.emit("userUpdate", user);
|
|
843
1136
|
});
|
|
844
1137
|
|
|
1138
|
+
//#endregion
|
|
1139
|
+
//#region src/lib/client/dispatches/handlers/thread.ts
|
|
1140
|
+
function resolveThread(client, payload) {
|
|
1141
|
+
let thread = client.cache.channels.get(payload.id);
|
|
1142
|
+
if (!thread?.isThread()) {
|
|
1143
|
+
thread = ClientChannelManager.create(client, payload);
|
|
1144
|
+
client.cache.channels.set(payload.id, thread);
|
|
1145
|
+
thread.guild.channels.set(payload.id, thread);
|
|
1146
|
+
} else thread._patch(payload);
|
|
1147
|
+
if ("member" in payload) {}
|
|
1148
|
+
return thread;
|
|
1149
|
+
}
|
|
1150
|
+
registerHandler(discord_api_types_v10.GatewayDispatchEvents.ThreadCreate, (client, payload) => {
|
|
1151
|
+
const thread = resolveThread(client, payload.d);
|
|
1152
|
+
if (thread.partial && !client.options.partials.has(Partial.Channel)) return;
|
|
1153
|
+
client.emit("threadCreate", thread);
|
|
1154
|
+
});
|
|
1155
|
+
registerHandler(discord_api_types_v10.GatewayDispatchEvents.ThreadUpdate, (client, payload) => {
|
|
1156
|
+
const thread = resolveThread(client, payload.d);
|
|
1157
|
+
if (thread.partial && !client.options.partials.has(Partial.Channel)) return;
|
|
1158
|
+
client.emit("threadUpdate", thread);
|
|
1159
|
+
});
|
|
1160
|
+
registerHandler(discord_api_types_v10.GatewayDispatchEvents.ThreadDelete, (client, payload) => {
|
|
1161
|
+
let thread = client.cache.channels.get(payload.d.id);
|
|
1162
|
+
if (thread) client.cache.channels.delete(payload.d.id);
|
|
1163
|
+
else thread = ClientChannelManager.create(client, {
|
|
1164
|
+
id: payload.d.id,
|
|
1165
|
+
guild_id: payload.d.guild_id,
|
|
1166
|
+
parent_id: payload.d.parent_id,
|
|
1167
|
+
type: payload.d.type
|
|
1168
|
+
});
|
|
1169
|
+
if (!thread.isThread()) return;
|
|
1170
|
+
if (thread.partial && !client.options.partials.has(Partial.Channel)) return;
|
|
1171
|
+
client.emit("threadDelete", thread);
|
|
1172
|
+
});
|
|
1173
|
+
registerHandler(discord_api_types_v10.GatewayDispatchEvents.ThreadListSync, (client, payload) => {
|
|
1174
|
+
for (const thread of payload.d.threads) resolveThread(client, thread);
|
|
1175
|
+
});
|
|
1176
|
+
|
|
1177
|
+
//#endregion
|
|
1178
|
+
//#region src/lib/client/dispatches/handlers/member.ts
|
|
1179
|
+
registerHandler(discord_api_types_v10.GatewayDispatchEvents.TypingStart, async (client, payload) => {
|
|
1180
|
+
const typing = new Typing(client, payload.d);
|
|
1181
|
+
client.emit("typingStart", typing);
|
|
1182
|
+
});
|
|
1183
|
+
|
|
845
1184
|
//#endregion
|
|
846
1185
|
//#region src/lib/client/Client.ts
|
|
847
1186
|
var Client = class extends node_events.default {
|
|
848
1187
|
options;
|
|
849
1188
|
shards;
|
|
850
1189
|
rest;
|
|
1190
|
+
/**
|
|
1191
|
+
* @private
|
|
1192
|
+
* @deprecated
|
|
1193
|
+
*/
|
|
851
1194
|
helper;
|
|
852
1195
|
cache;
|
|
1196
|
+
channels;
|
|
853
1197
|
#user;
|
|
854
1198
|
#ready = false;
|
|
855
1199
|
constructor(options, rest) {
|
|
@@ -873,6 +1217,7 @@ var Client = class extends node_events.default {
|
|
|
873
1217
|
intents: this.options.intents.toBigInt()
|
|
874
1218
|
}, rest);
|
|
875
1219
|
this.cache = new ClientCacheManager(this.options.cache);
|
|
1220
|
+
this.channels = new ClientChannelManager(this);
|
|
876
1221
|
this.helper = new ClientHelper(this);
|
|
877
1222
|
this.#setupShardsListeners();
|
|
878
1223
|
}
|
|
@@ -949,6 +1294,7 @@ Object.defineProperty(exports, 'DEFAULT_REST_OPTIONS', {
|
|
|
949
1294
|
return _bakit_rest.DEFAULT_REST_OPTIONS;
|
|
950
1295
|
}
|
|
951
1296
|
});
|
|
1297
|
+
exports.DMChannel = DMChannel;
|
|
952
1298
|
Object.defineProperty(exports, 'DiscordAPIV10', {
|
|
953
1299
|
enumerable: true,
|
|
954
1300
|
get: function () {
|
|
@@ -962,6 +1308,10 @@ Object.defineProperty(exports, 'DiscordHTTPError', {
|
|
|
962
1308
|
}
|
|
963
1309
|
});
|
|
964
1310
|
exports.Guild = Guild;
|
|
1311
|
+
exports.GuildAnnouncementChannel = GuildAnnouncementChannel;
|
|
1312
|
+
exports.GuildCategory = GuildCategory;
|
|
1313
|
+
exports.GuildForumChannel = GuildForumChannel;
|
|
1314
|
+
exports.GuildStageVoiceChannel = GuildStageVoiceChannel;
|
|
965
1315
|
exports.GuildTextChannel = GuildTextChannel;
|
|
966
1316
|
exports.GuildVoiceChannel = GuildVoiceChannel;
|
|
967
1317
|
exports.HybridCache = HybridCache;
|
|
@@ -1041,6 +1391,8 @@ Object.defineProperty(exports, 'ShardingManager', {
|
|
|
1041
1391
|
return _bakit_gateway.ShardingManager;
|
|
1042
1392
|
}
|
|
1043
1393
|
});
|
|
1394
|
+
exports.Tag = Tag;
|
|
1395
|
+
exports.ThreadChannel = ThreadChannel;
|
|
1044
1396
|
Object.defineProperty(exports, 'TransportClient', {
|
|
1045
1397
|
enumerable: true,
|
|
1046
1398
|
get: function () {
|
|
@@ -1053,6 +1405,7 @@ Object.defineProperty(exports, 'TransportServer', {
|
|
|
1053
1405
|
return _bakit_service.TransportServer;
|
|
1054
1406
|
}
|
|
1055
1407
|
});
|
|
1408
|
+
exports.Typing = Typing;
|
|
1056
1409
|
exports.User = User;
|
|
1057
1410
|
Object.defineProperty(exports, 'capitalize', {
|
|
1058
1411
|
enumerable: true,
|