bakit 3.0.1 → 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 CHANGED
@@ -1 +1,1488 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,a)=>(a=n==null?{}:e(i(n)),o(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));let c=require(`@bakit/gateway`),l=require(`@bakit/rest`),u=require(`@bakit/service`),d=require(`@bakit/utils`),f=require(`node:events`);f=s(f);let p=require(`@discordjs/collection`),m=require(`discord-api-types/v10`);m=s(m);let h=require(`tiny-mixin`);var g=class{constructor(e){Object.defineProperty(this,`client`,{value:e,enumerable:!1,writable:!1})}toJSON(){return{}}},_=class extends g{constructor(e,t){super(e),this.data=t}get id(){return this.data.id}get username(){return this.data.username}get discriminator(){return this.data.discriminator}get globalName(){return this.data.global_name}get tag(){return this.discriminator!==`0`&&this.discriminator!==`0000`?`${this.username}#${this.discriminator}`:this.username}get displayName(){return this.globalName??this.tag}get avatar(){return this.data.avatar??void 0}get bot(){return!!this.data.bot}get system(){return!!this.data.system}get mfaEnabled(){return this.data.mfa_enabled}get locale(){return this.data.locale}get verified(){return this.data.verified}get email(){return this.data.email}get flags(){return this.data.flags}get premiumType(){return this.data.premium_type}get publicFlags(){return this.data.public_flags}get banner(){return this.data.banner}get accentColor(){return this.data.accent_color??void 0}get createdAt(){return(0,d.getSnowflakeDate)(this.id)}get createdTimestamp(){return this.createdAt.getTime()}get hexAccentColor(){return this.accentColor===void 0?void 0:`#${this.accentColor.toString(16).padStart(6,`0`)}`}get defaultAvatarURL(){return`https://cdn.discordapp.com/embed/avatars/${this.discriminator!==`0`&&this.discriminator!==`0000`?BigInt(this.discriminator)%5n:(BigInt(this.id)>>22n)%6n}.png`}getAvatarURL(e){if(!this.avatar)return;let t=this.avatar.startsWith(`a_`),n=e?.extension??(t?`gif`:`png`),r=e?.size?`?size=${e.size}`:``;return`https://cdn.discordapp.com/avatars/${this.id}/${this.avatar}.${n}${r}`}getDisplayAvatarURL(e){return this.getAvatarURL(e)??this.defaultAvatarURL}equals(e){return typeof e==`string`?e===this.id:e.id===this.id&&e.username===this.username&&e.discriminator===this.discriminator&&e.bot===this.bot&&e.createdTimestamp===this.createdTimestamp}toJSON(){return this.data}toString(){return`<@${this.id}>`}},v=class extends g{cachedAuthor;constructor(e,t){super(e),this.data=t}get partial(){return typeof this.data.content!=`string`||typeof this.data.author!=`object`}get content(){return this.data.content}get id(){return this.data.id}get channelId(){return this.data.channel_id}get channel(){return this.guild.channels.get(this.channelId)}get guildId(){return`guild_id`in this.data?this.data.guild_id:void 0}get guild(){return this.guildId?this.client.guilds.get(this.guildId):void 0}get author(){return this.cachedAuthor??=new _(this.client,this.data.author),this.cachedAuthor}get createdAt(){return new Date(this.data.timestamp)}get editedAt(){return this.data.edited_timestamp?new Date(this.data.edited_timestamp):void 0}get createdTimestamp(){return this.createdAt.getTime()}get editedTimestamp(){return this.editedAt?.getTime()}get url(){return`https://discord.com/channels/${this.guildId??`@me`}/${this.channelId}/${this.id}`}async fetch(){let e=await this.client.helper.fetchMessage(this.channelId,this.id);return this.data=e.data,this.cachedAuthor=e.cachedAuthor,this}async reply(e){return this.client.helper.replyMessage(this.channelId,this.id,e)}async sendToChannel(e){return this.client.helper.createMessage(this.channelId,e)}toJSON(){return this.data}toString(){return this.data.content}},y=class extends g{constructor(e,t){super(e),this.data=t}get id(){return this.data.id}get type(){return this.data.type}toString(){return`<#${this.id}>`}toJSON(){return this.data}isTextBased(){return`send`in this}isVoiceBased(){return`join`in this}inGuild(){return`guild_id`in this.data}_patch(e){this.data={...this.data,...e}}};const b=(0,h.createMixin)(e=>{class t extends e{send(e){return this.client.helper.createMessage(this.id,e)}}return t}),x=(0,h.createMixin)(e=>{class t extends e{}return t}),S=(0,h.createMixin)(e=>{class t extends e{get guildId(){if(!this.data.guild_id)throw Error(`This channel is not a guild channel`);return this.data.guild_id}get guild(){return this.client.guilds.get(this.guildId)}}return t});var C=class extends (0,h.applyMixins)(y,[S,b]){},w=class extends (0,h.applyMixins)(y,[S,b,x]){};function T(e,t){switch(t.type){case m.ChannelType.GuildText:return new C(e,t);case m.ChannelType.GuildVoice:return new w(e,t);default:return null}}var E=class extends g{cachedChannels;constructor(e,t){super(e),this.data=t}get id(){return this.data.id}get name(){return this.data.name}get icon(){return this.data.icon}get banner(){return this.data.banner}get owner(){return this.data.owner_id}get mfaLevel(){return this.data.mfa_level}get verificationLevel(){return this.data.verification_level}get channels(){if(!this.cachedChannels&&(this.cachedChannels=new p.Collection,`channels`in this.data))for(let e of this.data.channels){let t=T(this.client,e);t&&this.cachedChannels.set(t.id,t)}return this.cachedChannels}_patch(e){this.data={...this.data,...e}}},D=class e{constructor(e){Object.defineProperty(this,`client`,{value:e,enumerable:!1,writable:!1})}async fetchMessage(e,t){let n=await this.client.rest.get(m.Routes.channelMessage(e,t));return new v(this.client,n)}async deleteMessage(e,t){return this.client.rest.delete(m.Routes.channelMessage(e,t))}async createMessage(t,n){return this.client.rest.post(m.Routes.channelMessages(t),{body:e.toAPICreateMessagePayload(n)})}async replyMessage(e,t,n){return this.createMessage(e,{...n,messageReference:{channel_id:e,message_id:t}})}async fetchGuild(e){let t=await this.client.rest.get(m.Routes.guild(e));return new E(this.client,t)}static toAPICreateMessagePayload(e){return{content:e.content,tts:e.tts,embeds:e.embeds,allowed_mentions:e.allowedMentions,message_reference:e.messageReference,flags:e.flags}}};let O=function(e){return e[e.Message=0]=`Message`,e[e.User=1]=`User`,e}({});var k=class e{value;constructor(t){this.value=e.resolve(t)}static resolve(e){return Array.isArray(e)?e.reduce((e,t)=>e|BigInt(t),0n):BigInt(e)}has(e){return(this.value&BigInt(e))!==0n}toBigInt(){return this.value}toNumber(){return Number(this.value)}toJSON(){return this.value.toString()}toString(){return this.value.toString()}},A=class extends f.default{options;shards;rest;helper;guilds=new p.Collection;#e;#t=!1;constructor(e,t){super();let n=e.intents instanceof k?e.intents:new k(e.intents),r={shardsPerCluster:e.sharding?.shardsPerCluster??1,totalShards:e.sharding?.totalShards??1};this.options={token:e.token,intents:n,sharding:r,partials:new Set(e.partials??[])},this.rest=t??new l.REST({token:e.token}),this.shards=new c.ShardingManager({...this.options.sharding,token:this.options.token,intents:this.options.intents.toBigInt()},t),this.helper=new D(this),this.#n()}get user(){return this.#e}async login(){if(this.#e||this.shards.ready||this.shards.clusters.size>0)throw Error(`Cannot login twice`);return await this.shards.spawn(),new Promise((e,t)=>{let n=()=>{this.removeListener(`ready`,r),this.removeListener(`error`,i)},r=()=>{n(),e()},i=e=>{n(),t(e)};this.once(`ready`,r),this.once(`error`,i)})}#n(){this.shards.on(`dispatch`,(e,t,n)=>this.#r(t,n)),this.shards.on(`raw`,(e,t,n)=>this.emit(`raw`,t,n)),this.shards.once(`ready`,()=>this.#i())}async#r(e,t){switch(this.emit(`dispatch`,e,t),t.t){case m.GatewayDispatchEvents.Ready:this.#e??=new _(this,t.d.user),this.#i();break;case m.GatewayDispatchEvents.MessageCreate:{let e=new v(this,t.d);if(e.partial&&!this.options.partials.has(O.Message))return;this.emit(`messageCreate`,e);break}case m.GatewayDispatchEvents.MessageUpdate:{let e=new v(this,t.d);if(e.partial&&!this.options.partials.has(O.Message))return;this.emit(`messageUpdate`,e);break}case m.GatewayDispatchEvents.MessageDelete:this.emit(`messageDelete`,{id:t.d.id,channelId:t.d.channel_id,guildId:t.d.guild_id});break;case m.GatewayDispatchEvents.UserUpdate:t.d.id===this.#e?.id&&(this.#e=new _(this,t.d)),this.emit(`userUpdate`,new _(this,t.d));break;case m.GatewayDispatchEvents.GuildCreate:{let e=this.guilds.get(t.d.id);e?e._patch(t.d):e=new E(this,t.d),this.guilds.set(t.d.id,e),t.d.unavailable?this.emit(`guildCreate`,e):this.emit(`guildAvailable`,e);break}case m.GatewayDispatchEvents.GuildDelete:{let e=this.guilds.get(t.d.id);if(!e)return;this.guilds.delete(t.d.id),this.emit(`guildDelete`,e);break}case m.GatewayDispatchEvents.GuildUpdate:{let e=this.guilds.get(t.d.id);e?e._patch(t.d):(e=new E(this,t.d),this.guilds.set(t.d.id,e)),this.emit(`guildUpdate`,e);break}case m.GatewayDispatchEvents.ChannelCreate:{let e=T(this,t.d);if(!e)return;e.inGuild()&&e.guild.channels.set(e.id,e),this.emit(`channelCreate`,e);break}case m.GatewayDispatchEvents.ChannelUpdate:{let e=this.guilds.get(t.d.guild_id);if(!e)return;let n=e.channels.get(t.d.id);if(n)n._patch(t.d);else{if(n=T(this,t.d),!n)return;e.channels.set(t.d.id,n)}this.emit(`channelUpdate`,n);break}case m.GatewayDispatchEvents.ChannelDelete:{let e=this.guilds.get(t.d.guild_id);if(!e)return;let n=e.channels.get(t.d.id);if(!n)return;e.channels.delete(t.d.id),this.emit(`channelDelete`,n);break}}}#i(){this.#t||!this.#e||!this.shards.ready||(this.#t=!0,this.emit(`ready`,this.#e))}};function j(e){return new A(e)}exports.BaseChannel=y,exports.Client=A,exports.ClientHelper=D,Object.defineProperty(exports,`Cluster`,{enumerable:!0,get:function(){return c.Cluster}}),Object.defineProperty(exports,`DEFAULT_REST_OPTIONS`,{enumerable:!0,get:function(){return l.DEFAULT_REST_OPTIONS}}),Object.defineProperty(exports,`DiscordAPIV10`,{enumerable:!0,get:function(){return m}}),Object.defineProperty(exports,`DiscordHTTPError`,{enumerable:!0,get:function(){return l.DiscordHTTPError}}),exports.Guild=E,exports.GuildTextChannel=C,exports.GuildVoiceChannel=w,Object.defineProperty(exports,`Intent`,{enumerable:!0,get:function(){return m.GatewayIntentBits}}),exports.IntentsBitField=k,exports.Message=v,exports.Partial=O,Object.defineProperty(exports,`REST`,{enumerable:!0,get:function(){return l.REST}}),Object.defineProperty(exports,`RESTAdapter`,{enumerable:!0,get:function(){return l.RESTAdapter}}),Object.defineProperty(exports,`RESTMethod`,{enumerable:!0,get:function(){return l.RESTMethod}}),Object.defineProperty(exports,`Service`,{enumerable:!0,get:function(){return u.Service}}),Object.defineProperty(exports,`ServiceDriver`,{enumerable:!0,get:function(){return u.ServiceDriver}}),Object.defineProperty(exports,`ServiceProcess`,{enumerable:!0,get:function(){return u.ServiceProcess}}),Object.defineProperty(exports,`ServiceState`,{enumerable:!0,get:function(){return u.ServiceState}}),Object.defineProperty(exports,`Shard`,{enumerable:!0,get:function(){return c.Shard}}),Object.defineProperty(exports,`ShardState`,{enumerable:!0,get:function(){return c.ShardState}}),Object.defineProperty(exports,`ShardStrategy`,{enumerable:!0,get:function(){return c.ShardStrategy}}),Object.defineProperty(exports,`ShardingManager`,{enumerable:!0,get:function(){return c.ShardingManager}}),Object.defineProperty(exports,`TransportClient`,{enumerable:!0,get:function(){return u.TransportClient}}),Object.defineProperty(exports,`TransportServer`,{enumerable:!0,get:function(){return u.TransportServer}}),exports.User=_,Object.defineProperty(exports,`capitalize`,{enumerable:!0,get:function(){return d.capitalize}}),exports.createClient=j,Object.defineProperty(exports,`createREST`,{enumerable:!0,get:function(){return l.createREST}}),Object.defineProperty(exports,`createRESTAdapter`,{enumerable:!0,get:function(){return l.createRESTAdapter}}),Object.defineProperty(exports,`createService`,{enumerable:!0,get:function(){return u.createService}}),Object.defineProperty(exports,`createTransportClient`,{enumerable:!0,get:function(){return u.createTransportClient}}),Object.defineProperty(exports,`createTransportServer`,{enumerable:!0,get:function(){return u.createTransportServer}}),Object.defineProperty(exports,`instanceToObject`,{enumerable:!0,get:function(){return d.instanceToObject}}),Object.defineProperty(exports,`isCommonJS`,{enumerable:!0,get:function(){return d.isCommonJS}}),Object.defineProperty(exports,`isESM`,{enumerable:!0,get:function(){return d.isESM}}),Object.defineProperty(exports,`isPlainObject`,{enumerable:!0,get:function(){return d.isPlainObject}}),Object.defineProperty(exports,`isPromiseLike`,{enumerable:!0,get:function(){return d.isPromiseLike}}),Object.defineProperty(exports,`promisify`,{enumerable:!0,get:function(){return d.promisify}}),Object.defineProperty(exports,`sleep`,{enumerable:!0,get:function(){return d.sleep}});
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ //#region \0rolldown/runtime.js
3
+ var __create = Object.create;
4
+ var __defProp = Object.defineProperty;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getProtoOf = Object.getPrototypeOf;
8
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
12
+ key = keys[i];
13
+ if (!__hasOwnProp.call(to, key) && key !== except) {
14
+ __defProp(to, key, {
15
+ get: ((k) => from[k]).bind(null, key),
16
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
17
+ });
18
+ }
19
+ }
20
+ }
21
+ return to;
22
+ };
23
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
24
+ value: mod,
25
+ enumerable: true
26
+ }) : target, mod));
27
+
28
+ //#endregion
29
+ let _bakit_gateway = require("@bakit/gateway");
30
+ let _bakit_rest = require("@bakit/rest");
31
+ let _bakit_service = require("@bakit/service");
32
+ let _bakit_utils = require("@bakit/utils");
33
+ let node_events = require("node:events");
34
+ node_events = __toESM(node_events);
35
+ let discord_api_types_v10 = require("discord-api-types/v10");
36
+ discord_api_types_v10 = __toESM(discord_api_types_v10);
37
+ let _discordjs_collection = require("@discordjs/collection");
38
+ let tiny_mixin = require("tiny-mixin");
39
+
40
+ //#region src/lib/structures/BaseStructure.ts
41
+ var BaseStructure = class {
42
+ constructor(client) {
43
+ Object.defineProperty(this, "client", {
44
+ value: client,
45
+ enumerable: false,
46
+ writable: false
47
+ });
48
+ }
49
+ toJSON() {
50
+ return {};
51
+ }
52
+ };
53
+
54
+ //#endregion
55
+ //#region src/lib/structures/User.ts
56
+ var User = class extends BaseStructure {
57
+ constructor(client, data) {
58
+ super(client);
59
+ this.data = data;
60
+ }
61
+ get id() {
62
+ return this.data.id;
63
+ }
64
+ get username() {
65
+ return this.data.username;
66
+ }
67
+ get discriminator() {
68
+ return this.data.discriminator;
69
+ }
70
+ get globalName() {
71
+ return this.data.global_name;
72
+ }
73
+ get tag() {
74
+ return this.discriminator !== "0" && this.discriminator !== "0000" ? `${this.username}#${this.discriminator}` : this.username;
75
+ }
76
+ get displayName() {
77
+ return this.globalName ?? this.tag;
78
+ }
79
+ get avatar() {
80
+ return this.data.avatar ?? void 0;
81
+ }
82
+ get bot() {
83
+ return !!this.data.bot;
84
+ }
85
+ get system() {
86
+ return !!this.data.system;
87
+ }
88
+ get mfaEnabled() {
89
+ return this.data.mfa_enabled;
90
+ }
91
+ get locale() {
92
+ return this.data.locale;
93
+ }
94
+ get verified() {
95
+ return this.data.verified;
96
+ }
97
+ get email() {
98
+ return this.data.email;
99
+ }
100
+ get flags() {
101
+ return this.data.flags;
102
+ }
103
+ get premiumType() {
104
+ return this.data.premium_type;
105
+ }
106
+ get publicFlags() {
107
+ return this.data.public_flags;
108
+ }
109
+ get banner() {
110
+ return this.data.banner;
111
+ }
112
+ get accentColor() {
113
+ return this.data.accent_color ?? void 0;
114
+ }
115
+ get createdAt() {
116
+ return (0, _bakit_utils.getSnowflakeDate)(this.id);
117
+ }
118
+ get createdTimestamp() {
119
+ return this.createdAt.getTime();
120
+ }
121
+ get hexAccentColor() {
122
+ return this.accentColor !== void 0 ? `#${this.accentColor.toString(16).padStart(6, "0")}` : void 0;
123
+ }
124
+ get defaultAvatarURL() {
125
+ return `https://cdn.discordapp.com/embed/avatars/${this.discriminator !== "0" && this.discriminator !== "0000" ? BigInt(this.discriminator) % 5n : (BigInt(this.id) >> 22n) % 6n}.png`;
126
+ }
127
+ getAvatarURL(options) {
128
+ if (!this.avatar) return;
129
+ const isAnimated = this.avatar.startsWith("a_");
130
+ const ext = options?.extension ?? (isAnimated ? "gif" : "png");
131
+ const size = options?.size ? `?size=${options.size}` : "";
132
+ return `https://cdn.discordapp.com/avatars/${this.id}/${this.avatar}.${ext}${size}`;
133
+ }
134
+ getDisplayAvatarURL(options) {
135
+ return this.getAvatarURL(options) ?? this.defaultAvatarURL;
136
+ }
137
+ equals(other) {
138
+ if (typeof other === "string") return other === this.id;
139
+ return other.id === this.id && other.username === this.username && other.discriminator === this.discriminator && other.bot === this.bot && other.createdTimestamp === this.createdTimestamp;
140
+ }
141
+ async createDM(force = false) {
142
+ return this.client.helper.createDM(this.id, force);
143
+ }
144
+ async send(options) {
145
+ return await (await this.createDM()).send(options);
146
+ }
147
+ _patch(data) {
148
+ this.data = {
149
+ ...this.data,
150
+ ...data
151
+ };
152
+ }
153
+ toJSON() {
154
+ return this.data;
155
+ }
156
+ toString() {
157
+ return `<@${this.id}>`;
158
+ }
159
+ };
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
+
343
+ //#endregion
344
+ //#region src/lib/structures/channel/BaseChannel.ts
345
+ var BaseChannel = class extends BaseStructure {
346
+ constructor(client, data) {
347
+ super(client);
348
+ this.data = data;
349
+ }
350
+ get partial() {
351
+ return Object.keys(this.data).length <= 2;
352
+ }
353
+ get id() {
354
+ return this.data.id;
355
+ }
356
+ get type() {
357
+ return this.data.type;
358
+ }
359
+ toString() {
360
+ return `<#${this.id}>`;
361
+ }
362
+ toJSON() {
363
+ return this.data;
364
+ }
365
+ isTextBased() {
366
+ return "send" in this;
367
+ }
368
+ isVoiceBased() {
369
+ return "join" in this;
370
+ }
371
+ isDM() {
372
+ return this.type === discord_api_types_v10.ChannelType.DM;
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
+ }
389
+ inGuild() {
390
+ return "guild_id" in this.data;
391
+ }
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;
396
+ }
397
+ _patch(data) {
398
+ this.data = {
399
+ ...this.data,
400
+ ...data
401
+ };
402
+ }
403
+ };
404
+
405
+ //#endregion
406
+ //#region src/lib/mixins/ChannelMixin.ts
407
+ const TextBasedChannelMixin = (0, tiny_mixin.createMixin)((base) => {
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
+ }
415
+ send(options) {
416
+ return this.client.channels.createMessage(this.id, options);
417
+ }
418
+ }
419
+ return TextBasedChannel;
420
+ });
421
+ const VoiceBasedChannelMixin = (0, tiny_mixin.createMixin)((base) => {
422
+ class VoiceBasedChannel extends base {}
423
+ return VoiceBasedChannel;
424
+ });
425
+ const GuildChannelMixin = (0, tiny_mixin.createMixin)((base) => {
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
+ }
433
+ get guildId() {
434
+ if (!this.data.guild_id) throw new Error("This channel is not a guild channel");
435
+ return this.data.guild_id;
436
+ }
437
+ get guild() {
438
+ return this.client.cache.guilds.get(this.guildId);
439
+ }
440
+ }
441
+ return GuildChannel;
442
+ });
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
+
524
+ //#endregion
525
+ //#region src/lib/structures/channel/DMChannel.ts
526
+ var DMChannel = class extends (0, tiny_mixin.applyMixins)(BaseChannel, [TextBasedChannelMixin]) {
527
+ #cachedRecipients;
528
+ constructor(client, data) {
529
+ super(client, data);
530
+ }
531
+ get recipients() {
532
+ if (!this.#cachedRecipients) {
533
+ this.#cachedRecipients = new _discordjs_collection.Collection();
534
+ for (const recipient of this.data.recipients ?? []) {
535
+ let user;
536
+ if (this.client.cache.isModuleEnabled("users")) user = this.client.cache.resolveLocal(this.client.cache.users.local, recipient.id, () => new User(this.client, recipient), (user) => user._patch(recipient));
537
+ else user = new User(this.client, recipient);
538
+ this.#cachedRecipients.set(recipient.id, user);
539
+ }
540
+ }
541
+ return this.#cachedRecipients;
542
+ }
543
+ get recipientId() {
544
+ const id = (this.data.recipients ?? []).find((user) => user.id !== this.client.user.id)?.id;
545
+ if (!id) throw new Error("No recipients found");
546
+ return id;
547
+ }
548
+ get recipient() {
549
+ const user = this.recipients.get(this.recipientId);
550
+ if (!user) throw new Error("Recipient not found");
551
+ return user;
552
+ }
553
+ async fetch() {
554
+ const data = await this.client.rest.post(discord_api_types_v10.Routes.userChannels(), { body: { recipient_id: this.recipientId } });
555
+ this._patch(data);
556
+ await this.#initRecipientsCache();
557
+ return this;
558
+ }
559
+ send(options) {
560
+ return super.send(options);
561
+ }
562
+ async fetchRecipients(force = false) {
563
+ if (!force && this.data.recipients?.length) {
564
+ await this.#initRecipientsCache();
565
+ return this.#cachedRecipients;
566
+ }
567
+ await this.fetch();
568
+ return this.#cachedRecipients;
569
+ }
570
+ async #initRecipientsCache() {
571
+ this.#cachedRecipients = new _discordjs_collection.Collection();
572
+ for (const recipient of this.data.recipients ?? []) {
573
+ let user;
574
+ if (this.client.cache.isModuleEnabled("users")) user = await this.client.cache.resolve(this.client.cache.users, recipient.id, () => new User(this.client, recipient), (user) => user._patch(recipient));
575
+ else user = new User(this.client, recipient);
576
+ this.#cachedRecipients.set(recipient.id, user);
577
+ }
578
+ }
579
+ _patch(data) {
580
+ super._patch(data);
581
+ this.#cachedRecipients = void 0;
582
+ }
583
+ };
584
+
585
+ //#endregion
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;
590
+ }
591
+ get archived() {
592
+ return this.data.thread_metadata?.archived ?? false;
593
+ }
594
+ get locked() {
595
+ return this.data.thread_metadata?.locked ?? false;
596
+ }
597
+ get autoArchiveDuration() {
598
+ return this.data.thread_metadata?.auto_archive_duration;
599
+ }
600
+ get archiveTimestamp() {
601
+ return this.data.thread_metadata?.archive_timestamp;
602
+ }
603
+ get invitable() {
604
+ return this.data.thread_metadata?.invitable;
605
+ }
606
+ get memberCount() {
607
+ return this.data.member_count;
608
+ }
609
+ get messageCount() {
610
+ return this.data.message_count;
611
+ }
612
+ get totalMessageSent() {
613
+ return this.data.total_message_sent;
614
+ }
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
+ });
626
+ }
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;
652
+ }
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;
659
+ }
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;
665
+ }
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;
672
+ }
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;
680
+ }
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;
690
+ }
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
+ });
700
+ }
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);
715
+ }
716
+ return new BaseChannel(client, data);
717
+ }
718
+ joinThread(threadId) {
719
+ return this.client.rest.post(discord_api_types_v10.Routes.threadMembers(threadId));
720
+ }
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
+ };
730
+ }
731
+ };
732
+
733
+ //#endregion
734
+ //#region src/lib/structures/Guild.ts
735
+ var Guild = class extends BaseStructure {
736
+ channels = new _discordjs_collection.Collection();
737
+ constructor(client, data) {
738
+ super(client);
739
+ this.data = data;
740
+ this.#initChannels();
741
+ }
742
+ get id() {
743
+ return this.data.id;
744
+ }
745
+ get name() {
746
+ return this.data.name;
747
+ }
748
+ get icon() {
749
+ return this.data.icon;
750
+ }
751
+ get banner() {
752
+ return this.data.banner;
753
+ }
754
+ get owner() {
755
+ return this.data.owner_id;
756
+ }
757
+ get mfaLevel() {
758
+ return this.data.mfa_level;
759
+ }
760
+ get verificationLevel() {
761
+ return this.data.verification_level;
762
+ }
763
+ _patch(data) {
764
+ this.data = {
765
+ ...this.data,
766
+ ...data
767
+ };
768
+ this.#initChannels();
769
+ }
770
+ #initChannels() {
771
+ if (!("channels" in this.data)) return;
772
+ for (const id of this.channels.keys()) this.client.cache.channels.delete(id);
773
+ this.channels.clear();
774
+ for (const channelData of this.data.channels) {
775
+ const channel = ClientChannelManager.create(this.client, channelData);
776
+ if (channel) {
777
+ this.channels.set(channel.id, channel);
778
+ this.client.cache.channels.set(channel.id, channel);
779
+ }
780
+ }
781
+ }
782
+ };
783
+
784
+ //#endregion
785
+ //#region src/lib/client/ClientHelper.ts
786
+ var ClientHelper = class {
787
+ constructor(client) {
788
+ Object.defineProperty(this, "client", {
789
+ value: client,
790
+ enumerable: false,
791
+ writable: false
792
+ });
793
+ }
794
+ async fetchUser(userId, force = false) {
795
+ let user;
796
+ if (this.client.cache.isModuleEnabled("users")) user = await this.client.cache.users.get(userId);
797
+ if (!user || force) {
798
+ const data = await this.client.rest.get(discord_api_types_v10.Routes.user(userId));
799
+ if (this.client.cache.isModuleEnabled("users")) user = await this.client.cache.resolve(this.client.cache.users, userId, () => new User(this.client, data), (u) => u._patch(data));
800
+ else user = new User(this.client, data);
801
+ }
802
+ return user;
803
+ }
804
+ async createDM(userId, force = false) {
805
+ if (!force) {
806
+ const channel = this.client.cache.channels.find((c) => c.isDM() && c.recipientId === userId);
807
+ if (channel && channel.isDM()) return channel;
808
+ }
809
+ const data = await this.client.rest.post(discord_api_types_v10.Routes.userChannels(), { body: { recipient_id: userId } });
810
+ const channel = new DMChannel(this.client, data);
811
+ await channel.fetchRecipients();
812
+ this.client.cache.channels.set(channel.id, channel);
813
+ return channel;
814
+ }
815
+ async fetchMessage(channelId, messageId, force = false) {
816
+ let message;
817
+ if (this.client.cache.isModuleEnabled("messages")) message = await this.client.cache.messages.get(messageId);
818
+ if (!message || force) {
819
+ const data = await this.client.rest.get(discord_api_types_v10.Routes.channelMessage(channelId, messageId));
820
+ 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));
821
+ else message = new Message(this.client, data);
822
+ }
823
+ return message;
824
+ }
825
+ async deleteMessage(channelId, messageId) {
826
+ await this.client.rest.delete(discord_api_types_v10.Routes.channelMessage(channelId, messageId));
827
+ if (this.client.cache.isModuleEnabled("messages")) await this.client.cache.messages.delete(messageId);
828
+ }
829
+ async fetchGuild(guildId, force = false) {
830
+ let guild = this.client.cache.guilds.get(guildId);
831
+ if (!guild || force) {
832
+ const data = await this.client.rest.get(discord_api_types_v10.Routes.guild(guildId));
833
+ guild = new Guild(this.client, data);
834
+ this.client.cache.guilds.set(guildId, guild);
835
+ }
836
+ return guild;
837
+ }
838
+ fetchChannel(channelId, force = false) {
839
+ return this.client.channels.fetch(channelId, force);
840
+ }
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;
846
+ }
847
+ };
848
+
849
+ //#endregion
850
+ //#region src/lib/client/Partial.ts
851
+ let Partial = /* @__PURE__ */ function(Partial) {
852
+ Partial[Partial["Message"] = 0] = "Message";
853
+ Partial[Partial["User"] = 1] = "User";
854
+ Partial[Partial["Channel"] = 2] = "Channel";
855
+ return Partial;
856
+ }({});
857
+
858
+ //#endregion
859
+ //#region src/lib/utils/IntentsBitField.ts
860
+ var IntentsBitField = class IntentsBitField {
861
+ value;
862
+ constructor(input) {
863
+ this.value = IntentsBitField.resolve(input);
864
+ }
865
+ static resolve(input) {
866
+ if (Array.isArray(input)) return input.reduce((acc, intent) => acc | BigInt(intent), 0n);
867
+ return BigInt(input);
868
+ }
869
+ has(intent) {
870
+ return (this.value & BigInt(intent)) !== 0n;
871
+ }
872
+ toBigInt() {
873
+ return this.value;
874
+ }
875
+ toNumber() {
876
+ return Number(this.value);
877
+ }
878
+ toJSON() {
879
+ return this.value.toString();
880
+ }
881
+ toString() {
882
+ return this.value.toString();
883
+ }
884
+ };
885
+
886
+ //#endregion
887
+ //#region src/lib/utils/cache/adapters/BaseCacheAdapter.ts
888
+ var BaseCacheAdapter = class {};
889
+
890
+ //#endregion
891
+ //#region src/lib/utils/cache/adapters/LocalCacheAdapter.ts
892
+ var LocalCacheAdapter = class extends BaseCacheAdapter {
893
+ collection = new _discordjs_collection.Collection();
894
+ #sweepTimer;
895
+ get(key) {
896
+ const entry = this.collection.get(key);
897
+ if (!entry) return;
898
+ if (entry.expiresAt && entry.expiresAt < Date.now()) {
899
+ this.collection.delete(key);
900
+ return;
901
+ }
902
+ this.#setupSweepTTL();
903
+ return entry.value;
904
+ }
905
+ set(key, value, ttl) {
906
+ const expiresAt = ttl ? Date.now() + ttl : void 0;
907
+ this.collection.set(key, {
908
+ value,
909
+ expiresAt
910
+ });
911
+ this.#setupSweepTTL();
912
+ }
913
+ delete(key) {
914
+ this.#setupSweepTTL();
915
+ this.collection.delete(key);
916
+ }
917
+ clear() {
918
+ this.collection.clear();
919
+ clearTimeout(this.#sweepTimer);
920
+ this.#sweepTimer = void 0;
921
+ }
922
+ has(key) {
923
+ this.#setupSweepTTL();
924
+ return this.get(key) !== void 0;
925
+ }
926
+ find(filter) {
927
+ for (const entry of this.collection.values()) if (filter(entry.value)) return entry.value;
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
+ }
935
+ sweep(filter) {
936
+ for (const [key, entry] of this.collection) if (filter(entry.value)) this.delete(key);
937
+ }
938
+ sweepTTL() {
939
+ for (const [key, entry] of this.collection) if (entry.expiresAt && entry.expiresAt < Date.now()) this.delete(key);
940
+ }
941
+ #setupSweepTTL() {
942
+ if (!this.collection.size) return;
943
+ if (this.#sweepTimer) return;
944
+ this.#sweepTimer = setTimeout(() => {
945
+ this.#sweepTimer = void 0;
946
+ this.sweepTTL();
947
+ this.#setupSweepTTL();
948
+ }, 1e3);
949
+ }
950
+ };
951
+
952
+ //#endregion
953
+ //#region src/lib/utils/cache/HybridCache.ts
954
+ var HybridCache = class {
955
+ local = new LocalCacheAdapter();
956
+ constructor(remote, defaultTTL) {
957
+ this.remote = remote;
958
+ this.defaultTTL = defaultTTL;
959
+ }
960
+ async get(key) {
961
+ const local = this.local.get(key);
962
+ if (local !== void 0) return local;
963
+ const remote = await this.remote?.get(key);
964
+ if (remote !== void 0) this.local.set(key, remote);
965
+ return remote;
966
+ }
967
+ async sweep(filter) {
968
+ this.local.sweep(filter);
969
+ await this.remote?.sweep(filter);
970
+ }
971
+ async set(key, value, ttl = this.defaultTTL) {
972
+ this.local.set(key, value, ttl);
973
+ await this.remote?.set(key, value, ttl);
974
+ }
975
+ async delete(key) {
976
+ this.local.delete(key);
977
+ await this.remote?.delete(key);
978
+ }
979
+ async clear() {
980
+ this.local.clear();
981
+ await this.remote?.clear();
982
+ }
983
+ async has(key) {
984
+ return await this.get(key) !== void 0;
985
+ }
986
+ };
987
+
988
+ //#endregion
989
+ //#region src/lib/managers/client/ClientCacheManager.ts
990
+ var ClientCacheManager = class {
991
+ channels = new LocalCacheAdapter();
992
+ guilds = new LocalCacheAdapter();
993
+ #users;
994
+ #messages;
995
+ #sweepers = new _discordjs_collection.Collection();
996
+ constructor(options) {
997
+ this.options = options;
998
+ }
999
+ get users() {
1000
+ let options;
1001
+ if (typeof this.options.users === "object") options = this.options.users;
1002
+ else options = { enabled: !!this.options.users };
1003
+ if (!options.enabled) throw new Error("User cache is disabled");
1004
+ if (!this.#users) this.#users = new HybridCache(options.adapter, options.ttl);
1005
+ if (options.sweeper) this.#sweepers.set("users", setInterval(() => this.#users.sweep(options.sweeper.filter), options.sweeper.interval));
1006
+ return this.#users;
1007
+ }
1008
+ get messages() {
1009
+ let options;
1010
+ if (typeof this.options.messages === "object") options = this.options.messages;
1011
+ else options = { enabled: !!this.options.messages };
1012
+ if (!options.enabled) throw new Error("Message cache is disabled");
1013
+ if (!this.#messages) this.#messages = new HybridCache(options.adapter, options.ttl);
1014
+ if (options.sweeper) this.#sweepers.set("messages", setInterval(() => this.#messages.sweep(options.sweeper.filter), options.sweeper.interval));
1015
+ return this.#messages;
1016
+ }
1017
+ isModuleEnabled(module) {
1018
+ return typeof this.options[module] === "object" ? this.options[module].enabled : !!this.options[module];
1019
+ }
1020
+ async resolve(cache, id, factory, patch) {
1021
+ let value = await cache.get(id);
1022
+ if (!value) {
1023
+ value = factory();
1024
+ await cache.set(id, value);
1025
+ }
1026
+ if (patch) patch(value);
1027
+ return value;
1028
+ }
1029
+ resolveLocal(cache, id, factory, patch) {
1030
+ let value = cache.get(id);
1031
+ if (!value) {
1032
+ value = factory();
1033
+ cache.set(id, value);
1034
+ }
1035
+ if (patch) patch(value);
1036
+ return value;
1037
+ }
1038
+ };
1039
+
1040
+ //#endregion
1041
+ //#region src/lib/client/dispatches/registry.ts
1042
+ const handlers = {};
1043
+ function registerHandler(event, handler) {
1044
+ if (handlers[event]) throw new Error(`Handler for ${event} already registered`);
1045
+ handlers[event] = handler;
1046
+ }
1047
+
1048
+ //#endregion
1049
+ //#region src/lib/client/dispatches/handlers/message.ts
1050
+ async function ensureMessageCache(client, payload) {
1051
+ let message;
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));
1053
+ else message = new Message(client, payload.d);
1054
+ return message;
1055
+ }
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
+ });
1073
+ registerHandler(discord_api_types_v10.GatewayDispatchEvents.MessageDelete, async (client, payload) => {
1074
+ let message;
1075
+ if (client.cache.isModuleEnabled("messages")) message = await client.cache.messages.get(payload.d.id);
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);
1078
+ client.emit("messageDelete", message);
1079
+ });
1080
+
1081
+ //#endregion
1082
+ //#region src/lib/client/dispatches/handlers/guild.ts
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
+ });
1093
+ registerHandler(discord_api_types_v10.GatewayDispatchEvents.GuildDelete, async (client, payload) => {
1094
+ const guild = client.cache.guilds.get(payload.d.id);
1095
+ if (!guild) return;
1096
+ for (const channel of guild.channels.values()) client.cache.channels.delete(channel.id);
1097
+ client.cache.guilds.delete(payload.d.id);
1098
+ client.emit("guildDelete", guild);
1099
+ });
1100
+
1101
+ //#endregion
1102
+ //#region src/lib/client/dispatches/handlers/channel.ts
1103
+ async function onCreateOrUpdate(client, payload) {
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
+ }
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;
1112
+ client.emit(payload.t === discord_api_types_v10.GatewayDispatchEvents.ChannelCreate ? "channelCreate" : "channelUpdate", channel);
1113
+ }
1114
+ registerHandler(discord_api_types_v10.GatewayDispatchEvents.ChannelCreate, onCreateOrUpdate);
1115
+ registerHandler(discord_api_types_v10.GatewayDispatchEvents.ChannelUpdate, onCreateOrUpdate);
1116
+ registerHandler(discord_api_types_v10.GatewayDispatchEvents.ChannelDelete, async (client, payload) => {
1117
+ const channel = client.channels.resolve(payload.d);
1118
+ const guild = client.cache.guilds.get(payload.d.guild_id);
1119
+ if (guild) guild.channels.delete(payload.d.id);
1120
+ client.cache.channels.delete(payload.d.id);
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
+ }));
1126
+ });
1127
+
1128
+ //#endregion
1129
+ //#region src/lib/client/dispatches/handlers/user.ts
1130
+ registerHandler(discord_api_types_v10.GatewayDispatchEvents.UserUpdate, async (client, payload) => {
1131
+ if (payload.d.id === client.user?.id) client.user._patch(payload.d);
1132
+ let user;
1133
+ if (client.cache.isModuleEnabled("users")) user = await client.cache.resolve(client.cache.users, payload.d.id, () => new User(client, payload.d), (user) => user._patch(payload.d));
1134
+ else user = new User(client, payload.d);
1135
+ client.emit("userUpdate", user);
1136
+ });
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
+
1184
+ //#endregion
1185
+ //#region src/lib/client/Client.ts
1186
+ var Client = class extends node_events.default {
1187
+ options;
1188
+ shards;
1189
+ rest;
1190
+ /**
1191
+ * @private
1192
+ * @deprecated
1193
+ */
1194
+ helper;
1195
+ cache;
1196
+ channels;
1197
+ #user;
1198
+ #ready = false;
1199
+ constructor(options, rest) {
1200
+ super();
1201
+ const intents = options.intents instanceof IntentsBitField ? options.intents : new IntentsBitField(options.intents);
1202
+ const sharding = {
1203
+ shardsPerCluster: options.sharding?.shardsPerCluster ?? 1,
1204
+ totalShards: options.sharding?.totalShards ?? 1
1205
+ };
1206
+ this.options = {
1207
+ token: options.token,
1208
+ intents,
1209
+ sharding,
1210
+ partials: new Set(options.partials ?? []),
1211
+ cache: options.cache ?? {}
1212
+ };
1213
+ this.rest = rest ?? new _bakit_rest.REST({ token: options.token });
1214
+ this.shards = new _bakit_gateway.ShardingManager({
1215
+ ...this.options.sharding,
1216
+ token: this.options.token,
1217
+ intents: this.options.intents.toBigInt()
1218
+ }, rest);
1219
+ this.cache = new ClientCacheManager(this.options.cache);
1220
+ this.channels = new ClientChannelManager(this);
1221
+ this.helper = new ClientHelper(this);
1222
+ this.#setupShardsListeners();
1223
+ }
1224
+ get user() {
1225
+ return this.#user;
1226
+ }
1227
+ async login() {
1228
+ if (this.#user || this.shards.ready || this.shards.clusters.size > 0) throw new Error("Cannot login twice");
1229
+ await this.shards.spawn();
1230
+ return new Promise((resolve, reject) => {
1231
+ const cleanup = () => {
1232
+ this.removeListener("ready", onReady);
1233
+ this.removeListener("error", onError);
1234
+ };
1235
+ const onReady = () => {
1236
+ cleanup();
1237
+ resolve();
1238
+ };
1239
+ const onError = (error) => {
1240
+ cleanup();
1241
+ reject(error);
1242
+ };
1243
+ this.once("ready", onReady);
1244
+ this.once("error", onError);
1245
+ });
1246
+ }
1247
+ #setupShardsListeners() {
1248
+ this.shards.on("dispatch", (_, shardId, payload) => this.#handleDispatch(shardId, payload));
1249
+ this.shards.on("raw", (_, shardId, payload) => this.emit("raw", shardId, payload));
1250
+ this.shards.once("ready", () => this.#tryEmitReady());
1251
+ }
1252
+ async #handleDispatch(shardId, payload) {
1253
+ this.emit("dispatch", shardId, payload);
1254
+ switch (payload.t) {
1255
+ case discord_api_types_v10.GatewayDispatchEvents.Ready:
1256
+ this.#user ??= new User(this, payload.d.user);
1257
+ this.#tryEmitReady();
1258
+ break;
1259
+ default: {
1260
+ const handler = handlers[payload.t];
1261
+ if (handler) await handler(this, payload);
1262
+ break;
1263
+ }
1264
+ }
1265
+ }
1266
+ /**
1267
+ * We use this method to emit ready event only once since we have 2 ways to emit it.
1268
+ * @private
1269
+ */
1270
+ #tryEmitReady() {
1271
+ if (this.#ready || !this.#user || !this.shards.ready) return;
1272
+ this.#ready = true;
1273
+ this.emit("ready", this.#user);
1274
+ }
1275
+ };
1276
+ function createClient(options) {
1277
+ return new Client(options);
1278
+ }
1279
+
1280
+ //#endregion
1281
+ exports.BaseCacheAdapter = BaseCacheAdapter;
1282
+ exports.BaseChannel = BaseChannel;
1283
+ exports.Client = Client;
1284
+ exports.ClientHelper = ClientHelper;
1285
+ Object.defineProperty(exports, 'Cluster', {
1286
+ enumerable: true,
1287
+ get: function () {
1288
+ return _bakit_gateway.Cluster;
1289
+ }
1290
+ });
1291
+ Object.defineProperty(exports, 'DEFAULT_REST_OPTIONS', {
1292
+ enumerable: true,
1293
+ get: function () {
1294
+ return _bakit_rest.DEFAULT_REST_OPTIONS;
1295
+ }
1296
+ });
1297
+ exports.DMChannel = DMChannel;
1298
+ Object.defineProperty(exports, 'DiscordAPIV10', {
1299
+ enumerable: true,
1300
+ get: function () {
1301
+ return discord_api_types_v10;
1302
+ }
1303
+ });
1304
+ Object.defineProperty(exports, 'DiscordHTTPError', {
1305
+ enumerable: true,
1306
+ get: function () {
1307
+ return _bakit_rest.DiscordHTTPError;
1308
+ }
1309
+ });
1310
+ exports.Guild = Guild;
1311
+ exports.GuildAnnouncementChannel = GuildAnnouncementChannel;
1312
+ exports.GuildCategory = GuildCategory;
1313
+ exports.GuildForumChannel = GuildForumChannel;
1314
+ exports.GuildStageVoiceChannel = GuildStageVoiceChannel;
1315
+ exports.GuildTextChannel = GuildTextChannel;
1316
+ exports.GuildVoiceChannel = GuildVoiceChannel;
1317
+ exports.HybridCache = HybridCache;
1318
+ Object.defineProperty(exports, 'Intent', {
1319
+ enumerable: true,
1320
+ get: function () {
1321
+ return discord_api_types_v10.GatewayIntentBits;
1322
+ }
1323
+ });
1324
+ exports.IntentsBitField = IntentsBitField;
1325
+ exports.LocalCacheAdapter = LocalCacheAdapter;
1326
+ exports.Message = Message;
1327
+ exports.Partial = Partial;
1328
+ Object.defineProperty(exports, 'REST', {
1329
+ enumerable: true,
1330
+ get: function () {
1331
+ return _bakit_rest.REST;
1332
+ }
1333
+ });
1334
+ Object.defineProperty(exports, 'RESTAdapter', {
1335
+ enumerable: true,
1336
+ get: function () {
1337
+ return _bakit_rest.RESTAdapter;
1338
+ }
1339
+ });
1340
+ Object.defineProperty(exports, 'RESTMethod', {
1341
+ enumerable: true,
1342
+ get: function () {
1343
+ return _bakit_rest.RESTMethod;
1344
+ }
1345
+ });
1346
+ Object.defineProperty(exports, 'Service', {
1347
+ enumerable: true,
1348
+ get: function () {
1349
+ return _bakit_service.Service;
1350
+ }
1351
+ });
1352
+ Object.defineProperty(exports, 'ServiceDriver', {
1353
+ enumerable: true,
1354
+ get: function () {
1355
+ return _bakit_service.ServiceDriver;
1356
+ }
1357
+ });
1358
+ Object.defineProperty(exports, 'ServiceProcess', {
1359
+ enumerable: true,
1360
+ get: function () {
1361
+ return _bakit_service.ServiceProcess;
1362
+ }
1363
+ });
1364
+ Object.defineProperty(exports, 'ServiceState', {
1365
+ enumerable: true,
1366
+ get: function () {
1367
+ return _bakit_service.ServiceState;
1368
+ }
1369
+ });
1370
+ Object.defineProperty(exports, 'Shard', {
1371
+ enumerable: true,
1372
+ get: function () {
1373
+ return _bakit_gateway.Shard;
1374
+ }
1375
+ });
1376
+ Object.defineProperty(exports, 'ShardState', {
1377
+ enumerable: true,
1378
+ get: function () {
1379
+ return _bakit_gateway.ShardState;
1380
+ }
1381
+ });
1382
+ Object.defineProperty(exports, 'ShardStrategy', {
1383
+ enumerable: true,
1384
+ get: function () {
1385
+ return _bakit_gateway.ShardStrategy;
1386
+ }
1387
+ });
1388
+ Object.defineProperty(exports, 'ShardingManager', {
1389
+ enumerable: true,
1390
+ get: function () {
1391
+ return _bakit_gateway.ShardingManager;
1392
+ }
1393
+ });
1394
+ exports.Tag = Tag;
1395
+ exports.ThreadChannel = ThreadChannel;
1396
+ Object.defineProperty(exports, 'TransportClient', {
1397
+ enumerable: true,
1398
+ get: function () {
1399
+ return _bakit_service.TransportClient;
1400
+ }
1401
+ });
1402
+ Object.defineProperty(exports, 'TransportServer', {
1403
+ enumerable: true,
1404
+ get: function () {
1405
+ return _bakit_service.TransportServer;
1406
+ }
1407
+ });
1408
+ exports.Typing = Typing;
1409
+ exports.User = User;
1410
+ Object.defineProperty(exports, 'capitalize', {
1411
+ enumerable: true,
1412
+ get: function () {
1413
+ return _bakit_utils.capitalize;
1414
+ }
1415
+ });
1416
+ exports.createClient = createClient;
1417
+ Object.defineProperty(exports, 'createREST', {
1418
+ enumerable: true,
1419
+ get: function () {
1420
+ return _bakit_rest.createREST;
1421
+ }
1422
+ });
1423
+ Object.defineProperty(exports, 'createRESTAdapter', {
1424
+ enumerable: true,
1425
+ get: function () {
1426
+ return _bakit_rest.createRESTAdapter;
1427
+ }
1428
+ });
1429
+ Object.defineProperty(exports, 'createService', {
1430
+ enumerable: true,
1431
+ get: function () {
1432
+ return _bakit_service.createService;
1433
+ }
1434
+ });
1435
+ Object.defineProperty(exports, 'createTransportClient', {
1436
+ enumerable: true,
1437
+ get: function () {
1438
+ return _bakit_service.createTransportClient;
1439
+ }
1440
+ });
1441
+ Object.defineProperty(exports, 'createTransportServer', {
1442
+ enumerable: true,
1443
+ get: function () {
1444
+ return _bakit_service.createTransportServer;
1445
+ }
1446
+ });
1447
+ Object.defineProperty(exports, 'instanceToObject', {
1448
+ enumerable: true,
1449
+ get: function () {
1450
+ return _bakit_utils.instanceToObject;
1451
+ }
1452
+ });
1453
+ Object.defineProperty(exports, 'isCommonJS', {
1454
+ enumerable: true,
1455
+ get: function () {
1456
+ return _bakit_utils.isCommonJS;
1457
+ }
1458
+ });
1459
+ Object.defineProperty(exports, 'isESM', {
1460
+ enumerable: true,
1461
+ get: function () {
1462
+ return _bakit_utils.isESM;
1463
+ }
1464
+ });
1465
+ Object.defineProperty(exports, 'isPlainObject', {
1466
+ enumerable: true,
1467
+ get: function () {
1468
+ return _bakit_utils.isPlainObject;
1469
+ }
1470
+ });
1471
+ Object.defineProperty(exports, 'isPromiseLike', {
1472
+ enumerable: true,
1473
+ get: function () {
1474
+ return _bakit_utils.isPromiseLike;
1475
+ }
1476
+ });
1477
+ Object.defineProperty(exports, 'promisify', {
1478
+ enumerable: true,
1479
+ get: function () {
1480
+ return _bakit_utils.promisify;
1481
+ }
1482
+ });
1483
+ Object.defineProperty(exports, 'sleep', {
1484
+ enumerable: true,
1485
+ get: function () {
1486
+ return _bakit_utils.sleep;
1487
+ }
1488
+ });