bakit 3.0.0 → 3.1.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.d.cts CHANGED
@@ -1,276 +1,417 @@
1
- import { ShardingManagerOptions, ShardingManager } from '@bakit/gateway';
2
- export { Cluster, ClusterEvents, ClusterOptions, Shard, ShardEvents, ShardOptions, ShardState, ShardStrategy, ShardingManager, ShardingManagerEvents, ShardingManagerOptions } from '@bakit/gateway';
3
- import { RESTLike } from '@bakit/rest';
4
- export { BaseRESTEvents, DEFAULT_REST_OPTIONS, DiscordHTTPError, DiscordHTTPErrorRequest, DiscordHTTPFlattenedError, DiscordHTTPValidationError, REST, RESTAdapter, RESTAdapterEvents, RESTEndpoint, RESTEvents, RESTLike, RESTMethod, RESTOptions, RESTProxyOptions, RESTRequestFn, RESTRequestOptions, createREST, createRESTAdapter } from '@bakit/rest';
5
- export { RPCHandler, Service, ServiceClientRuntime, ServiceDriver, ServiceOptions, ServiceProcess, ServiceProcessEvents, ServiceServerRuntime, ServiceState, TransportClient, TransportClientEvents, TransportServer, TransportServerEvents, createService, createTransportClient, createTransportServer } from '@bakit/service';
6
- import * as _bakit_utils from '@bakit/utils';
7
- export { AbstractConstructor, Awaitable, Constructor, FunctionLike, Promisify, PromisifyValue, RejectFn, ResolveFn, capitalize, instanceToObject, isCommonJS, isESM, isPlainObject, isPromiseLike, promisify, sleep } from '@bakit/utils';
8
- import EventEmitter from 'node:events';
9
- import { Collection } from '@discordjs/collection';
10
- import * as discord_api_types_v10 from 'discord-api-types/v10';
11
- import { APITextBasedChannel, ChannelType, APIGuildVoiceChannel, APIChannelBase, GatewayChannelCreateDispatchData, GatewayChannelUpdateDispatchData, APIChannel, APIGuild, GatewayGuildUpdateDispatchData, GatewayGuildCreateDispatchData, APIUser, GatewayReadyDispatchData, APIEmbed, APIAllowedMentions, APIMessageReference, APIMessage, GatewayMessageCreateDispatchData, GatewayMessageUpdateDispatchData, GatewayIntentBits, GatewayDispatchPayload, GatewayReceivePayload } from 'discord-api-types/v10';
12
- export { discord_api_types_v10 as DiscordAPIV10 };
13
- export { GatewayIntentBits as Intent } from 'discord-api-types/v10';
1
+ import { Cluster, ClusterEvents, ClusterOptions, Shard, ShardEvents, ShardOptions, ShardState, ShardStrategy, ShardingManager, ShardingManager as ShardingManager$1, ShardingManagerEvents, ShardingManagerOptions, ShardingManagerOptions as ShardingManagerOptions$1 } from "@bakit/gateway";
2
+ import { BaseRESTEvents, DEFAULT_REST_OPTIONS, DiscordHTTPError, DiscordHTTPErrorRequest, DiscordHTTPFlattenedError, DiscordHTTPValidationError, REST, RESTAdapter, RESTAdapterEvents, RESTEndpoint, RESTEvents, RESTLike, RESTLike as RESTLike$1, RESTMethod, RESTOptions, RESTProxyOptions, RESTRequestFn, RESTRequestOptions, createREST, createRESTAdapter } from "@bakit/rest";
3
+ import { RPCHandler, Service, ServiceClientRuntime, ServiceDriver, ServiceOptions, ServiceProcess, ServiceProcessEvents, ServiceServerRuntime, ServiceState, TransportClient, TransportClientEvents, TransportServer, TransportServerEvents, createService, createTransportClient, createTransportServer } from "@bakit/service";
4
+ import * as _bakit_utils0 from "@bakit/utils";
5
+ import { AbstractConstructor, Awaitable, Awaitable as Awaitable$1, Constructor, FunctionLike, Promisify, PromisifyValue, RejectFn, ResolveFn, capitalize, instanceToObject, isCommonJS, isESM, isPlainObject, isPromiseLike, promisify, sleep } from "@bakit/utils";
6
+ import EventEmitter from "node:events";
7
+ import * as discord_api_types_v100 from "discord-api-types/v10";
8
+ import { APIAllowedMentions, APIChannel, APIChannelBase, APIDMChannel, APIEmbed, APIGuild, APIGuildVoiceChannel, APIMessage, APIMessageReference, APITextBasedChannel, APIUser, ChannelType, GatewayChannelCreateDispatchData, GatewayChannelUpdateDispatchData, GatewayDispatchPayload, GatewayGuildCreateDispatchData, GatewayGuildUpdateDispatchData, GatewayIntentBits, GatewayIntentBits as Intent, GatewayMessageCreateDispatchData, GatewayMessageUpdateDispatchData, GatewayReadyDispatchData, GatewayReceivePayload } from "discord-api-types/v10";
9
+ import { Collection } from "@discordjs/collection";
14
10
 
11
+ //#region src/lib/structures/BaseStructure.d.ts
15
12
  declare class BaseStructure {
16
- client: Client;
17
- constructor(client: Client);
18
- toJSON(): {};
13
+ client: Client<true>;
14
+ constructor(client: Client<true>);
15
+ toJSON(): {};
19
16
  }
20
-
21
- declare const GuildTextChannel_base: (abstract new (client: Client, data: APITextBasedChannel<ChannelType.GuildText>) => BaseChannel<APITextBasedChannel<ChannelType.GuildText>>) & (abstract new (...args: any[]) => {
22
- get guildId(): string;
23
- get guild(): Guild;
24
- data: discord_api_types_v10.APIGuildChannel<discord_api_types_v10.GuildChannelType>;
25
- get id(): string;
26
- get type(): ChannelType;
27
- toString(): string;
28
- toJSON(): discord_api_types_v10.APIGuildChannel<discord_api_types_v10.GuildChannelType>;
29
- isTextBased(): this is TextBasedChannel;
30
- isVoiceBased(): this is VoiceBasedChannel;
31
- inGuild(): this is GuildChannel;
32
- _patch(data: Partial<discord_api_types_v10.APIGuildChannel<discord_api_types_v10.GuildChannelType>>): void;
33
- client: Client;
34
- }) & _bakit_utils.AbstractConstructor<BaseChannel<discord_api_types_v10.APIGuildChannel<discord_api_types_v10.GuildChannelType>>> & (abstract new (...args: any[]) => {
35
- send(options: MessageCreateOptions): Promise<discord_api_types_v10.APIMessage>;
36
- data: APITextBasedChannel<ChannelType>;
37
- get id(): string;
38
- get type(): ChannelType;
39
- toString(): string;
40
- toJSON(): APITextBasedChannel<ChannelType>;
41
- isTextBased(): this is TextBasedChannel;
42
- isVoiceBased(): this is VoiceBasedChannel;
43
- inGuild(): this is GuildChannel;
44
- _patch(data: Partial<APITextBasedChannel<ChannelType>>): void;
45
- client: Client;
46
- }) & _bakit_utils.AbstractConstructor<BaseChannel<APITextBasedChannel<ChannelType>>>;
47
- declare class GuildTextChannel extends GuildTextChannel_base {
17
+ //#endregion
18
+ //#region src/lib/structures/Guild.d.ts
19
+ type GuildPayload = APIGuild | GatewayGuildUpdateDispatchData | GatewayGuildCreateDispatchData;
20
+ declare class Guild extends BaseStructure {
21
+ #private;
22
+ data: GuildPayload;
23
+ readonly channels: Collection<string, Channel>;
24
+ constructor(client: Client, data: GuildPayload);
25
+ get id(): string;
26
+ get name(): string;
27
+ get icon(): string | null;
28
+ get banner(): string | null;
29
+ get owner(): string;
30
+ get mfaLevel(): discord_api_types_v100.GuildMFALevel;
31
+ get verificationLevel(): discord_api_types_v100.GuildVerificationLevel;
32
+ _patch(data: Partial<GuildPayload>): void;
48
33
  }
49
-
34
+ //#endregion
35
+ //#region src/lib/structures/channel/GuildTextChannel.d.ts
36
+ declare const GuildTextChannel_base: (abstract new (client: Client, data: APITextBasedChannel<ChannelType.GuildText>) => BaseChannel<APITextBasedChannel<ChannelType.GuildText>>) & (abstract new (...args: any[]) => {
37
+ get guildId(): string;
38
+ get guild(): Guild;
39
+ data: discord_api_types_v100.APIGuildChannel<discord_api_types_v100.GuildChannelType>;
40
+ get id(): string;
41
+ get type(): ChannelType;
42
+ toString(): string;
43
+ toJSON(): discord_api_types_v100.APIGuildChannel<discord_api_types_v100.GuildChannelType>;
44
+ isTextBased(): this is TextBasedChannel;
45
+ isVoiceBased(): this is VoiceBasedChannel;
46
+ isDM(): this is DMChannel;
47
+ inGuild(): this is GuildChannel;
48
+ fetch(): Promise< /*elided*/any>;
49
+ _patch(data: Partial<discord_api_types_v100.APIGuildChannel<discord_api_types_v100.GuildChannelType>>): void;
50
+ client: Client<true>;
51
+ }) & _bakit_utils0.AbstractConstructor<BaseChannel<discord_api_types_v100.APIGuildChannel<discord_api_types_v100.GuildChannelType>>> & (abstract new (...args: any[]) => {
52
+ send(options: MessageCreateOptions | string): Promise<Message<boolean>>;
53
+ data: APITextBasedChannel<ChannelType>;
54
+ get id(): string;
55
+ get type(): ChannelType;
56
+ toString(): string;
57
+ toJSON(): APITextBasedChannel<ChannelType>;
58
+ isTextBased(): this is TextBasedChannel;
59
+ isVoiceBased(): this is VoiceBasedChannel;
60
+ isDM(): this is DMChannel;
61
+ inGuild(): this is GuildChannel;
62
+ fetch(): Promise< /*elided*/any>;
63
+ _patch(data: Partial<APITextBasedChannel<ChannelType>>): void;
64
+ client: Client<true>;
65
+ }) & _bakit_utils0.AbstractConstructor<BaseChannel<APITextBasedChannel<ChannelType>>>;
66
+ declare class GuildTextChannel extends GuildTextChannel_base {}
67
+ //#endregion
68
+ //#region src/lib/structures/channel/GuildVoiceChannel.d.ts
50
69
  declare const GuildVoiceChannel_base: (abstract new (client: Client, data: APIGuildVoiceChannel) => BaseChannel<APIGuildVoiceChannel>) & (abstract new (...args: any[]) => {
51
- get guildId(): string;
52
- get guild(): Guild;
53
- data: discord_api_types_v10.APIGuildChannel<discord_api_types_v10.GuildChannelType>;
54
- get id(): string;
55
- get type(): discord_api_types_v10.ChannelType;
56
- toString(): string;
57
- toJSON(): discord_api_types_v10.APIGuildChannel<discord_api_types_v10.GuildChannelType>;
58
- isTextBased(): this is TextBasedChannel;
59
- isVoiceBased(): this is VoiceBasedChannel;
60
- inGuild(): this is GuildChannel;
61
- _patch(data: Partial<discord_api_types_v10.APIGuildChannel<discord_api_types_v10.GuildChannelType>>): void;
62
- client: Client;
63
- }) & _bakit_utils.AbstractConstructor<BaseChannel<discord_api_types_v10.APIGuildChannel<discord_api_types_v10.GuildChannelType>>> & (abstract new (...args: any[]) => {
64
- send(options: MessageCreateOptions): Promise<discord_api_types_v10.APIMessage>;
65
- data: discord_api_types_v10.APITextBasedChannel<discord_api_types_v10.ChannelType>;
66
- get id(): string;
67
- get type(): discord_api_types_v10.ChannelType;
68
- toString(): string;
69
- toJSON(): discord_api_types_v10.APITextBasedChannel<discord_api_types_v10.ChannelType>;
70
- isTextBased(): this is TextBasedChannel;
71
- isVoiceBased(): this is VoiceBasedChannel;
72
- inGuild(): this is GuildChannel;
73
- _patch(data: Partial<discord_api_types_v10.APITextBasedChannel<discord_api_types_v10.ChannelType>>): void;
74
- client: Client;
75
- }) & _bakit_utils.AbstractConstructor<BaseChannel<discord_api_types_v10.APITextBasedChannel<discord_api_types_v10.ChannelType>>> & (abstract new (...args: any[]) => {
76
- data: discord_api_types_v10.APIVoiceChannelBase<discord_api_types_v10.GuildChannelType>;
77
- get id(): string;
78
- get type(): discord_api_types_v10.ChannelType;
79
- toString(): string;
80
- toJSON(): discord_api_types_v10.APIVoiceChannelBase<discord_api_types_v10.GuildChannelType>;
81
- isTextBased(): this is TextBasedChannel;
82
- isVoiceBased(): this is VoiceBasedChannel;
83
- inGuild(): this is GuildChannel;
84
- _patch(data: Partial<discord_api_types_v10.APIVoiceChannelBase<discord_api_types_v10.GuildChannelType>>): void;
85
- client: Client;
86
- }) & _bakit_utils.AbstractConstructor<BaseChannel<discord_api_types_v10.APIVoiceChannelBase<discord_api_types_v10.GuildChannelType>>>;
87
- declare class GuildVoiceChannel extends GuildVoiceChannel_base {
88
- }
89
-
70
+ get guildId(): string;
71
+ get guild(): Guild;
72
+ data: discord_api_types_v100.APIGuildChannel<discord_api_types_v100.GuildChannelType>;
73
+ get id(): string;
74
+ get type(): discord_api_types_v100.ChannelType;
75
+ toString(): string;
76
+ toJSON(): discord_api_types_v100.APIGuildChannel<discord_api_types_v100.GuildChannelType>;
77
+ isTextBased(): this is TextBasedChannel;
78
+ isVoiceBased(): this is VoiceBasedChannel;
79
+ isDM(): this is DMChannel;
80
+ inGuild(): this is GuildChannel;
81
+ fetch(): Promise< /*elided*/any>;
82
+ _patch(data: Partial<discord_api_types_v100.APIGuildChannel<discord_api_types_v100.GuildChannelType>>): void;
83
+ client: Client<true>;
84
+ }) & _bakit_utils0.AbstractConstructor<BaseChannel<discord_api_types_v100.APIGuildChannel<discord_api_types_v100.GuildChannelType>>> & (abstract new (...args: any[]) => {
85
+ send(options: MessageCreateOptions | string): Promise<Message<boolean>>;
86
+ data: discord_api_types_v100.APITextBasedChannel<discord_api_types_v100.ChannelType>;
87
+ get id(): string;
88
+ get type(): discord_api_types_v100.ChannelType;
89
+ toString(): string;
90
+ toJSON(): discord_api_types_v100.APITextBasedChannel<discord_api_types_v100.ChannelType>;
91
+ isTextBased(): this is TextBasedChannel;
92
+ isVoiceBased(): this is VoiceBasedChannel;
93
+ isDM(): this is DMChannel;
94
+ inGuild(): this is GuildChannel;
95
+ fetch(): Promise< /*elided*/any>;
96
+ _patch(data: Partial<discord_api_types_v100.APITextBasedChannel<discord_api_types_v100.ChannelType>>): void;
97
+ client: Client<true>;
98
+ }) & _bakit_utils0.AbstractConstructor<BaseChannel<discord_api_types_v100.APITextBasedChannel<discord_api_types_v100.ChannelType>>> & (abstract new (...args: any[]) => {
99
+ data: discord_api_types_v100.APIVoiceChannelBase<discord_api_types_v100.GuildChannelType>;
100
+ get id(): string;
101
+ get type(): discord_api_types_v100.ChannelType;
102
+ toString(): string;
103
+ toJSON(): discord_api_types_v100.APIVoiceChannelBase<discord_api_types_v100.GuildChannelType>;
104
+ isTextBased(): this is TextBasedChannel;
105
+ isVoiceBased(): this is VoiceBasedChannel;
106
+ isDM(): this is DMChannel;
107
+ inGuild(): this is GuildChannel;
108
+ fetch(): Promise< /*elided*/any>;
109
+ _patch(data: Partial<discord_api_types_v100.APIVoiceChannelBase<discord_api_types_v100.GuildChannelType>>): void;
110
+ client: Client<true>;
111
+ }) & _bakit_utils0.AbstractConstructor<BaseChannel<discord_api_types_v100.APIVoiceChannelBase<discord_api_types_v100.GuildChannelType>>>;
112
+ declare class GuildVoiceChannel extends GuildVoiceChannel_base {}
113
+ //#endregion
114
+ //#region src/lib/structures/channel/BaseChannel.d.ts
90
115
  type BaseChannelPayload = APIChannelBase<ChannelType> | GatewayChannelCreateDispatchData | GatewayChannelUpdateDispatchData | APIChannel;
91
- type TextBasedChannel = GuildTextChannel | GuildVoiceChannel;
116
+ type TextBasedChannel = GuildTextChannel | GuildVoiceChannel | DMChannel;
92
117
  type VoiceBasedChannel = GuildVoiceChannel;
93
118
  type GuildChannel = GuildTextChannel | GuildVoiceChannel;
94
- type Channel = TextBasedChannel | VoiceBasedChannel | GuildChannel;
119
+ type Channel = TextBasedChannel | VoiceBasedChannel | GuildChannel | BaseChannel<BaseChannelPayload>;
95
120
  declare abstract class BaseChannel<D extends BaseChannelPayload> extends BaseStructure {
96
- data: D;
97
- constructor(client: Client, data: D);
98
- get id(): string;
99
- get type(): ChannelType;
100
- toString(): string;
101
- toJSON(): D;
102
- isTextBased(): this is TextBasedChannel;
103
- isVoiceBased(): this is VoiceBasedChannel;
104
- inGuild(): this is GuildChannel;
105
- _patch(data: Partial<D>): void;
121
+ data: D;
122
+ constructor(client: Client, data: D);
123
+ get id(): string;
124
+ get type(): ChannelType;
125
+ toString(): string;
126
+ toJSON(): D;
127
+ isTextBased(): this is TextBasedChannel;
128
+ isVoiceBased(): this is VoiceBasedChannel;
129
+ isDM(): this is DMChannel;
130
+ inGuild(): this is GuildChannel;
131
+ fetch(): Promise<this>;
132
+ _patch(data: Partial<D>): void;
106
133
  }
107
-
108
- type GuildPayload = APIGuild | GatewayGuildUpdateDispatchData | GatewayGuildCreateDispatchData;
109
- declare class Guild extends BaseStructure {
110
- data: GuildPayload;
111
- private cachedChannels;
112
- constructor(client: Client, data: GuildPayload);
113
- get id(): string;
114
- get name(): string;
115
- get icon(): string | null;
116
- get banner(): string | null;
117
- get owner(): string;
118
- get mfaLevel(): discord_api_types_v10.GuildMFALevel;
119
- get verificationLevel(): discord_api_types_v10.GuildVerificationLevel;
120
- get channels(): Collection<string, Channel>;
121
- _patch(data: Partial<GuildPayload>): void;
122
- }
123
-
124
- type UserPayload = APIUser | GatewayReadyDispatchData["user"];
125
- declare class User extends BaseStructure {
126
- data: UserPayload;
127
- constructor(client: Client, data: UserPayload);
128
- get id(): string;
129
- get username(): string;
130
- get discriminator(): string;
131
- get globalName(): string | null;
132
- get tag(): string;
133
- get displayName(): string;
134
- get avatar(): string | undefined;
135
- get bot(): boolean;
136
- get system(): boolean;
137
- get mfaEnabled(): boolean | undefined;
138
- get locale(): string | undefined;
139
- get verified(): boolean | undefined;
140
- get email(): string | null | undefined;
141
- get flags(): discord_api_types_v10.UserFlags | undefined;
142
- get premiumType(): discord_api_types_v10.UserPremiumType | undefined;
143
- get publicFlags(): discord_api_types_v10.UserFlags | undefined;
144
- get banner(): string | null | undefined;
145
- get accentColor(): number | undefined;
146
- get createdAt(): Date;
147
- get createdTimestamp(): number;
148
- get hexAccentColor(): string | undefined;
149
- get defaultAvatarURL(): string;
150
- getAvatarURL(options?: {
151
- size?: number;
152
- extension?: "png" | "jpg" | "webp" | "gif";
153
- }): string | undefined;
154
- getDisplayAvatarURL(options?: {
155
- size?: number;
156
- extension?: "png" | "jpg" | "webp" | "gif";
157
- }): string;
158
- equals(other: User | string): boolean;
159
- toJSON(): APIUser;
160
- toString(): string;
161
- }
162
-
134
+ //#endregion
135
+ //#region src/lib/client/ClientHelper.d.ts
163
136
  interface MessageCreateOptions {
164
- content?: string;
165
- tts?: boolean;
166
- embeds?: APIEmbed[];
167
- allowedMentions?: APIAllowedMentions;
168
- messageReference?: APIMessageReference;
169
- flags?: number;
137
+ content?: string;
138
+ tts?: boolean;
139
+ embeds?: APIEmbed[];
140
+ allowedMentions?: APIAllowedMentions;
141
+ messageReference?: APIMessageReference;
142
+ flags?: number;
170
143
  }
171
144
  type MessageReplyOptions = Omit<MessageCreateOptions, "messageReference">;
145
+ type MessageEditOptions = Omit<MessageCreateOptions, "messageReference">;
172
146
  declare class ClientHelper {
173
- readonly client: Client;
174
- constructor(client: Client);
175
- fetchMessage(channelId: string, messageId: string): Promise<Message>;
176
- deleteMessage(channelId: string, messageId: string): Promise<unknown>;
177
- createMessage(channelId: string, options: MessageCreateOptions): Promise<APIMessage>;
178
- replyMessage(channelId: string, messageId: string, options: MessageReplyOptions): Promise<APIMessage>;
179
- fetchGuild(guildId: string): Promise<Guild>;
180
- static toAPICreateMessagePayload(options: MessageCreateOptions): {
181
- content: string | undefined;
182
- tts: boolean | undefined;
183
- embeds: APIEmbed[] | undefined;
184
- allowed_mentions: APIAllowedMentions | undefined;
185
- message_reference: APIMessageReference | undefined;
186
- flags: number | undefined;
187
- };
147
+ readonly client: Client;
148
+ constructor(client: Client);
149
+ fetchUser(userId: string, force?: boolean): Promise<User>;
150
+ createDM(userId: string, force?: boolean): Promise<DMChannel>;
151
+ fetchMessage(channelId: string, messageId: string, force?: boolean): Promise<Message<boolean>>;
152
+ deleteMessage(channelId: string, messageId: string): Promise<void>;
153
+ createMessage(channelId: string, options: MessageCreateOptions | string): Promise<Message<boolean>>;
154
+ editMessage(channelId: string, messageId: string, options: MessageEditOptions | string): Promise<Message<boolean>>;
155
+ replyMessage(channelId: string, messageId: string, options: MessageReplyOptions): Promise<Message<boolean>>;
156
+ fetchGuild(guildId: string, force?: boolean): Promise<Guild>;
157
+ fetchChannel<C extends Channel>(channelId: string, force?: boolean): Promise<C>;
158
+ static toAPICreateMessagePayload(options: MessageCreateOptions): {
159
+ content: string | undefined;
160
+ tts: boolean | undefined;
161
+ embeds: APIEmbed[] | undefined;
162
+ allowed_mentions: APIAllowedMentions | undefined;
163
+ message_reference: APIMessageReference | undefined;
164
+ flags: number | undefined;
165
+ };
188
166
  }
189
-
167
+ //#endregion
168
+ //#region src/lib/structures/channel/DMChannel.d.ts
169
+ declare const DMChannel_base: (abstract new (client: Client, data: APIDMChannel) => BaseChannel<APIDMChannel>) & (abstract new (...args: any[]) => {
170
+ send(options: MessageCreateOptions | string): Promise<Message<boolean>>;
171
+ data: discord_api_types_v100.APITextBasedChannel<discord_api_types_v100.ChannelType>;
172
+ get id(): string;
173
+ get type(): discord_api_types_v100.ChannelType;
174
+ toString(): string;
175
+ toJSON(): discord_api_types_v100.APITextBasedChannel<discord_api_types_v100.ChannelType>;
176
+ isTextBased(): this is TextBasedChannel;
177
+ isVoiceBased(): this is VoiceBasedChannel;
178
+ isDM(): this is DMChannel;
179
+ inGuild(): this is GuildChannel;
180
+ fetch(): Promise< /*elided*/any>;
181
+ _patch(data: Partial<discord_api_types_v100.APITextBasedChannel<discord_api_types_v100.ChannelType>>): void;
182
+ client: Client<true>;
183
+ }) & _bakit_utils0.AbstractConstructor<BaseChannel<discord_api_types_v100.APITextBasedChannel<discord_api_types_v100.ChannelType>>>;
184
+ declare class DMChannel extends DMChannel_base {
185
+ #private;
186
+ constructor(client: Client, data: APIDMChannel);
187
+ get recipients(): Collection<string, User>;
188
+ get recipientId(): string;
189
+ get recipient(): User;
190
+ fetch(): Promise<this>;
191
+ send(options: MessageCreateOptions | string): Promise<Message<false>>;
192
+ fetchRecipients(force?: boolean): Promise<Collection<string, User> | undefined>;
193
+ _patch(data: Partial<APIDMChannel>): void;
194
+ }
195
+ //#endregion
196
+ //#region src/lib/structures/User.d.ts
197
+ type UserPayload = APIUser | GatewayReadyDispatchData["user"];
198
+ declare class User extends BaseStructure {
199
+ data: UserPayload;
200
+ constructor(client: Client, data: UserPayload);
201
+ get id(): string;
202
+ get username(): string;
203
+ get discriminator(): string;
204
+ get globalName(): string | null;
205
+ get tag(): string;
206
+ get displayName(): string;
207
+ get avatar(): string | undefined;
208
+ get bot(): boolean;
209
+ get system(): boolean;
210
+ get mfaEnabled(): boolean | undefined;
211
+ get locale(): string | undefined;
212
+ get verified(): boolean | undefined;
213
+ get email(): string | null | undefined;
214
+ get flags(): discord_api_types_v100.UserFlags | undefined;
215
+ get premiumType(): discord_api_types_v100.UserPremiumType | undefined;
216
+ get publicFlags(): discord_api_types_v100.UserFlags | undefined;
217
+ get banner(): string | null | undefined;
218
+ get accentColor(): number | undefined;
219
+ get createdAt(): Date;
220
+ get createdTimestamp(): number;
221
+ get hexAccentColor(): string | undefined;
222
+ get defaultAvatarURL(): string;
223
+ getAvatarURL(options?: {
224
+ size?: number;
225
+ extension?: "png" | "jpg" | "webp" | "gif";
226
+ }): string | undefined;
227
+ getDisplayAvatarURL(options?: {
228
+ size?: number;
229
+ extension?: "png" | "jpg" | "webp" | "gif";
230
+ }): string;
231
+ equals(other: User | string): boolean;
232
+ createDM(force?: boolean): Promise<DMChannel>;
233
+ send(options: MessageCreateOptions | string): Promise<Message<false>>;
234
+ _patch(data: Partial<UserPayload>): void;
235
+ toJSON(): APIUser;
236
+ toString(): string;
237
+ }
238
+ //#endregion
239
+ //#region src/lib/structures/Message.d.ts
190
240
  type MessagePayload = APIMessage | GatewayMessageCreateDispatchData | GatewayMessageUpdateDispatchData;
191
- declare class Message extends BaseStructure {
192
- data: MessagePayload;
193
- protected cachedAuthor?: User;
194
- constructor(client: Client, data: MessagePayload);
195
- get partial(): boolean;
196
- get content(): string;
197
- get id(): string;
198
- get channelId(): string;
199
- get channel(): TextBasedChannel;
200
- get guildId(): string | undefined;
201
- get guild(): Guild | undefined;
202
- get author(): User;
203
- get createdAt(): Date;
204
- get editedAt(): Date | undefined;
205
- get createdTimestamp(): number;
206
- get editedTimestamp(): number | undefined;
207
- get url(): string;
208
- fetch(): Promise<Message>;
209
- reply(options: MessageReplyOptions): Promise<APIMessage>;
210
- sendToChannel(options: MessageReplyOptions): Promise<APIMessage>;
211
- toJSON(): MessagePayload;
212
- toString(): string;
241
+ declare class Message<InGuild extends boolean = boolean> extends BaseStructure {
242
+ #private;
243
+ data: MessagePayload;
244
+ constructor(client: Client, data: MessagePayload);
245
+ get partial(): boolean;
246
+ get content(): string;
247
+ get id(): string;
248
+ get channelId(): string;
249
+ get channel(): InGuild extends true ? TextBasedChannel & GuildChannel : TextBasedChannel;
250
+ get guildId(): InGuild extends true ? string : undefined;
251
+ get guild(): InGuild extends true ? Guild : undefined;
252
+ /**
253
+ * The author of this message.
254
+ *
255
+ * **Note:** This property returns the cached `User` synchronously.
256
+ * It may be stale if the users cache has short lifetime or uses an asynchronous remote store.
257
+ * To ensure the author is up-to-date, use the `fetchAuthor()` method instead.
258
+ */
259
+ get author(): User;
260
+ get createdAt(): Date;
261
+ get editedAt(): Date | undefined;
262
+ get createdTimestamp(): number;
263
+ get editedTimestamp(): number | undefined;
264
+ get url(): string;
265
+ inGuild(): this is Message<true>;
266
+ fetch(): Promise<Message>;
267
+ /**
268
+ * Fetches the author of this message from cache or Discord API.
269
+ *
270
+ * **Note:** It is recommended to use this method instead of the `author` property
271
+ * if the users cache has short lifetime or is backed by an asynchronous remote cache.
272
+ *
273
+ * @param force - Whether to bypass the cache and force a request to the API.
274
+ * @returns A promise that resolves to the `User` who authored this message.
275
+ */
276
+ fetchAuthor(force?: boolean): Promise<User>;
277
+ reply(options: MessageReplyOptions): Promise<Message<boolean>>;
278
+ sendToChannel(options: MessageReplyOptions): Promise<Message<boolean>>;
279
+ edit(options: MessageEditOptions | string): Promise<Message<boolean>>;
280
+ _patch(data: Partial<MessagePayload>): Promise<void>;
281
+ toJSON(): MessagePayload;
282
+ toString(): string;
213
283
  }
214
-
284
+ //#endregion
285
+ //#region src/lib/client/Partial.d.ts
215
286
  declare enum Partial$1 {
216
- Message = 0,
217
- User = 1
287
+ Message = 0,
288
+ User = 1
218
289
  }
219
-
290
+ //#endregion
291
+ //#region src/lib/utils/IntentsBitField.d.ts
220
292
  type IntentResolvable = number | bigint | GatewayIntentBits | GatewayIntentBits[];
221
293
  declare class IntentsBitField {
222
- private readonly value;
223
- constructor(input: IntentResolvable);
224
- static resolve(input: IntentResolvable): bigint;
225
- has(intent: GatewayIntentBits): boolean;
226
- toBigInt(): bigint;
227
- toNumber(): number;
228
- toJSON(): string;
229
- toString(): string;
294
+ private readonly value;
295
+ constructor(input: IntentResolvable);
296
+ static resolve(input: IntentResolvable): bigint;
297
+ has(intent: GatewayIntentBits): boolean;
298
+ toBigInt(): bigint;
299
+ toNumber(): number;
300
+ toJSON(): string;
301
+ toString(): string;
230
302
  }
231
-
303
+ //#endregion
304
+ //#region src/lib/utils/cache/adapters/BaseCacheAdapter.d.ts
305
+ declare abstract class BaseCacheAdapter<Key, Value> {
306
+ abstract get(key: Key): Awaitable$1<Value | undefined>;
307
+ abstract set(key: Key, value: Value, ttl?: number): Awaitable$1<void>;
308
+ abstract delete(key: Key): Awaitable$1<void>;
309
+ abstract clear(): Awaitable$1<void>;
310
+ abstract has(key: Key): Awaitable$1<boolean>;
311
+ abstract sweep(filter: (data: Value) => boolean): Awaitable$1<void>;
312
+ }
313
+ //#endregion
314
+ //#region src/lib/utils/cache/adapters/LocalCacheAdapter.d.ts
315
+ interface LocalCacheTTLEntry<Value> {
316
+ value: Value;
317
+ expiresAt?: number;
318
+ }
319
+ declare class LocalCacheAdapter<Key, Value> extends BaseCacheAdapter<Key, Value> {
320
+ #private;
321
+ collection: Collection<Key, LocalCacheTTLEntry<Value>>;
322
+ get(key: Key): Value | undefined;
323
+ set(key: Key, value: Value, ttl?: number): void;
324
+ delete(key: Key): void;
325
+ clear(): void;
326
+ has(key: Key): boolean;
327
+ find(filter: (data: Value) => boolean): Value | undefined;
328
+ sweep(filter: (data: Value) => boolean): void;
329
+ sweepTTL(): void;
330
+ }
331
+ //#endregion
332
+ //#region src/lib/utils/cache/HybridCache.d.ts
333
+ declare class HybridCache<Key, Value> {
334
+ remote?: BaseCacheAdapter<Key, Value> | undefined;
335
+ defaultTTL?: number | undefined;
336
+ local: LocalCacheAdapter<Key, Value>;
337
+ constructor(remote?: BaseCacheAdapter<Key, Value> | undefined, defaultTTL?: number | undefined);
338
+ get(key: Key): Promise<Value | undefined>;
339
+ sweep(filter: (data: Value) => boolean): Promise<void>;
340
+ set(key: Key, value: Value, ttl?: number | undefined): Promise<void>;
341
+ delete(key: Key): Promise<void>;
342
+ clear(): Promise<void>;
343
+ has(key: Key): Promise<boolean>;
344
+ }
345
+ //#endregion
346
+ //#region src/lib/client/ClientCacheManager.d.ts
347
+ interface ClientCacheManagerOptions {
348
+ users?: ClientModuleCacheOptions<User> | boolean;
349
+ messages?: ClientModuleCacheOptions<Message> | boolean;
350
+ }
351
+ interface ClientModuleCacheOptions<Value> {
352
+ enabled: boolean;
353
+ adapter?: BaseCacheAdapter<string, Value>;
354
+ ttl?: number;
355
+ sweeper?: ClientModuleCacheSweeperOptions<Value>;
356
+ }
357
+ interface ClientModuleCacheSweeperOptions<Value> {
358
+ interval: number;
359
+ filter: (data: Value) => boolean;
360
+ }
361
+ declare class ClientCacheManager {
362
+ #private;
363
+ options: ClientCacheManagerOptions;
364
+ channels: LocalCacheAdapter<string, Channel>;
365
+ guilds: LocalCacheAdapter<string, Guild>;
366
+ constructor(options: ClientCacheManagerOptions);
367
+ get users(): HybridCache<string, User>;
368
+ get messages(): HybridCache<string, Message<boolean>>;
369
+ isModuleEnabled(module: keyof ClientCacheManagerOptions): boolean;
370
+ resolve<Value>(cache: HybridCache<string, Value> | LocalCacheAdapter<string, Value>, id: string, factory: () => Value, patch?: (value: Value) => void): Promise<Value>;
371
+ resolveLocal<Value>(cache: LocalCacheAdapter<string, Value>, id: string, factory: () => Value, patch?: (value: Value) => void): Value;
372
+ }
373
+ //#endregion
374
+ //#region src/lib/client/Client.d.ts
232
375
  interface ClientOptions {
233
- token: string;
234
- intents: IntentResolvable | IntentsBitField;
235
- sharding?: ClientShardingOptions;
236
- partials?: Partial$1[];
376
+ token: string;
377
+ intents: IntentResolvable | IntentsBitField;
378
+ sharding?: ClientShardingOptions;
379
+ partials?: Partial$1[];
380
+ cache?: ClientCacheManagerOptions;
237
381
  }
238
- type ClientShardingOptions = Omit<ShardingManagerOptions, "token" | "intents">;
382
+ type ClientShardingOptions = Omit<ShardingManagerOptions$1, "token" | "intents">;
239
383
  interface ClientEvents {
240
- ready: [user: User];
241
- error: [error: Error];
242
- dispatch: [shardId: number, payload: GatewayDispatchPayload];
243
- raw: [shardId: number, payload: GatewayReceivePayload];
244
- messageCreate: [message: Message];
245
- messageUpdate: [message: Message];
246
- messageDelete: [message: {
247
- id: string;
248
- channelId: string;
249
- guildId?: string;
250
- }];
251
- userUpdate: [user: User];
252
- guildCreate: [guild: Guild];
253
- guildAvailable: [guild: Guild];
254
- guildUpdate: [guild: Guild];
255
- guildDelete: [guild: Guild];
256
- channelCreate: [channel: Channel];
257
- channelUpdate: [channel: Channel];
258
- channelDelete: [channel: Channel];
384
+ ready: [user: User];
385
+ error: [error: Error];
386
+ dispatch: [shardId: number, payload: GatewayDispatchPayload];
387
+ raw: [shardId: number, payload: GatewayReceivePayload];
388
+ messageCreate: [message: Message];
389
+ messageUpdate: [message: Message];
390
+ messageDelete: [message: Message];
391
+ userUpdate: [user: User];
392
+ guildCreate: [guild: Guild];
393
+ guildAvailable: [guild: Guild];
394
+ guildUpdate: [guild: Guild];
395
+ guildDelete: [guild: Guild];
396
+ channelCreate: [channel: Channel];
397
+ channelUpdate: [channel: Channel];
398
+ channelDelete: [channel: Channel];
259
399
  }
260
- declare class Client extends EventEmitter<ClientEvents> {
261
- #private;
262
- readonly options: Omit<Required<ClientOptions>, "partials" | "intents"> & {
263
- partials: Set<Partial$1>;
264
- intents: IntentsBitField;
265
- };
266
- readonly shards: ShardingManager;
267
- readonly rest: RESTLike;
268
- readonly helper: ClientHelper;
269
- readonly guilds: Collection<string, Guild>;
270
- constructor(options: ClientOptions, rest?: RESTLike);
271
- get user(): User | undefined;
272
- login(): Promise<void>;
400
+ declare class Client<Ready extends boolean = boolean> extends EventEmitter<ClientEvents> {
401
+ #private;
402
+ readonly options: Omit<Required<ClientOptions>, "partials" | "intents"> & {
403
+ partials: Set<Partial$1>;
404
+ intents: IntentsBitField;
405
+ };
406
+ readonly shards: ShardingManager$1;
407
+ readonly rest: RESTLike$1;
408
+ readonly helper: ClientHelper;
409
+ readonly cache: ClientCacheManager;
410
+ constructor(options: ClientOptions, rest?: RESTLike$1);
411
+ get user(): Ready extends true ? User : User | undefined;
412
+ login(): Promise<void>;
273
413
  }
274
- declare function createClient(options: ClientOptions): Client;
275
-
276
- export { BaseChannel, type BaseChannelPayload, type Channel, Client, type ClientEvents, ClientHelper, type ClientOptions, type ClientShardingOptions, Guild, type GuildChannel, type GuildPayload, GuildTextChannel, GuildVoiceChannel, type IntentResolvable, IntentsBitField, Message, type MessageCreateOptions, type MessagePayload, type MessageReplyOptions, Partial$1 as Partial, type TextBasedChannel, User, type UserPayload, type VoiceBasedChannel, createClient };
414
+ declare function createClient(options: ClientOptions): Client<boolean>;
415
+ //#endregion
416
+ export { type AbstractConstructor, type Awaitable, BaseCacheAdapter, BaseChannel, BaseChannelPayload, type BaseRESTEvents, Channel, Client, ClientEvents, ClientHelper, ClientOptions, ClientShardingOptions, Cluster, type ClusterEvents, type ClusterOptions, type Constructor, DEFAULT_REST_OPTIONS, discord_api_types_v100 as DiscordAPIV10, DiscordHTTPError, type DiscordHTTPErrorRequest, type DiscordHTTPFlattenedError, type DiscordHTTPValidationError, type FunctionLike, Guild, GuildChannel, GuildPayload, GuildTextChannel, GuildVoiceChannel, HybridCache, Intent, IntentResolvable, IntentsBitField, LocalCacheAdapter, LocalCacheTTLEntry, Message, MessageCreateOptions, MessageEditOptions, MessagePayload, MessageReplyOptions, Partial$1 as Partial, type Promisify, type PromisifyValue, REST, RESTAdapter, type RESTAdapterEvents, type RESTEndpoint, type RESTEvents, type RESTLike, RESTMethod, type RESTOptions, type RESTProxyOptions, type RESTRequestFn, type RESTRequestOptions, type RPCHandler, type RejectFn, type ResolveFn, Service, type ServiceClientRuntime, ServiceDriver, type ServiceOptions, ServiceProcess, type ServiceProcessEvents, type ServiceServerRuntime, ServiceState, Shard, type ShardEvents, type ShardOptions, ShardState, ShardStrategy, ShardingManager, type ShardingManagerEvents, type ShardingManagerOptions, TextBasedChannel, TransportClient, type TransportClientEvents, TransportServer, type TransportServerEvents, User, UserPayload, VoiceBasedChannel, capitalize, createClient, createREST, createRESTAdapter, createService, createTransportClient, createTransportServer, instanceToObject, isCommonJS, isESM, isPlainObject, isPromiseLike, promisify, sleep };
417
+ //# sourceMappingURL=index.d.cts.map