revbot.js 0.0.1

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.
@@ -0,0 +1,2430 @@
1
+ import { User as User$1, FieldsUser, SystemMessage, File, Message as Message$1, Server as Server$1, FieldsServer, Role as Role$1, FieldsRole, Channel as Channel$1, Invite as Invite$1, Embed as Embed$1, SendableEmbed, Special, FieldsChannel, Member, FieldsMember, Category as Category$1, MessageSort } from 'revolt-api';
2
+ import { EventEmitter } from 'node:events';
3
+
4
+ type PartialObject = Partial<{
5
+ _id: string;
6
+ } | {
7
+ id: string;
8
+ } | {
9
+ _id: {
10
+ user: string;
11
+ };
12
+ }>;
13
+ /**
14
+ * Represents the base structure for all objects in the client.
15
+ * Provides common functionality such as equality checks, cloning, and patching data.
16
+ */
17
+ declare abstract class Base {
18
+ readonly client: client;
19
+ /** The unique identifier for the object. */
20
+ id: string;
21
+ /**
22
+ * Creates a new Base instance.
23
+ *
24
+ * @param {client} client - The client instance.
25
+ */
26
+ constructor(client: client);
27
+ /**
28
+ * Compares this object with another to determine if they are equal.
29
+ *
30
+ * @param {this | null} [obj] - The object to compare with.
31
+ * @returns {boolean} `true` if the objects are equal, otherwise `false`.
32
+ */
33
+ equals(obj?: this | null): boolean;
34
+ /**
35
+ * Updates the object with new data and returns a clone of the object.
36
+ *
37
+ * @param {PartialObject} data - The data to update the object with.
38
+ * @param {string[]} [clear] - Fields to clear in the object.
39
+ * @returns {this} A clone of the updated object.
40
+ */
41
+ _update(data: PartialObject, clear?: string[]): this;
42
+ /**
43
+ * Patches the object with new data.
44
+ *
45
+ * @param {PartialObject} data - The data to patch the object with.
46
+ * @param {string[]} [_clear] - Fields to clear in the object.
47
+ * @returns {this} The updated object.
48
+ * @protected
49
+ */
50
+ protected _patch(data: PartialObject, _clear?: string[]): this;
51
+ /**
52
+ * Creates a deep clone of the object.
53
+ *
54
+ * @returns {this} A clone of the object.
55
+ */
56
+ _clone(): this;
57
+ }
58
+
59
+ declare class UUID extends null {
60
+ static readonly ENCODING = "0123456789ABCDEFGHJKMNPQRSTVWXYZ";
61
+ static readonly ENCODING_LENGTH: number;
62
+ static readonly RANDOM_LENGTH = 16;
63
+ static readonly TIME_LENGTH = 10;
64
+ static readonly TIME_MAX: number;
65
+ static get PROG(): number;
66
+ private static time;
67
+ private static hash;
68
+ static generate(timestamp?: number): string;
69
+ static timestampOf(id: string): Date;
70
+ }
71
+
72
+ type BitFieldResolvable = BitField | number | string | BitFieldResolvable[];
73
+ declare class BitField {
74
+ static FLAGS: Record<string, number>;
75
+ bitfield: number;
76
+ constructor(bits?: BitFieldResolvable);
77
+ static resolve(bit: BitFieldResolvable): number;
78
+ get self(): {
79
+ FLAGS: Record<string, number>;
80
+ resolve(bit: BitFieldResolvable): number;
81
+ new (bits?: BitFieldResolvable): BitField;
82
+ };
83
+ any(bit: BitFieldResolvable): boolean;
84
+ has(bit: BitFieldResolvable): boolean;
85
+ toArray(): string[];
86
+ add(...bits: BitFieldResolvable[]): this;
87
+ remove(...bits: BitFieldResolvable[]): this;
88
+ freeze(): Readonly<this>;
89
+ valueOf(): number;
90
+ serialize(): Record<string, boolean>;
91
+ [Symbol.iterator](): Iterable<string>;
92
+ }
93
+
94
+ declare class RestClient {
95
+ private readonly client;
96
+ constructor(client: BaseClient);
97
+ /**
98
+ * Helper function to handle API requests.
99
+ * @param method The HTTP method (GET, POST, PATCH, PUT, DELETE).
100
+ * @param url The URL for the request.
101
+ * @param body The request body (if applicable).
102
+ * @param query Query parameters (if applicable).
103
+ * @returns The API response.
104
+ */
105
+ private request;
106
+ /**
107
+ * GET request.
108
+ * @param url The URL for the request.
109
+ * @param query Query parameters (if applicable).
110
+ * @returns The API response.
111
+ */
112
+ get<T>(url: string, query?: Record<string, string | number>): Promise<T>;
113
+ /**
114
+ * POST request.
115
+ * @param url The URL for the request.
116
+ * @param body The request body.
117
+ * @param query Query parameters (if applicable).
118
+ * @returns The API response.
119
+ */
120
+ post<T>(url: string, body: any, query?: Record<string, string | number>): Promise<T>;
121
+ /**
122
+ * PATCH request.
123
+ * @param url The URL for the request.
124
+ * @param body The request body.
125
+ * @param query Query parameters (if applicable).
126
+ * @returns The API response.
127
+ */
128
+ patch<T>(url: string, body: any, query?: Record<string, string | number>): Promise<T>;
129
+ /**
130
+ * PUT request.
131
+ * @param url The URL for the request.
132
+ * @param body The request body.
133
+ * @param query Query parameters (if applicable).
134
+ * @returns The API response.
135
+ */
136
+ put<T>(url: string, body?: any, query?: Record<string, string | number>): Promise<T>;
137
+ /**
138
+ * DELETE request.
139
+ * @param url The URL for the request.
140
+ * @param query Query parameters (if applicable).
141
+ * @returns The API response.
142
+ */
143
+ delete<T>(url: string, body?: any, query?: Record<string, string | number>): Promise<T>;
144
+ }
145
+
146
+ /**
147
+ * Represents the events that the client can emit.
148
+ */
149
+ interface ClientEvents {
150
+ /** Emitted when a debug message is logged. */
151
+ [Events.DEBUG]: [unknown];
152
+ /** Emitted when a message is received. */
153
+ [Events.MESSAGE]: [Message];
154
+ /** Emitted when a message is deleted. */
155
+ [Events.MESSAGE_DELETE]: [Message];
156
+ /** Emitted when a message is updated. */
157
+ [Events.MESSAGE_UPDATE]: [Message, Message];
158
+ /** Emitted when a reaction is added to a message. */
159
+ [Events.MESSAGE_REACT]: [Message];
160
+ /** Emitted when a reaction is removed from a message. */
161
+ [Events.MESSAGE_REACT_REMOVE]: [Message];
162
+ /** Emitted when a message is bulk deleted. */
163
+ [Events.MESSAGE_DELETE_BULK]: [string[]];
164
+ /** Emitted when a channel is created. */
165
+ [Events.CHANNEL_CREATE]: [Channel];
166
+ /** Emitted when a channel is deleted. */
167
+ [Events.CHANNEL_DELETE]: [Channel];
168
+ /** Emitted when a channel is updated. */
169
+ [Events.CHANNEL_UPDATE]: [Channel, Channel];
170
+ /** Emitted when a server is created. */
171
+ [Events.SERVER_CREATE]: [Server];
172
+ /** Emitted when a server is deleted. */
173
+ [Events.SERVER_DELETE]: [Server];
174
+ /** Emitted when a server is updated. */
175
+ [Events.SERVER_UPDATE]: [Server, Server];
176
+ /** Emitted when a server member joins. */
177
+ [Events.SERVER_MEMBER_JOIN]: [ServerMember];
178
+ /** Emitted when a server member leaves. */
179
+ [Events.SERVER_MEMBER_LEAVE]: [ServerMember];
180
+ /** Emitted when a server member is updated. */
181
+ [Events.SERVER_MEMBER_UPDATE]: [ServerMember, ServerMember];
182
+ /** Emitted when a user is updated. */
183
+ [Events.USER_UPDATE]: [User, User];
184
+ /** Emitted when a user is typing. */
185
+ [Events.TYPING_START]: [Channel, User];
186
+ /** Emitted when a user stops typing. */
187
+ [Events.TYPING_STOP]: [Channel, User];
188
+ /** Emitted when a group member joins. */
189
+ [Events.GROUP_JOIN]: [Channel, User];
190
+ /** Emitted when a group member leaves. */
191
+ [Events.GROUP_LEAVE]: [Channel, User];
192
+ /** Emitted when the client is ready. */
193
+ [Events.READY]: [client];
194
+ /** Emitted when an error occurs. */
195
+ [Events.ERROR]: [unknown];
196
+ /** Emitted when a raw event is received. */
197
+ [Events.RAW]: [unknown];
198
+ /** emitted when a role is created */
199
+ [Events.ROLE_CREATE]: [Role];
200
+ /** emitted when a role is deleted */
201
+ [Events.ROLE_DELETE]: [Role];
202
+ /** emitted when a role is updated */
203
+ [Events.ROLE_UPDATE]: [Role, Role];
204
+ }
205
+ /**
206
+ * Represents the options for configuring the client.
207
+ */
208
+ interface clientOptions {
209
+ /** Whether to fetch all members of a server. */
210
+ fetchMembers?: boolean;
211
+ /** Configuration for REST API requests. */
212
+ rest?: {
213
+ /** The timeout for REST requests in milliseconds. */
214
+ timeout: number;
215
+ /** The number of retries for failed REST requests. */
216
+ retries: number;
217
+ };
218
+ /** Configuration for WebSocket connections. */
219
+ ws?: {
220
+ /** The interval for sending heartbeats in milliseconds. */
221
+ heartbeatInterval?: number;
222
+ /** Whether to automatically reconnect on disconnection. */
223
+ reconnect?: boolean;
224
+ };
225
+ }
226
+ /**
227
+ * Represents the base client that provides core functionality for interacting with the API.
228
+ *
229
+ * @extends EventEmitter
230
+ */
231
+ declare interface BaseClient {
232
+ on<K extends keyof ClientEvents>(event: K, listener: (...args: ClientEvents[K]) => Awaited<void>): this;
233
+ on<S extends string | symbol>(event: Exclude<S, keyof ClientEvents>, listener: (...args: any[]) => Awaited<void>): this;
234
+ once<K extends keyof ClientEvents>(event: K, listener: (...args: ClientEvents[K]) => Awaited<void>): this;
235
+ once<S extends string | symbol>(event: Exclude<S, keyof ClientEvents>, listener: (...args: any[]) => Awaited<void>): this;
236
+ emit<K extends keyof ClientEvents>(event: K, ...args: ClientEvents[K]): boolean;
237
+ emit<S extends string | symbol>(event: Exclude<S, keyof ClientEvents>, ...args: unknown[]): boolean;
238
+ off<K extends keyof ClientEvents>(event: K, listener: (...args: ClientEvents[K]) => Awaited<void>): this;
239
+ off<S extends string | symbol>(event: Exclude<S, keyof ClientEvents>, listener: (...args: any[]) => Awaited<void>): this;
240
+ removeAllListeners<K extends keyof ClientEvents>(event?: K): this;
241
+ removeAllListeners<S extends string | symbol>(event?: Exclude<S, keyof ClientEvents>): this;
242
+ }
243
+ /**
244
+ * Represents the base client that provides core functionality for interacting with the API.
245
+ *
246
+ * @extends EventEmitter
247
+ */
248
+ declare abstract class BaseClient extends EventEmitter {
249
+ #private;
250
+ /** The REST client for making API requests. */
251
+ readonly api: RestClient;
252
+ /** The options for configuring the client. */
253
+ options: clientOptions;
254
+ /** Whether the client is a bot. */
255
+ bot: boolean;
256
+ /**
257
+ * Creates a new BaseClient instance.
258
+ *
259
+ * @param {clientOptions} [options={}] - The options for configuring the client.
260
+ */
261
+ constructor(options?: clientOptions);
262
+ /**
263
+ * Emits a debug message.
264
+ *
265
+ * @param {unknown} msg - The debug message to emit.
266
+ */
267
+ debug(msg: unknown): void;
268
+ /**
269
+ * Sets the authentication token for the client.
270
+ *
271
+ * @param {string | null} token - The authentication token.
272
+ */
273
+ set token(token: string | null);
274
+ /**
275
+ * Gets the authentication token for the client.
276
+ *
277
+ * @returns {string | null} The authentication token, or `null` if not set.
278
+ */
279
+ get token(): string | null;
280
+ }
281
+
282
+ /**
283
+ * Enum representing the client events that can be emitted.
284
+ */
285
+ declare enum Events {
286
+ CHANNEL_CREATE = "channelCreate",
287
+ CHANNEL_DELETE = "channelDelete",
288
+ CHANNEL_UPDATE = "channelUpdate",
289
+ DEBUG = "debug",
290
+ ERROR = "error",
291
+ GROUP_JOIN = "groupJoin",
292
+ GROUP_LEAVE = "groupLeave",
293
+ MESSAGE = "message",
294
+ MESSAGE_DELETE = "messageDelete",
295
+ MESSAGE_DELETE_BULK = "messageDeleteBulk",
296
+ MESSAGE_UPDATE = "messageUpdate",
297
+ MESSAGE_REACT = "messageReact",
298
+ MESSAGE_REACT_REMOVE = "messageUnreact",
299
+ RAW = "raw",
300
+ READY = "ready",
301
+ ROLE_CREATE = "roleCreate",
302
+ ROLE_DELETE = "roleDelete",
303
+ ROLE_UPDATE = "roleUpdate",
304
+ SERVER_CREATE = "serverCreate",
305
+ SERVER_DELETE = "serverDelete",
306
+ SERVER_MEMBER_JOIN = "serverMemberJoin",
307
+ SERVER_MEMBER_LEAVE = "serverMemberLeave",
308
+ SERVER_MEMBER_UPDATE = "serverMemberUpdate",
309
+ SERVER_UPDATE = "serverUpdate",
310
+ TYPING_START = "typingStart",
311
+ TYPING_STOP = "typingStop",
312
+ USER_UPDATE = "userUpdate"
313
+ }
314
+ /**
315
+ * Enum representing the WebSocket events used for communication.
316
+ */
317
+ declare enum WSEvents {
318
+ AUTHENTICATE = "Authenticate",
319
+ AUTHENTICATED = "Authenticated",
320
+ BEGIN_TYPING = "BeginTyping",
321
+ BULK = "Bulk",
322
+ CHANNEL_ACK = "ChannelAck",
323
+ CHANNEL_CREATE = "ChannelCreate",
324
+ CHANNEL_DELETE = "ChannelDelete",
325
+ CHANNEL_GROUP_JOIN = "ChannelGroupJoin",
326
+ CHANNEL_GROUP_LEAVE = "ChannelGroupLeave",
327
+ CHANNEL_START_TYPING = "ChannelStartTyping",
328
+ CHANNEL_STOP_TYPING = "ChannelStopTyping",
329
+ CHANNEL_UPDATE = "ChannelUpdate",
330
+ END_TYPING = "EndTyping",
331
+ ERROR = "Error",
332
+ MESSAGE = "Message",
333
+ MESSAGE_BULK_DELETE = "BulkMessageDelete",
334
+ MESSAGE_DELETE = "MessageDelete",
335
+ MESSAGE_UPDATE = "MessageUpdate",
336
+ PING = "Ping",
337
+ PONG = "Pong",
338
+ READY = "Ready",
339
+ SERVER_DELETE = "ServerDelete",
340
+ SERVER_MEMBER_JOIN = "ServerMemberJoin",
341
+ SERVER_MEMBER_LEAVE = "ServerMemberLeave",
342
+ SERVER_MEMBER_UPDATE = "ServerMemberUpdate",
343
+ SERVER_ROLE_DELETE = "ServerRoleDelete",
344
+ SERVER_ROLE_UPDATE = "ServerRoleUpdate",
345
+ SERVER_UPDATE = "ServerUpdate",
346
+ USER_RELATIONSHIP = "UserRelationship",
347
+ USER_UPDATE = "UserUpdate"
348
+ }
349
+ /**
350
+ * Enum representing the types of channels supported by the client.
351
+ */
352
+ declare enum ChannelTypes {
353
+ DM = "DM",
354
+ GROUP = "GROUP",
355
+ TEXT = "TEXT",
356
+ VOICE = "VOICE",
357
+ NOTES = "NOTES"
358
+ }
359
+ /**
360
+ * The default options for configuring the client.
361
+ */
362
+ declare const DEFAULT_CLIENT_OPTIONS: clientOptions;
363
+ /** The WebSocket URL for connecting to the Revolt API. */
364
+ declare const wsUrl = "wss://ws.revolt.chat?version=1&format=json";
365
+ /** The base API URL for interacting with the Revolt API. */
366
+ declare const apiUrl = "https://api.revolt.chat";
367
+ /** The system user ID used for identifying system messages. */
368
+ declare const SYSTEM_USER_ID: string;
369
+
370
+ type ChannelPermissionsString = keyof typeof ChannelPermissions.FLAGS;
371
+ type UserPermissionsString = keyof typeof UserPermissions.FLAGS;
372
+ type ServerPermissionsString = keyof typeof ServerPermissions.FLAGS;
373
+ type ChannelPermissionsResolvable = number | ChannelPermissionsString | ChannelPermissions | ChannelPermissionsResolvable[];
374
+ type UserPermissionsResolvable = number | UserPermissionsString | UserPermissions | UserPermissionsResolvable[];
375
+ type ServerPermissionsResolvable = number | ServerPermissionsString | ServerPermissions | ServerPermissionsResolvable[];
376
+ declare interface ChannelPermissions {
377
+ serialize(): Record<ChannelPermissionsString, boolean>;
378
+ any(bit: ChannelPermissionsResolvable): boolean;
379
+ add(...bits: ChannelPermissionsResolvable[]): this;
380
+ remove(...bits: ChannelPermissionsResolvable[]): this;
381
+ has(bit: ChannelPermissionsResolvable): boolean;
382
+ }
383
+ declare class ChannelPermissions extends BitField {
384
+ static readonly FLAGS: {
385
+ readonly VIEW_CHANNEL: number;
386
+ readonly SEND_MESSAGE: number;
387
+ readonly MANAGE_MESSAGE: number;
388
+ readonly MANAGE_CHANNEL: number;
389
+ readonly VOICE_CALL: number;
390
+ readonly INVITE_OTHERS: number;
391
+ readonly EMBED_LINKS: number;
392
+ readonly UPLOAD_FILES: number;
393
+ };
394
+ constructor(bits?: ChannelPermissionsResolvable);
395
+ static resolve(bit: ChannelPermissionsResolvable): number;
396
+ }
397
+ declare interface UserPermissions {
398
+ serialize(): Record<UserPermissionsString, boolean>;
399
+ any(bit: UserPermissionsResolvable): boolean;
400
+ add(...bits: UserPermissionsResolvable[]): this;
401
+ remove(...bits: UserPermissionsResolvable[]): this;
402
+ has(bit: UserPermissionsResolvable): boolean;
403
+ }
404
+ declare class UserPermissions extends BitField {
405
+ static readonly FLAGS: {
406
+ readonly ACCESS: number;
407
+ readonly VIEW_PROFILE: number;
408
+ readonly SEND_MESSAGES: number;
409
+ readonly INVITE: number;
410
+ };
411
+ constructor(bits?: UserPermissionsResolvable);
412
+ static resolve(bit: UserPermissionsResolvable): number;
413
+ }
414
+ declare interface ServerPermissions {
415
+ serialize(): Record<ServerPermissionsString, boolean>;
416
+ any(bit: ServerPermissionsResolvable): boolean;
417
+ add(...bits: ServerPermissionsResolvable[]): this;
418
+ remove(...bits: ServerPermissionsResolvable[]): this;
419
+ has(bit: ServerPermissionsResolvable): boolean;
420
+ }
421
+ declare class ServerPermissions extends BitField {
422
+ static readonly FLAGS: {
423
+ readonly VIEW_SERVER: number;
424
+ readonly MANAGE_ROLES: number;
425
+ readonly MANAGE_CHANNELS: number;
426
+ readonly MANAGE_SERVER: number;
427
+ readonly KICK_MEMBERS: number;
428
+ readonly BAN_MEMBERS: number;
429
+ readonly CHANGE_NICKNAME: number;
430
+ readonly MANAGE_NICKNAMES: number;
431
+ readonly CHANGE_AVATAR: number;
432
+ readonly REMOVE_AVATARS: number;
433
+ };
434
+ constructor(bits?: ServerPermissionsResolvable);
435
+ static resolve(bit: ServerPermissionsResolvable): number;
436
+ }
437
+ declare const DEFAULT_PERMISSION_DM: Readonly<ChannelPermissions>;
438
+
439
+ type BadgeString = keyof typeof Badges.FLAGS;
440
+ type BadgesResolvable = number | BadgeString | Badges | BadgesResolvable[];
441
+ declare interface Badges {
442
+ serialize(): Record<BadgeString, boolean>;
443
+ any(bit: BadgesResolvable): boolean;
444
+ add(...bits: BadgesResolvable[]): this;
445
+ remove(...bits: BadgesResolvable[]): this;
446
+ has(bit: BadgesResolvable): boolean;
447
+ }
448
+ declare class Badges extends BitField {
449
+ static readonly FLAGS: {
450
+ readonly DEVELOPER: number;
451
+ readonly TRANSLATOR: number;
452
+ readonly SUPPORTER: number;
453
+ readonly RESPONSIBLE_DISCLOSURE: number;
454
+ readonly REVOLT_TEAM: number;
455
+ readonly EARLY_ADOPTER: number;
456
+ };
457
+ constructor(bits?: BadgesResolvable);
458
+ static resolve(bit: BadgesResolvable): number;
459
+ }
460
+
461
+ /**
462
+ * Represents a user in the client.
463
+ *
464
+ * @extends Base
465
+ */
466
+ declare class User extends Base {
467
+ /** The username of the user. */
468
+ username: string;
469
+ /** The avatar of the user, or `null` if none is set. */
470
+ avatar: Attachment | null;
471
+ /** The presence status of the user. */
472
+ presence: Presence;
473
+ /** The badges associated with the user. */
474
+ badges: Badges;
475
+ /** Whether the user is a bot. */
476
+ bot: boolean;
477
+ /**
478
+ * Creates a new User instance.
479
+ *
480
+ * @param {client} client - The client instance.
481
+ * @param {APIUser} data - The raw data for the user from the API.
482
+ */
483
+ constructor(client: client, data: User$1);
484
+ /**
485
+ * Updates the user instance with new data from the API.
486
+ *
487
+ * @param {APIUser} data - The raw data for the user from the API.
488
+ * @param {FieldsUser[]} [clear=[]] - Fields to clear in the user.
489
+ * @returns {this} The updated user instance.
490
+ * @protected
491
+ */
492
+ protected _patch(data: User$1, clear?: FieldsUser[]): this;
493
+ /**
494
+ * Gets the creation date of the user.
495
+ *
496
+ * @returns {Date} The date when the user was created.
497
+ */
498
+ get createdAt(): Date;
499
+ /**
500
+ * Gets the creation timestamp of the user in milliseconds.
501
+ *
502
+ * @returns {number} The timestamp of when the user was created.
503
+ */
504
+ get createdTimestamp(): number;
505
+ /**
506
+ * Blocks the user.
507
+ *
508
+ * @returns {Promise<void>} A promise that resolves when the user is blocked.
509
+ *
510
+ * @example
511
+ * ```typescript
512
+ * await user.block();
513
+ * ```
514
+ */
515
+ block(): Promise<void>;
516
+ /**
517
+ * Unblocks the user.
518
+ *
519
+ * @returns {Promise<void>} A promise that resolves when the user is unblocked.
520
+ *
521
+ * @example
522
+ * ```typescript
523
+ * await user.unblock();
524
+ * ```
525
+ */
526
+ unblock(): Promise<void>;
527
+ /**
528
+ * Creates a direct message (DM) channel with the user.
529
+ *
530
+ * @returns {Promise<DMChannel>} A promise that resolves with the created DM channel.
531
+ *
532
+ * @example
533
+ * ```typescript
534
+ * const dmChannel = await user.createDM();
535
+ * ```
536
+ */
537
+ createDM(): Promise<DMChannel>;
538
+ /**
539
+ * Fetches the latest data for the user from the API.
540
+ *
541
+ * @param {boolean} [force=true] - Whether to force a fetch even if the user is cached.
542
+ * @returns {Promise<User>} A promise that resolves with the updated user instance.
543
+ */
544
+ fetch(force?: boolean): Promise<User>;
545
+ /**
546
+ * Converts the user to a string representation.
547
+ *
548
+ * @returns {string} A string representation of the user in the format `<@userId>`.
549
+ */
550
+ toString(): string;
551
+ }
552
+
553
+ /**
554
+ * Represents a message in a channel.
555
+ *
556
+ * @extends Base
557
+ */
558
+ declare class Message extends Base {
559
+ /** The type of the message (e.g., TEXT, SYSTEM). */
560
+ type: Uppercase<SystemMessage["type"]>;
561
+ /** The content of the message. */
562
+ content: string;
563
+ /** The ID of the channel where the message was sent. */
564
+ channelId: string;
565
+ /** The ID of the user who authored the message. */
566
+ authorId: string;
567
+ /** An array of embeds included in the message. */
568
+ embeds: Embed[];
569
+ /** An array of file attachments included in the message. */
570
+ attachments: File[];
571
+ /** Mentions included in the message. */
572
+ mentions: Mentions;
573
+ /** The timestamp of when the message was last edited, or `null` if not edited. */
574
+ editedTimestamp: number | null;
575
+ /** the reactions and count on a message */
576
+ reactions: Map<string, string[]>;
577
+ /**
578
+ * Creates a new Message instance.
579
+ *
580
+ * @param {client} client - The client instance.
581
+ * @param {APIMessage} data - The raw data for the message from the API.
582
+ */
583
+ constructor(client: client, data: Message$1);
584
+ /**
585
+ * Updates the message instance with new data from the API.
586
+ *
587
+ * @param {APIMessage} data - The raw data for the message from the API.
588
+ * @returns {this} The updated message instance.
589
+ * @protected
590
+ */
591
+ protected _patch(data: Message$1): this;
592
+ /**
593
+ * Gets the creation date of the message.
594
+ *
595
+ * @returns {Date} The date when the message was created.
596
+ */
597
+ get createdAt(): Date;
598
+ /**
599
+ * Gets the creation timestamp of the message in milliseconds.
600
+ *
601
+ * @returns {number} The timestamp of when the message was created.
602
+ */
603
+ get createdTimestamp(): number;
604
+ /**
605
+ * Gets the date when the message was last edited.
606
+ *
607
+ * @returns {Date | null} The date of the last edit, or `null` if not edited.
608
+ */
609
+ get editedAt(): Date | null;
610
+ /**
611
+ * Checks if the message is a system message.
612
+ *
613
+ * @returns {boolean} `true` if the message is a system message, otherwise `false`.
614
+ */
615
+ get system(): boolean;
616
+ /**
617
+ * Retrieves the author of the message.
618
+ *
619
+ * @returns {User | null} The user who authored the message, or `null` if not found.
620
+ */
621
+ get author(): User | null;
622
+ /**
623
+ * Retrieves the channel where the message was sent.
624
+ *
625
+ * @returns {TextChannel | DMChannel | GroupChannel} The channel instance.
626
+ */
627
+ get channel(): TextChannel | DMChannel | GroupChannel;
628
+ /**
629
+ * Retrieves the server ID associated with the message, if any.
630
+ *
631
+ * @returns {string | null} The server ID, or `null` if the message is not in a server.
632
+ */
633
+ get serverId(): string | null;
634
+ /**
635
+ * Retrieves the server associated with the message, if any.
636
+ *
637
+ * @returns {Server | null} The server instance, or `null` if not found.
638
+ */
639
+ get server(): Server | null;
640
+ /**
641
+ * Retrieves the server member who authored the message, if any.
642
+ *
643
+ * @returns {ServerMember | null} The server member instance, or `null` if not found.
644
+ */
645
+ get member(): ServerMember | null;
646
+ /**
647
+ * Gets the URL of the message.
648
+ *
649
+ * @returns {string} The URL of the message.
650
+ */
651
+ get url(): string;
652
+ /**
653
+ * Acknowledges the message.
654
+ *
655
+ * @returns {Promise<void>} A promise that resolves when the message is acknowledged.
656
+ */
657
+ ack(): Promise<void>;
658
+ /**
659
+ * Deletes the message.
660
+ *
661
+ * @returns {Promise<void>} A promise that resolves when the message is deleted.
662
+ */
663
+ delete(): Promise<void>;
664
+ /**
665
+ * Replies to the message.
666
+ *
667
+ * @param {string} content - The content of the reply.
668
+ * @param {boolean} [mention=true] - Whether to mention the original message author.
669
+ * @returns {Promise<Message>} A promise that resolves with the sent reply message.
670
+ */
671
+ reply(content: string, mention?: boolean): Promise<Message>;
672
+ /**
673
+ * Edits the message.
674
+ *
675
+ * @param {MessageEditOptions | string} options - The new content or edit options.
676
+ * @returns {Promise<void>} A promise that resolves when the message is edited.
677
+ */
678
+ edit(options: MessageEditOptions | string): Promise<void>;
679
+ /**
680
+ * Fetches the latest data for the message.
681
+ *
682
+ * @returns {Promise<Message>} A promise that resolves with the updated message instance.
683
+ */
684
+ fetch(): Promise<Message>;
685
+ /**
686
+ * Adds a reaction to the message.
687
+ *
688
+ * @param {string} emoji - The emoji to react with.
689
+ * @returns {Promise<void>} A promise that resolves when the reaction is added.
690
+ */
691
+ addReaction(emoji: string): Promise<void>;
692
+ /**
693
+ * Removes a reaction from the message.
694
+ *
695
+ * @param {string} emoji - The emoji to remove the reaction for.
696
+ * @param {object} [options] - Options for removing the reaction.
697
+ * @param {string} [options.user_id] - The user ID to remove the reaction for. If not provided, removes the reaction for the current user.
698
+ * @param {boolean} [options.remove_all=false] - Whether to remove all of the specified reaction for the message.
699
+ * @returns {Promise<void>} A promise that resolves when the reaction is removed.
700
+ */
701
+ removeReaction(emoji: string, options?: {
702
+ user_id?: string;
703
+ remove_all?: boolean;
704
+ }): Promise<void>;
705
+ /**
706
+ * Removes all reactions from the message.
707
+ *
708
+ * @returns {Promise<void>} A promise that resolves when all reactions are removed.
709
+ */
710
+ removeAllReactions(): Promise<void>;
711
+ /**
712
+ * Checks if the message is in a server.
713
+ *
714
+ * @returns {boolean} `true` if the message is in a server, otherwise `false`.
715
+ */
716
+ inServer(): this is this & {
717
+ serverId: string;
718
+ server: Server;
719
+ channel: TextChannel;
720
+ };
721
+ /**
722
+ * Converts the message to a string representation.
723
+ *
724
+ * @returns {string} The content of the message.
725
+ */
726
+ toString(): string;
727
+ }
728
+
729
+ /**
730
+ * Represents an attachment, such as a file or image, in a message or channel.
731
+ *
732
+ * @extends Base
733
+ */
734
+ declare class Attachment extends Base {
735
+ /** The filename of the attachment. */
736
+ filename: string;
737
+ /** The MIME type of the attachment (e.g., `image/png`, `application/pdf`). */
738
+ type: string;
739
+ /** The size of the attachment in bytes. */
740
+ size: number;
741
+ /** Metadata associated with the attachment (e.g., dimensions for images). */
742
+ metadata: File["metadata"];
743
+ /**
744
+ * Creates a new Attachment instance.
745
+ *
746
+ * @param {client} client - The client instance.
747
+ * @param {File} data - The raw data for the attachment from the API.
748
+ */
749
+ constructor(client: client, data: File);
750
+ /**
751
+ * Updates the attachment instance with new data from the API.
752
+ *
753
+ * @param {File} data - The raw data for the attachment from the API.
754
+ * @returns {this} The updated attachment instance.
755
+ * @protected
756
+ */
757
+ protected _patch(data: File): this;
758
+ }
759
+
760
+ /**
761
+ * Enum representing the possible presence statuses of a user.
762
+ */
763
+ declare enum Status {
764
+ Online = "ONLINE",
765
+ Idle = "IDLE",
766
+ Busy = "DND",
767
+ Invisible = "OFFLINE"
768
+ }
769
+ /**
770
+ * Represents the presence of a user, including their status and custom text.
771
+ *
772
+ * @extends Base
773
+ */
774
+ declare class Presence extends Base {
775
+ /** The custom status text of the user, or `null` if none is set. */
776
+ text: string | null;
777
+ /** The current status of the user (e.g., Online, Idle, Busy, Invisible). */
778
+ status: Status;
779
+ }
780
+
781
+ /**
782
+ * Represents a server (guild) in the client.
783
+ *
784
+ * @extends Base
785
+ */
786
+ declare class Server extends Base {
787
+ /** The name of the server. */
788
+ name: string;
789
+ /** The description of the server, or `null` if none is set. */
790
+ description: string | null;
791
+ /** The ID of the user who owns the server. */
792
+ ownerId: string;
793
+ /** Manages the members of the server. */
794
+ members: ServerMemberManager;
795
+ /** Manages the channels of the server. */
796
+ channels: ServerChannelManager;
797
+ /** Manages the roles of the server. */
798
+ roles: RoleManager;
799
+ /** The icon of the server, or `null` if none is set. */
800
+ icon: Attachment | null;
801
+ /** The banner of the server, or `null` if none is set. */
802
+ banner: Attachment | null;
803
+ /** Whether analytics are enabled for the server. */
804
+ analytics: boolean;
805
+ /** Whether the server is discoverable. */
806
+ discoverable: boolean;
807
+ /** Whether the server is marked as NSFW (Not Safe For Work). */
808
+ nsfw: boolean;
809
+ /** The default permissions for the server. */
810
+ permissions: ServerPermissions;
811
+ /** The categories in the server. */
812
+ categories: Map<string, Category>;
813
+ /** the emojies associated with the server */
814
+ emojis: Map<string, Emoji>;
815
+ /**
816
+ * Creates a new Server instance.
817
+ *
818
+ * @param {client} client - The client instance.
819
+ * @param {APIServer} data - The raw data for the server from the API.
820
+ */
821
+ constructor(client: client, data: Server$1);
822
+ /**
823
+ * Updates the server instance with new data from the API.
824
+ *
825
+ * @param {APIServer} data - The raw data for the server from the API.
826
+ * @param {FieldsServer[]} [clear=[]] - Fields to clear in the server.
827
+ * @returns {this} The updated server instance.
828
+ * @protected
829
+ */
830
+ protected _patch(data: Server$1, clear?: FieldsServer[]): this;
831
+ /**
832
+ * Retrieves the current user's member instance in the server.
833
+ *
834
+ * @returns {ServerMember | null} The current user's member instance, or `null` if not found.
835
+ */
836
+ get me(): ServerMember | null;
837
+ /**
838
+ * Gets the creation date of the server.
839
+ *
840
+ * @returns {Date} The date when the server was created.
841
+ */
842
+ get createdAt(): Date;
843
+ /**
844
+ * Gets the creation timestamp of the server in milliseconds.
845
+ *
846
+ * @returns {number} The timestamp of when the server was created.
847
+ */
848
+ get createdTimestamp(): number;
849
+ /**
850
+ * Retrieves the owner of the server.
851
+ *
852
+ * @returns {User | null} The owner of the server, or `null` if not found.
853
+ */
854
+ get owner(): User | null;
855
+ /**
856
+ * Converts the server to a string representation.
857
+ *
858
+ * @returns {string} The name of the server.
859
+ */
860
+ toString(): string;
861
+ }
862
+
863
+ /**
864
+ * Represents a role in a server.
865
+ *
866
+ * @extends Base
867
+ */
868
+ declare class Role extends Base {
869
+ server: Server;
870
+ /** The name of the role. */
871
+ name: string;
872
+ /** The color of the role, or `null` if no color is set. */
873
+ color: string | null;
874
+ /** Whether the role is displayed separately in the member list. */
875
+ hoist: boolean;
876
+ /** The rank of the role, used for ordering. */
877
+ rank: number;
878
+ /** The permissions overwrite for the role. */
879
+ overwrite: Overwrite;
880
+ /**
881
+ * Creates a new Role instance.
882
+ *
883
+ * @param {Server} server - The server this role belongs to.
884
+ * @param {APIRole & { id: string }} data - The raw data for the role from the API.
885
+ */
886
+ constructor(server: Server, data: Role$1 & {
887
+ id: string;
888
+ });
889
+ /**
890
+ * Updates the role instance with new data from the API.
891
+ *
892
+ * @param {APIRole & { _id?: string }} data - The raw data for the role from the API.
893
+ * @param {FieldsRole[]} [clear=[]] - Fields to clear in the role.
894
+ * @returns {this} The updated role instance.
895
+ * @protected
896
+ */
897
+ protected _patch(data: Role$1 & {
898
+ _id?: string;
899
+ }, clear?: FieldsRole[]): this;
900
+ /**
901
+ * Gets the date when the role was created.
902
+ *
903
+ * @returns {Date} The creation date of the role.
904
+ */
905
+ get createdAt(): Date;
906
+ /**
907
+ * Gets the timestamp of when the role was created.
908
+ *
909
+ * @returns {number} The creation timestamp of the role in milliseconds.
910
+ */
911
+ get createdTimestamp(): number;
912
+ /**
913
+ * Gets the permissions overwrite for the role.
914
+ *
915
+ * @returns {Overwrite} The permissions overwrite for the role.
916
+ */
917
+ get permissions(): Overwrite;
918
+ /**
919
+ * Deletes the role from the server.
920
+ *
921
+ * @returns {Promise<void>} A promise that resolves when the role is deleted.
922
+ *
923
+ * @example
924
+ * ```typescript
925
+ * await role.delete();
926
+ * console.log("Role deleted successfully.");
927
+ * ```
928
+ */
929
+ delete(): Promise<void>;
930
+ /**
931
+ * Converts the role to a string representation.
932
+ *
933
+ * @returns {string} A string representation of the role in the format `<@&roleId>`.
934
+ */
935
+ toString(): string;
936
+ }
937
+
938
+ /**
939
+ * Represents a generic communication channel in the client.
940
+ * This abstract class provides a base structure and common functionality
941
+ * for all types of channels, such as text, voice, group, and server channels.
942
+ *
943
+ * @abstract
944
+ * @extends Base
945
+ *
946
+ * @property {ChannelTypes | "UNKNOWN"} type - The type of the channel. Defaults to "UNKNOWN".
947
+ * @property {number} createdTimestamp - The timestamp (in milliseconds) when the channel was created.
948
+ * @property {Date} createdAt - The date and time when the channel was created.
949
+ */
950
+ declare abstract class Channel extends Base {
951
+ type: ChannelTypes | "UNKNOWN";
952
+ /**
953
+ * Gets the timestamp (in milliseconds) when the channel was created.
954
+ *
955
+ * @returns {number} The timestamp of the channel's creation.
956
+ */
957
+ get createdTimestamp(): number;
958
+ /**
959
+ * Gets the date and time when the channel was created.
960
+ *
961
+ * @returns {Date} The creation date of the channel.
962
+ */
963
+ get createdAt(): Date;
964
+ /**
965
+ * Deletes the current channel instance from the client's channel collection.
966
+ *
967
+ * This method interacts with the client's channel management system to remove
968
+ * the channel. Once deleted, the channel will no longer be accessible through
969
+ * the client.
970
+ *
971
+ * @returns {Promise<void>} A promise that resolves when the channel has been successfully deleted.
972
+ *
973
+ * @example
974
+ * ```typescript
975
+ * const channel = client.channels.get('1234567890');
976
+ * if (channel) {
977
+ * await channel.delete();
978
+ * console.log('Channel deleted successfully.');
979
+ * }
980
+ * ```
981
+ */
982
+ delete(): Promise<void>;
983
+ /**
984
+ * Checks if the channel is a text-based channel.
985
+ *
986
+ * @returns {boolean} True if the channel is a text-based channel, otherwise false.
987
+ */
988
+ isText(): this is TextChannel | GroupChannel | DMChannel;
989
+ /**
990
+ * Checks if the channel is a voice channel.
991
+ *
992
+ * @returns {boolean} True if the channel is a voice channel, otherwise false.
993
+ */
994
+ isVoice(): this is VoiceChannel;
995
+ /**
996
+ * Checks if the channel is a group channel.
997
+ *
998
+ * @returns {boolean} True if the channel is a group channel, otherwise false.
999
+ */
1000
+ isGroup(): this is GroupChannel;
1001
+ /**
1002
+ * Checks if the channel is part of a server.
1003
+ *
1004
+ * @returns {boolean} True if the channel is a server channel, otherwise false.
1005
+ */
1006
+ inServer(): this is ServerChannel;
1007
+ /**
1008
+ * Converts the channel to a string representation.
1009
+ *
1010
+ * @returns {string} A string representation of the channel in the format `<#channelId>`.
1011
+ */
1012
+ toString(): string;
1013
+ /**
1014
+ * Fetches the latest data for the channel from the client's channel collection.
1015
+ *
1016
+ * @param {boolean} [force=true] - Whether to force a fetch even if the channel is cached.
1017
+ * @returns {Promise<Channel>} A promise that resolves with the updated channel instance.
1018
+ */
1019
+ fetch(force?: boolean): Promise<Channel>;
1020
+ }
1021
+
1022
+ /**
1023
+ * Interface representing a text-based channel, which supports sending and managing messages.
1024
+ */
1025
+ interface TextBasedChannel {
1026
+ /** Manages the messages in the channel. */
1027
+ messages: MessageManager;
1028
+ /** The ID of the last message sent in the channel, or `null` if no message exists. */
1029
+ lastMessageId: string | null;
1030
+ /** The last message sent in the channel, or `null` if no message exists. */
1031
+ lastMessage: Message | null;
1032
+ /**
1033
+ * Sends a message to the channel.
1034
+ *
1035
+ * @param {MessageOptions | string} options - The message content or options for the message.
1036
+ * @returns {Promise<Message>} A promise that resolves with the sent message.
1037
+ *
1038
+ * @example
1039
+ * ```typescript
1040
+ * await channel.send("Hello, world!");
1041
+ * ```
1042
+ */
1043
+ send(options: MessageOptions | string): Promise<Message>;
1044
+ /**
1045
+ * Deletes multiple messages from the channel.
1046
+ *
1047
+ * @param {MessageResolvable[] | Map<string, Message> | number} messages - The messages to delete. This can be an array of message resolvables, a map of messages, or a number indicating how many recent messages to delete.
1048
+ * @returns {Promise<void>} A promise that resolves when the messages have been successfully deleted.
1049
+ *
1050
+ * @example
1051
+ * ```typescript
1052
+ * await channel.bulkDelete(10); // Deletes the last 10 messages.
1053
+ * ```
1054
+ */
1055
+ bulkDelete(messages: MessageResolvable[] | Map<string, Message> | number): Promise<void>;
1056
+ }
1057
+
1058
+ type APIDirectChannel = Extract<Channel$1, {
1059
+ channel_type: "DirectMessage";
1060
+ }>;
1061
+ /**
1062
+ * Represents a direct message (DM) channel between users.
1063
+ *
1064
+ * @extends Channel
1065
+ */
1066
+ declare class DMChannel extends Channel implements TextBasedChannel {
1067
+ /** The type of the channel, which is always `DM` for direct message channels. */
1068
+ readonly type = ChannelTypes.DM;
1069
+ /** Whether the DM channel is currently active. */
1070
+ active: boolean;
1071
+ /** The default permissions for the DM channel. */
1072
+ permissions: Readonly<ChannelPermissions>;
1073
+ /** Manages the messages in this DM channel. */
1074
+ messages: MessageManager;
1075
+ /** The ID of the last message sent in this DM channel, if any. */
1076
+ lastMessageId: string | null;
1077
+ /**
1078
+ * Creates a new DMChannel instance.
1079
+ *
1080
+ * @param {client} client - The client instance.
1081
+ * @param {APIDirectChannel} data - The raw data for the DM channel from the API.
1082
+ */
1083
+ constructor(client: client, data: APIDirectChannel);
1084
+ /**
1085
+ * Updates the DM channel instance with new data from the API.
1086
+ *
1087
+ * @param {APIDirectChannel} data - The raw data for the DM channel from the API.
1088
+ * @returns {this} The updated DM channel instance.
1089
+ * @protected
1090
+ */
1091
+ protected _patch(data: APIDirectChannel): this;
1092
+ /**
1093
+ * Retrieves the last message sent in this DM channel.
1094
+ *
1095
+ * @returns {Message | null} The last message, or `null` if no message exists.
1096
+ */
1097
+ get lastMessage(): Message | null;
1098
+ /**
1099
+ * Deletes multiple messages from this DM channel.
1100
+ *
1101
+ * @param {MessageResolvable[] | Map<string, Message> | number} messages - The messages to delete. This can be an array of message resolvables, a map of messages, or a number indicating how many recent messages to delete.
1102
+ * @returns {Promise<void>} A promise that resolves when the messages have been successfully deleted.
1103
+ *
1104
+ * @example
1105
+ * ```typescript
1106
+ * await dmChannel.bulkDelete(10); // Deletes the last 10 messages.
1107
+ * ```
1108
+ */
1109
+ bulkDelete(messages: MessageResolvable[] | Map<string, Message> | number): Promise<void>;
1110
+ /**
1111
+ * Sends a message to this DM channel.
1112
+ *
1113
+ * @param {MessageOptions | string} options - The message content or options for the message.
1114
+ * @returns {Promise<Message>} A promise that resolves with the sent message.
1115
+ *
1116
+ * @example
1117
+ * ```typescript
1118
+ * await dmChannel.send("Hello, world!");
1119
+ * ```
1120
+ */
1121
+ send(options: MessageOptions | string): Promise<Message>;
1122
+ }
1123
+
1124
+ type APIGroupChannel = Extract<Channel$1, {
1125
+ channel_type: "Group";
1126
+ }>;
1127
+ /**
1128
+ * Represents a group channel, which allows multiple users to communicate.
1129
+ *
1130
+ * @extends Channel
1131
+ */
1132
+ declare class GroupChannel extends Channel implements TextBasedChannel {
1133
+ /** The type of the channel, which is always `GROUP` for group channels. */
1134
+ readonly type = ChannelTypes.GROUP;
1135
+ /** The name of the group channel. */
1136
+ name: string;
1137
+ /** The description of the group channel, if any. */
1138
+ description: string | null;
1139
+ /** The ID of the user who owns the group channel. */
1140
+ ownerId: string;
1141
+ /** The permissions for the group channel. */
1142
+ permissions: Readonly<ChannelPermissions>;
1143
+ /** The icon of the group channel, if any. */
1144
+ icon: Attachment | null;
1145
+ /** Manages the messages in this group channel. */
1146
+ messages: MessageManager;
1147
+ /** The ID of the last message sent in this group channel, if any. */
1148
+ lastMessageId: string | null;
1149
+ /** A map of user IDs to their corresponding `User` instances in the group channel. */
1150
+ users: Map<string, User>;
1151
+ /** Whether the group channel is marked as NSFW (Not Safe For Work). */
1152
+ nsfw: boolean;
1153
+ /**
1154
+ * Creates a new GroupChannel instance.
1155
+ *
1156
+ * @param {client} client - The client instance.
1157
+ * @param {APIGroupChannel} data - The raw data for the group channel from the API.
1158
+ */
1159
+ constructor(client: client, data: APIGroupChannel);
1160
+ /**
1161
+ * Updates the group channel instance with new data from the API.
1162
+ *
1163
+ * @param {APIGroupChannel} data - The raw data for the group channel from the API.
1164
+ * @returns {this} The updated group channel instance.
1165
+ * @protected
1166
+ */
1167
+ protected _patch(data: APIGroupChannel): this;
1168
+ /**
1169
+ * Retrieves the last message sent in this group channel.
1170
+ *
1171
+ * @returns {Message | null} The last message, or `null` if no message exists.
1172
+ */
1173
+ get lastMessage(): Message | null;
1174
+ /**
1175
+ * Retrieves the owner of the group channel.
1176
+ *
1177
+ * @returns {User | null} The owner of the group channel, or `null` if not found.
1178
+ */
1179
+ get owner(): User | null;
1180
+ /**
1181
+ * Deletes multiple messages from this group channel.
1182
+ *
1183
+ * @param {MessageResolvable[] | Map<string, Message> | number} messages - The messages to delete. This can be an array of message resolvables, a map of messages, or a number indicating how many recent messages to delete.
1184
+ * @returns {Promise<void>} A promise that resolves when the messages have been successfully deleted.
1185
+ *
1186
+ * @example
1187
+ * ```typescript
1188
+ * await groupChannel.bulkDelete(10); // Deletes the last 10 messages.
1189
+ * ```
1190
+ */
1191
+ bulkDelete(messages: MessageResolvable[] | Map<string, Message> | number): Promise<void>;
1192
+ /**
1193
+ * Creates an invite for the group channel.
1194
+ *
1195
+ * @returns {Promise<Invite>} A promise that resolves with the created invite.
1196
+ *
1197
+ * @example
1198
+ * ```typescript
1199
+ * const invite = await groupChannel.createInvite();
1200
+ * console.log(`Invite created: ${invite}`);
1201
+ * ```
1202
+ */
1203
+ createInvite(): Promise<Invite>;
1204
+ /**
1205
+ * Adds a user to the group channel.
1206
+ *
1207
+ * @param {UserResolvable} user - The user to add to the group channel.
1208
+ * @returns {Promise<void>} A promise that resolves when the user has been successfully added.
1209
+ *
1210
+ * @example
1211
+ * ```typescript
1212
+ * await groupChannel.add(user);
1213
+ * ```
1214
+ */
1215
+ add(user: UserResolvable): Promise<void>;
1216
+ /**
1217
+ * Removes a user from the group channel.
1218
+ *
1219
+ * @param {UserResolvable} user - The user to remove from the group channel.
1220
+ * @returns {Promise<void>} A promise that resolves when the user has been successfully removed.
1221
+ *
1222
+ * @example
1223
+ * ```typescript
1224
+ * await groupChannel.remove(user);
1225
+ * ```
1226
+ */
1227
+ remove(user: UserResolvable): Promise<void>;
1228
+ /**
1229
+ * Leaves the group channel.
1230
+ *
1231
+ * @returns {Promise<void>} A promise that resolves when the group channel has been successfully left.
1232
+ *
1233
+ * @example
1234
+ * ```typescript
1235
+ * await groupChannel.leave();
1236
+ * ```
1237
+ */
1238
+ leave(): Promise<void>;
1239
+ /**
1240
+ * Sends a message to this group channel.
1241
+ *
1242
+ * @param {MessageOptions | string} options - The message content or options for the message.
1243
+ * @returns {Promise<Message>} A promise that resolves with the sent message.
1244
+ *
1245
+ * @example
1246
+ * ```typescript
1247
+ * await groupChannel.send("Hello, group!");
1248
+ * ```
1249
+ */
1250
+ send(options: MessageOptions | string): Promise<Message>;
1251
+ }
1252
+
1253
+ /**
1254
+ * Represents an invite to a server or channel.
1255
+ *
1256
+ * @extends Base
1257
+ */
1258
+ declare class Invite extends Base {
1259
+ /** The ID of the server associated with the invite, if any. */
1260
+ serverId: string | null;
1261
+ /** The ID of the user who created the invite. */
1262
+ inviterId: string;
1263
+ /** The ID of the channel associated with the invite. */
1264
+ channelId: string;
1265
+ /**
1266
+ * Creates a new Invite instance.
1267
+ *
1268
+ * @param {client} client - The client instance.
1269
+ * @param {APIInvite} data - The raw data for the invite from the API.
1270
+ */
1271
+ constructor(client: client, data: Invite$1);
1272
+ /**
1273
+ * Updates the invite instance with new data from the API.
1274
+ *
1275
+ * @param {APIInvite} data - The raw data for the invite from the API.
1276
+ * @returns {this} The updated invite instance.
1277
+ * @protected
1278
+ */
1279
+ protected _patch(data: Invite$1): this;
1280
+ /**
1281
+ * Retrieves the server associated with the invite.
1282
+ *
1283
+ * @returns {Server | null} The server associated with the invite, or `null` if not found.
1284
+ */
1285
+ get server(): Server | null;
1286
+ /**
1287
+ * Retrieves the channel associated with the invite.
1288
+ *
1289
+ * @returns {Channel | null} The channel associated with the invite, or `null` if not found.
1290
+ */
1291
+ get channel(): Channel | null;
1292
+ /**
1293
+ * Retrieves the user who created the invite.
1294
+ *
1295
+ * @returns {User | null} The user who created the invite, or `null` if not found.
1296
+ */
1297
+ get inviter(): User | null;
1298
+ }
1299
+
1300
+ /**
1301
+ * Represents the mentions in a message, including users and server members.
1302
+ */
1303
+ declare class Mentions {
1304
+ readonly message: Message;
1305
+ protected _users: string[];
1306
+ /** The client instance. */
1307
+ readonly client: client;
1308
+ /**
1309
+ * Creates a new Mentions instance.
1310
+ *
1311
+ * @param {Message} message - The message associated with the mentions.
1312
+ * @param {string[]} _users - An array of user IDs mentioned in the message.
1313
+ */
1314
+ constructor(message: Message, _users: string[]);
1315
+ /**
1316
+ * Checks if a specific user is mentioned in the message.
1317
+ *
1318
+ * @param {UserResolvable} user - The user to check.
1319
+ * @returns {boolean} `true` if the user is mentioned, otherwise `false`.
1320
+ * @throws {TypeError} Throws an error if the user cannot be resolved.
1321
+ *
1322
+ * @example
1323
+ * ```typescript
1324
+ * if (mentions.has(someUser)) {
1325
+ * console.log("User is mentioned!");
1326
+ * }
1327
+ * ```
1328
+ */
1329
+ has(user: UserResolvable): boolean;
1330
+ /**
1331
+ * Retrieves the server members mentioned in the message.
1332
+ *
1333
+ * @returns {Map<string, ServerMember> | null} A map of user IDs to `ServerMember` instances, or `null` if the message is not in a server.
1334
+ *
1335
+ * @example
1336
+ * ```typescript
1337
+ * const members = mentions.members;
1338
+ * if (members) {
1339
+ * members.forEach(member => console.log(member.displayName));
1340
+ * }
1341
+ * ```
1342
+ */
1343
+ get members(): Map<string, ServerMember> | null;
1344
+ /**
1345
+ * Retrieves the users mentioned in the message.
1346
+ *
1347
+ * @returns {Map<string, User>} A map of user IDs to `User` instances.
1348
+ *
1349
+ * @example
1350
+ * ```typescript
1351
+ * const users = mentions.users;
1352
+ * users.forEach(user => console.log(user.username));
1353
+ * ```
1354
+ */
1355
+ get users(): Map<string, User>;
1356
+ }
1357
+
1358
+ type Embed = Embed$1;
1359
+ type EmbedImage = Extract<Embed, {
1360
+ type: "Image";
1361
+ }>;
1362
+ type EmbedVideo = Extract<Embed, {
1363
+ type: "Video";
1364
+ }>;
1365
+ type EmbedSpecial = Special;
1366
+ /**
1367
+ * Represents a message embed, which can include rich content such as titles, descriptions, URLs, and media.
1368
+ */
1369
+ declare class MessageEmbed {
1370
+ #private;
1371
+ /**
1372
+ * Sets the title of the embed.
1373
+ *
1374
+ * @param {string} title - The title to set.
1375
+ * @returns {this} The updated `MessageEmbed` instance.
1376
+ */
1377
+ setTitle(title: string): this;
1378
+ /**
1379
+ * Sets the icon URL of the embed.
1380
+ *
1381
+ * @param {string} iconURL - The URL of the icon to set.
1382
+ * @returns {this} The updated `MessageEmbed` instance.
1383
+ */
1384
+ setIcon(iconURL: string): this;
1385
+ /**
1386
+ * Sets the color of the embed.
1387
+ *
1388
+ * @param {string} color - The color to set (e.g., a hex code).
1389
+ * @returns {this} The updated `MessageEmbed` instance.
1390
+ */
1391
+ setColor(color: string): this;
1392
+ /**
1393
+ * Sets the description of the embed.
1394
+ *
1395
+ * @param {string} description - The description to set.
1396
+ * @returns {this} The updated `MessageEmbed` instance.
1397
+ */
1398
+ setDescription(description: string): this;
1399
+ /**
1400
+ * Sets the URL of the embed.
1401
+ *
1402
+ * @param {string} url - The URL to set.
1403
+ * @returns {this} The updated `MessageEmbed` instance.
1404
+ */
1405
+ setURL(url: string): this;
1406
+ /**
1407
+ * Sets the media (e.g., image or video) of the embed.
1408
+ *
1409
+ * @param {string} media - The media URL to set.
1410
+ * @returns {this} The updated `MessageEmbed` instance.
1411
+ */
1412
+ setMedia(media: string): this;
1413
+ /**
1414
+ * Converts the embed to a JSON object that can be sent to the API.
1415
+ *
1416
+ * @returns {SendableEmbed} The JSON representation of the embed.
1417
+ */
1418
+ toJSON(): SendableEmbed;
1419
+ }
1420
+
1421
+ type APINotesChannel = Extract<Channel$1, {
1422
+ channel_type: "SavedMessages";
1423
+ }>;
1424
+ /**
1425
+ * Represents a notes channel, which is used for saving personal messages.
1426
+ *
1427
+ * @extends Channel
1428
+ */
1429
+ declare class NotesChannel extends Channel implements TextBasedChannel {
1430
+ /** The type of the channel, which is always `NOTES` for notes channels. */
1431
+ readonly type = ChannelTypes.NOTES;
1432
+ /** The ID of the user associated with the notes channel. */
1433
+ userId: string;
1434
+ /** The ID of the last message sent in this notes channel, if any. */
1435
+ lastMessageId: string | null;
1436
+ /** Manages the messages in this notes channel. */
1437
+ messages: MessageManager;
1438
+ /**
1439
+ * Creates a new NotesChannel instance.
1440
+ *
1441
+ * @param {client} client - The client instance.
1442
+ * @param {APINotesChannel} data - The raw data for the notes channel from the API.
1443
+ */
1444
+ constructor(client: client, data: APINotesChannel);
1445
+ /**
1446
+ * Updates the notes channel instance with new data from the API.
1447
+ *
1448
+ * @param {APINotesChannel} data - The raw data for the notes channel from the API.
1449
+ * @returns {this} The updated notes channel instance.
1450
+ * @protected
1451
+ */
1452
+ protected _patch(data: APINotesChannel): this;
1453
+ /**
1454
+ * Sends a message to this notes channel.
1455
+ *
1456
+ * @param {MessageOptions | string} options - The message content or options for the message.
1457
+ * @returns {Promise<Message>} A promise that resolves with the sent message.
1458
+ *
1459
+ * @example
1460
+ * ```typescript
1461
+ * await notesChannel.send("This is a saved message.");
1462
+ * ```
1463
+ */
1464
+ send(options: MessageOptions | string): Promise<Message>;
1465
+ /**
1466
+ * Deletes multiple messages from this notes channel.
1467
+ *
1468
+ * @param {MessageResolvable[] | Map<string, Message> | number} messages - The messages to delete. This can be an array of message resolvables, a map of messages, or a number indicating how many recent messages to delete.
1469
+ * @returns {Promise<void>} A promise that resolves when the messages have been successfully deleted.
1470
+ *
1471
+ * @example
1472
+ * ```typescript
1473
+ * await notesChannel.bulkDelete(5); // Deletes the last 5 messages.
1474
+ * ```
1475
+ */
1476
+ bulkDelete(messages: MessageResolvable[] | Map<string, Message> | number): Promise<void>;
1477
+ /**
1478
+ * Retrieves the last message sent in this notes channel.
1479
+ *
1480
+ * @returns {Message | null} The last message, or `null` if no message exists.
1481
+ */
1482
+ get lastMessage(): Message | null;
1483
+ /**
1484
+ * Retrieves the user associated with this notes channel.
1485
+ *
1486
+ * @returns {User} The user associated with the notes channel.
1487
+ */
1488
+ get user(): User;
1489
+ }
1490
+
1491
+ type APIServerChannel$1 = Extract<Channel$1, {
1492
+ channel_type: "TextChannel" | "VoiceChannel";
1493
+ }>;
1494
+ interface Overwrite {
1495
+ allow: ChannelPermissions;
1496
+ deny: ChannelPermissions;
1497
+ }
1498
+ /**
1499
+ * Represents a server channel, which can be a text or voice channel.
1500
+ *
1501
+ * @extends Channel
1502
+ */
1503
+ declare class ServerChannel extends Channel {
1504
+ /** The name of the channel. */
1505
+ name: string;
1506
+ /** The ID of the server this channel belongs to. */
1507
+ serverId: string;
1508
+ /** The description of the channel, or `null` if none is set. */
1509
+ description: string | null;
1510
+ /** The icon of the channel, or `null` if none is set. */
1511
+ icon: Attachment | null;
1512
+ /** The permission overwrites for the channel. */
1513
+ overwrites: Map<string, Overwrite>;
1514
+ /** Whether the channel is marked as NSFW (Not Safe For Work). */
1515
+ nsfw: boolean;
1516
+ /**
1517
+ * Creates a new ServerChannel instance.
1518
+ *
1519
+ * @param {client} client - The client instance.
1520
+ * @param {APIServerChannel} data - The raw data for the server channel from the API.
1521
+ */
1522
+ constructor(client: client, data: APIServerChannel$1);
1523
+ /**
1524
+ * Updates the server channel instance with new data from the API.
1525
+ *
1526
+ * @param {APIServerChannel} data - The raw data for the server channel from the API.
1527
+ * @param {FieldsChannel[]} [clear=[]] - Fields to clear in the channel.
1528
+ * @returns {this} The updated server channel instance.
1529
+ * @protected
1530
+ */
1531
+ protected _patch(data: APIServerChannel$1, clear?: FieldsChannel[]): this;
1532
+ /**
1533
+ * Creates an invite for the server channel.
1534
+ *
1535
+ * @returns {Promise<Invite>} A promise that resolves with the created invite.
1536
+ *
1537
+ * @example
1538
+ * ```typescript
1539
+ * const invite = await serverChannel.createInvite();
1540
+ * console.log(`Invite created: ${invite}`);
1541
+ * ```
1542
+ */
1543
+ createInvite(): Promise<Invite>;
1544
+ /**
1545
+ * Retrieves the server this channel belongs to.
1546
+ *
1547
+ * @returns {Server} The server instance.
1548
+ */
1549
+ get server(): Server;
1550
+ /**
1551
+ * Retrieves the category this channel belongs to, if any.
1552
+ *
1553
+ * @returns {Category | null} The category instance, or `null` if the channel is not in a category.
1554
+ */
1555
+ get category(): Category | null;
1556
+ }
1557
+
1558
+ /**
1559
+ * Represents a member of a server.
1560
+ *
1561
+ * @extends Base
1562
+ */
1563
+ declare class ServerMember extends Base {
1564
+ /** The ID of the server this member belongs to. */
1565
+ serverId: string;
1566
+ /** The nickname of the member, or `null` if none is set. */
1567
+ nickname: string | null;
1568
+ /** The avatar of the member, or `null` if none is set. */
1569
+ avatar: Attachment | null;
1570
+ /**
1571
+ * Creates a new ServerMember instance.
1572
+ *
1573
+ * @param {client} client - The client instance.
1574
+ * @param {APIMember} data - The raw data for the server member from the API.
1575
+ */
1576
+ constructor(client: client, data: Member);
1577
+ /**
1578
+ * Updates the server member instance with new data from the API.
1579
+ *
1580
+ * @param {APIMember} data - The raw data for the server member from the API.
1581
+ * @param {FieldsMember[]} [clear=[]] - Fields to clear in the server member.
1582
+ * @returns {this} The updated server member instance.
1583
+ * @protected
1584
+ */
1585
+ protected _patch(data: Member, clear?: FieldsMember[]): this;
1586
+ /**
1587
+ * Sets the nickname of the server member.
1588
+ *
1589
+ * @param {string} [nickname] - The new nickname to set, or `undefined` to clear the nickname.
1590
+ * @returns {Promise<this>} A promise that resolves with the updated server member instance.
1591
+ *
1592
+ * @example
1593
+ * ```typescript
1594
+ * await member.setNickname("NewNickname");
1595
+ * ```
1596
+ */
1597
+ setNickname(nickname?: string): Promise<this>;
1598
+ /**
1599
+ * Bans the server member.
1600
+ *
1601
+ * @param {string} [reason] - The reason for the ban.
1602
+ * @returns {Promise<void>} A promise that resolves when the member is banned.
1603
+ *
1604
+ * @example
1605
+ * ```typescript
1606
+ * await member.ban("Violation of rules");
1607
+ * ```
1608
+ */
1609
+ ban(reason?: string): Promise<void>;
1610
+ /**
1611
+ * Kicks the server member.
1612
+ *
1613
+ * @returns {Promise<void>} A promise that resolves when the member is kicked.
1614
+ *
1615
+ * @example
1616
+ * ```typescript
1617
+ * await member.kick();
1618
+ * ```
1619
+ */
1620
+ kick(): Promise<void>;
1621
+ /**
1622
+ * Leaves the server.
1623
+ *
1624
+ * @returns {Promise<void>} A promise that resolves when the member leaves the server.
1625
+ *
1626
+ * @example
1627
+ * ```typescript
1628
+ * await member.leave();
1629
+ * ```
1630
+ */
1631
+ leave(): Promise<void>;
1632
+ /**
1633
+ * Retrieves the user associated with this server member.
1634
+ *
1635
+ * @returns {User} The user instance.
1636
+ */
1637
+ get user(): User;
1638
+ /**
1639
+ * Retrieves the server this member belongs to.
1640
+ *
1641
+ * @returns {Server} The server instance.
1642
+ */
1643
+ get server(): Server;
1644
+ /**
1645
+ * Converts the server member to a string representation.
1646
+ *
1647
+ * @returns {string} A string representation of the server member in the format `<@userId>`.
1648
+ */
1649
+ toString(): string;
1650
+ }
1651
+
1652
+ type APITextChannel = Extract<Channel$1, {
1653
+ channel_type: "TextChannel";
1654
+ }>;
1655
+ /**
1656
+ * Represents a text channel in a server.
1657
+ *
1658
+ * @extends ServerChannel
1659
+ */
1660
+ declare class TextChannel extends ServerChannel implements TextBasedChannel {
1661
+ /** The ID of the last message sent in this text channel, if any. */
1662
+ lastMessageId: string | null;
1663
+ /** Manages the messages in this text channel. */
1664
+ messages: MessageManager;
1665
+ /** The type of the channel, which is always `TEXT` for text channels. */
1666
+ readonly type = ChannelTypes.TEXT;
1667
+ /**
1668
+ * Creates a new TextChannel instance.
1669
+ *
1670
+ * @param {client} client - The client instance.
1671
+ * @param {APITextChannel} data - The raw data for the text channel from the API.
1672
+ */
1673
+ constructor(client: client, data: APITextChannel);
1674
+ /**
1675
+ * Updates the text channel instance with new data from the API.
1676
+ *
1677
+ * @param {APITextChannel} data - The raw data for the text channel from the API.
1678
+ * @returns {this} The updated text channel instance.
1679
+ * @protected
1680
+ */
1681
+ protected _patch(data: APITextChannel): this;
1682
+ /**
1683
+ * Retrieves the last message sent in this text channel.
1684
+ *
1685
+ * @returns {Message | null} The last message, or `null` if no message exists.
1686
+ */
1687
+ get lastMessage(): Message | null;
1688
+ /**
1689
+ * Sends a message to this text channel.
1690
+ *
1691
+ * @param {MessageOptions | string} options - The message content or options for the message.
1692
+ * @returns {Promise<Message>} A promise that resolves with the sent message.
1693
+ *
1694
+ * @example
1695
+ * ```typescript
1696
+ * await textChannel.send("Hello, world!");
1697
+ * ```
1698
+ */
1699
+ send(options: MessageOptions | string): Promise<Message>;
1700
+ /**
1701
+ * Deletes multiple messages from this text channel.
1702
+ *
1703
+ * @param {MessageResolvable[] | Map<string, Message> | number} messages - The messages to delete. This can be an array of message resolvables, a map of messages, or a number indicating how many recent messages to delete.
1704
+ * @returns {Promise<void>} A promise that resolves when the messages have been successfully deleted.
1705
+ *
1706
+ * @example
1707
+ * ```typescript
1708
+ * await textChannel.bulkDelete(10); // Deletes the last 10 messages.
1709
+ * ```
1710
+ */
1711
+ bulkDelete(messages: MessageResolvable[] | Map<string, Message> | number): Promise<void>;
1712
+ }
1713
+
1714
+ type APIVoiceChannel = Extract<Channel$1, {
1715
+ channel_type: "VoiceChannel";
1716
+ }>;
1717
+ /**
1718
+ * Represents a voice channel in a server.
1719
+ *
1720
+ * @extends ServerChannel
1721
+ */
1722
+ declare class VoiceChannel extends ServerChannel {
1723
+ /** The type of the channel, which is always `VOICE` for voice channels. */
1724
+ readonly type = ChannelTypes.VOICE;
1725
+ /**
1726
+ * Creates a new VoiceChannel instance.
1727
+ *
1728
+ * @param {client} client - The client instance.
1729
+ * @param {APIVoiceChannel} data - The raw data for the voice channel from the API.
1730
+ */
1731
+ constructor(client: client, data: APIVoiceChannel);
1732
+ /**
1733
+ * Updates the voice channel instance with new data from the API.
1734
+ *
1735
+ * @param {APIVoiceChannel} data - The raw data for the voice channel from the API.
1736
+ * @returns {this} The updated voice channel instance.
1737
+ * @protected
1738
+ */
1739
+ protected _patch(data: APIVoiceChannel): this;
1740
+ /**
1741
+ * Acknowledges the voice channel.
1742
+ *
1743
+ * @throws {TypeError} Throws an error because voice channels cannot be acknowledged.
1744
+ *
1745
+ * @example
1746
+ * ```typescript
1747
+ * try {
1748
+ * await voiceChannel.ack();
1749
+ * } catch (error) {
1750
+ * console.error(error.message); // "Cannot ack voice channel"
1751
+ * }
1752
+ * ```
1753
+ */
1754
+ ack(): Promise<void>;
1755
+ }
1756
+
1757
+ /**
1758
+ * Represents a category in a server, which groups multiple channels together.
1759
+ *
1760
+ * @extends Base
1761
+ */
1762
+ declare class Category extends Base {
1763
+ readonly server: Server;
1764
+ /** The name of the category. */
1765
+ name: string;
1766
+ /** An array of channel IDs that belong to this category. */
1767
+ protected _children: string[];
1768
+ /**
1769
+ * Creates a new Category instance.
1770
+ *
1771
+ * @param {Server} server - The server this category belongs to.
1772
+ * @param {APICategory} data - The raw data for the category from the API.
1773
+ */
1774
+ constructor(server: Server, data: Category$1);
1775
+ /**
1776
+ * Updates the category instance with new data from the API.
1777
+ *
1778
+ * @param {APICategory} data - The raw data for the category from the API.
1779
+ * @returns {this} The updated category instance.
1780
+ * @protected
1781
+ */
1782
+ protected _patch(data: Category$1): this;
1783
+ /**
1784
+ * Retrieves the channels that belong to this category.
1785
+ *
1786
+ * @returns {Map<string, ServerChannel>} A map of channel IDs to their corresponding `ServerChannel` instances.
1787
+ */
1788
+ get children(): Map<string, ServerChannel>;
1789
+ /**
1790
+ * Converts the category to a string representation.
1791
+ *
1792
+ * @returns {string} The name of the category.
1793
+ */
1794
+ toString(): string;
1795
+ }
1796
+
1797
+ /**
1798
+ * Represents an emoji in the client.
1799
+ *
1800
+ * @extends Base
1801
+ */
1802
+ declare class Emoji extends Base {
1803
+ /** The parent object of the emoji, which can be a server or other entity. */
1804
+ parent?: {
1805
+ type: string;
1806
+ id: string;
1807
+ } | null;
1808
+ /** The ID of the user who created the emoji, or `null` if not available. */
1809
+ creator_id?: string | null;
1810
+ /** The name of the emoji, or `null` if not set. */
1811
+ name?: string | null;
1812
+ /**
1813
+ * Creates a new Emoji instance.
1814
+ *
1815
+ * @param {client} client - The client instance.
1816
+ * @param {Emoji} data - The raw data for the emoji.
1817
+ */
1818
+ constructor(client: client, data: Emoji);
1819
+ /**
1820
+ * Retrieves the user who created the emoji.
1821
+ *
1822
+ * @returns {User | null} The creator of the emoji, or `null` if not found.
1823
+ */
1824
+ get creator(): User | null;
1825
+ /**
1826
+ * Retrieves the server associated with the emoji, if any.
1827
+ *
1828
+ * @returns {Server | null} The server instance, or `null` if the emoji is not associated with a server.
1829
+ */
1830
+ get server(): Server | null;
1831
+ }
1832
+
1833
+ type UserResolvable = User | User$1 | Message | string;
1834
+ declare class UserManager extends BaseManager<User, User$1> {
1835
+ holds: typeof User;
1836
+ /**
1837
+ *
1838
+ * @param user The user to delete
1839
+ * @returns A promise that resolves when the user is deleted
1840
+ */
1841
+ fetch(user: UserResolvable, { force }?: {
1842
+ force?: boolean | undefined;
1843
+ }): Promise<User>;
1844
+ /**
1845
+ * get a user form cache
1846
+ * @param resolvable The user to resolve
1847
+ * @returns The user or null if it cannot be resolved
1848
+ */
1849
+ resolve(resolvable: Message | User): User;
1850
+ resolve(resolvable: string | User$1): User | null;
1851
+ /**
1852
+ * get a user id form cache
1853
+ * @param resolvable The user to resolve
1854
+ * @returns The user id or null if it cannot be resolved
1855
+ */
1856
+ resolveId(resolvable: UserResolvable): string | null;
1857
+ }
1858
+
1859
+ /**
1860
+ * Represents the client user, which is the authenticated user or bot.
1861
+ *
1862
+ * @extends User
1863
+ */
1864
+ declare class ClientUser extends User {
1865
+ /** The notes channel associated with the client user, if any. */
1866
+ notes: NotesChannel | null;
1867
+ /**
1868
+ * Updates the username of the client user.
1869
+ *
1870
+ * @param {string} username - The new username to set.
1871
+ * @param {string} [password] - The current password of the user (required for non-bot accounts).
1872
+ * @returns {Promise<void>} A promise that resolves when the username has been successfully updated.
1873
+ * @throws {Error} Throws an error if the client user is a bot and a password is provided.
1874
+ *
1875
+ * @example
1876
+ * ```typescript
1877
+ * await clientUser.setUsername("NewUsername", "CurrentPassword");
1878
+ * ```
1879
+ */
1880
+ setUsername(username: string, password?: string): Promise<void>;
1881
+ /**
1882
+ * Updates the status of the client user.
1883
+ *
1884
+ * @param {string | null} text - The status text to set, or `null` to clear the status.
1885
+ * @param {Status} [presence] - The presence status (e.g., online, idle, etc.).
1886
+ * @returns {Promise<void>} A promise that resolves when the status has been successfully updated.
1887
+ *
1888
+ * @example
1889
+ * ```typescript
1890
+ * await clientUser.setStatus("Available", "online");
1891
+ * ```
1892
+ */
1893
+ setStatus(text: string | null, presence?: Status): Promise<void>;
1894
+ }
1895
+
1896
+ /**
1897
+ * Represents the base class for all event handlers.
1898
+ * All event handlers must extend this class and implement the `handle` method.
1899
+ */
1900
+ declare abstract class Event {
1901
+ protected readonly client: client;
1902
+ /**
1903
+ * Creates a new Event instance.
1904
+ *
1905
+ * @param {client} client - The client instance.
1906
+ */
1907
+ constructor(client: client);
1908
+ /**
1909
+ * Handles the event logic.
1910
+ * This method must be implemented by subclasses to define the behavior for the specific event.
1911
+ *
1912
+ * @param {unknown} data - The data associated with the event.
1913
+ * @returns {Promise<unknown | void>} A promise that resolves with the result of the event handling or `void`.
1914
+ */
1915
+ abstract handle(data: unknown): Awaited<unknown | void>;
1916
+ }
1917
+
1918
+ /**
1919
+ * Manages the registration and retrieval of events for the client.
1920
+ */
1921
+ declare class EventManager {
1922
+ #private;
1923
+ protected readonly client: client;
1924
+ /**
1925
+ * Creates a new EventManager instance.
1926
+ *
1927
+ * @param {client} client - The client instance.
1928
+ */
1929
+ constructor(client: client);
1930
+ /**
1931
+ * Registers an event with the manager.
1932
+ *
1933
+ * @param {new (client: client) => CustomEvent} Event - The event class to register.
1934
+ */
1935
+ register(Event: new (client: client) => Event): void;
1936
+ /**
1937
+ * Retrieves a registered event by its name.
1938
+ *
1939
+ * @param {string} name - The name of the event to retrieve.
1940
+ * @returns {CustomEvent | null} The event instance, or `null` if not found.
1941
+ */
1942
+ get(name: string): Event | null;
1943
+ }
1944
+
1945
+ /**
1946
+ * Represents the WebSocket client used for real-time communication with the API.
1947
+ */
1948
+ declare class WebSocketClient {
1949
+ protected readonly client: client;
1950
+ /** The interval for sending heartbeats, in milliseconds. */
1951
+ heartbeatInterval?: number;
1952
+ /** The timestamp of the last ping sent, in milliseconds. */
1953
+ lastPingTimestamp?: number;
1954
+ /** Whether the last pong acknowledgment was received. */
1955
+ lastPongAck?: boolean;
1956
+ /** The WebSocket connection instance. */
1957
+ socket?: WebSocket | null;
1958
+ /** Whether the WebSocket client is connected. */
1959
+ connected: boolean;
1960
+ /** A promise representing the reconnecting process, or `null` if not reconnecting. */
1961
+ reconnecting: Promise<unknown> | null;
1962
+ /** Whether the WebSocket client is ready. */
1963
+ ready: boolean;
1964
+ /**
1965
+ * Creates a new WebSocketClient instance.
1966
+ *
1967
+ * @param {client} client - The client instance.
1968
+ */
1969
+ constructor(client: client);
1970
+ /**
1971
+ * Logs a debug message.
1972
+ *
1973
+ * @param {unknown} message - The message to log.
1974
+ * @private
1975
+ */
1976
+ private debug;
1977
+ /**
1978
+ * Sends data through the WebSocket connection.
1979
+ *
1980
+ * @param {unknown} data - The data to send.
1981
+ * @returns {Promise<void>} A promise that resolves when the data is sent.
1982
+ * @throws {Error} Throws an error if the WebSocket is not open.
1983
+ */
1984
+ send(data: unknown): Promise<void>;
1985
+ /**
1986
+ * Handles the WebSocket connection opening.
1987
+ *
1988
+ * @private
1989
+ */
1990
+ private onOpen;
1991
+ /**
1992
+ * Gets the current ping (latency) of the WebSocket connection.
1993
+ *
1994
+ * @returns {number} The ping in milliseconds, or `-0` if the WebSocket is not connected.
1995
+ */
1996
+ get ping(): number;
1997
+ /**
1998
+ * Sets the heartbeat interval for the WebSocket connection.
1999
+ *
2000
+ * @param {number} time - The interval time in milliseconds. Use `-1` to clear the interval.
2001
+ */
2002
+ setHeartbeatTimer(time: number): void;
2003
+ /**
2004
+ * Sends a heartbeat to the server to keep the connection alive.
2005
+ */
2006
+ sendHeartbeat(): void;
2007
+ /**
2008
+ * Handles WebSocket errors.
2009
+ *
2010
+ * @param {unknown} event - The error event.
2011
+ * @private
2012
+ */
2013
+ private onError;
2014
+ /**
2015
+ * Handles incoming WebSocket messages.
2016
+ *
2017
+ * @param {{ data: unknown }} param0 - The message event containing the data.
2018
+ * @private
2019
+ */
2020
+ private onMessage;
2021
+ /**
2022
+ * Handles the WebSocket connection closing.
2023
+ *
2024
+ * @param {{ code: number; reason: string }} event - The close event containing the code and reason.
2025
+ * @private
2026
+ */
2027
+ private onClose;
2028
+ /**
2029
+ * Handles incoming WebSocket packets.
2030
+ *
2031
+ * @param {any} packet - The packet data.
2032
+ * @private
2033
+ */
2034
+ private onPacket;
2035
+ /**
2036
+ * Connects to the WebSocket server.
2037
+ *
2038
+ * @returns {Promise<this>} A promise that resolves when the connection is established.
2039
+ */
2040
+ connect(): Promise<this>;
2041
+ /**
2042
+ * Destroys the WebSocket connection and clears its state.
2043
+ *
2044
+ * @returns {Promise<void>} A promise that resolves when the connection is destroyed.
2045
+ */
2046
+ destroy(): Promise<void>;
2047
+ }
2048
+
2049
+ /**
2050
+ * Represents the main client for interacting with the API.
2051
+ *
2052
+ * @extends BaseClient
2053
+ */
2054
+ declare class client extends BaseClient {
2055
+ /** The WebSocket client used for real-time communication. */
2056
+ protected readonly ws: WebSocketClient;
2057
+ /** Manages the channels in the client. */
2058
+ readonly channels: ChannelManager;
2059
+ /** Manages the servers in the client. */
2060
+ readonly servers: ServerManager;
2061
+ /** Manages the users in the client. */
2062
+ readonly users: UserManager;
2063
+ /** Manages the events in the client. */
2064
+ readonly events: EventManager;
2065
+ /** The authenticated user, or `null` if not logged in. */
2066
+ user: ClientUser | null;
2067
+ /** The timestamp when the client became ready, or `null` if not ready. */
2068
+ readyAt: Date | null;
2069
+ /**
2070
+ * Gets the timestamp when the client became ready.
2071
+ *
2072
+ * @returns {number | null} The ready timestamp in milliseconds, or `null` if not ready.
2073
+ */
2074
+ get readyTimestamp(): number | null;
2075
+ /**
2076
+ * Gets the uptime of the client in milliseconds.
2077
+ *
2078
+ * @returns {number | null} The uptime in milliseconds, or `null` if the client is not ready.
2079
+ */
2080
+ get upTime(): number | null;
2081
+ /**
2082
+ * Logs the client into the API using the provided token.
2083
+ *
2084
+ * @param {string} token - The authentication token.
2085
+ * @returns {Promise<void>} A promise that resolves when the client is logged in.
2086
+ * @throws {Error} Throws an error if the token is not provided or if the WebSocket connection fails.
2087
+ *
2088
+ * @example
2089
+ * ```typescript
2090
+ * await client.login("your-token-here");
2091
+ * ```
2092
+ */
2093
+ login(token: string): Promise<void>;
2094
+ /**
2095
+ * Destroys the client, disconnecting it from the API and clearing its state.
2096
+ *
2097
+ * @returns {Promise<void>} A promise that resolves when the client is destroyed.
2098
+ *
2099
+ * @example
2100
+ * ```typescript
2101
+ * await client.destroy();
2102
+ * ```
2103
+ */
2104
+ destroy(): Promise<void>;
2105
+ /**
2106
+ * Checks if the client is ready.
2107
+ *
2108
+ * @returns {boolean} `true` if the client is ready, otherwise `false`.
2109
+ *
2110
+ * @example
2111
+ * ```typescript
2112
+ * if (client.isReady()) {
2113
+ * console.log("Client is ready!");
2114
+ * }
2115
+ * ```
2116
+ */
2117
+ isReady(): boolean;
2118
+ }
2119
+
2120
+ declare abstract class BaseManager<Holds extends {
2121
+ id: string;
2122
+ }, R = unknown> {
2123
+ protected readonly client: client;
2124
+ readonly cache: Map<string, Holds>;
2125
+ Holds: any;
2126
+ constructor(client: client);
2127
+ _add(raw: R): Holds;
2128
+ _remove(id: string): void;
2129
+ abstract readonly holds: (new (...args: any[]) => Holds) | null;
2130
+ resolve(resolvable: Holds): Holds | null;
2131
+ resolve(resolvable: string | R): Holds | null;
2132
+ resolve(resolvable: string | R | Holds): Holds | null;
2133
+ resolveId(resolvable: string | Holds | R): string | null;
2134
+ valueOf(): this["cache"];
2135
+ }
2136
+
2137
+ type ChannelResolvable = Channel | Channel$1 | string;
2138
+ declare class ChannelManager extends BaseManager<Channel, Channel$1> {
2139
+ holds: null;
2140
+ _add(data: Channel$1): Channel;
2141
+ _remove(id: string): void;
2142
+ /**
2143
+ * used to delete a channel
2144
+ *
2145
+ * @param channel The channel to delete
2146
+ * @returns A promise that resolves when the channel is deleted
2147
+ */
2148
+ delete(channel: ChannelResolvable): Promise<void>;
2149
+ /**
2150
+ * used to fetch a channel
2151
+ *
2152
+ * @param channel The channel to fetch
2153
+ * @param force Whether to force fetch the channel using the api or return it form cache if able
2154
+ * @returns A promise that resolves with the fetched channel
2155
+ */
2156
+ fetch(channel: ChannelResolvable, { force }?: {
2157
+ force?: boolean | undefined;
2158
+ }): Promise<Channel>;
2159
+ /**
2160
+ * resolves a channel from a string or a channel object
2161
+ * @param channel The channel to resolve
2162
+ * @returns the resolved channel or null if not found
2163
+ */
2164
+ resolve(channel: ChannelResolvable): Channel | null;
2165
+ /**
2166
+ * resolves a channel id from a string or a channel object
2167
+ * @param channel The channel to resolve
2168
+ * @returns the resolved channel id or null if not found
2169
+ */
2170
+ resolveId(channel: ChannelResolvable): string | null;
2171
+ }
2172
+
2173
+ type ServerResolvable = Server | Server$1 | string;
2174
+ interface EditServerOptions {
2175
+ name?: string;
2176
+ description?: string;
2177
+ }
2178
+ declare class ServerManager extends BaseManager<Server, Server$1> {
2179
+ readonly holds: typeof Server;
2180
+ _remove(id: string): void;
2181
+ /**
2182
+ * edits a server
2183
+ * @param server The server to edit
2184
+ * @param options The options to edit the server with
2185
+ * @param options.name The name of the server
2186
+ * @param options.description The description of the server
2187
+ * @returns A promise that resolves when the server is edited
2188
+ */
2189
+ edit(server: ServerResolvable, options: EditServerOptions): Promise<void>;
2190
+ /**
2191
+ * leaves a server
2192
+ * @param server the server to leave
2193
+ */
2194
+ delete(server: ServerResolvable): Promise<void>;
2195
+ fetch(server: ServerResolvable, { force }?: {
2196
+ force?: boolean | undefined;
2197
+ }): Promise<Server>;
2198
+ }
2199
+
2200
+ type MessageResolvable = Message | Message$1 | string;
2201
+ interface MessageReply {
2202
+ id: string;
2203
+ mention: boolean;
2204
+ }
2205
+ interface MessageOptions {
2206
+ content?: string;
2207
+ replies?: MessageReply[];
2208
+ attachments?: string[];
2209
+ embeds?: MessageEmbed[];
2210
+ }
2211
+ interface MessageEditOptions {
2212
+ content?: string;
2213
+ attachments?: string[];
2214
+ embeds?: MessageEmbed[];
2215
+ }
2216
+ interface MessageSearchOptions {
2217
+ query: string;
2218
+ limit?: number;
2219
+ before?: string;
2220
+ after?: string;
2221
+ sort?: MessageSort;
2222
+ }
2223
+ interface MessageQueryOptions {
2224
+ limit?: number;
2225
+ before?: string;
2226
+ after?: string;
2227
+ sort?: MessageSort;
2228
+ nearby?: string;
2229
+ }
2230
+ declare class MessageManager extends BaseManager<Message, Message$1> {
2231
+ protected readonly channel: Channel;
2232
+ holds: typeof Message;
2233
+ constructor(channel: Channel);
2234
+ /**
2235
+ *
2236
+ * @param content The content to send. Can be a string or an object with the following properties:
2237
+ * - content: The content of the message
2238
+ * - replies: An array of message IDs to reply to
2239
+ * - attachments: An array of attachment URLs
2240
+ * - embeds: An array of MessageEmbed objects
2241
+ * @returns Promise that resolves to the sent message
2242
+ */
2243
+ send(content: MessageOptions | string): Promise<Message>;
2244
+ /**
2245
+ * acknowledge a message to mark it as read (not important for bots)
2246
+ * @param message The message to acknowledge
2247
+ * @returns Promise that resolves when the message is acknowledged
2248
+ */
2249
+ ack(message: MessageResolvable): Promise<void>;
2250
+ /**
2251
+ * bulk delete messages from the channel
2252
+ * @param messages The messages to delete. Can be an array of message IDs or a Map of message IDs to Message objects.
2253
+ * @returns Promise that resolves when the messages are deleted
2254
+ */
2255
+ bulkDelete(messages: MessageResolvable[] | number | Map<string, Message>): Promise<void>;
2256
+ /**
2257
+ * delete a message from the channel
2258
+ * @param message The message to delete. Can be a Message object or a message ID.
2259
+ * @returns Promise that resolves when the message is deleted
2260
+ */
2261
+ delete(message: MessageResolvable): Promise<void>;
2262
+ /**
2263
+ * edit a message in the channel
2264
+ * @param message The message to edit. Can be a Message object or a message ID.
2265
+ * @param options The options to edit the message with. Can be a string or an object with the following properties:
2266
+ * - content: The new content of the message
2267
+ * - attachments: An array of attachment URLs
2268
+ * - embeds: An array of MessageEmbed objects
2269
+ * @returns Promise that resolves when the message is edited
2270
+ */
2271
+ edit(message: MessageResolvable, options: MessageEditOptions | string): Promise<void>;
2272
+ /**
2273
+ * search for messages in the channel
2274
+ * @param query The query to search for. Can be a string or an object with the following properties:
2275
+ * - query: The query to search for
2276
+ * - limit: The maximum number of messages to return
2277
+ * - before: The message ID to start searching from (exclusive)
2278
+ * - after: The message ID to stop searching at (exclusive)
2279
+ * - sort: The sort order of the results (asc or desc)
2280
+ * @returns Promise that resolves to a Map of message IDs to Message objects
2281
+ */
2282
+ search(query: MessageSearchOptions | string): Promise<Map<string, Message>>;
2283
+ /**
2284
+ * fetch a message from the channel
2285
+ * @param message The message to fetch. Can be a Message object, a message ID, or an object with the following properties:
2286
+ * - limit: The maximum number of messages to return
2287
+ * - before: The message ID to start fetching from (exclusive)
2288
+ * - after: The message ID to stop fetching at (exclusive)
2289
+ * @returns Promise that resolves to a Message object or a Map of message IDs to Message objects
2290
+ */
2291
+ fetch(message: MessageResolvable): Promise<Message>;
2292
+ fetch(query?: MessageQueryOptions): Promise<Map<string, Message>>;
2293
+ fetch(limit: number): Promise<Map<string, Message>>;
2294
+ /**
2295
+ * add a reaction to a message
2296
+ * @param message The message to react to. Can be a Message object or a message ID.
2297
+ * @param emoji emoji to react with. Can be a string or an Emoji object.
2298
+ * @returns Promise that resolves when the reaction is added
2299
+ */
2300
+ addReaction(message: MessageResolvable | string, emoji: string | Emoji): Promise<void>;
2301
+ /**
2302
+ *
2303
+ * @param message The message to unreact. Can be a Message object or a message ID.
2304
+ * @param emoji the emoji to unreact with. Can be a string or an Emoji object.
2305
+ * @param user_id The user ID to remove the reaction for. If not provided, removes the reaction for the current user.
2306
+ * @param remove_all Whether to remove all of the specified reaction for the message. Defaults to false.
2307
+ * @returns Promise that resolves when the reaction is removed
2308
+ */
2309
+ removeReaction(message: MessageResolvable | string, emoji: string | Emoji, user_id?: string, remove_all?: boolean): Promise<void>;
2310
+ /**
2311
+ * remove all reactions from a message
2312
+ * @param message The message to remove reactions from. Can be a Message object or a message ID.
2313
+ * @returns Promise that resolves when the reactions are removed
2314
+ */
2315
+ removeAllReactions(message: MessageResolvable | string): Promise<void>;
2316
+ }
2317
+
2318
+ type RoleResolvable = Role | string;
2319
+ declare class RoleManager extends BaseManager<Role, Role$1 & {
2320
+ id: string;
2321
+ }> {
2322
+ protected readonly server: Server;
2323
+ holds: typeof Role;
2324
+ constructor(server: Server);
2325
+ _add(data: Role$1 & {
2326
+ id: string;
2327
+ }): Role;
2328
+ /**
2329
+ * creates a new role in the server
2330
+ * @param name The name of the role to create
2331
+ * @returns
2332
+ */
2333
+ create(name: string): Promise<Role>;
2334
+ /**
2335
+ * deletes a role from the server
2336
+ * @param role the role to delete
2337
+ * @returns A promise that resolves when the role is deleted
2338
+ */
2339
+ delete(role: RoleResolvable): Promise<void>;
2340
+ }
2341
+
2342
+ type APIServerChannel = Extract<Channel$1, {
2343
+ channel_type: "TextChannel" | "VoiceChannel";
2344
+ }>;
2345
+ type ServerChannelResolvable = ServerChannel | APIServerChannel | string;
2346
+ interface CreateChannelOptions {
2347
+ name: string;
2348
+ type?: "Text" | "Voice";
2349
+ description?: string;
2350
+ }
2351
+ declare class ServerChannelManager extends BaseManager<ServerChannel> {
2352
+ protected readonly server: Server;
2353
+ holds: typeof ServerChannel;
2354
+ constructor(server: Server);
2355
+ _add(data: APIServerChannel): ServerChannel;
2356
+ /**
2357
+ * creates a new channel in the server
2358
+ * @param name The name of the channel to create
2359
+ * @param type The type of the channel to create. Can be "Text" or "Voice". Defaults to "Text".
2360
+ * @param description The description of the channel to create. Only used for voice channels.
2361
+ * @returns A promise that resolves to the created channel
2362
+ */
2363
+ create({ name, type, description, }: CreateChannelOptions): Promise<ServerChannel>;
2364
+ /**
2365
+ * fetch a channel from the server
2366
+ * @param channel The channel to fetch. Can be a string, a channel object, or an API channel object.
2367
+ * @param force Whether to force fetch the channel from the API. Defaults to true.
2368
+ * If set to false, the method will return the channel from the cache if it exists.
2369
+ * @returns A promise that resolves to the fetched channel
2370
+ */
2371
+ fetch(channel: ServerChannelResolvable, { force }?: {
2372
+ force?: boolean | undefined;
2373
+ }): Promise<ServerChannel>;
2374
+ }
2375
+
2376
+ type ServerMemberResolvable = ServerMember | User | Member | string;
2377
+ interface EditServerMemberOptions {
2378
+ nickname?: string;
2379
+ avatar?: string;
2380
+ roles?: string[];
2381
+ }
2382
+ declare class ServerMemberManager extends BaseManager<ServerMember, Member> {
2383
+ protected readonly server: Server;
2384
+ holds: typeof ServerMember;
2385
+ constructor(server: Server);
2386
+ /**
2387
+ * edit selected member in the server
2388
+ * @param member The member to edit
2389
+ * @param options The options to edit the member with
2390
+ * @param options.nickname The nickname of the member to set
2391
+ * @param options.avatar The avatar of the member to set
2392
+ * @param options.roles The roles of the member to set
2393
+ * @returns A promise that resolves when the member is edited
2394
+ */
2395
+ edit(member: ServerMemberResolvable, options: EditServerMemberOptions): Promise<void>;
2396
+ /**
2397
+ * ban selected member in the server
2398
+ * @param member The member to ban
2399
+ * @param reason the reason for the ban
2400
+ * @returns A promise that resolves when the member is banned
2401
+ */
2402
+ ban(member: ServerMemberResolvable, reason?: string): Promise<void>;
2403
+ /**
2404
+ * kick selected member in the server
2405
+ * @param member The member to kick
2406
+ * @returns A promise that resolves when the member is kicked
2407
+ */
2408
+ kick(member: ServerMemberResolvable): Promise<void>;
2409
+ /**
2410
+ * unban selected member in the server
2411
+ * @param member The member to unban
2412
+ * @returns A promise that resolves when the member is unbanned
2413
+ */
2414
+ unban(member: ServerMemberResolvable): Promise<void>;
2415
+ /**
2416
+ * fetch a member from the server
2417
+ * @param member The member to fetch
2418
+ * @returns A promise that resolves with the fetched member
2419
+ */
2420
+ fetch(member: ServerMemberResolvable): Promise<ServerMember>;
2421
+ fetch(): Promise<Map<string, ServerMember>>;
2422
+ /**
2423
+ * resolves a member from a string or a member object
2424
+ * @param member The member to resolve
2425
+ * @returns The id of the member or null if it cannot be resolved
2426
+ */
2427
+ resolveId(member: ServerMemberResolvable): string | null;
2428
+ }
2429
+
2430
+ export { Attachment, type BadgeString, Badges, type BadgesResolvable, Base, BaseManager, BitField, type BitFieldResolvable, Category, Channel, ChannelManager, ChannelPermissions, type ChannelPermissionsResolvable, type ChannelPermissionsString, type ChannelResolvable, ChannelTypes, type CreateChannelOptions, DEFAULT_CLIENT_OPTIONS, DEFAULT_PERMISSION_DM, DMChannel, type EditServerMemberOptions, type EditServerOptions, type Embed, type EmbedImage, type EmbedSpecial, type EmbedVideo, Emoji, Events, GroupChannel, Invite, Mentions, Message, type MessageEditOptions, MessageEmbed, MessageManager, type MessageOptions, type MessageQueryOptions, type MessageReply, type MessageResolvable, type MessageSearchOptions, NotesChannel, type Overwrite, Presence, Role, RoleManager, type RoleResolvable, SYSTEM_USER_ID, Server, ServerChannel, ServerChannelManager, type ServerChannelResolvable, ServerManager, ServerMember, ServerMemberManager, type ServerMemberResolvable, ServerPermissions, type ServerPermissionsResolvable, type ServerPermissionsString, type ServerResolvable, Status, TextChannel, UUID, User, UserManager, UserPermissions, type UserPermissionsResolvable, type UserPermissionsString, type UserResolvable, VoiceChannel, WSEvents, apiUrl, client, wsUrl };