stoat-selfbot.js 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,3502 @@
1
+ import { Role as Role$1, User as User$1, FieldsUser, SystemMessage, File as File$1, Masquerade, Message, Server as Server$1, FieldsServer, FieldsRole, Channel as Channel$1, MessageSort, Invite as Invite$1, Embed as Embed$1, SendableEmbed, Special, FieldsChannel, Member, FieldsMember, Category as Category$1, UserProfile as UserProfile$1 } from 'revolt-api';
2
+ import { Readable } from 'stream';
3
+ import { File as File$2 } from 'node:buffer';
4
+ import { Readable as Readable$1 } from 'node:stream';
5
+ import { EventEmitter } from 'node:events';
6
+ import FormData from 'form-data';
7
+
8
+ type PartialObject = Partial<{
9
+ _id: string;
10
+ } | {
11
+ id: string;
12
+ } | {
13
+ _id: {
14
+ user: string;
15
+ };
16
+ }>;
17
+ /**
18
+ * Represents the base structure for all objects in the client.
19
+ * Provides common functionality such as equality checks, cloning, and patching data.
20
+ */
21
+ declare abstract class Base {
22
+ readonly client: Client;
23
+ /** The unique identifier for the object. */
24
+ id: string;
25
+ /**
26
+ * Creates a new Base instance.
27
+ *
28
+ * @param {client} client - The client instance.
29
+ */
30
+ constructor(client: Client);
31
+ /**
32
+ * Compares this object with another to determine if they are equal.
33
+ *
34
+ * @param {this | null} [obj] - The object to compare with.
35
+ * @returns {boolean} `true` if the objects are equal, otherwise `false`.
36
+ */
37
+ equals(obj?: this | null): boolean;
38
+ /**
39
+ * Updates the object with new data and returns a clone of the object.
40
+ *
41
+ * @param {PartialObject} data - The data to update the object with.
42
+ * @param {string[]} [clear] - Fields to clear in the object.
43
+ * @returns {this} A clone of the updated object.
44
+ */
45
+ _update(data: PartialObject, clear?: string[]): this;
46
+ /**
47
+ * Patches the object with new data.
48
+ *
49
+ * @param {PartialObject} data - The data to patch the object with.
50
+ * @param {string[]} [_clear] - Fields to clear in the object.
51
+ * @returns {this} The updated object.
52
+ * @protected
53
+ */
54
+ protected _patch(data: PartialObject, _clear?: string[]): this;
55
+ /**
56
+ * Creates a deep clone of the object.
57
+ *
58
+ * @returns {this} A clone of the object.
59
+ */
60
+ _clone(): this;
61
+ }
62
+
63
+ declare class UUID extends null {
64
+ static readonly ENCODING = "0123456789ABCDEFGHJKMNPQRSTVWXYZ";
65
+ static readonly ENCODING_LENGTH: number;
66
+ static readonly RANDOM_LENGTH = 16;
67
+ static readonly TIME_LENGTH = 10;
68
+ static readonly TIME_MAX: number;
69
+ static get PROG(): number;
70
+ private static time;
71
+ private static hash;
72
+ static generate(timestamp?: number): string;
73
+ static timestampOf(id: string): Date;
74
+ }
75
+
76
+ /** A type that can be a BitField, number, string, or an array of these types.
77
+ * @private
78
+ */
79
+ type BitFieldResolvable = BitField | number | string | BitFieldResolvable[];
80
+ /**
81
+ * Represents a bitfield that can be used to manage flags or permissions.
82
+ */
83
+ declare class BitField {
84
+ static FLAGS: Record<string, number>;
85
+ bitfield: number;
86
+ constructor(bits?: BitFieldResolvable);
87
+ /**
88
+ * Resolves a bitfield or an array of bitfields into a single number.
89
+ * @param bit The bitfield or array of bitfields to resolve.
90
+ * @returns The resolved bitfield as a number.
91
+ */
92
+ static resolve(bit: BitFieldResolvable): number;
93
+ /**
94
+ * Returns the class that this instance belongs to.
95
+ * @returns The class of the bitfield.
96
+ */
97
+ get self(): {
98
+ FLAGS: Record<string, number>;
99
+ resolve(bit: BitFieldResolvable): number;
100
+ new (bits?: BitFieldResolvable): BitField;
101
+ };
102
+ /**
103
+ * Checks if any of the bits in the bitfield are set.
104
+ * @param bit The bitfield or array of bitfields to check.
105
+ * @returns True if any bits are set, false otherwise.
106
+ */
107
+ any(bit: BitFieldResolvable): boolean;
108
+ /**
109
+ * checks if a specific permission is set.
110
+ */
111
+ has(bit: BitFieldResolvable): boolean;
112
+ /**
113
+ * Returns an array of all the Permissions that are set in the bitfield.
114
+ * @returns An array of flag names.
115
+ */
116
+ toArray(): string[];
117
+ add(...bits: BitFieldResolvable[]): this;
118
+ remove(...bits: BitFieldResolvable[]): this;
119
+ freeze(): Readonly<this>;
120
+ valueOf(): number;
121
+ /**
122
+ *
123
+ * @returns A record of all flags and their boolean values indicating whether they are set.
124
+ */
125
+ serialize(): Record<string, boolean>;
126
+ [Symbol.iterator](): Iterable<string>;
127
+ }
128
+
129
+ declare class RestClient {
130
+ private readonly client;
131
+ private rateLimitQueue;
132
+ constructor(client: BaseClient);
133
+ /**
134
+ * Helper function to handle API requests.
135
+ * @param method The HTTP method (GET, POST, PATCH, PUT, DELETE).
136
+ * @param url The URL for the request.
137
+ * @param body The request body (if applicable).
138
+ * @param query Query parameters (if applicable).
139
+ * @returns The API response.
140
+ */
141
+ private request;
142
+ getConfig(): Promise<void>;
143
+ private retryRequest;
144
+ /**
145
+ * GET request.
146
+ * @param url The URL for the request.
147
+ * @param query Query parameters (if applicable).
148
+ * @returns The API response.
149
+ */
150
+ get<T>(url: string, query?: Record<string, string | number>): Promise<T>;
151
+ /**
152
+ * POST request.
153
+ * @param url The URL for the request.
154
+ * @param body The request body.
155
+ * @param query Query parameters (if applicable).
156
+ * @returns The API response.
157
+ */
158
+ post<T>(url: string, body?: any, query?: Record<string, string | number>): Promise<T>;
159
+ /**
160
+ * PATCH request.
161
+ * @param url The URL for the request.
162
+ * @param body The request body.
163
+ * @param query Query parameters (if applicable).
164
+ * @returns The API response.
165
+ */
166
+ patch<T>(url: string, body: any, query?: Record<string, string | number>): Promise<T>;
167
+ /**
168
+ * PUT request.
169
+ * @param url The URL for the request.
170
+ * @param body The request body.
171
+ * @param query Query parameters (if applicable).
172
+ * @returns The API response.
173
+ */
174
+ put<T>(url: string, body?: any, query?: Record<string, string | number>): Promise<T>;
175
+ /**
176
+ * DELETE request.
177
+ * @param url The URL for the request.
178
+ * @param query Query parameters (if applicable).
179
+ * @returns The API response.
180
+ */
181
+ delete<T>(url: string, body?: any, query?: Record<string, string | number>): Promise<T>;
182
+ }
183
+
184
+ declare class CDNClient {
185
+ private readonly client;
186
+ private rateLimitQueue;
187
+ constructor(client: BaseClient);
188
+ /**
189
+ * Helper function to handle API requests.
190
+ * @param method The HTTP method (GET, POST, PATCH, PUT, DELETE).
191
+ * @param url The URL for the request.
192
+ * @param body The request body (if applicable).
193
+ * @param query Query parameters (if applicable).
194
+ * @returns The API response.
195
+ */
196
+ private request;
197
+ private retryRequest;
198
+ /**
199
+ * POST request.
200
+ * @param url The URL for the request.
201
+ * @param data The request body.
202
+ * @returns The API response.
203
+ */
204
+ post<T>(url: string, data: FormData): Promise<T>;
205
+ }
206
+
207
+ type ChannelPermissionsString = keyof typeof ChannelPermissions.FLAGS;
208
+ type UserPermissionsString = keyof typeof UserPermissions.FLAGS;
209
+ type ServerPermissionsString = keyof typeof ServerPermissions.FLAGS;
210
+ type ChannelPermissionsResolvable = number | ChannelPermissionsString | ChannelPermissions | ChannelPermissionsResolvable[];
211
+ type UserPermissionsResolvable = number | UserPermissionsString | UserPermissions | UserPermissionsResolvable[];
212
+ type ServerPermissionsResolvable = number | ServerPermissionsString | ServerPermissions | ServerPermissionsResolvable[];
213
+ declare interface ChannelPermissions {
214
+ serialize(): Record<ChannelPermissionsString, boolean>;
215
+ any(bit: ChannelPermissionsResolvable): boolean;
216
+ add(...bits: ChannelPermissionsResolvable[]): this;
217
+ remove(...bits: ChannelPermissionsResolvable[]): this;
218
+ has(bit: ChannelPermissionsResolvable): boolean;
219
+ }
220
+ declare class ChannelPermissions extends BitField {
221
+ static readonly FLAGS: {
222
+ readonly VIEW_CHANNEL: number;
223
+ readonly SEND_MESSAGE: number;
224
+ readonly MANAGE_MESSAGE: number;
225
+ readonly MANAGE_CHANNEL: number;
226
+ readonly VOICE_CALL: number;
227
+ readonly INVITE_OTHERS: number;
228
+ readonly EMBED_LINKS: number;
229
+ readonly UPLOAD_FILES: number;
230
+ };
231
+ constructor(bits?: ChannelPermissionsResolvable);
232
+ static resolve(bit: ChannelPermissionsResolvable): number;
233
+ }
234
+ declare interface UserPermissions {
235
+ serialize(): Record<UserPermissionsString, boolean>;
236
+ any(bit: UserPermissionsResolvable): boolean;
237
+ add(...bits: UserPermissionsResolvable[]): this;
238
+ remove(...bits: UserPermissionsResolvable[]): this;
239
+ has(bit: UserPermissionsResolvable): boolean;
240
+ }
241
+ declare class UserPermissions extends BitField {
242
+ static readonly FLAGS: {
243
+ readonly ACCESS: number;
244
+ readonly VIEW_PROFILE: number;
245
+ readonly SEND_MESSAGES: number;
246
+ readonly INVITE: number;
247
+ };
248
+ constructor(bits?: UserPermissionsResolvable);
249
+ static resolve(bit: UserPermissionsResolvable): number;
250
+ }
251
+ declare interface ServerPermissions {
252
+ serialize(): Record<ServerPermissionsString, boolean>;
253
+ any(bit: ServerPermissionsResolvable): boolean;
254
+ add(...bits: ServerPermissionsResolvable[]): this;
255
+ remove(...bits: ServerPermissionsResolvable[]): this;
256
+ has(bit: ServerPermissionsResolvable): boolean;
257
+ }
258
+ declare class ServerPermissions extends BitField {
259
+ static readonly FLAGS: {
260
+ readonly VIEW_SERVER: number;
261
+ readonly MANAGE_ROLES: number;
262
+ readonly MANAGE_CHANNELS: number;
263
+ readonly MANAGE_SERVER: number;
264
+ readonly KICK_MEMBERS: number;
265
+ readonly BAN_MEMBERS: number;
266
+ readonly CHANGE_NICKNAME: number;
267
+ readonly MANAGE_NICKNAMES: number;
268
+ readonly CHANGE_AVATAR: number;
269
+ readonly REMOVE_AVATARS: number;
270
+ };
271
+ constructor(bits?: ServerPermissionsResolvable);
272
+ static resolve(bit: ServerPermissionsResolvable): number;
273
+ }
274
+ declare class FullPermissions extends BitField {
275
+ static readonly FLAGS: {
276
+ readonly ManageChannel: number;
277
+ readonly ManageServer: number;
278
+ readonly ManagePermissions: number;
279
+ readonly ManageRole: number;
280
+ readonly ManageCustomisation: number;
281
+ readonly KickMembers: number;
282
+ readonly BanMembers: number;
283
+ readonly TimeoutMembers: number;
284
+ readonly AssignRoles: number;
285
+ readonly ChangeNickname: number;
286
+ readonly ManageNicknames: number;
287
+ readonly ChangeAvatar: number;
288
+ readonly RemoveAvatars: number;
289
+ readonly ViewChannel: number;
290
+ readonly ReadMessageHistory: number;
291
+ readonly SendMessage: number;
292
+ readonly ManageMessages: number;
293
+ readonly ManageWebhooks: number;
294
+ readonly InviteOthers: number;
295
+ readonly SendEmbeds: number;
296
+ readonly UploadFiles: number;
297
+ readonly Masquerade: number;
298
+ readonly React: number;
299
+ readonly Connect: number;
300
+ readonly Speak: number;
301
+ readonly Video: number;
302
+ readonly MuteMembers: number;
303
+ readonly DeafenMembers: number;
304
+ readonly MoveMembers: number;
305
+ readonly MentionEveryone: number;
306
+ readonly MentionRoles: number;
307
+ readonly GrantAll: 4503599627370495;
308
+ };
309
+ constructor(bits?: number | string | FullPermissions | Array<number | string | FullPermissions>);
310
+ static resolve(bit: number | string | FullPermissions): number;
311
+ }
312
+ declare const DEFAULT_PERMISSION_DM: Readonly<ChannelPermissions>;
313
+
314
+ /**
315
+ * Represents a webhook avatar attachment.
316
+ */
317
+ interface WebhookAvatar {
318
+ /** The unique identifier of the attachment. */
319
+ _id: string;
320
+ /** The tag associated with the attachment. */
321
+ tag: string;
322
+ /** The filename of the attachment. */
323
+ filename: string;
324
+ /** Additional metadata for the attachment. */
325
+ metadata: any;
326
+ /** The MIME type of the attachment. */
327
+ content_type: string;
328
+ /** The size of the attachment in bytes. */
329
+ size: number;
330
+ }
331
+ /**
332
+ * Represents data for a webhook creation event.
333
+ */
334
+ interface WebhookCreateData {
335
+ /** The unique identifier of the webhook. */
336
+ webhookId: string;
337
+ /** The ID of the channel the webhook belongs to. */
338
+ channelId: string;
339
+ /** The name of the webhook. */
340
+ name: string;
341
+ /** The ID of the user who created the webhook. */
342
+ creatorId: string;
343
+ /** The webhook's token. */
344
+ token: string;
345
+ }
346
+ /**
347
+ * Represents data for a webhook deletion event.
348
+ */
349
+ interface WebhookDeleteData {
350
+ /** The unique identifier of the webhook. */
351
+ webhookId: string;
352
+ }
353
+ /**
354
+ * Represents data for a webhook update event.
355
+ */
356
+ interface WebhookUpdateData {
357
+ /** The unique identifier of the webhook. */
358
+ webhookId: string;
359
+ /** The updated name of the webhook. */
360
+ name: string;
361
+ /** The updated avatar of the webhook, if any. */
362
+ avatar: WebhookAvatar | undefined;
363
+ /** Fields to remove from the webhook. */
364
+ remove: string[];
365
+ }
366
+ /**
367
+ * Represents the permissions that can be set for a role.
368
+ */
369
+ type editablePermissions = {
370
+ /**
371
+ * Permissions to allow for the role.
372
+ * Each key corresponds to a permission flag in FullPermissions.
373
+ */
374
+ a?: Array<keyof (typeof FullPermissions)["FLAGS"]>;
375
+ /**
376
+ * Permissions to deny for the role.
377
+ * Each key corresponds to a permission flag in FullPermissions.
378
+ */
379
+ d?: Array<keyof (typeof FullPermissions)["FLAGS"]>;
380
+ };
381
+ /**
382
+ * Represents a role that can be edited in a server.
383
+ */
384
+ type editableRole = {
385
+ /**
386
+ * Name of the role.
387
+ */
388
+ name?: string;
389
+ /**
390
+ * Colour of the role, or `null` if no colour is set.
391
+ */
392
+ colour?: string | null;
393
+ /**
394
+ * Whether the role is displayed separately in the member list.
395
+ */
396
+ hoist?: boolean;
397
+ /**
398
+ * Rank of the role, used for ordering.
399
+ */
400
+ rank?: number;
401
+ /**
402
+ * Permissions to set for the role.
403
+ * Format: { a: allow, d: deny }
404
+ */
405
+ permissions?: editablePermissions;
406
+ /**
407
+ * Fields to remove from the role.
408
+ * Each key corresponds to a field in the Role type.
409
+ */
410
+ remove?: Array<keyof Role$1 & {
411
+ [key: string]: unknown;
412
+ }>;
413
+ };
414
+ interface createWebhookResponse {
415
+ id: "string";
416
+ name: "string";
417
+ avatar: {
418
+ _id: "string";
419
+ tag: "string";
420
+ filename: "string";
421
+ metadata: {
422
+ type: "File";
423
+ };
424
+ content_type: "string";
425
+ size: 1;
426
+ deleted: null;
427
+ reported: null;
428
+ message_id: null;
429
+ user_id: null;
430
+ server_id: null;
431
+ object_id: null;
432
+ };
433
+ creator_id: "string";
434
+ channel_id: "string";
435
+ permissions: 0;
436
+ token: null;
437
+ }
438
+ interface editWebhookOptions {
439
+ name: string;
440
+ avatar?: Readable | string | File;
441
+ remove?: [];
442
+ }
443
+
444
+ /**
445
+ * Represents the base class for all event handlers.
446
+ * All event handlers must extend this class and implement the `handle` method.
447
+ * @private
448
+ */
449
+ declare abstract class Event {
450
+ protected readonly client: Client;
451
+ /**
452
+ * Creates a new Event instance.
453
+ *
454
+ * @param {client} client - The client instance.
455
+ */
456
+ constructor(client: Client);
457
+ /**
458
+ * Handles the event logic.
459
+ * This method must be implemented by subclasses to define the behavior for the specific event.
460
+ *
461
+ * @param {unknown} data - The data associated with the event.
462
+ * @returns {Promise<unknown | void>} A promise that resolves with the result of the event handling or `void`.
463
+ */
464
+ abstract handle(data: unknown): Awaited<unknown | void>;
465
+ }
466
+
467
+ /**
468
+ * Data structure for user voice state update event.
469
+ */
470
+ interface UserVoiceStateUpdateData {
471
+ id: string;
472
+ channel_id: string;
473
+ data: {
474
+ is_publishing: boolean;
475
+ screensharing: boolean;
476
+ camera: boolean;
477
+ };
478
+ }
479
+
480
+ /**
481
+ * Data structure for voice channel join event.
482
+ */
483
+ interface VoiceChannelJoinData {
484
+ id: string;
485
+ state: voiceParticipant;
486
+ }
487
+
488
+ /**
489
+ * Data structure for voice channel leave event.
490
+ */
491
+ interface VoiceChannelLeaveData {
492
+ id: string;
493
+ user: string;
494
+ }
495
+
496
+ /**
497
+ * Represents the events that the client can emit (discord.js style).
498
+ */
499
+ interface ClientEvents {
500
+ /** Emitted when a debug message is logged. */
501
+ [Events.DEBUG]: [unknown];
502
+ /** Emitted when a message is received. */
503
+ [Events.MESSAGE_CREATE]: [MessageStruct];
504
+ /** Emitted when a message is deleted. */
505
+ [Events.MESSAGE_DELETE]: [MessageStruct];
506
+ /** Emitted when a message is updated. */
507
+ [Events.MESSAGE_UPDATE]: [MessageStruct, MessageStruct];
508
+ /** Emitted when a reaction is added to a message. */
509
+ [Events.MESSAGE_REACTION_ADD]: [MessageStruct];
510
+ /** Emitted when a reaction is removed from a message. */
511
+ [Events.MESSAGE_REACTION_REMOVE]: [MessageStruct];
512
+ /** Emitted when a message is bulk deleted. */
513
+ [Events.MESSAGE_DELETE_BULK]: [string[]];
514
+ /** Emitted when a channel is created. */
515
+ [Events.CHANNEL_CREATE]: [Channel];
516
+ /** Emitted when a channel is deleted. */
517
+ [Events.CHANNEL_DELETE]: [Channel];
518
+ /** Emitted when a channel is updated. */
519
+ [Events.CHANNEL_UPDATE]: [Channel, Channel];
520
+ /** Emitted when a server is created. */
521
+ [Events.SERVER_CREATE]: [Server];
522
+ /** Emitted when a server is deleted. */
523
+ [Events.SERVER_DELETE]: [Server];
524
+ /** Emitted when a server is updated. */
525
+ [Events.SERVER_UPDATE]: [Server, Server];
526
+ /** Emitted when a server member joins (discord.js: guildMemberAdd). */
527
+ [Events.SERVER_MEMBER_JOIN]: [ServerMember];
528
+ /** Emitted when a server member leaves (discord.js: guildMemberRemove). */
529
+ [Events.SERVER_MEMBER_LEAVE]: [ServerMember];
530
+ /** Emitted when a server member is updated (discord.js: guildMemberUpdate). */
531
+ [Events.SERVER_MEMBER_UPDATE]: [ServerMember, ServerMember];
532
+ /** Emitted when a user is updated. */
533
+ [Events.USER_UPDATE]: [User, User];
534
+ /** Emitted when a user is typing. */
535
+ [Events.TYPING_START]: [Channel, User];
536
+ /** Emitted when a user stops typing. */
537
+ [Events.TYPING_STOP]: [Channel, User];
538
+ /** Emitted when a group member joins. */
539
+ [Events.GROUP_JOIN]: [Channel, User];
540
+ /** Emitted when a group member leaves. */
541
+ [Events.GROUP_LEAVE]: [Channel, User];
542
+ /** Emitted when the client is ready. */
543
+ [Events.READY]: [Client];
544
+ /** Emitted when an error occurs. */
545
+ [Events.ERROR]: [unknown];
546
+ /** Emitted when a raw event is received. */
547
+ [Events.RAW]: [unknown];
548
+ /** emitted when a role is created */
549
+ [Events.ROLE_CREATE]: [Role];
550
+ /** emitted when a role is deleted */
551
+ [Events.ROLE_DELETE]: [Role];
552
+ /** emitted when a role is updated */
553
+ [Events.ROLE_UPDATE]: [Role, Role];
554
+ /** emitted when a webhook is created */
555
+ [Events.WEBHOOKS_CREATE]: [WebhookCreateData];
556
+ /** emitted when a webhook is deleted */
557
+ [Events.WEBHOOKS_DELETE]: [WebhookDeleteData];
558
+ /** emitted when a webhook is updated */
559
+ [Events.WEBHOOKS_UPDATE]: [WebhookUpdateData];
560
+ /** emitted when a user's voice state is updated (discord.js: voiceStateUpdate) */
561
+ [Events.USER_VOICE_STATE_UPDATE]: [UserVoiceStateUpdateData];
562
+ /** emitted when a user joins a voice channel */
563
+ [Events.VOICE_CHANNEL_JOIN]: [VoiceChannelJoinData];
564
+ /** emitted when a user leaves a voice channel */
565
+ [Events.VOICE_CHANNEL_LEAVE]: [VoiceChannelLeaveData];
566
+ }
567
+ /**
568
+ * Represents the options for configuring the selfbot client.
569
+ */
570
+ interface clientOptions {
571
+ /** Whether to fetch all members of a server. */
572
+ fetchMembers?: boolean;
573
+ /** events for the client to ignore.*/
574
+ ignoreEvents?: string[];
575
+ /** Configuration for REST API requests. */
576
+ rest?: {
577
+ /** The timeout for REST requests in milliseconds. */
578
+ timeout?: number;
579
+ /** The number of retries for failed REST requests. */
580
+ retries?: number;
581
+ /** URL for stoat API instance without trailing slash */
582
+ instanceURL?: string;
583
+ /** URL for stoat CDN instance without trailing slash */
584
+ instanceCDNURL?: string;
585
+ };
586
+ MessageCache?: {
587
+ /** The maximum size of the cache. */
588
+ maxSize?: number;
589
+ };
590
+ /** Configuration for WebSocket connections. */
591
+ ws?: {
592
+ /** The interval for sending heartbeats in milliseconds. */
593
+ heartbeatInterval?: number;
594
+ /** Whether to automatically reconnect on disconnection. */
595
+ reconnect?: boolean;
596
+ /** URL for stoat WebSocket instance without trailing slash */
597
+ instanceURL?: string;
598
+ };
599
+ }
600
+ interface VoiceClientOptions {
601
+ enabled?: boolean;
602
+ nodes?: VoiceNode[];
603
+ }
604
+ interface VoiceNode {
605
+ name: string;
606
+ lat: number;
607
+ lon: number;
608
+ public_url: string;
609
+ }
610
+ /**
611
+ * Represents the base client that provides core functionality for interacting with the API.
612
+ *
613
+ * @extends EventEmitter
614
+ */
615
+ declare interface BaseClient {
616
+ on<K extends keyof ClientEvents>(event: K, listener: (...args: ClientEvents[K]) => Awaited<void>): this;
617
+ on<S extends string | symbol>(event: Exclude<S, keyof ClientEvents>, listener: (...args: any[]) => Awaited<void>): this;
618
+ once<K extends keyof ClientEvents>(event: K, listener: (...args: ClientEvents[K]) => Awaited<void>): this;
619
+ once<S extends string | symbol>(event: Exclude<S, keyof ClientEvents>, listener: (...args: any[]) => Awaited<void>): this;
620
+ emit<K extends keyof ClientEvents>(event: K, ...args: ClientEvents[K]): boolean;
621
+ emit<S extends string | symbol>(event: Exclude<S, keyof ClientEvents>, ...args: unknown[]): boolean;
622
+ off<K extends keyof ClientEvents>(event: K, listener: (...args: ClientEvents[K]) => Awaited<void>): this;
623
+ off<S extends string | symbol>(event: Exclude<S, keyof ClientEvents>, listener: (...args: any[]) => Awaited<void>): this;
624
+ removeAllListeners<K extends keyof ClientEvents>(event?: K): this;
625
+ removeAllListeners<S extends string | symbol>(event?: Exclude<S, keyof ClientEvents>): this;
626
+ }
627
+ /**
628
+ * Represents the base client that provides core functionality for interacting with the API.
629
+ *
630
+ * @extends EventEmitter
631
+ */
632
+ declare abstract class BaseClient extends EventEmitter {
633
+ #private;
634
+ /** The REST client for making API requests. */
635
+ readonly api: RestClient;
636
+ /** The CDN client for accessing media resources. */
637
+ readonly cdn: CDNClient;
638
+ /** The options for configuring the client. */
639
+ options: clientOptions;
640
+ voiceOptions: VoiceClientOptions;
641
+ /** Track current voice connection to prevent AlreadyConnected errors */
642
+ currentVoiceConnection: {
643
+ channelId: string;
644
+ playerId: string;
645
+ } | null;
646
+ /** Whether this is a selfbot client (always true for this package). */
647
+ readonly bot = false;
648
+ /**
649
+ * Creates a new BaseClient instance.
650
+ *
651
+ * @param {clientOptions} [options={}] - The options for configuring the client.
652
+ */
653
+ constructor(options?: clientOptions);
654
+ /**
655
+ * Emits a debug message.
656
+ *
657
+ * @param {unknown} msg - The debug message to emit.
658
+ */
659
+ debug(msg: unknown): void;
660
+ /**
661
+ * Sets the authentication token for the client.
662
+ *
663
+ * @param {string | null} token - The authentication token.
664
+ */
665
+ set token(token: string | null);
666
+ /**
667
+ * Gets the authentication token for the client.
668
+ *
669
+ * @returns {string | null} The authentication token, or `null` if not set.
670
+ */
671
+ get token(): string | null;
672
+ }
673
+
674
+ /**
675
+ * Enum representing the client events that can be emitted (discord.js style naming).
676
+ * @private
677
+ */
678
+ declare enum Events {
679
+ CHANNEL_CREATE = "channelCreate",
680
+ CHANNEL_DELETE = "channelDelete",
681
+ CHANNEL_UPDATE = "channelUpdate",
682
+ DEBUG = "debug",
683
+ ERROR = "error",
684
+ GROUP_JOIN = "groupJoin",
685
+ GROUP_LEAVE = "groupLeave",
686
+ MESSAGE_CREATE = "messageCreate",
687
+ MESSAGE_DELETE = "messageDelete",
688
+ MESSAGE_DELETE_BULK = "messageDeleteBulk",
689
+ MESSAGE_UPDATE = "messageUpdate",
690
+ MESSAGE_REACTION_ADD = "messageReactionAdd",
691
+ MESSAGE_REACTION_REMOVE = "messageReactionRemove",
692
+ RAW = "raw",
693
+ READY = "ready",
694
+ ROLE_CREATE = "roleCreate",
695
+ ROLE_DELETE = "roleDelete",
696
+ ROLE_UPDATE = "roleUpdate",
697
+ SERVER_CREATE = "serverCreate",
698
+ SERVER_DELETE = "serverDelete",
699
+ SERVER_MEMBER_JOIN = "guildMemberAdd",
700
+ SERVER_MEMBER_LEAVE = "guildMemberRemove",
701
+ SERVER_MEMBER_UPDATE = "guildMemberUpdate",
702
+ SERVER_UPDATE = "serverUpdate",
703
+ TYPING_START = "typingStart",
704
+ TYPING_STOP = "typingStop",
705
+ USER_UPDATE = "userUpdate",
706
+ WEBHOOKS_CREATE = "webhookCreate",
707
+ WEBHOOKS_DELETE = "webhookDelete",
708
+ WEBHOOKS_UPDATE = "webhookUpdate",
709
+ USER_VOICE_STATE_UPDATE = "voiceStateUpdate",
710
+ VOICE_CHANNEL_JOIN = "voiceChannelJoin",
711
+ VOICE_CHANNEL_LEAVE = "voiceChannelLeave"
712
+ }
713
+ /**
714
+ * Enum representing the WebSocket events used for communication.
715
+ * @private
716
+ */
717
+ declare enum WSEvents {
718
+ AUTHENTICATE = "Authenticate",
719
+ AUTHENTICATED = "Authenticated",
720
+ BEGIN_TYPING = "BeginTyping",
721
+ BULK = "Bulk",
722
+ CHANNEL_ACK = "ChannelAck",
723
+ CHANNEL_CREATE = "ChannelCreate",
724
+ CHANNEL_DELETE = "ChannelDelete",
725
+ CHANNEL_GROUP_JOIN = "ChannelGroupJoin",
726
+ CHANNEL_GROUP_LEAVE = "ChannelGroupLeave",
727
+ CHANNEL_START_TYPING = "ChannelStartTyping",
728
+ CHANNEL_STOP_TYPING = "ChannelStopTyping",
729
+ CHANNEL_UPDATE = "ChannelUpdate",
730
+ END_TYPING = "EndTyping",
731
+ ERROR = "Error",
732
+ MESSAGE = "Message",
733
+ MESSAGE_BULK_DELETE = "BulkMessageDelete",
734
+ MESSAGE_DELETE = "MessageDelete",
735
+ MESSAGE_UPDATE = "MessageUpdate",
736
+ PING = "Ping",
737
+ PONG = "Pong",
738
+ READY = "Ready",
739
+ SERVER_DELETE = "ServerDelete",
740
+ SERVER_MEMBER_JOIN = "ServerMemberJoin",
741
+ SERVER_MEMBER_LEAVE = "ServerMemberLeave",
742
+ SERVER_MEMBER_UPDATE = "ServerMemberUpdate",
743
+ SERVER_ROLE_DELETE = "ServerRoleDelete",
744
+ SERVER_ROLE_UPDATE = "ServerRoleUpdate",
745
+ SERVER_UPDATE = "ServerUpdate",
746
+ USER_RELATIONSHIP = "UserRelationship",
747
+ USER_UPDATE = "UserUpdate",
748
+ WEBHOOKS_CREATE = "WebhooksCreate",
749
+ WEBHOOKS_DELETE = "WebhooksDelete",
750
+ WEBHOOKS_UPDATE = "WebhooksUpdate",
751
+ VOICE_STATE_UPDATE = "VoiceStateUpdate",
752
+ VOICE_CHANNEL_JOIN = "VoiceChannelJoin",
753
+ VOICE_CHANNEL_LEAVE = "VoiceChannelLeave"
754
+ }
755
+ /**
756
+ * Enum representing the types of channels supported by the client.
757
+ */
758
+ declare enum ChannelTypes {
759
+ DM = "DM",
760
+ GROUP = "GROUP",
761
+ TEXT = "TEXT",
762
+ VOICE = "VOICE",
763
+ NOTES = "NOTES"
764
+ }
765
+ /**
766
+ * The default options for configuring the selfbot client.
767
+ */
768
+ declare const DEFAULT_CLIENT_OPTIONS: clientOptions;
769
+ declare const apiUrl = "https://api.stoat.chat";
770
+ declare const cdnUrl = "https://cdn.stoatusercontent.com";
771
+ /** The system user ID used for identifying system messages. */
772
+ declare const SYSTEM_USER_ID: string;
773
+
774
+ type BadgeString = keyof typeof Badges.FLAGS;
775
+ type BadgesResolvable = number | BadgeString | Badges | BadgesResolvable[];
776
+ declare interface Badges {
777
+ serialize(): Record<BadgeString, boolean>;
778
+ any(bit: BadgesResolvable): boolean;
779
+ add(...bits: BadgesResolvable[]): this;
780
+ remove(...bits: BadgesResolvable[]): this;
781
+ has(bit: BadgesResolvable): boolean;
782
+ }
783
+ declare class Badges extends BitField {
784
+ static readonly FLAGS: {
785
+ readonly DEVELOPER: number;
786
+ readonly TRANSLATOR: number;
787
+ readonly SUPPORTER: number;
788
+ readonly RESPONSIBLE_DISCLOSURE: number;
789
+ readonly REVOLT_TEAM: number;
790
+ readonly EARLY_ADOPTER: number;
791
+ };
792
+ constructor(bits?: BadgesResolvable);
793
+ static resolve(bit: BadgesResolvable): number;
794
+ }
795
+
796
+ declare class Collection<K, V> extends Map<K, V> {
797
+ private _array;
798
+ private _keyArray;
799
+ constructor(iterable?: Iterable<readonly [K, V]> | null);
800
+ set(key: K, value: V): this;
801
+ delete(key: K): boolean;
802
+ array(): V[];
803
+ keyArray(): K[];
804
+ first(): V | undefined;
805
+ first(amount: number): V[];
806
+ firstKey(): K | undefined;
807
+ firstKey(amount: number): K[];
808
+ last(): V | undefined;
809
+ last(amount: number): V[];
810
+ lastKey(): K | undefined;
811
+ lastKey(amount: number): K[];
812
+ random(): V | undefined;
813
+ random(amount: number): V[];
814
+ randomKey(): K | undefined;
815
+ randomKey(amount: number): K[];
816
+ find(fn: (value: V, key: K, collection: this) => boolean): V | undefined;
817
+ findKey(fn: (value: V, key: K, collection: this) => boolean): K | undefined;
818
+ filter(fn: (value: V, key: K, collection: this) => boolean): Collection<K, V>;
819
+ filterKey(fn: (value: V, key: K, collection: this) => boolean): Collection<K, V>;
820
+ map<T>(fn: (value: V, key: K, collection: this) => T): T[];
821
+ some(fn: (value: V, key: K, collection: this) => boolean): boolean;
822
+ every(fn: (value: V, key: K, collection: this) => boolean): boolean;
823
+ reduce<T>(fn: (acc: T, value: V, key: K, collection: this) => T, initialValue?: T): T;
824
+ each(fn: (value: V, key: K, collection: this) => void): this;
825
+ tap(fn: (collection: this) => void): this;
826
+ at(index: number): V | undefined;
827
+ keyAt(index: number): K | undefined;
828
+ concat(...collections: Collection<K, V>[]): Collection<K, V>;
829
+ reverse(): this;
830
+ sort(compareFn?: (a: V, b: V) => number): this;
831
+ sweep(fn: (value: V, key: K, collection: this) => boolean): number;
832
+ partition(fn: (value: V, key: K, collection: this) => boolean): [Collection<K, V>, Collection<K, V>];
833
+ flatMap<T>(fn: (value: V, key: K, collection: this) => Collection<K, T>): Collection<K, T>;
834
+ mapValues<T>(fn: (value: V, key: K, collection: this) => T): Collection<K, T>;
835
+ clone(): Collection<K, V>;
836
+ equals(collection: Collection<K, V>): boolean;
837
+ diff(collection: Collection<K, V>): Collection<K, V>;
838
+ intersect(collection: Collection<K, V>): Collection<K, V>;
839
+ indexOf(value: V): number;
840
+ findIndex(fn: (value: V, key: K, collection: this) => boolean): number;
841
+ remove(value: V): boolean;
842
+ toJSON(): {
843
+ key: K;
844
+ value: V;
845
+ }[];
846
+ }
847
+
848
+ declare class User extends Base {
849
+ username: string;
850
+ avatar: Attachment | null;
851
+ presence: Presence;
852
+ badges: Badges;
853
+ bot: boolean;
854
+ constructor(client: Client, data: User$1);
855
+ protected _patch(data: User$1, clear?: FieldsUser[]): this;
856
+ get createdAt(): Date;
857
+ get isOwner(): boolean;
858
+ get createdTimestamp(): number;
859
+ block(): Promise<void>;
860
+ unblock(): Promise<void>;
861
+ createDM(): Promise<DMChannel>;
862
+ avatarURL(): string | undefined;
863
+ bannerURL(): string | undefined;
864
+ defaultAvatarURL(): string;
865
+ displayAvatarURL(): Promise<string>;
866
+ fetchProfile(): Promise<UserProfile>;
867
+ fetch(force?: boolean): Promise<User>;
868
+ toString(): string;
869
+ }
870
+
871
+ /**
872
+ * Represents a message in a channel.
873
+ *
874
+ * @extends Base
875
+ */
876
+ declare class MessageStruct extends Base {
877
+ /** The type of the message (e.g., TEXT, SYSTEM). */
878
+ type: Uppercase<SystemMessage["type"]>;
879
+ /** The content of the message. */
880
+ content: string;
881
+ /** The ID of the channel where the message was sent. */
882
+ channelId: string;
883
+ /** The ID of the user who authored the message. */
884
+ authorId: string;
885
+ /** An array of embeds included in the message. */
886
+ embeds: Embed[];
887
+ /** An array of file attachments included in the message. */
888
+ attachments: File$1[];
889
+ /** Mentions included in the message. */
890
+ mentions: Mentions;
891
+ /** The timestamp of when the message was last edited, or `null` if not edited. */
892
+ editedTimestamp: number | null;
893
+ /** the reactions and count on a message */
894
+ reactions: Map<string, string[]>;
895
+ /** Masquerade information for the message, Name and / or avatar override information */
896
+ masquerade?: Masquerade;
897
+ /** Webhook information for the message, Name and / or avatar override information */
898
+ webhook?: {
899
+ name: string;
900
+ avatar: string | null;
901
+ };
902
+ /**
903
+ * Creates a new Message instance.
904
+ *
905
+ * @param {client} client - The client instance.
906
+ * @param {APIMessage} data - The raw data for the message from the API.
907
+ */
908
+ constructor(client: Client, data: Message);
909
+ /**
910
+ * Updates the message instance with new data from the API.
911
+ *
912
+ * @param {APIMessage} data - The raw data for the message from the API.
913
+ * @returns {this} The updated message instance.
914
+ * @protected
915
+ */
916
+ protected _patch(data: Message): this;
917
+ /**
918
+ * Gets the creation date of the message.
919
+ *
920
+ * @returns {Date} The date when the message was created.
921
+ */
922
+ get createdAt(): Date;
923
+ /**
924
+ * Gets the creation timestamp of the message in milliseconds.
925
+ *
926
+ * @returns {number} The timestamp of when the message was created.
927
+ */
928
+ get createdTimestamp(): number;
929
+ /**
930
+ * Gets the date when the message was last edited.
931
+ *
932
+ * @returns {Date | null} The date of the last edit, or `null` if not edited.
933
+ */
934
+ get editedAt(): Date | null;
935
+ /**
936
+ * Checks if the message is a system message.
937
+ *
938
+ * @returns {boolean} `true` if the message is a system message, otherwise `false`.
939
+ */
940
+ get system(): boolean;
941
+ /**
942
+ * Retrieves the author of the message.
943
+ *
944
+ * @returns {User | ServerMember | null} The user who authored the message, or `null` if not found.
945
+ */
946
+ get author(): User | ServerMember | Partial<User & {
947
+ isWebhook: boolean;
948
+ }> | null;
949
+ /**
950
+ * Retrieves the channel where the message was sent.
951
+ *
952
+ * @returns {TextChannel | DMChannel | GroupChannel | VoiceChannel} The channel instance.
953
+ */
954
+ get channel(): TextChannel | DMChannel | GroupChannel | VoiceChannel;
955
+ /**
956
+ * Retrieves the server ID associated with the message, if any.
957
+ *
958
+ * @returns {string | null} The server ID, or `null` if the message is not in a server.
959
+ */
960
+ get serverId(): string | null;
961
+ /**
962
+ * Retrieves the server associated with the message, if any.
963
+ *
964
+ * @returns {Server | null} The server instance, or `null` if not found.
965
+ */
966
+ get server(): Server | null;
967
+ /**
968
+ * Retrieves the server member who authored the message, if any.
969
+ *
970
+ * @returns {ServerMember | null} The server member instance, or `null` if not found.
971
+ */
972
+ get member(): ServerMember | null;
973
+ /**
974
+ * Gets the URL of the message.
975
+ *
976
+ * @returns {string} The URL of the message.
977
+ */
978
+ get url(): string;
979
+ /**
980
+ * Acknowledges the message.
981
+ *
982
+ * @returns {Promise<void>} A promise that resolves when the message is acknowledged.
983
+ */
984
+ ack(): Promise<void>;
985
+ /**
986
+ * Deletes the message.
987
+ *
988
+ * @returns {Promise<void>} A promise that resolves when the message is deleted.
989
+ */
990
+ delete(): Promise<void>;
991
+ /**
992
+ * Replies to the message.
993
+ *
994
+ * @param {string} content - The content of the reply.
995
+ * @param {boolean} [mention=true] - Whether to mention the original message author.
996
+ * @returns {Promise<Message>} A promise that resolves with the sent reply message.
997
+ */
998
+ reply(content: MessageOptions | string, mention?: boolean): Promise<MessageStruct>;
999
+ /**
1000
+ * Edits the message.
1001
+ *
1002
+ * @param {MessageEditOptions | string} options - The new content or edit options.
1003
+ * @returns {Promise<void>} A promise that resolves when the message is edited.
1004
+ */
1005
+ edit(options: MessageEditOptions | string): Promise<void>;
1006
+ /**
1007
+ * Fetches the latest data for the message.
1008
+ *
1009
+ * @returns {Promise<Message>} A promise that resolves with the updated message instance.
1010
+ */
1011
+ fetch(): Promise<MessageStruct>;
1012
+ /**
1013
+ * Adds a reaction to the message.
1014
+ *
1015
+ * @param {string} emoji - The emoji to react with.
1016
+ * @returns {Promise<void>} A promise that resolves when the reaction is added.
1017
+ */
1018
+ addReaction(emoji: string): Promise<void>;
1019
+ /**
1020
+ * Removes a reaction from the message.
1021
+ *
1022
+ * @param {string} emoji - The emoji to remove the reaction for.
1023
+ * @param {object} [options] - Options for removing the reaction.
1024
+ * @param {string} [options.user_id] - The user ID to remove the reaction for. If not provided, removes the reaction for the current user.
1025
+ * @param {boolean} [options.remove_all=false] - Whether to remove all of the specified reaction for the message.
1026
+ * @returns {Promise<void>} A promise that resolves when the reaction is removed.
1027
+ */
1028
+ removeReaction(emoji: string, options?: {
1029
+ user_id?: string;
1030
+ remove_all?: boolean;
1031
+ }): Promise<void>;
1032
+ /**
1033
+ * Removes all reactions from the message.
1034
+ *
1035
+ * @returns {Promise<void>} A promise that resolves when all reactions are removed.
1036
+ */
1037
+ removeAllReactions(): Promise<void>;
1038
+ pin(): Promise<void>;
1039
+ unpin(): Promise<void>;
1040
+ inServer(): this is this & {
1041
+ serverId: string;
1042
+ server: Server;
1043
+ channel: TextChannel;
1044
+ };
1045
+ /**
1046
+ * Converts the message to a string representation.
1047
+ *
1048
+ * @returns {string} The content of the message.
1049
+ */
1050
+ toString(): string;
1051
+ }
1052
+
1053
+ declare class Attachment extends Base {
1054
+ filename: string;
1055
+ type: string;
1056
+ size: number;
1057
+ metadata: File$1["metadata"];
1058
+ tag?: string;
1059
+ constructor(client: Client, data: File$1);
1060
+ protected _patch(data: File$1): this;
1061
+ get url(): string;
1062
+ }
1063
+
1064
+ /**
1065
+ * Enum representing the possible presence statuses of a user.
1066
+ */
1067
+ declare enum Status {
1068
+ Online = "Online",
1069
+ Idle = "Idle",
1070
+ Focus = "Focus",
1071
+ Busy = "Busy",
1072
+ Invisible = "Invisible"
1073
+ }
1074
+ /**
1075
+ * Represents the presence of a user, including their status and custom text.
1076
+ *
1077
+ * @extends Base
1078
+ */
1079
+ declare class Presence extends Base {
1080
+ /** The custom status text of the user, or `null` if none is set. */
1081
+ text: string | null;
1082
+ /** The current status of the user (e.g., Online, Idle, Busy, Invisible). */
1083
+ status: Status;
1084
+ }
1085
+
1086
+ declare class Server extends Base {
1087
+ name: string;
1088
+ description: string | null;
1089
+ ownerId: string;
1090
+ members: ServerMemberManager;
1091
+ channels: ServerChannelManager;
1092
+ roles: RoleManager;
1093
+ icon: Attachment | null;
1094
+ banner: Attachment | null;
1095
+ analytics: boolean;
1096
+ discoverable: boolean;
1097
+ nsfw: boolean;
1098
+ permissions: FullPermissions;
1099
+ categories: Map<string, Category>;
1100
+ emojis: Map<string, Emoji>;
1101
+ constructor(client: Client, data: Server$1);
1102
+ protected _patch(data: Server$1, clear?: FieldsServer[]): this;
1103
+ get me(): ServerMember | null;
1104
+ get createdAt(): Date;
1105
+ get createdTimestamp(): number;
1106
+ get owner(): User | null;
1107
+ iconURL(): string | undefined;
1108
+ bannerURL(): string | undefined;
1109
+ setName(name: string): Promise<void>;
1110
+ setDescription(description: string | null): Promise<void>;
1111
+ setIcon(icon: Readable$1 | Buffer | string): Promise<void>;
1112
+ setBanner(banner: Readable$1 | Buffer | string): Promise<void>;
1113
+ leave(): Promise<void>;
1114
+ delete(): Promise<void>;
1115
+ createInvite(): Promise<string>;
1116
+ fetchInvites(): Promise<any[]>;
1117
+ fetchBans(): Promise<any[]>;
1118
+ toString(): string;
1119
+ }
1120
+
1121
+ declare class Role extends Base {
1122
+ server: Server;
1123
+ name: string;
1124
+ color: string | null;
1125
+ hoist: boolean;
1126
+ rank: number;
1127
+ overwrite: Overwrite;
1128
+ constructor(server: Server, data: Role$1 & {
1129
+ id: string;
1130
+ });
1131
+ protected _patch(data: Role$1 & {
1132
+ _id?: string;
1133
+ }, clear?: FieldsRole[]): this;
1134
+ get createdAt(): Date;
1135
+ get createdTimestamp(): number;
1136
+ get permissions(): Overwrite;
1137
+ delete(): Promise<void>;
1138
+ edit(data: editableRole): Promise<Role>;
1139
+ setName(name: string): Promise<Role>;
1140
+ setColor(colour: string | null): Promise<Role>;
1141
+ setHoist(hoist: boolean): Promise<Role>;
1142
+ setRank(rank: number): Promise<Role>;
1143
+ setPermissions(allow: Array<keyof typeof FullPermissions.FLAGS>, deny?: Array<keyof typeof FullPermissions.FLAGS>): Promise<Role>;
1144
+ toString(): string;
1145
+ }
1146
+
1147
+ /**
1148
+ * Represents a channel in the API.
1149
+ * @private
1150
+ */
1151
+ type APIServerChannel = Extract<Channel$1, {
1152
+ channel_type: "TextChannel" | "VoiceChannel";
1153
+ }>;
1154
+
1155
+ type ServerChannelResolvable = ServerChannel | APIServerChannel | string;
1156
+ interface CreateChannelOptions {
1157
+ name: string;
1158
+ type?: "Text" | "Voice";
1159
+ description?: string;
1160
+ nsfw?: boolean;
1161
+ voice: {
1162
+ max_users?: number;
1163
+ };
1164
+ }
1165
+ declare class ServerChannelManager extends BaseManager<ServerChannel> {
1166
+ protected readonly server: Server;
1167
+ /** @private */
1168
+ holds: typeof ServerChannel;
1169
+ constructor(server: Server);
1170
+ /** @private */
1171
+ _add(data: APIServerChannel): ServerChannel;
1172
+ /**
1173
+ * Creates a new channel in the server.
1174
+ * @param options - Options for creating the channel.
1175
+ * @param options.name - The name of the channel to create.
1176
+ * @param [options.type="Text"] - The type of the channel to create. Can be "Text" or "Voice". Defaults to "Text".
1177
+ * @param [options.description] - The description of the channel to create. Only used for voice channels.
1178
+ * @returns A promise that resolves to the created channel.
1179
+ */
1180
+ create({ name, type, description, }: CreateChannelOptions): Promise<ServerChannel>;
1181
+ /**
1182
+ * fetch a channel from the server
1183
+ * @param channel The channel to fetch. Can be a string, a channel object, or an API channel object.
1184
+ * @param force Whether to force fetch the channel from the API. Defaults to true.
1185
+ * If set to false, the method will return the channel from the cache if it exists.
1186
+ * @returns A promise that resolves to the fetched channel
1187
+ */
1188
+ fetch(channel: ServerChannelResolvable, { force }?: {
1189
+ force?: boolean | undefined;
1190
+ }): Promise<ServerChannel>;
1191
+ }
1192
+
1193
+ type MessageResolvable = MessageStruct | Message | string;
1194
+ interface MessageReply {
1195
+ id: string;
1196
+ mention: boolean;
1197
+ }
1198
+ interface MessageOptions {
1199
+ content?: string;
1200
+ replies?: MessageReply[];
1201
+ attachments?: Readable[] | string[] | File$2[];
1202
+ embeds?: MessageEmbed[];
1203
+ masquerade?: Masquerade;
1204
+ }
1205
+ interface MessageEditOptions {
1206
+ content?: string;
1207
+ attachments?: string[];
1208
+ embeds?: MessageEmbed[];
1209
+ }
1210
+ interface MessageSearchOptions {
1211
+ query: string;
1212
+ limit?: number;
1213
+ before?: string;
1214
+ after?: string;
1215
+ sort?: MessageSort;
1216
+ }
1217
+ interface MessageQueryOptions {
1218
+ limit?: number;
1219
+ before?: string;
1220
+ after?: string;
1221
+ sort?: MessageSort;
1222
+ nearby?: string;
1223
+ }
1224
+ declare class MessageManager extends BaseManager<MessageStruct, Message> {
1225
+ protected readonly channel: Channel;
1226
+ /** @private */
1227
+ holds: typeof MessageStruct;
1228
+ constructor(channel: Channel, maxSize?: number);
1229
+ /**
1230
+ *
1231
+ * @param content The content to send. Can be a string or an object with the following properties:
1232
+ * - content: The content of the message
1233
+ * - replies: An array of message IDs to reply to
1234
+ * - attachments: An array of attachment URLs, Files, or ReadStreams
1235
+ * - embeds: An array of MessageEmbed objects
1236
+ * @returns Promise that resolves to the sent message
1237
+ */
1238
+ send(content: MessageOptions | string): Promise<MessageStruct>;
1239
+ /**
1240
+ * acknowledge a message to mark it as read (not important for bots)
1241
+ * @param message The message to acknowledge
1242
+ * @returns Promise that resolves when the message is acknowledged
1243
+ */
1244
+ ack(message: MessageResolvable): Promise<void>;
1245
+ /**
1246
+ * bulk delete messages from the channel
1247
+ * @param messages The messages to delete. Can be an array of message IDs or a Map of message IDs to Message objects.
1248
+ * @returns Promise that resolves when the messages are deleted
1249
+ */
1250
+ bulkDelete(messages: MessageResolvable[] | number | Map<string, MessageStruct>): Promise<void>;
1251
+ /**
1252
+ * delete a message from the channel
1253
+ * @param message The message to delete. Can be a Message object or a message ID.
1254
+ * @returns Promise that resolves when the message is deleted
1255
+ */
1256
+ delete(message: MessageResolvable): Promise<void>;
1257
+ /**
1258
+ * edit a message in the channel
1259
+ * @param message The message to edit. Can be a Message object or a message ID.
1260
+ * @param options The options to edit the message with. Can be a string or an object with the following properties:
1261
+ * - content: The new content of the message
1262
+ * - attachments: An array of attachment URLs
1263
+ * - embeds: An array of MessageEmbed objects
1264
+ * @returns Promise that resolves when the message is edited
1265
+ */
1266
+ edit(message: MessageResolvable, options: MessageEditOptions | string): Promise<void>;
1267
+ /**
1268
+ * search for messages in the channel
1269
+ * @param query The query to search for. Can be a string or an object with the following properties:
1270
+ * - query: The query to search for
1271
+ * - limit: The maximum number of messages to return
1272
+ * - before: The message ID to start searching from (exclusive)
1273
+ * - after: The message ID to stop searching at (exclusive)
1274
+ * - sort: The sort order of the results (asc or desc)
1275
+ * @returns Promise that resolves to a Map of message IDs to Message objects
1276
+ */
1277
+ search(query: MessageSearchOptions | string): Promise<Map<string, MessageStruct>>;
1278
+ /**
1279
+ * fetch a message from the channel
1280
+ * @param message The message to fetch. Can be a Message object, a message ID, or an object with the following properties:
1281
+ * - limit: The maximum number of messages to return
1282
+ * - before: The message ID to start fetching from (exclusive)
1283
+ * - after: The message ID to stop fetching at (exclusive)
1284
+ * @returns Promise that resolves to a Message object or a Map of message IDs to Message objects
1285
+ */
1286
+ fetch(message: MessageResolvable): Promise<MessageStruct>;
1287
+ fetch(query?: MessageQueryOptions): Promise<Map<string, MessageStruct>>;
1288
+ fetch(limit: number): Promise<Map<string, MessageStruct>>;
1289
+ /**
1290
+ * add a reaction to a message
1291
+ * @param message The message to react to. Can be a Message object or a message ID.
1292
+ * @param emoji emoji to react with. Can be a string or an Emoji object.
1293
+ * @returns Promise that resolves when the reaction is added
1294
+ */
1295
+ addReaction(message: MessageResolvable | string, emoji: string | Emoji): Promise<void>;
1296
+ /**
1297
+ *
1298
+ * @param message The message to unreact. Can be a Message object or a message ID.
1299
+ * @param emoji the emoji to unreact with. Can be a string or an Emoji object.
1300
+ * @param user_id The user ID to remove the reaction for. If not provided, removes the reaction for the current user.
1301
+ * @param remove_all Whether to remove all of the specified reaction for the message. Defaults to false.
1302
+ * @returns Promise that resolves when the reaction is removed
1303
+ */
1304
+ removeReaction(message: MessageResolvable | string, emoji: string | Emoji, user_id?: string, remove_all?: boolean): Promise<void>;
1305
+ /**
1306
+ * remove all reactions from a message
1307
+ * @param message The message to remove reactions from. Can be a Message object or a message ID.
1308
+ * @returns Promise that resolves when the reactions are removed
1309
+ */
1310
+ removeAllReactions(message: MessageResolvable | string): Promise<void>;
1311
+ }
1312
+
1313
+ /**
1314
+ * Represents a generic communication channel in the client.
1315
+ * This abstract class provides a base structure and common functionality
1316
+ * for all types of channels, such as text, voice, group, and server channels.
1317
+ *
1318
+ * @abstract
1319
+ * @extends Base
1320
+ *
1321
+ * @property {ChannelTypes | "UNKNOWN"} type - The type of the channel. Defaults to "UNKNOWN".
1322
+ * @property {number} createdTimestamp - The timestamp (in milliseconds) when the channel was created.
1323
+ * @property {Date} createdAt - The date and time when the channel was created.
1324
+ */
1325
+ declare abstract class Channel extends Base {
1326
+ type: ChannelTypes | "UNKNOWN";
1327
+ voice?: Map<string, voiceParticipant>;
1328
+ /**
1329
+ * Gets the timestamp (in milliseconds) when the channel was created.
1330
+ *
1331
+ * @returns {number} The timestamp of the channel's creation.
1332
+ */
1333
+ get createdTimestamp(): number;
1334
+ /**
1335
+ * Gets the date and time when the channel was created.
1336
+ *
1337
+ * @returns {Date} The creation date of the channel.
1338
+ */
1339
+ get createdAt(): Date;
1340
+ /**
1341
+ * Deletes the current channel instance from the client's channel collection.
1342
+ *
1343
+ * This method interacts with the client's channel management system to remove
1344
+ * the channel. Once deleted, the channel will no longer be accessible through
1345
+ * the client.
1346
+ *
1347
+ * @returns {Promise<void>} A promise that resolves when the channel has been successfully deleted.
1348
+ *
1349
+ * @example
1350
+ * ```typescript
1351
+ * const channel = client.channels.get('1234567890');
1352
+ * if (channel) {
1353
+ * await channel.delete();
1354
+ * console.log('Channel deleted successfully.');
1355
+ * }
1356
+ * ```
1357
+ */
1358
+ delete(): Promise<void>;
1359
+ /**
1360
+ * Checks if the channel is a text-based channel.
1361
+ *
1362
+ * @returns {boolean} True if the channel is a text-based channel, otherwise false.
1363
+ */
1364
+ isText(): this is TextChannel | GroupChannel | DMChannel;
1365
+ /**
1366
+ * Checks if the channel is a voice channel.
1367
+ *
1368
+ * @returns {boolean} True if the channel is a voice channel, otherwise false.
1369
+ */
1370
+ isVoice(): this is VoiceChannel;
1371
+ /**
1372
+ * Checks if the channel is a group channel.
1373
+ *
1374
+ * @returns {boolean} True if the channel is a group channel, otherwise false.
1375
+ */
1376
+ isGroup(): this is GroupChannel;
1377
+ /**
1378
+ * Checks if the channel is part of a server.
1379
+ *
1380
+ * @returns {boolean} True if the channel is a server channel, otherwise false.
1381
+ */
1382
+ inServer(): this is ServerChannel;
1383
+ /**
1384
+ * Converts the channel to a string representation.
1385
+ *
1386
+ * @returns {string} A string representation of the channel in the format `<#channelId>`.
1387
+ */
1388
+ toString(): string;
1389
+ /**
1390
+ * Fetches the latest data for the channel from the client's channel collection.
1391
+ *
1392
+ * @param {boolean} [force=true] - Whether to force a fetch even if the channel is cached.
1393
+ * @returns {Promise<Channel>} A promise that resolves with the updated channel instance.
1394
+ */
1395
+ fetch(force?: boolean): Promise<Channel>;
1396
+ edit(data: Partial<CreateChannelOptions>): Promise<{
1397
+ channel_type: string;
1398
+ _id: string;
1399
+ user: string;
1400
+ }>;
1401
+ /**
1402
+ * Sets role permissions for this channel.
1403
+ *
1404
+ * @param roleId - The ID of the role to set permissions for.
1405
+ * @param allow - Array of permissions to allow for the role.
1406
+ * @returns A promise that resolves when the permissions have been updated.
1407
+ *
1408
+ * @throws {TypeError} If the channel ID is invalid.
1409
+ *
1410
+ * @example
1411
+ * ```typescript
1412
+ * // Allow specific permissions
1413
+ * await channel.setRolePermissions(roleId, ["ViewChannel", "SendMessage"]);
1414
+ * ```
1415
+ */
1416
+ setRolePermissions(roleId: string, allow: editablePermissions["a"]): Promise<void>;
1417
+ /**
1418
+ * Sets role permissions for this channel.
1419
+ *
1420
+ * @param roleId - The ID of the role to set permissions for.
1421
+ * @param allow - Array of permissions to allow for the role.
1422
+ * @param deny - Array of permissions to deny for the role.
1423
+ * @returns A promise that resolves when the permissions have been updated.
1424
+ *
1425
+ * @throws {TypeError} If the channel ID is invalid.
1426
+ *
1427
+ * @example
1428
+ * ```typescript
1429
+ * // Set both allow and deny permissions
1430
+ * await channel.setRolePermissions(roleId, ["ViewChannel"], ["ManageMessages"]);
1431
+ * ```
1432
+ */
1433
+ setRolePermissions(roleId: string, allow: editablePermissions["a"], deny: editablePermissions["d"]): Promise<void>;
1434
+ /**
1435
+ * Sets role permissions for this channel.
1436
+ *
1437
+ * @param roleId - The ID of the role to set permissions for.
1438
+ * @param options - Object containing allow and/or deny permissions.
1439
+ * @returns A promise that resolves when the permissions have been updated.
1440
+ *
1441
+ * @throws {TypeError} If the channel ID is invalid or if both allow and deny are undefined.
1442
+ *
1443
+ * @example
1444
+ * ```typescript
1445
+ * // Allow specific permissions only
1446
+ * await channel.setRolePermissions(roleId, { allow: ["ViewChannel", "SendMessage"] });
1447
+ *
1448
+ * // Deny specific permissions only
1449
+ * await channel.setRolePermissions(roleId, { deny: ["ManageMessages"] });
1450
+ *
1451
+ * // Set both allow and deny permissions
1452
+ * await channel.setRolePermissions(roleId, {
1453
+ * allow: ["ViewChannel"],
1454
+ * deny: ["ManageMessages"]
1455
+ * });
1456
+ * ```
1457
+ */
1458
+ setRolePermissions(roleId: string, options: {
1459
+ allow?: editablePermissions["a"];
1460
+ deny?: editablePermissions["d"];
1461
+ }): Promise<void>;
1462
+ /**
1463
+ * Sets default permissions for this channel.
1464
+ *
1465
+ * @param allow - Array of permissions to allow by default.
1466
+ * @returns A promise that resolves when the permissions have been updated.
1467
+ *
1468
+ * @throws {TypeError} If the channel ID is invalid.
1469
+ *
1470
+ * @example
1471
+ * ```typescript
1472
+ * // Allow specific permissions
1473
+ * await channel.setDefaultPermissions(["ViewChannel", "SendMessage"]);
1474
+ * ```
1475
+ */
1476
+ setDefaultPermissions(allow: editablePermissions["a"]): Promise<void>;
1477
+ /**
1478
+ * Sets default permissions for this channel.
1479
+ *
1480
+ * @param options - Object containing allow and/or deny permissions.
1481
+ * @returns A promise that resolves when the permissions have been updated.
1482
+ *
1483
+ * @throws {TypeError} If the channel ID is invalid or if both allow and deny are undefined.
1484
+ *
1485
+ * @example
1486
+ * ```typescript
1487
+ * // Allow specific permissions only
1488
+ * await channel.setDefaultPermissions({ allow: ["ViewChannel", "SendMessage"] });
1489
+ *
1490
+ * // Deny specific permissions only
1491
+ * await channel.setDefaultPermissions({ deny: ["ManageMessages"] });
1492
+ *
1493
+ * // Set both allow and deny permissions
1494
+ * await channel.setDefaultPermissions({
1495
+ * allow: ["ViewChannel"],
1496
+ * deny: ["ManageMessages"]
1497
+ * });
1498
+ * ```
1499
+ */
1500
+ setDefaultPermissions(options: {
1501
+ allow?: editablePermissions["a"];
1502
+ deny?: editablePermissions["d"];
1503
+ }): Promise<void>;
1504
+ /**
1505
+ * Sets default permissions for this channel (legacy format).
1506
+ *
1507
+ * @param permissions - Object containing allow and deny permissions.
1508
+ * @returns A promise that resolves when the permissions have been updated.
1509
+ *
1510
+ * @throws {TypeError} If the channel ID is invalid.
1511
+ *
1512
+ * @example
1513
+ * ```typescript
1514
+ * // Legacy format
1515
+ * await channel.setDefaultPermissions({
1516
+ * a: ["ViewChannel"],
1517
+ * d: ["ManageMessages"]
1518
+ * });
1519
+ * ```
1520
+ */
1521
+ setDefaultPermissions(permissions: editablePermissions): Promise<void>;
1522
+ /**
1523
+ * Creates a new webhook in this channel.
1524
+ *
1525
+ * @param name - The name of the webhook
1526
+ * @param avatar - Optional avatar for the webhook. Can be a URL string, Readable stream, or File object
1527
+ * @returns Promise resolving to the created webhook response
1528
+ *
1529
+ * @example
1530
+ * ```typescript
1531
+ * const webhook = await channel.createWebhook("My Webhook", "https://example.com/avatar.png");
1532
+ * ```
1533
+ */
1534
+ createWebhook(name: string, avatar?: Readable | string | File): Promise<createWebhookResponse>;
1535
+ /**
1536
+ * Retrieves all webhooks for this channel.
1537
+ *
1538
+ * @returns Promise resolving to an array of webhook responses
1539
+ *
1540
+ * @example
1541
+ * ```typescript
1542
+ * const webhooks = await channel.getWebhooks();
1543
+ * console.log(`Found ${webhooks.length} webhooks`);
1544
+ * ```
1545
+ */
1546
+ getWebhooks(): Promise<createWebhookResponse[]>;
1547
+ /**
1548
+ * Retrieves a specific webhook by ID and token.
1549
+ *
1550
+ * @param webhookId - The ID of the webhook to retrieve
1551
+ * @param token - The token of the webhook
1552
+ * @returns Promise resolving to the webhook response
1553
+ *
1554
+ * @example
1555
+ * ```typescript
1556
+ * const webhook = await channel.getWebhook("webhookId", "webhookToken");
1557
+ * console.log(`Webhook name: ${webhook.name}`);
1558
+ * ```
1559
+ */
1560
+ getWebhook(webhookId: string, token: string): Promise<createWebhookResponse>;
1561
+ /**
1562
+ * Sends a message through a webhook in this channel.
1563
+ *
1564
+ * @param webhookId - The ID of the webhook to send the message through
1565
+ * @param token - The token of the webhook
1566
+ * @param content - The message content. Can be a string or MessageOptions object with attachments and embeds
1567
+ * @returns Promise resolving to the sent message
1568
+ *
1569
+ * @example
1570
+ * ```typescript
1571
+ * // Send a simple text message
1572
+ * await channel.sendWebhookMessage("webhookId", "token", "Hello, world!");
1573
+ *
1574
+ * // Send a message with embeds and attachments
1575
+ * await channel.sendWebhookMessage("webhookId", "token", {
1576
+ * content: "Check out this image!",
1577
+ * attachments: ["https://example.com/image.png"],
1578
+ * embeds: [myEmbed]
1579
+ * });
1580
+ * ```
1581
+ */
1582
+ sendWebhookMessage(webhookId: string, token: string, content: MessageOptions | string): Promise<Message>;
1583
+ /**
1584
+ * Deletes a webhook.
1585
+ *
1586
+ * @param webhookId - The ID of the webhook to delete
1587
+ * @param token - The token of the webhook
1588
+ * @returns Promise that resolves when the webhook is deleted
1589
+ *
1590
+ * @example
1591
+ * ```typescript
1592
+ * await channel.deleteWebhook("webhookId", "webhookToken");
1593
+ * console.log("Webhook deleted successfully");
1594
+ * ```
1595
+ */
1596
+ deleteWebhook(webhookId: string, token: string): Promise<void>;
1597
+ /**
1598
+ * Edits a webhook's properties.
1599
+ *
1600
+ * @param webhookId - The ID of the webhook to edit
1601
+ * @param token - The token of the webhook
1602
+ * @param options - The options to edit on the webhook
1603
+ * @returns Promise resolving to the updated webhook response
1604
+ *
1605
+ * @example
1606
+ * ```typescript
1607
+ * const updatedWebhook = await channel.editWebhook("webhookId", "token", {
1608
+ * name: "New Webhook Name",
1609
+ * avatar: "https://example.com/new-avatar.png"
1610
+ * });
1611
+ * ```
1612
+ */
1613
+ editWebhook(webhookId: string, token: string, options: editWebhookOptions): Promise<createWebhookResponse>;
1614
+ /**
1615
+ * Retrieves partial information about a webhook using only its ID.
1616
+ * This method provides limited webhook information without requiring a token.
1617
+ *
1618
+ * @param webhookId - The ID of the webhook to retrieve partial information for
1619
+ * @returns Promise resolving to the webhook response with partial information
1620
+ *
1621
+ * @example
1622
+ * ```typescript
1623
+ * const partialWebhook = await channel.getPartialWebhook("webhookId");
1624
+ * console.log(`Webhook name: ${partialWebhook.name}`);
1625
+ * ```
1626
+ */
1627
+ getPartialWebhook(webhookId: string): Promise<createWebhookResponse>;
1628
+ }
1629
+
1630
+ /**
1631
+ * Interface representing a text-based channel, which supports sending and managing messages.
1632
+ */
1633
+ interface TextBasedChannel {
1634
+ /** Manages the messages in the channel. */
1635
+ messages: MessageManager;
1636
+ /** The ID of the last message sent in the channel, or `null` if no message exists. */
1637
+ lastMessageId: string | null;
1638
+ /** The last message sent in the channel, or `null` if no message exists. */
1639
+ lastMessage: MessageStruct | null;
1640
+ /**
1641
+ * Sends a message to the channel.
1642
+ *
1643
+ * @param {MessageOptions | string} options - The message content or options for the message.
1644
+ * @returns {Promise<Message>} A promise that resolves with the sent message.
1645
+ *
1646
+ * @example
1647
+ * ```typescript
1648
+ * await channel.send("Hello, world!");
1649
+ * ```
1650
+ */
1651
+ send(options: MessageOptions | string): Promise<MessageStruct>;
1652
+ /**
1653
+ * Deletes multiple messages from the channel.
1654
+ *
1655
+ * @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.
1656
+ * @returns {Promise<void>} A promise that resolves when the messages have been successfully deleted.
1657
+ *
1658
+ * @example
1659
+ * ```typescript
1660
+ * await channel.bulkDelete(10); // Deletes the last 10 messages.
1661
+ * ```
1662
+ */
1663
+ bulkDelete(messages: MessageResolvable[] | Map<string, MessageStruct> | number): Promise<void>;
1664
+ }
1665
+
1666
+ type APIDirectChannel = Extract<Channel$1, {
1667
+ channel_type: "DirectMessage";
1668
+ }>;
1669
+ /**
1670
+ * Represents a direct message (DM) channel between users.
1671
+ *
1672
+ * @extends Channel
1673
+ */
1674
+ declare class DMChannel extends Channel implements TextBasedChannel {
1675
+ /** The type of the channel, which is always `DM` for direct message channels. */
1676
+ readonly type = ChannelTypes.DM;
1677
+ /** Whether the DM channel is currently active. */
1678
+ active: boolean;
1679
+ /** The default permissions for the DM channel. */
1680
+ permissions: Readonly<ChannelPermissions>;
1681
+ /** Manages the messages in this DM channel. */
1682
+ messages: MessageManager;
1683
+ /** The ID of the last message sent in this DM channel, if any. */
1684
+ lastMessageId: string | null;
1685
+ /**
1686
+ * Creates a new DMChannel instance.
1687
+ *
1688
+ * @param {Client} client - The client instance.
1689
+ * @param {APIDirectChannel} data - The raw data for the DM channel from the API.
1690
+ */
1691
+ constructor(client: Client, data: APIDirectChannel);
1692
+ /**
1693
+ * Updates the DM channel instance with new data from the API.
1694
+ *
1695
+ * @param {APIDirectChannel} data - The raw data for the DM channel from the API.
1696
+ * @returns {this} The updated DM channel instance.
1697
+ * @protected
1698
+ */
1699
+ protected _patch(data: APIDirectChannel): this;
1700
+ /**
1701
+ * Retrieves the last message sent in this DM channel.
1702
+ *
1703
+ * @returns {Message | null} The last message, or `null` if no message exists.
1704
+ */
1705
+ get lastMessage(): MessageStruct | null;
1706
+ /**
1707
+ * Deletes multiple messages from this DM channel.
1708
+ *
1709
+ * @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.
1710
+ * @returns {Promise<void>} A promise that resolves when the messages have been successfully deleted.
1711
+ *
1712
+ * @example
1713
+ * ```typescript
1714
+ * await dmChannel.bulkDelete(10); // Deletes the last 10 messages.
1715
+ * ```
1716
+ */
1717
+ bulkDelete(messages: MessageResolvable[] | Map<string, MessageStruct> | number): Promise<void>;
1718
+ /**
1719
+ * Sends a message to this DM channel.
1720
+ *
1721
+ * @param {MessageOptions | string} options - The message content or options for the message.
1722
+ * @returns {Promise<Message>} A promise that resolves with the sent message.
1723
+ *
1724
+ * @example
1725
+ * ```typescript
1726
+ * await dmChannel.send("Hello, world!");
1727
+ * ```
1728
+ */
1729
+ send(options: MessageOptions | string): Promise<MessageStruct>;
1730
+ }
1731
+
1732
+ /**
1733
+ * Events emitted by the AudioPlayer
1734
+ */
1735
+ interface AudioPlayerEvents {
1736
+ connected: [channelId: string, serverId: string, roomName?: string];
1737
+ disconnected: [channelId: string, serverId: string, reason?: string];
1738
+ audioStart: [source: string, type: string];
1739
+ audioEnd: [source: string, type: string];
1740
+ audioError: [source: string, type: string, error: Error];
1741
+ volumeChanged: [oldVolume: number, newVolume: number];
1742
+ muted: [previousVolume: number];
1743
+ unmuted: [newVolume: number];
1744
+ trackPublished: [trackId: string];
1745
+ trackStopped: [trackId: string];
1746
+ conversionStart: [source: string, sampleRate: number, channels: number];
1747
+ conversionEnd: [source: string, samplesProcessed: number];
1748
+ conversionError: [source: string, error: Error];
1749
+ debug: [message: string, data?: any];
1750
+ error: [error: Error, context?: string];
1751
+ }
1752
+ declare interface AudioPlayer {
1753
+ on<K extends keyof AudioPlayerEvents>(event: K, listener: (...args: AudioPlayerEvents[K]) => void): this;
1754
+ off<K extends keyof AudioPlayerEvents>(event: K, listener: (...args: AudioPlayerEvents[K]) => void): this;
1755
+ removeAllListeners<K extends keyof AudioPlayerEvents>(event?: K): this;
1756
+ }
1757
+ declare class AudioPlayer extends EventEmitter {
1758
+ private readonly channelId;
1759
+ private readonly serverId;
1760
+ private readonly client;
1761
+ private _volume;
1762
+ private room?;
1763
+ private publications;
1764
+ private audioSources;
1765
+ private isConnected;
1766
+ private shouldStop;
1767
+ private isStreaming;
1768
+ constructor(channelId: string, serverId: string, client: Client);
1769
+ /**
1770
+ * Get the channel ID this player is associated with
1771
+ */
1772
+ get channel(): string;
1773
+ /**
1774
+ * Get the server ID this player is associated with
1775
+ */
1776
+ get server(): string;
1777
+ /**
1778
+ * Get current volume level (0.0 to 2.0)
1779
+ */
1780
+ get volume(): number;
1781
+ /**
1782
+ * Check if the player is connected to a voice channel
1783
+ */
1784
+ get connected(): boolean;
1785
+ /**
1786
+ * Set volume level
1787
+ * @param level - Volume level from 0.0 (mute) to 2.0 (200%)
1788
+ */
1789
+ setVolume(level: number): void;
1790
+ /**
1791
+ * Increase volume by specified amount
1792
+ * @param amount - Amount to increase (default: 0.1)
1793
+ */
1794
+ increaseVolume(amount?: number): void;
1795
+ /**
1796
+ * Decrease volume by specified amount
1797
+ * @param amount - Amount to decrease (default: 0.1)
1798
+ */
1799
+ decreaseVolume(amount?: number): void;
1800
+ /**
1801
+ * Mute audio (set volume to 0)
1802
+ */
1803
+ mute(): void;
1804
+ /**
1805
+ * Unmute audio (restore to 100% if currently muted)
1806
+ */
1807
+ unmute(): void;
1808
+ /**
1809
+ * Apply volume to PCM audio data
1810
+ * @param pcmData - Int16Array audio data
1811
+ * @returns Modified PCM data with volume applied
1812
+ * @private
1813
+ */
1814
+ private applyVolume;
1815
+ /**
1816
+ * Check if a string is a valid URL
1817
+ * @param input - The string to check
1818
+ * @returns True if the input is a valid URL
1819
+ */
1820
+ private isUrl;
1821
+ /**
1822
+ * Check if a string is a valid file path that exists
1823
+ * @param input - The string to check
1824
+ * @returns True if the input is an existing file path
1825
+ * @private
1826
+ */
1827
+ private isFilePath;
1828
+ /**
1829
+ * Check if input is a Readable stream
1830
+ * @param input - The input to check
1831
+ * @returns True if the input is a Readable stream
1832
+ * @private
1833
+ */
1834
+ private isStream;
1835
+ /**
1836
+ * Connect to the voice channel
1837
+ */
1838
+ connect(targetChannelId?: string): Promise<void>;
1839
+ /**
1840
+ * Generic play method that automatically detects the input type and uses the appropriate play method
1841
+ * @param input - Can be a URL string, file path string, or Readable stream
1842
+ * @returns Promise that resolves when playback starts
1843
+ *
1844
+ * @example
1845
+ * ```typescript
1846
+ * // Play from URL
1847
+ * await player.play("https://example.com/audio.mp3");
1848
+ *
1849
+ * // Play from file path
1850
+ * await player.play("/path/to/audio.mp3");
1851
+ *
1852
+ * // Play from stream
1853
+ * await player.play(readableStream);
1854
+ * ```
1855
+ */
1856
+ play(input: string | Readable$1): Promise<void>;
1857
+ /**
1858
+ * Play audio from a URL (supports both files and streaming URLs like radio stations)
1859
+ * @private
1860
+ */
1861
+ private playFromUrl;
1862
+ /**
1863
+ * Play audio from a stream in real-time (for radio stations, live streams)
1864
+ */
1865
+ private playStreamingAudio;
1866
+ /**
1867
+ * Play audio from a finite stream (for regular audio files)
1868
+ * @private
1869
+ */
1870
+ private playFromStream; /**
1871
+ * Convert audio to PCM format using FFmpeg
1872
+ * @private
1873
+ */
1874
+ private convertAudioToPCM;
1875
+ /**
1876
+ * Publish PCM audio to the voice channel
1877
+ */
1878
+ private publishPCMAudio;
1879
+ /**
1880
+ * Play audio from a file
1881
+ * @private
1882
+ */
1883
+ private playFromFile;
1884
+ /**
1885
+ * Stop current audio playback
1886
+ */
1887
+ stop(trackName?: string): Promise<void>;
1888
+ /**
1889
+ * Disconnect from the voice channel
1890
+ */
1891
+ disconnect(): Promise<void>;
1892
+ /**
1893
+ * Handle unexpected disconnection
1894
+ * @private
1895
+ */
1896
+ private handleDisconnected;
1897
+ /**
1898
+ * Get player status information
1899
+ */
1900
+ getStatus(): {
1901
+ connected: boolean;
1902
+ volume: number;
1903
+ activeTracksCount: number;
1904
+ channelId: string;
1905
+ serverId: string;
1906
+ };
1907
+ }
1908
+
1909
+ type APIGroupChannel = Extract<Channel$1, {
1910
+ channel_type: "Group";
1911
+ }>;
1912
+ /**
1913
+ * Represents a group channel, which allows multiple users to communicate.
1914
+ *
1915
+ * @extends Channel
1916
+ */
1917
+ declare class GroupChannel extends Channel implements TextBasedChannel {
1918
+ /** The type of the channel, which is always `GROUP` for group channels. */
1919
+ readonly type = ChannelTypes.GROUP;
1920
+ /** The name of the group channel. */
1921
+ name: string;
1922
+ /** The description of the group channel, if any. */
1923
+ description: string | null;
1924
+ /** The ID of the user who owns the group channel. */
1925
+ ownerId: string;
1926
+ /** The permissions for the group channel. */
1927
+ permissions: Readonly<ChannelPermissions>;
1928
+ /** The icon of the group channel, if any. */
1929
+ icon: Attachment | null;
1930
+ /** Manages the messages in this group channel. */
1931
+ messages: MessageManager;
1932
+ /** The ID of the last message sent in this group channel, if any. */
1933
+ lastMessageId: string | null;
1934
+ /** A map of user IDs to their corresponding `User` instances in the group channel. */
1935
+ users: Map<string, User>;
1936
+ /** Whether the group channel is marked as NSFW (Not Safe For Work). */
1937
+ nsfw: boolean;
1938
+ /**
1939
+ * Creates a new GroupChannel instance.
1940
+ *
1941
+ * @param {client} client - The client instance.
1942
+ * @param {APIGroupChannel} data - The raw data for the group channel from the API.
1943
+ */
1944
+ constructor(client: Client, data: APIGroupChannel);
1945
+ /**
1946
+ * Updates the group channel instance with new data from the API.
1947
+ *
1948
+ * @param {APIGroupChannel} data - The raw data for the group channel from the API.
1949
+ * @returns {this} The updated group channel instance.
1950
+ * @protected
1951
+ */
1952
+ protected _patch(data: APIGroupChannel): this;
1953
+ /**
1954
+ * Retrieves the last message sent in this group channel.
1955
+ *
1956
+ * @returns {Message | null} The last message, or `null` if no message exists.
1957
+ */
1958
+ get lastMessage(): MessageStruct | null;
1959
+ /**
1960
+ * Retrieves the owner of the group channel.
1961
+ *
1962
+ * @returns {User | null} The owner of the group channel, or `null` if not found.
1963
+ */
1964
+ get owner(): User | null;
1965
+ /**
1966
+ * Deletes multiple messages from this group channel.
1967
+ *
1968
+ * @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.
1969
+ * @returns {Promise<void>} A promise that resolves when the messages have been successfully deleted.
1970
+ *
1971
+ * @example
1972
+ * ```typescript
1973
+ * await groupChannel.bulkDelete(10); // Deletes the last 10 messages.
1974
+ * ```
1975
+ */
1976
+ bulkDelete(messages: MessageResolvable[] | Map<string, MessageStruct> | number): Promise<void>;
1977
+ /**
1978
+ * Creates an invite for the group channel.
1979
+ *
1980
+ * @returns {Promise<Invite>} A promise that resolves with the created invite.
1981
+ *
1982
+ * @example
1983
+ * ```typescript
1984
+ * const invite = await groupChannel.createInvite();
1985
+ * console.log(`Invite created: ${invite}`);
1986
+ * ```
1987
+ */
1988
+ createInvite(): Promise<Invite>;
1989
+ /**
1990
+ * Adds a user to the group channel.
1991
+ *
1992
+ * @param {UserResolvable} user - The user to add to the group channel.
1993
+ * @returns {Promise<void>} A promise that resolves when the user has been successfully added.
1994
+ *
1995
+ * @example
1996
+ * ```typescript
1997
+ * await groupChannel.add(user);
1998
+ * ```
1999
+ */
2000
+ add(user: UserResolvable): Promise<void>;
2001
+ /**
2002
+ * Removes a user from the group channel.
2003
+ *
2004
+ * @param {UserResolvable} user - The user to remove from the group channel.
2005
+ * @returns {Promise<void>} A promise that resolves when the user has been successfully removed.
2006
+ *
2007
+ * @example
2008
+ * ```typescript
2009
+ * await groupChannel.remove(user);
2010
+ * ```
2011
+ */
2012
+ remove(user: UserResolvable): Promise<void>;
2013
+ /**
2014
+ * Leaves the group channel.
2015
+ *
2016
+ * @returns {Promise<void>} A promise that resolves when the group channel has been successfully left.
2017
+ *
2018
+ * @example
2019
+ * ```typescript
2020
+ * await groupChannel.leave();
2021
+ * ```
2022
+ */
2023
+ leave(): Promise<void>;
2024
+ /**
2025
+ * Sends a message to this group channel.
2026
+ *
2027
+ * @param {MessageOptions | string} options - The message content or options for the message.
2028
+ * @returns {Promise<Message>} A promise that resolves with the sent message.
2029
+ *
2030
+ * @example
2031
+ * ```typescript
2032
+ * await groupChannel.send("Hello, group!");
2033
+ * ```
2034
+ */
2035
+ send(options: MessageOptions | string): Promise<MessageStruct>;
2036
+ /**
2037
+ * Creates and connects an AudioPlayer to this voice channel in one step.
2038
+ * This is a convenience method that combines createPlayer() and connect().
2039
+ *
2040
+ * @returns {Promise<AudioPlayer>} A promise that resolves to a connected AudioPlayer
2041
+ *
2042
+ * @example
2043
+ * ```typescript
2044
+ * const voiceChannel = await client.channels.fetch('voice-channel-id') as VoiceChannel;
2045
+ * const player = await voiceChannel.connect();
2046
+ *
2047
+ * // Already connected, ready to play
2048
+ * await player.playFromUrl('https://example.com/music.mp3');
2049
+ * ```
2050
+ */
2051
+ connect(): Promise<AudioPlayer>;
2052
+ /** Disconnects the AudioPlayer from this voice channel's server. */
2053
+ disconnect(): Promise<void>;
2054
+ /** Stops the AudioPlayer in this voice channel's server. */
2055
+ stop(): Promise<void>;
2056
+ /** Plays audio through the AudioPlayer connected to this voice channel.
2057
+ * @param source - The audio source (URL, file path, or stream)
2058
+ */
2059
+ play(source: string): Promise<void>;
2060
+ /** Retrieves the AudioPlayer associated with this voice channel, if any.
2061
+ * @returns {Promise<AudioPlayer | null>} A promise that resolves to the AudioPlayer or null if not found
2062
+ */
2063
+ getPlayer(): Promise<AudioPlayer | null>;
2064
+ }
2065
+
2066
+ /**
2067
+ * Represents an invite to a server or channel.
2068
+ *
2069
+ * @extends Base
2070
+ */
2071
+ declare class Invite extends Base {
2072
+ /** The ID of the server associated with the invite, if any. */
2073
+ serverId: string | null;
2074
+ /** The ID of the user who created the invite. */
2075
+ inviterId: string;
2076
+ /** The ID of the channel associated with the invite. */
2077
+ channelId: string;
2078
+ /**
2079
+ * Creates a new Invite instance.
2080
+ *
2081
+ * @param {client} client - The client instance.
2082
+ * @param {APIInvite} data - The raw data for the invite from the API.
2083
+ */
2084
+ constructor(client: Client, data: Invite$1);
2085
+ /**
2086
+ * Updates the invite instance with new data from the API.
2087
+ *
2088
+ * @param {APIInvite} data - The raw data for the invite from the API.
2089
+ * @returns {this} The updated invite instance.
2090
+ * @protected
2091
+ */
2092
+ protected _patch(data: Invite$1): this;
2093
+ /**
2094
+ * Retrieves the server associated with the invite.
2095
+ *
2096
+ * @returns {Server | null} The server associated with the invite, or `null` if not found.
2097
+ */
2098
+ get server(): Server | null;
2099
+ /**
2100
+ * Retrieves the channel associated with the invite.
2101
+ *
2102
+ * @returns {Channel | null} The channel associated with the invite, or `null` if not found.
2103
+ */
2104
+ get channel(): Channel | null;
2105
+ /**
2106
+ * Retrieves the user who created the invite.
2107
+ *
2108
+ * @returns {User | null} The user who created the invite, or `null` if not found.
2109
+ */
2110
+ get inviter(): User | null;
2111
+ }
2112
+
2113
+ /**
2114
+ * Represents the mentions in a message, including users and server members.
2115
+ */
2116
+ declare class Mentions {
2117
+ readonly message: MessageStruct;
2118
+ protected _users: string[];
2119
+ /** The client instance. */
2120
+ readonly client: Client;
2121
+ /**
2122
+ * Creates a new Mentions instance.
2123
+ *
2124
+ * @param {Message} message - The message associated with the mentions.
2125
+ * @param {string[]} _users - An array of user IDs mentioned in the message.
2126
+ */
2127
+ constructor(message: MessageStruct, _users: string[]);
2128
+ /**
2129
+ * Checks if a specific user is mentioned in the message.
2130
+ *
2131
+ * @param {UserResolvable} user - The user to check.
2132
+ * @returns {boolean} `true` if the user is mentioned, otherwise `false`.
2133
+ * @throws {TypeError} Throws an error if the user cannot be resolved.
2134
+ *
2135
+ * @example
2136
+ * ```typescript
2137
+ * if (mentions.has(someUser)) {
2138
+ * console.log("User is mentioned!");
2139
+ * }
2140
+ * ```
2141
+ */
2142
+ has(user: UserResolvable): boolean;
2143
+ /**
2144
+ * Retrieves the server members mentioned in the message.
2145
+ *
2146
+ * @returns {Map<string, ServerMember> | null} A map of user IDs to `ServerMember` instances, or `null` if the message is not in a server.
2147
+ *
2148
+ * @example
2149
+ * ```typescript
2150
+ * const members = mentions.members;
2151
+ * if (members) {
2152
+ * members.forEach(member => console.log(member.displayName));
2153
+ * }
2154
+ * ```
2155
+ */
2156
+ get members(): Map<string, ServerMember> | null;
2157
+ /**
2158
+ * Retrieves the users mentioned in the message.
2159
+ *
2160
+ * @returns {Map<string, User>} A map of user IDs to `User` instances.
2161
+ *
2162
+ * @example
2163
+ * ```typescript
2164
+ * const users = mentions.users;
2165
+ * users.forEach(user => console.log(user.username));
2166
+ * ```
2167
+ */
2168
+ get users(): Map<string, User>;
2169
+ }
2170
+
2171
+ type Embed = Embed$1;
2172
+ type EmbedImage = Extract<Embed, {
2173
+ type: "Image";
2174
+ }>;
2175
+ type EmbedVideo = Extract<Embed, {
2176
+ type: "Video";
2177
+ }>;
2178
+ type EmbedSpecial = Special;
2179
+ /**
2180
+ * Represents a message embed, which can include rich content such as titles, descriptions, URLs, and media.
2181
+ */
2182
+ declare class MessageEmbed {
2183
+ #private;
2184
+ /**
2185
+ * Sets the title of the embed.
2186
+ *
2187
+ * @param {string} title - The title to set.
2188
+ * @returns {this} The updated `MessageEmbed` instance.
2189
+ */
2190
+ setTitle(title: string): this;
2191
+ /**
2192
+ * Sets the icon URL of the embed.
2193
+ *
2194
+ * @param {string} iconURL - The URL of the icon to set.
2195
+ * @returns {this} The updated `MessageEmbed` instance.
2196
+ */
2197
+ setIcon(iconURL: string): this;
2198
+ /**
2199
+ * Sets the color of the embed.
2200
+ *
2201
+ * @param {string} color - The color to set (e.g., a hex code).
2202
+ * @returns {this} The updated `MessageEmbed` instance.
2203
+ */
2204
+ setColor(color: string): this;
2205
+ /**
2206
+ * Sets the description of the embed.
2207
+ *
2208
+ * @param {string} description - The description to set.
2209
+ * @returns {this} The updated `MessageEmbed` instance.
2210
+ */
2211
+ setDescription(description: string): this;
2212
+ /**
2213
+ * Sets the URL of the embed.
2214
+ *
2215
+ * @param {string} url - The URL to set.
2216
+ * @returns {this} The updated `MessageEmbed` instance.
2217
+ */
2218
+ setURL(url: string): this;
2219
+ /**
2220
+ * Sets the media (e.g., image or video) of the embed.
2221
+ *
2222
+ * @param {Readable | string | File} media - The media URL, File or Stream to set.
2223
+ * @returns {this} The updated `MessageEmbed` instance.
2224
+ */
2225
+ setMedia(media: Readable | string | File$2): this;
2226
+ /**
2227
+ *
2228
+ * @param client The client instance used to send the embed.
2229
+ * @returns SendableEmbed
2230
+ * Converts the embed to a JSON object that can be sent to the API, including media handling.
2231
+ */
2232
+ toJSONWithMedia(client: Client): Promise<SendableEmbed>;
2233
+ /**
2234
+ * Converts the embed to a JSON object that can be sent to the API.
2235
+ *
2236
+ * @returns {SendableEmbed} The JSON representation of the embed.
2237
+ */
2238
+ toJSON(): SendableEmbed;
2239
+ }
2240
+
2241
+ type APINotesChannel = Extract<Channel$1, {
2242
+ channel_type: "SavedMessages";
2243
+ }>;
2244
+ /**
2245
+ * Represents a notes channel, which is used for saving personal messages.
2246
+ *
2247
+ * @extends Channel
2248
+ */
2249
+ declare class NotesChannel extends Channel implements TextBasedChannel {
2250
+ /** The type of the channel, which is always `NOTES` for notes channels. */
2251
+ readonly type = ChannelTypes.NOTES;
2252
+ /** The ID of the user associated with the notes channel. */
2253
+ userId: string;
2254
+ /** The ID of the last message sent in this notes channel, if any. */
2255
+ lastMessageId: string | null;
2256
+ /** Manages the messages in this notes channel. */
2257
+ messages: MessageManager;
2258
+ /**
2259
+ * Creates a new NotesChannel instance.
2260
+ *
2261
+ * @param {client} client - The client instance.
2262
+ * @param {APINotesChannel} data - The raw data for the notes channel from the API.
2263
+ */
2264
+ constructor(client: Client, data: APINotesChannel);
2265
+ /**
2266
+ * Updates the notes channel instance with new data from the API.
2267
+ *
2268
+ * @param {APINotesChannel} data - The raw data for the notes channel from the API.
2269
+ * @returns {this} The updated notes channel instance.
2270
+ * @protected
2271
+ */
2272
+ protected _patch(data: APINotesChannel): this;
2273
+ /**
2274
+ * Sends a message to this notes channel.
2275
+ *
2276
+ * @param {MessageOptions | string} options - The message content or options for the message.
2277
+ * @returns {Promise<Message>} A promise that resolves with the sent message.
2278
+ *
2279
+ * @example
2280
+ * ```typescript
2281
+ * await notesChannel.send("This is a saved message.");
2282
+ * ```
2283
+ */
2284
+ send(options: MessageOptions | string): Promise<MessageStruct>;
2285
+ /**
2286
+ * Deletes multiple messages from this notes channel.
2287
+ *
2288
+ * @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.
2289
+ * @returns {Promise<void>} A promise that resolves when the messages have been successfully deleted.
2290
+ *
2291
+ * @example
2292
+ * ```typescript
2293
+ * await notesChannel.bulkDelete(5); // Deletes the last 5 messages.
2294
+ * ```
2295
+ */
2296
+ bulkDelete(messages: MessageResolvable[] | Map<string, MessageStruct> | number): Promise<void>;
2297
+ /**
2298
+ * Retrieves the last message sent in this notes channel.
2299
+ *
2300
+ * @returns {Message | null} The last message, or `null` if no message exists.
2301
+ */
2302
+ get lastMessage(): MessageStruct | null;
2303
+ /**
2304
+ * Retrieves the user associated with this notes channel.
2305
+ *
2306
+ * @returns {User} The user associated with the notes channel.
2307
+ */
2308
+ get user(): User;
2309
+ }
2310
+
2311
+ interface Overwrite {
2312
+ allow: FullPermissions;
2313
+ deny: FullPermissions;
2314
+ }
2315
+ /**
2316
+ * Represents a server channel, which can be a text or voice channel.
2317
+ *
2318
+ * @extends Channel
2319
+ */
2320
+ declare class ServerChannel extends Channel {
2321
+ /** The name of the channel. */
2322
+ name: string;
2323
+ /** The ID of the server this channel belongs to. */
2324
+ serverId: string;
2325
+ /** The description of the channel, or `null` if none is set. */
2326
+ description: string | null;
2327
+ /** The icon of the channel, or `null` if none is set. */
2328
+ icon: Attachment | null;
2329
+ /** Manages the messages in this Server channel. */
2330
+ messages: MessageManager;
2331
+ /** The permission overwrites for the channel. */
2332
+ overwrites: Map<string, Overwrite>;
2333
+ /** Whether the channel is marked as NSFW (Not Safe For Work). */
2334
+ nsfw: boolean;
2335
+ /**
2336
+ * Creates a new ServerChannel instance.
2337
+ *
2338
+ * @param {client} client - The client instance.
2339
+ * @param {APIServerChannel} data - The raw data for the server channel from the API.
2340
+ */
2341
+ constructor(client: Client, data: APIServerChannel);
2342
+ /**
2343
+ * Updates the server channel instance with new data from the API.
2344
+ *
2345
+ * @param {APIServerChannel} data - The raw data for the server channel from the API.
2346
+ * @param {FieldsChannel[]} [clear=[]] - Fields to clear in the channel.
2347
+ * @returns {this} The updated server channel instance.
2348
+ * @protected
2349
+ */
2350
+ protected _patch(data: APIServerChannel, clear?: FieldsChannel[]): this;
2351
+ /**
2352
+ * Creates an invite for the server channel.
2353
+ *
2354
+ * @returns {Promise<Invite>} A promise that resolves with the created invite.
2355
+ *
2356
+ * @example
2357
+ * ```typescript
2358
+ * const invite = await serverChannel.createInvite();
2359
+ * console.log(`Invite created: ${invite}`);
2360
+ * ```
2361
+ */
2362
+ createInvite(): Promise<Invite>;
2363
+ /**
2364
+ * Retrieves the server this channel belongs to.
2365
+ *
2366
+ * @returns {Server} The server instance.
2367
+ */
2368
+ get server(): Server;
2369
+ /**
2370
+ * Sends a message to this Server channel.
2371
+ *
2372
+ * @param {MessageOptions | string} options - The message content or options for the message.
2373
+ * @returns {Promise<Message>} A promise that resolves with the sent message.
2374
+ *
2375
+ * @example
2376
+ * ```typescript
2377
+ * await serverChannel.send("Hello, world!");
2378
+ * ```
2379
+ */
2380
+ send(options: MessageOptions | string): Promise<MessageStruct>;
2381
+ /**
2382
+ * Retrieves the category this channel belongs to, if any.
2383
+ *
2384
+ * @returns {Category | null} The category instance, or `null` if the channel is not in a category.
2385
+ */
2386
+ get category(): Category | null;
2387
+ setName(name: string): Promise<void>;
2388
+ setDescription(description: string | null): Promise<void>;
2389
+ setNSFW(nsfw: boolean): Promise<void>;
2390
+ }
2391
+
2392
+ /**
2393
+ * Represents a member of a server.
2394
+ *
2395
+ * @extends Base
2396
+ */
2397
+ declare class ServerMember extends Base {
2398
+ /** The ID of the server this member belongs to. */
2399
+ serverId: string;
2400
+ /** The nickname of the member, or `null` if none is set. */
2401
+ nickname: string | null;
2402
+ /** The avatar of the member, or `null` if none is set. */
2403
+ avatar: Attachment | null;
2404
+ /** roles assigned to the member */
2405
+ roles: Role[];
2406
+ /**
2407
+ * Creates a new ServerMember instance.
2408
+ *
2409
+ * @param {client} client - The client instance.
2410
+ * @param {APIMember} data - The raw data for the server member from the API.
2411
+ */
2412
+ constructor(client: Client, data: Member);
2413
+ /**
2414
+ * Updates the server member instance with new data from the API.
2415
+ *
2416
+ * @param {APIMember} data - The raw data for the server member from the API.
2417
+ * @param {FieldsMember[]} [clear=[]] - Fields to clear in the server member.
2418
+ * @returns {this} The updated server member instance.
2419
+ * @protected
2420
+ */
2421
+ protected _patch(data: Member, clear?: FieldsMember[]): this;
2422
+ /**
2423
+ * Sets the nickname of the server member.
2424
+ *
2425
+ * @param {string} [nickname] - The new nickname to set, or `undefined` to clear the nickname.
2426
+ * @returns {Promise<this>} A promise that resolves with the updated server member instance.
2427
+ *
2428
+ * @example
2429
+ * ```typescript
2430
+ * await member.setNickname("NewNickname");
2431
+ * ```
2432
+ */
2433
+ setNickname(nickname?: string): Promise<this>;
2434
+ /**
2435
+ * adds a role to the server member.
2436
+ * @param roleId - The ID of the role to add to the member.
2437
+ * @returns
2438
+ */
2439
+ addRole(roleId: string): Promise<this>;
2440
+ /**
2441
+ * Removes a role from the server member.
2442
+ *
2443
+ * @param {string} roleId - The ID of the role to remove from the member.
2444
+ * @returns {Promise<this>} A promise that resolves with the updated server member instance.
2445
+ *
2446
+ * @example
2447
+ * ```typescript
2448
+ * await member.removeRole("roleId");
2449
+ * ```
2450
+ */
2451
+ removeRole(roleId: string): Promise<this>;
2452
+ /**
2453
+ * Bans the server member.
2454
+ *
2455
+ * @param {string} [reason] - The reason for the ban.
2456
+ * @returns {Promise<void>} A promise that resolves when the member is banned.
2457
+ *
2458
+ * @example
2459
+ * ```typescript
2460
+ * await member.ban("Violation of rules");
2461
+ * ```
2462
+ */
2463
+ ban(reason?: string): Promise<void>;
2464
+ /**
2465
+ * Kicks the server member.
2466
+ *
2467
+ * @returns {Promise<void>} A promise that resolves when the member is kicked.
2468
+ *
2469
+ * @example
2470
+ * ```typescript
2471
+ * await member.kick();
2472
+ * ```
2473
+ */
2474
+ kick(): Promise<void>;
2475
+ /**
2476
+ * Leaves the server.
2477
+ *
2478
+ * @returns {Promise<void>} A promise that resolves when the member leaves the server.
2479
+ *
2480
+ * @example
2481
+ * ```typescript
2482
+ * await member.leave();
2483
+ * ```
2484
+ */
2485
+ leave(): Promise<void>;
2486
+ /**
2487
+ * Gets the effective permissions for this server member based on their roles.
2488
+ *
2489
+ * The permissions are calculated by:
2490
+ * 1. Starting with a base FullPermissions with no permissions
2491
+ * 2. For each role the member has, applying the role's allow permissions
2492
+ * 3. For each role the member has, removing the role's deny permissions
2493
+ *
2494
+ * @returns {FullPermissions} The effective permissions for this member
2495
+ *
2496
+ * @example
2497
+ * ```typescript
2498
+ * const permissions = member.getPermissions();
2499
+ * console.log(permissions.has('MANAGE_MESSAGES')); // true or false
2500
+ * ```
2501
+ */
2502
+ permissions(): FullPermissions;
2503
+ /**
2504
+ * Checks if this server member has a specific permission.
2505
+ *
2506
+ * @param {string | number | FullPermissions} permission - The permission to check for
2507
+ * @returns {boolean} Whether the member has the permission
2508
+ *
2509
+ * @example
2510
+ * ```typescript
2511
+ * if (member.hasPermission('MANAGE_MESSAGES')) {
2512
+ * // Member can manage messages
2513
+ * }
2514
+ * ```
2515
+ *
2516
+ * note this works on the same basis as stoats permissions checking
2517
+ */
2518
+ hasPermission(permission: string | number | FullPermissions): boolean;
2519
+ /**
2520
+ * Retrieves the user associated with this server member.
2521
+ *
2522
+ * @returns {User} The user instance.
2523
+ */
2524
+ get user(): User;
2525
+ /**
2526
+ * Gets the username of the user.
2527
+ *
2528
+ * @returns {string} The username of the user.
2529
+ */
2530
+ get username(): string;
2531
+ /**
2532
+ * Gets whether the user is a bot.
2533
+ *
2534
+ * @returns {boolean} Whether the user is a bot.
2535
+ */
2536
+ get bot(): boolean;
2537
+ /**
2538
+ * Retrieves the server this member belongs to.
2539
+ *
2540
+ * @returns {Server} The server instance.
2541
+ */
2542
+ get server(): Server;
2543
+ /**
2544
+ * Converts the server member to a string representation.
2545
+ *
2546
+ * @returns {string} A string representation of the server member in the format `<@userId>`.
2547
+ */
2548
+ toString(): string;
2549
+ /**
2550
+ * Sets a timeout for the server member.
2551
+ * @param duration - The duration of the timeout as a Date object.
2552
+ * @returns A promise that resolves when the timeout is set.
2553
+ */
2554
+ timeout(duration: Date): Promise<void>;
2555
+ }
2556
+
2557
+ type APITextChannel = Extract<Channel$1, {
2558
+ channel_type: "TextChannel";
2559
+ }>;
2560
+ /**
2561
+ * Represents a text channel in a server.
2562
+ *
2563
+ * @extends ServerChannel
2564
+ */
2565
+ declare class TextChannel extends ServerChannel implements TextBasedChannel {
2566
+ /** The ID of the last message sent in this text channel, if any. */
2567
+ lastMessageId: string | null;
2568
+ /** Manages the messages in this text channel. */
2569
+ messages: MessageManager;
2570
+ /** The type of the channel, which is always `TEXT` for text channels. */
2571
+ readonly type = ChannelTypes.TEXT;
2572
+ /**
2573
+ * Creates a new TextChannel instance.
2574
+ *
2575
+ * @param {client} client - The client instance.
2576
+ * @param {APITextChannel} data - The raw data for the text channel from the API.
2577
+ */
2578
+ constructor(client: Client, data: APITextChannel);
2579
+ /**
2580
+ * Updates the text channel instance with new data from the API.
2581
+ *
2582
+ * @param {APITextChannel} data - The raw data for the text channel from the API.
2583
+ * @returns {this} The updated text channel instance.
2584
+ * @protected
2585
+ */
2586
+ protected _patch(data: APITextChannel): this;
2587
+ /**
2588
+ * Retrieves the last message sent in this text channel.
2589
+ *
2590
+ * @returns {Message | null} The last message, or `null` if no message exists.
2591
+ */
2592
+ get lastMessage(): MessageStruct | null;
2593
+ /**
2594
+ * Sends a message to this text channel.
2595
+ *
2596
+ * @param {MessageOptions | string} options - The message content or options for the message.
2597
+ * @returns {Promise<Message>} A promise that resolves with the sent message.
2598
+ *
2599
+ * @example
2600
+ * ```typescript
2601
+ * await textChannel.send("Hello, world!");
2602
+ * ```
2603
+ */
2604
+ send(options: MessageOptions | string): Promise<MessageStruct>;
2605
+ /**
2606
+ * Deletes multiple messages from this text channel.
2607
+ *
2608
+ * @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.
2609
+ * @returns {Promise<void>} A promise that resolves when the messages have been successfully deleted.
2610
+ *
2611
+ * @example
2612
+ * ```typescript
2613
+ * await textChannel.bulkDelete(10); // Deletes the last 10 messages.
2614
+ * ```
2615
+ */
2616
+ bulkDelete(messages: MessageResolvable[] | Map<string, MessageStruct> | number): Promise<void>;
2617
+ }
2618
+
2619
+ type APIVoiceChannel = Extract<Channel$1, {
2620
+ channel_type: "VoiceChannel";
2621
+ }>;
2622
+ type Voice = {
2623
+ id: string;
2624
+ participants: voiceParticipant[];
2625
+ };
2626
+ type voiceParticipant = {
2627
+ id: string;
2628
+ joined_at: string;
2629
+ is_receving: boolean;
2630
+ is_publishing: boolean;
2631
+ screensharing: boolean;
2632
+ camera: boolean;
2633
+ };
2634
+ /**
2635
+ * Represents a voice channel in a server.
2636
+ *
2637
+ * @extends ServerChannel
2638
+ */
2639
+ declare class VoiceChannel extends ServerChannel {
2640
+ /** The type of the channel, which is always `VOICE` for voice channels. */
2641
+ readonly type = ChannelTypes.VOICE;
2642
+ voice?: Map<string, voiceParticipant>;
2643
+ /**
2644
+ * Creates a new VoiceChannel instance.
2645
+ *
2646
+ * @param {client} client - The client instance.
2647
+ * @param {APIVoiceChannel} data - The raw data for the voice channel from the API.
2648
+ */
2649
+ constructor(client: Client, data: APIVoiceChannel);
2650
+ /**
2651
+ * Updates the voice channel instance with new data from the API.
2652
+ *
2653
+ * @param {APIVoiceChannel} data - The raw data for the voice channel from the API.
2654
+ * @returns {this} The updated voice channel instance.
2655
+ * @protected
2656
+ */
2657
+ protected _patch(data: APIVoiceChannel): this;
2658
+ /**
2659
+ * Acknowledges the voice channel.
2660
+ *
2661
+ * @throws {TypeError} Throws an error because voice channels cannot be acknowledged.
2662
+ *
2663
+ * @example
2664
+ * ```typescript
2665
+ * try {
2666
+ * await voiceChannel.ack();
2667
+ * } catch (error) {
2668
+ * console.error(error.message); // "Cannot ack voice channel"
2669
+ * }
2670
+ * ```
2671
+ */
2672
+ ack(): Promise<void>;
2673
+ /**
2674
+ * Creates and connects an AudioPlayer to this voice channel in one step.
2675
+ * This is a convenience method that combines createPlayer() and connect().
2676
+ *
2677
+ * @returns {Promise<AudioPlayer>} A promise that resolves to a connected AudioPlayer
2678
+ *
2679
+ * @example
2680
+ * ```typescript
2681
+ * const voiceChannel = await client.channels.fetch('voice-channel-id') as VoiceChannel;
2682
+ * const player = await voiceChannel.connect();
2683
+ *
2684
+ * // Already connected, ready to play
2685
+ * await player.playFromUrl('https://example.com/music.mp3');
2686
+ * ```
2687
+ */
2688
+ connect(): Promise<AudioPlayer>;
2689
+ /** Disconnects the AudioPlayer from this voice channel's server. */
2690
+ disconnect(): Promise<void>;
2691
+ /** Stops the AudioPlayer in this voice channel's server. */
2692
+ stop(): Promise<void>;
2693
+ /** Plays audio through the AudioPlayer connected to this voice channel.
2694
+ * @param source - The audio source (URL, file path, or stream)
2695
+ */
2696
+ play(source: string): Promise<void>;
2697
+ /** Retrieves the AudioPlayer associated with this voice channel, if any.
2698
+ * @returns {Promise<AudioPlayer | null>} A promise that resolves to the AudioPlayer or null if not found
2699
+ */
2700
+ getPlayer(): Promise<AudioPlayer | null>;
2701
+ }
2702
+
2703
+ /**
2704
+ * Represents a category in a server, which groups multiple channels together.
2705
+ *
2706
+ * @extends Base
2707
+ */
2708
+ declare class Category extends Base {
2709
+ readonly server: Server;
2710
+ /** The name of the category. */
2711
+ name: string;
2712
+ /** An array of channel IDs that belong to this category. */
2713
+ protected _children: string[];
2714
+ /**
2715
+ * Creates a new Category instance.
2716
+ *
2717
+ * @param {Server} server - The server this category belongs to.
2718
+ * @param {APICategory} data - The raw data for the category from the API.
2719
+ */
2720
+ constructor(server: Server, data: Category$1);
2721
+ /**
2722
+ * Updates the category instance with new data from the API.
2723
+ *
2724
+ * @param {APICategory} data - The raw data for the category from the API.
2725
+ * @returns {this} The updated category instance.
2726
+ * @protected
2727
+ */
2728
+ protected _patch(data: Category$1): this;
2729
+ /**
2730
+ * Retrieves the channels that belong to this category.
2731
+ *
2732
+ * @returns {Map<string, ServerChannel>} A map of channel IDs to their corresponding `ServerChannel` instances.
2733
+ */
2734
+ get children(): Map<string, ServerChannel>;
2735
+ /**
2736
+ * Converts the category to a string representation.
2737
+ *
2738
+ * @returns {string} The name of the category.
2739
+ */
2740
+ toString(): string;
2741
+ }
2742
+
2743
+ /**
2744
+ * Represents an emoji in the client.
2745
+ *
2746
+ * @extends Base
2747
+ */
2748
+ declare class Emoji extends Base {
2749
+ /** The parent object of the emoji, which can be a server or other entity. */
2750
+ parent?: {
2751
+ type: string;
2752
+ id: string;
2753
+ } | null;
2754
+ /** The ID of the user who created the emoji, or `null` if not available. */
2755
+ creator_id?: string | null;
2756
+ /** The name of the emoji, or `null` if not set. */
2757
+ name?: string | null;
2758
+ /**
2759
+ * Creates a new Emoji instance.
2760
+ *
2761
+ * @param {client} client - The client instance.
2762
+ * @param {Emoji} data - The raw data for the emoji.
2763
+ */
2764
+ constructor(client: Client, data: Emoji);
2765
+ /**
2766
+ * Retrieves the user who created the emoji.
2767
+ *
2768
+ * @returns {User | null} The creator of the emoji, or `null` if not found.
2769
+ */
2770
+ get creator(): User | null;
2771
+ /**
2772
+ * Retrieves the server associated with the emoji, if any.
2773
+ *
2774
+ * @returns {Server | null} The server instance, or `null` if the emoji is not associated with a server.
2775
+ */
2776
+ get server(): Server | null;
2777
+ }
2778
+
2779
+ declare class UserProfile extends Base {
2780
+ userId: string;
2781
+ content: string | null;
2782
+ background: Attachment | null;
2783
+ constructor(client: Client, data: UserProfile$1 & {
2784
+ userId: string;
2785
+ });
2786
+ protected _patch(data: PartialObject & {
2787
+ userId?: string;
2788
+ content?: string | null;
2789
+ background?: UserProfile$1["background"];
2790
+ }): this;
2791
+ get user(): User | null;
2792
+ fetch(): Promise<UserProfile>;
2793
+ setContent(content: string | null): Promise<void>;
2794
+ setBackground(background: Attachment | null): Promise<void>;
2795
+ toJSON(): {
2796
+ content: string | null;
2797
+ background: Attachment | null;
2798
+ };
2799
+ }
2800
+
2801
+ type UserResolvable = User | User$1 | MessageStruct | string;
2802
+ declare class UserManager extends BaseManager<User, User$1> {
2803
+ /** @private */
2804
+ holds: typeof User;
2805
+ /**
2806
+ *
2807
+ * @param user The user to fetch
2808
+ * @returns A promise that resolves when the user is fetched
2809
+ */
2810
+ fetch(user: UserResolvable, { force }?: {
2811
+ force?: boolean | undefined;
2812
+ }): Promise<User>;
2813
+ /**
2814
+ * get a user form cache
2815
+ * @param resolvable The user to resolve
2816
+ * @returns The user or null if it cannot be resolved
2817
+ */
2818
+ resolve(resolvable: MessageStruct | User): User | null;
2819
+ resolve(resolvable: string | User$1): User | null;
2820
+ /**
2821
+ * get a user id form cache
2822
+ * @param resolvable The user to resolve
2823
+ * @returns The user id or null if it cannot be resolved
2824
+ */
2825
+ resolveId(resolvable: UserResolvable): string | null;
2826
+ }
2827
+
2828
+ /**
2829
+ * Manages webhooks for the client.
2830
+ * Provides methods for creating, managing, and sending messages through webhooks.
2831
+ */
2832
+ declare class WebhookManager {
2833
+ protected readonly client: Client;
2834
+ /**
2835
+ * Creates a new WebhookManager instance.
2836
+ *
2837
+ * @param client - The client instance this manager belongs to
2838
+ */
2839
+ constructor(client: Client);
2840
+ /**
2841
+ * Creates a new webhook in the specified channel.
2842
+ *
2843
+ * @param channelId - The ID of the channel where the webhook will be created
2844
+ * @param name - The name of the webhook
2845
+ * @param avatar - Optional avatar for the webhook. Can be a URL string, Readable stream, or File object
2846
+ * @returns Promise resolving to the created webhook response
2847
+ *
2848
+ * @example
2849
+ * ```typescript
2850
+ * const webhook = await client.webhooks.create("channelId", "My Webhook", "https://example.com/avatar.png");
2851
+ * ```
2852
+ */
2853
+ create(channelId: string, name: string, avatar?: Readable | string | File): Promise<createWebhookResponse>;
2854
+ /**
2855
+ * Retrieves all webhooks for the specified channel.
2856
+ *
2857
+ * @param channelId - The ID of the channel to get webhooks from
2858
+ * @returns Promise resolving to an array of webhook responses
2859
+ *
2860
+ * @example
2861
+ * ```typescript
2862
+ * const webhooks = await client.webhooks.getAll("channelId");
2863
+ * console.log(`Found ${webhooks.length} webhooks`);
2864
+ * ```
2865
+ */
2866
+ getAll(channelId: string): Promise<createWebhookResponse[]>;
2867
+ /**
2868
+ * Retrieves a specific webhook by ID and token.
2869
+ *
2870
+ * @param webhookId - The ID of the webhook to retrieve
2871
+ * @param token - The token of the webhook
2872
+ * @returns Promise resolving to the webhook response
2873
+ *
2874
+ * @example
2875
+ * ```typescript
2876
+ * const webhook = await client.webhooks.get("webhookId", "webhookToken");
2877
+ * console.log(`Webhook name: ${webhook.name}`);
2878
+ * ```
2879
+ */
2880
+ get(webhookId: string, token: string): Promise<createWebhookResponse>;
2881
+ /**
2882
+ * Sends a message through a webhook.
2883
+ *
2884
+ * @param webhookId - The ID of the webhook to send the message through
2885
+ * @param token - The token of the webhook
2886
+ * @param content - The message content. Can be a string or MessageOptions object with attachments and embeds
2887
+ * @returns Promise resolving to the sent message
2888
+ *
2889
+ * @example
2890
+ * ```typescript
2891
+ * // Send a simple text message
2892
+ * await client.webhooks.send("webhookId", "token", "Hello, world!");
2893
+ *
2894
+ * // Send a message with embeds and attachments
2895
+ * await client.webhooks.send("webhookId", "token", {
2896
+ * content: "Check out this image!",
2897
+ * attachments: ["https://example.com/image.png"],
2898
+ * embeds: [myEmbed]
2899
+ * });
2900
+ * ```
2901
+ */
2902
+ send(webhookId: string, token: string, content: MessageOptions | string): Promise<Message>;
2903
+ /**
2904
+ * Deletes a webhook.
2905
+ *
2906
+ * @param webhookId - The ID of the webhook to delete
2907
+ * @param token - The token of the webhook
2908
+ * @returns Promise that resolves when the webhook is deleted
2909
+ *
2910
+ * @example
2911
+ * ```typescript
2912
+ * await client.webhooks.delete("webhookId", "webhookToken");
2913
+ * console.log("Webhook deleted successfully");
2914
+ * ```
2915
+ */
2916
+ delete(webhookId: string, token: string): Promise<void>;
2917
+ /**
2918
+ * Edits a webhook's properties.
2919
+ *
2920
+ * @param webhookId - The ID of the webhook to edit
2921
+ * @param token - The token of the webhook
2922
+ * @param options - The options to edit on the webhook
2923
+ * @returns Promise resolving to the updated webhook response
2924
+ *
2925
+ * @example
2926
+ * ```typescript
2927
+ * const updatedWebhook = await client.webhooks.edit("webhookId", "token", {
2928
+ * name: "New Webhook Name",
2929
+ * avatar: "https://example.com/new-avatar.png"
2930
+ * });
2931
+ * ```
2932
+ */
2933
+ edit(webhookId: string, token: string, options: editWebhookOptions): Promise<createWebhookResponse>;
2934
+ /**
2935
+ * Retrieves partial information about a webhook using only its ID.
2936
+ * This method provides limited webhook information without requiring a token.
2937
+ *
2938
+ * @param webhookId - The ID of the webhook to retrieve partial information for
2939
+ * @returns Promise resolving to the webhook response with partial information
2940
+ *
2941
+ * @example
2942
+ * ```typescript
2943
+ * const partialWebhook = await client.webhooks.getPartial("webhookId");
2944
+ * console.log(`Webhook name: ${partialWebhook.name}`);
2945
+ * ```
2946
+ */
2947
+ getPartial(webhookId: string): Promise<createWebhookResponse>;
2948
+ }
2949
+
2950
+ declare class ClientUser extends User {
2951
+ notes: NotesChannel | null;
2952
+ owner: string | null;
2953
+ constructor(client: Client, data: User$1);
2954
+ setUsername(username: string, password?: string): Promise<void>;
2955
+ setStatus(text?: string | null): Promise<void>;
2956
+ setStatus(presence?: Status): Promise<void>;
2957
+ setStatus(text?: string | null, presence?: keyof typeof Status): Promise<void>;
2958
+ setAvatar(avatar: Readable$1 | Buffer | string): Promise<void>;
2959
+ setBanner(banner: Readable$1 | Buffer | string): Promise<void>;
2960
+ setBio(content: string): Promise<void>;
2961
+ setProfile(data: {
2962
+ content?: string;
2963
+ background?: Readable$1 | Buffer | string;
2964
+ }): Promise<void>;
2965
+ clearAvatar(): Promise<void>;
2966
+ clearBanner(): Promise<void>;
2967
+ clearStatus(): Promise<void>;
2968
+ setPresence(presence: "Online" | "Idle" | "Busy" | "Invisible"): Promise<void>;
2969
+ fetchProfile(): Promise<UserProfile>;
2970
+ }
2971
+
2972
+ /**
2973
+ * Manages the registration and retrieval of events for the client.
2974
+ * @private
2975
+ * @extends Event
2976
+ */
2977
+ declare class EventManager {
2978
+ #private;
2979
+ protected readonly client: Client;
2980
+ /**
2981
+ * Creates a new EventManager instance.
2982
+ *
2983
+ * @param {client} client - The client instance.
2984
+ */
2985
+ constructor(client: Client);
2986
+ /**
2987
+ * Registers an event with the manager.
2988
+ *
2989
+ * @param {new (client: client) => CustomEvent} Event - The event class to register.
2990
+ */
2991
+ register(Event: new (client: Client) => Event): void;
2992
+ /**
2993
+ * Retrieves a registered event by its name.
2994
+ *
2995
+ * @param {string} name - The name of the event to retrieve.
2996
+ * @returns {CustomEvent | null} The event instance, or `null` if not found.
2997
+ */
2998
+ get(name: string): Event | null;
2999
+ }
3000
+
3001
+ /**
3002
+ * VoiceClient acts as a factory for creating AudioPlayer instances.
3003
+ * Users manage the AudioPlayer instances themselves rather than the VoiceClient managing them internally.
3004
+ * This design gives users full control over their voice connections and audio playback.
3005
+ */
3006
+ declare class VoiceClient {
3007
+ private readonly client;
3008
+ /** Map of active audio players by server ID */
3009
+ private readonly players;
3010
+ constructor(client: Client);
3011
+ /**
3012
+ * Creates a new AudioPlayer instance for the specified voice channel.
3013
+ *
3014
+ * @param channelId - The ID of the voice channel to connect to
3015
+ * @param serverId - The ID of the server containing the voice channel
3016
+ * @returns A new AudioPlayer instance that the user can manage
3017
+ *
3018
+ * @example
3019
+ * ```typescript
3020
+ * // Create a player for a specific voice channel
3021
+ * const player = client.voice.createPlayer('voice-channel-id', 'server-id');
3022
+ *
3023
+ * // Set up event listeners
3024
+ * player.on('connected', () => {
3025
+ * console.log('Connected to voice channel!');
3026
+ * });
3027
+ *
3028
+ * player.on('audioStart', (source, type) => {
3029
+ * console.log(`Started playing ${type}: ${source}`);
3030
+ * });
3031
+ *
3032
+ * // Connect and play audio
3033
+ * await player.connect();
3034
+ * await player.playFromFile('./music.mp3');
3035
+ *
3036
+ * // The user is responsible for managing the player lifecycle
3037
+ * await player.disconnect();
3038
+ * ```
3039
+ */
3040
+ createPlayer(channelId: string, serverId: string): AudioPlayer;
3041
+ /**
3042
+ * Creates a new AudioPlayer instance and immediately connects it to the voice channel.
3043
+ * This is a convenience method that combines createPlayer() and connect().
3044
+ *
3045
+ * @param channelId - The ID of the voice channel to connect to
3046
+ * @param serverId - The ID of the server containing the voice channel
3047
+ * @returns A new connected AudioPlayer instance
3048
+ *
3049
+ * @example
3050
+ * ```typescript
3051
+ * // Create and connect in one step
3052
+ * const player = await client.voice.connectToChannel('voice-channel-id', 'server-id');
3053
+ *
3054
+ * // Player is already connected and ready to use
3055
+ * await player.playFromUrl('https://example.com/music.mp3');
3056
+ * ```
3057
+ */
3058
+ connectToChannel(channelId: string, serverId: string): Promise<AudioPlayer>;
3059
+ /**
3060
+ * Disconnects the AudioPlayer from the specified server.
3061
+ *
3062
+ * @param serverId - The ID of the server to disconnect from
3063
+ */
3064
+ disconnectFromChannel(serverId: string): Promise<void>;
3065
+ /**
3066
+ * Stops the AudioPlayer in the specified server.
3067
+ *
3068
+ * @param serverId - The ID of the server whose player should be stopped
3069
+ */
3070
+ stopPlayerInChannel(serverId: string): Promise<void>;
3071
+ }
3072
+
3073
+ /**
3074
+ * Represents the WebSocket client used for real-time communication with the API.
3075
+ */
3076
+ declare class WebSocketClient {
3077
+ protected readonly client: Client;
3078
+ /** The interval for sending heartbeats, in milliseconds. */
3079
+ heartbeatInterval?: number;
3080
+ /** The timestamp of the last ping sent, in milliseconds. */
3081
+ lastPingTimestamp?: number;
3082
+ /** Whether the last pong acknowledgment was received. */
3083
+ lastPongAck?: boolean;
3084
+ /** The WebSocket connection instance. */
3085
+ socket?: WebSocket | null;
3086
+ /** Whether the WebSocket client is connected. */
3087
+ connected: boolean;
3088
+ /** A promise representing the reconnecting process, or `null` if not reconnecting. */
3089
+ reconnecting: Promise<unknown> | null;
3090
+ /** Whether the WebSocket client is ready. */
3091
+ ready: boolean;
3092
+ /** The number of reconnection attempts made. */
3093
+ retryCount: number;
3094
+ /**
3095
+ * Creates a new WebSocketClient instance.
3096
+ *
3097
+ * @param {Client} client - The client instance.
3098
+ */
3099
+ constructor(client: Client);
3100
+ /**
3101
+ * Logs a debug message.
3102
+ *
3103
+ * @param {unknown} message - The message to log.
3104
+ * @private
3105
+ */
3106
+ private debug;
3107
+ /**
3108
+ * Sends data through the WebSocket connection.
3109
+ *
3110
+ * @param {unknown} data - The data to send.
3111
+ * @returns {Promise<void>} A promise that resolves when the data is sent.
3112
+ * @throws {Error} Throws an error if the WebSocket is not open.
3113
+ */
3114
+ send(data: unknown): Promise<void>;
3115
+ /**
3116
+ * Handles the WebSocket connection opening.
3117
+ *
3118
+ * @private
3119
+ */
3120
+ private onOpen;
3121
+ /**
3122
+ * Gets the current ping (latency) of the WebSocket connection.
3123
+ *
3124
+ * @returns {number} The ping in milliseconds, or `-0` if the WebSocket is not connected.
3125
+ */
3126
+ get ping(): number;
3127
+ /**
3128
+ * Sets the heartbeat interval for the WebSocket connection.
3129
+ *
3130
+ * @param {number} time - The interval time in milliseconds. Use `-1` to clear the interval.
3131
+ */
3132
+ setHeartbeatTimer(time: number): void;
3133
+ /**
3134
+ * Sends a heartbeat to the server to keep the connection alive.
3135
+ */
3136
+ sendHeartbeat(): void;
3137
+ /**
3138
+ * Handles WebSocket errors.
3139
+ *
3140
+ * @param {unknown} event - The error event.
3141
+ * @private
3142
+ */
3143
+ private onError;
3144
+ /**
3145
+ * Handles incoming WebSocket messages.
3146
+ *
3147
+ * @param {{ data: unknown }} param0 - The message event containing the data.
3148
+ * @private
3149
+ */
3150
+ private onMessage;
3151
+ /**
3152
+ * Handles the WebSocket connection closing.
3153
+ *
3154
+ * @param {{ code: number; reason: string }} event - The close event containing the code and reason.
3155
+ * @private
3156
+ */
3157
+ private onClose;
3158
+ /**
3159
+ * Handles incoming WebSocket packets.
3160
+ *
3161
+ * @param {any} packet - The packet data.
3162
+ * @private
3163
+ */
3164
+ private onPacket;
3165
+ /**
3166
+ * Connects to the WebSocket server.
3167
+ *
3168
+ * @returns {Promise<this>} A promise that resolves when the connection is established.
3169
+ */
3170
+ connect(): Promise<this>;
3171
+ /**
3172
+ * Destroys the WebSocket connection and clears its state.
3173
+ *
3174
+ * @returns {Promise<void>} A promise that resolves when the connection is destroyed.
3175
+ */
3176
+ destroy(isUserInitiated?: boolean): Promise<void>;
3177
+ }
3178
+
3179
+ /**
3180
+ * Represents the main selfbot client for interacting with the Stoat API (discord.js style).
3181
+ *
3182
+ * @extends BaseClient
3183
+ *
3184
+ * @example
3185
+ * ```typescript
3186
+ * import { Client } from "stoat-selfbot.js";
3187
+ *
3188
+ * const selfbot = new Client({});
3189
+ *
3190
+ * selfbot.on("ready", () => {
3191
+ * console.log("Selfbot is ready!");
3192
+ * });
3193
+ *
3194
+ * selfbot.on("messageCreate", (message) => {
3195
+ * if (message.author?.id === selfbot.user?.id) {
3196
+ * console.log("Received my own message:", message.content);
3197
+ * }
3198
+ * });
3199
+ *
3200
+ * // Login with session token (get from browser localStorage)
3201
+ * selfbot.login("YOUR_SESSION_TOKEN");
3202
+ * ```
3203
+ */
3204
+ declare class Client extends BaseClient {
3205
+ /** The WebSocket client used for real-time communication. */
3206
+ protected readonly ws: WebSocketClient;
3207
+ /** Manages the channels in the client. */
3208
+ readonly channels: ChannelManager;
3209
+ /** Manages the servers in the client. */
3210
+ readonly servers: ServerManager;
3211
+ /** Manages the users in the client. */
3212
+ readonly users: UserManager;
3213
+ /** Manages the events in the client. */
3214
+ readonly events: EventManager;
3215
+ /** Manages the webhooks in the client. */
3216
+ readonly webhooks: WebhookManager;
3217
+ /** Manages the voice connections in the client. */
3218
+ readonly voice: VoiceClient;
3219
+ /** The authenticated user, or `null` if not logged in. */
3220
+ user: ClientUser | null;
3221
+ /** The timestamp when the client became ready, or `null` if not ready. */
3222
+ readyAt: Date | null;
3223
+ /**
3224
+ * Creates a new Client instance.
3225
+ * Automatically configures the client for selfbot mode (X-Session-Token).
3226
+ *
3227
+ * @param {clientOptions} [options={}] - The options for configuring the client.
3228
+ */
3229
+ constructor(options?: clientOptions);
3230
+ /**
3231
+ * Initializes the client.
3232
+ * @private
3233
+ */
3234
+ init(): Promise<void>;
3235
+ /**
3236
+ * Gets the timestamp when the client became ready.
3237
+ *
3238
+ * @returns {number | null} The ready timestamp in milliseconds, or `null` if not ready.
3239
+ */
3240
+ get readyTimestamp(): number | null;
3241
+ /**
3242
+ * Gets the uptime of the client in milliseconds.
3243
+ *
3244
+ * @returns {number | null} The uptime in milliseconds, or `null` if the client is not ready.
3245
+ */
3246
+ get upTime(): number | null;
3247
+ /**
3248
+ * Logs the selfbot into the API using the provided session token.
3249
+ *
3250
+ * @param {string} token - The user session token (obtain from browser localStorage).
3251
+ * @returns {Promise<void>} A promise that resolves when the selfbot is logged in.
3252
+ * @throws {Error} Throws an error if the session token is not provided or is invalid.
3253
+ *
3254
+ * @example
3255
+ * ```typescript
3256
+ * await client.login("your-session-token-here");
3257
+ * ```
3258
+ */
3259
+ login(token: string): Promise<void>;
3260
+ /**
3261
+ * Destroys the client, disconnecting it from the API and clearing its state.
3262
+ *
3263
+ * @returns {Promise<void>} A promise that resolves when the client is destroyed.
3264
+ *
3265
+ * @example
3266
+ * ```typescript
3267
+ * await client.destroy();
3268
+ * ```
3269
+ */
3270
+ destroy(): Promise<void>;
3271
+ /**
3272
+ * Checks if the client is ready.
3273
+ *
3274
+ * @returns {boolean} `true` if the client is ready, otherwise `false`.
3275
+ *
3276
+ * @example
3277
+ * ```typescript
3278
+ * if (client.isReady()) {
3279
+ * console.log("Client is ready!");
3280
+ * }
3281
+ * ```
3282
+ */
3283
+ isReady(): boolean;
3284
+ /**
3285
+ * Gets whether this client is a selfbot.
3286
+ * Always returns true since this is a selfbot-only package.
3287
+ *
3288
+ * @returns {boolean} Always true.
3289
+ */
3290
+ get isSelfbot(): boolean;
3291
+ }
3292
+ /** @deprecated Use Client instead */
3293
+ declare const client: typeof Client;
3294
+
3295
+ declare abstract class BaseManager<Holds extends {
3296
+ id: string;
3297
+ }, R = unknown> {
3298
+ protected readonly client: Client;
3299
+ /** Shared default max size for all managers (can be changed globally). */
3300
+ static defaultMaxSize: number;
3301
+ /** Insertion ordered cache of items this manager holds. */
3302
+ readonly cache: Map<string, Holds>;
3303
+ /** Instance level max size (can be changed per manager instance). */
3304
+ protected maxSize: number;
3305
+ /** @private */
3306
+ Holds: any;
3307
+ constructor(client: Client, maxSize?: number);
3308
+ /**
3309
+ * Adds a raw object to the cache, constructing the holdable class.
3310
+ * Automatically evicts oldest entries if the max size is exceeded.
3311
+ * @private
3312
+ */
3313
+ _add(raw: R): Holds;
3314
+ /** Remove an entry by id.
3315
+ * @private
3316
+ */
3317
+ _remove(id: string): void;
3318
+ /** Adjust the maximum size for this manager at runtime. */
3319
+ setMaxSize(size: number): void;
3320
+ /** Force eviction until cache size is within the limit. */
3321
+ protected enforceMaxSize(): void;
3322
+ abstract readonly holds: (new (...args: any[]) => Holds) | null;
3323
+ resolve(resolvable: Holds): Holds | null;
3324
+ resolve(resolvable: string | R): Holds | null;
3325
+ resolve(resolvable: string | R | Holds): Holds | null;
3326
+ resolveId(resolvable: string | Holds | R): string | null;
3327
+ valueOf(): this["cache"];
3328
+ }
3329
+
3330
+ type ChannelResolvable = Channel | Channel$1 | string;
3331
+ declare class ChannelManager extends BaseManager<Channel, Channel$1> {
3332
+ /** @private */
3333
+ holds: null;
3334
+ /** @private */
3335
+ _add(data: Channel$1 & {
3336
+ voice?: any;
3337
+ }): Channel;
3338
+ _remove(id: string): void;
3339
+ /**
3340
+ * used to delete a channel
3341
+ *
3342
+ * @param channel The channel to delete
3343
+ * @returns A promise that resolves when the channel is deleted
3344
+ */
3345
+ delete(channel: ChannelResolvable): Promise<void>;
3346
+ /**
3347
+ * used to fetch a channel
3348
+ *
3349
+ * @param channel The channel to fetch
3350
+ * @param force Whether to force fetch the channel using the api or return it form cache if able
3351
+ * @returns A promise that resolves with the fetched channel
3352
+ */
3353
+ fetch(channel: ChannelResolvable, { force }?: {
3354
+ force?: boolean | undefined;
3355
+ }): Promise<Channel>;
3356
+ /**
3357
+ * resolves a channel from a string or a channel object
3358
+ * @param channel The channel to resolve
3359
+ * @returns the resolved channel or null if not found
3360
+ */
3361
+ resolve(channel: ChannelResolvable): Channel | null;
3362
+ /**
3363
+ * resolves a channel id from a string or a channel object
3364
+ * @param channel The channel to resolve
3365
+ * @returns the resolved channel id or null if not found
3366
+ */
3367
+ resolveId(channel: ChannelResolvable): string | null;
3368
+ }
3369
+
3370
+ type ServerResolvable = Server | Server$1 | string;
3371
+ interface EditServerOptions {
3372
+ name?: string;
3373
+ description?: string;
3374
+ }
3375
+ declare class ServerManager extends BaseManager<Server, Server$1> {
3376
+ /** @private */
3377
+ readonly holds: typeof Server;
3378
+ /** @private */
3379
+ _remove(id: string): void;
3380
+ /**
3381
+ * edits a server
3382
+ * @param server The server to edit
3383
+ * @param options The options to edit the server with
3384
+ * @param options.name The name of the server
3385
+ * @param options.description The description of the server
3386
+ * @returns A promise that resolves when the server is edited
3387
+ */
3388
+ edit(server: ServerResolvable, options: EditServerOptions): Promise<void>;
3389
+ /**
3390
+ * leaves a server
3391
+ * @param server the server to leave
3392
+ */
3393
+ delete(server: ServerResolvable): Promise<void>;
3394
+ fetch(server: ServerResolvable, { force }?: {
3395
+ force?: boolean | undefined;
3396
+ }): Promise<Server>;
3397
+ }
3398
+
3399
+ type RoleResolvable = Role | string;
3400
+ declare class RoleManager extends BaseManager<Role, Role$1 & {
3401
+ id: string;
3402
+ }> {
3403
+ protected readonly server: Server;
3404
+ /** @private */
3405
+ holds: typeof Role;
3406
+ constructor(server: Server);
3407
+ /** @private */
3408
+ _add(data: Role$1 & {
3409
+ id: string;
3410
+ }): Role;
3411
+ /**
3412
+ * creates a new role in the server
3413
+ * @param name The name of the role to create
3414
+ * @returns
3415
+ */
3416
+ create(name: string): Promise<Role>;
3417
+ /**
3418
+ * deletes a role from the server
3419
+ * @param role the role to delete
3420
+ * @returns A promise that resolves when the role is deleted
3421
+ */
3422
+ delete(role: RoleResolvable): Promise<void>;
3423
+ /**
3424
+ *
3425
+ * @param role the role to edit
3426
+ * @param data data to edit the role with
3427
+ * @param data.permissions The permissions to set for the role, in the format { a: allow, d: deny }
3428
+ * @param data.name The name of the role
3429
+ * @param data.colour The color of the role, or `null` if no color is set
3430
+ * @param data.hoist Whether the role is displayed separately in the member list
3431
+ * @param data.rank The rank of the role, used for ordering
3432
+ * @param data.remove Fields to remove from the role
3433
+ * @returns Role
3434
+ * @throws {TypeError} If the role ID is invalid
3435
+ */
3436
+ edit(role: RoleResolvable, data: editableRole): Promise<Role>;
3437
+ }
3438
+
3439
+ type ServerMemberResolvable = ServerMember | User | Member | string;
3440
+ interface EditServerMemberOptions {
3441
+ nickname?: string;
3442
+ avatar?: string;
3443
+ roles?: string[];
3444
+ timeout?: Date | number;
3445
+ }
3446
+ declare class ServerMemberManager extends BaseManager<ServerMember, Member> {
3447
+ protected readonly server: Server;
3448
+ /** @private */
3449
+ holds: typeof ServerMember;
3450
+ constructor(server: Server);
3451
+ /**
3452
+ * edit selected member in the server
3453
+ * @param member The member to edit
3454
+ * @param options The options to edit the member with
3455
+ * @param options.nickname The nickname of the member to set
3456
+ * @param options.avatar The avatar of the member to set
3457
+ * @param options.roles The roles of the member to set
3458
+ * @returns A promise that resolves when the member is edited
3459
+ */
3460
+ edit(member: ServerMemberResolvable, options: EditServerMemberOptions): Promise<void>;
3461
+ /**
3462
+ * ban selected member in the server
3463
+ * @param member The member to ban
3464
+ * @param reason the reason for the ban
3465
+ * @returns A promise that resolves when the member is banned
3466
+ */
3467
+ ban(member: ServerMemberResolvable, reason?: string): Promise<void>;
3468
+ /**
3469
+ * kick selected member in the server
3470
+ * @param member The member to kick
3471
+ * @returns A promise that resolves when the member is kicked
3472
+ */
3473
+ kick(member: ServerMemberResolvable): Promise<void>;
3474
+ /**
3475
+ * unban selected member in the server
3476
+ * @param member The member to unban
3477
+ * @returns A promise that resolves when the member is unbanned
3478
+ */
3479
+ unban(member: ServerMemberResolvable): Promise<void>;
3480
+ /**
3481
+ * set timeout for a member in the server
3482
+ * @param member The member to set the timeout for
3483
+ * @param duration The duration of the timeout as a Date object
3484
+ * @returns A promise that resolves when the timeout is set
3485
+ */
3486
+ timeout(member: string, duration: Date): Promise<void>;
3487
+ /**
3488
+ * fetch a member from the server
3489
+ * @param member The member to fetch
3490
+ * @returns A promise that resolves with the fetched member
3491
+ */
3492
+ fetch(member: ServerMemberResolvable): Promise<ServerMember>;
3493
+ fetch(): Promise<Map<string, ServerMember>>;
3494
+ /**
3495
+ * resolves a member from a string or a member object
3496
+ * @param member The member to resolve
3497
+ * @returns The id of the member or null if it cannot be resolved
3498
+ */
3499
+ resolveId(member: ServerMemberResolvable): string | null;
3500
+ }
3501
+
3502
+ export { Attachment, AudioPlayer, type AudioPlayerEvents, type BadgeString, Badges, type BadgesResolvable, Base, BaseManager, BitField, type BitFieldResolvable, Category, Channel, ChannelManager, ChannelPermissions, type ChannelPermissionsResolvable, type ChannelPermissionsString, type ChannelResolvable, ChannelTypes, Client, Collection, type CreateChannelOptions, DEFAULT_CLIENT_OPTIONS, DEFAULT_PERMISSION_DM, DMChannel, type EditServerMemberOptions, type EditServerOptions, type Embed, type EmbedImage, type EmbedSpecial, type EmbedVideo, Emoji, Events, FullPermissions, GroupChannel, Invite, Mentions, type MessageEditOptions, MessageEmbed, MessageManager, type MessageOptions, type MessageQueryOptions, type MessageReply, type MessageResolvable, type MessageSearchOptions, MessageStruct, NotesChannel, type Overwrite, type PartialObject, 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, UserProfile, type UserResolvable, type Voice, VoiceChannel, WSEvents, apiUrl, cdnUrl, client, type voiceParticipant };