serchat.ts 0.1.4

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,2090 @@
1
+ // Generated by dts-bundle-generator v9.5.1
2
+
3
+ import { EventEmitter } from 'events';
4
+ import WebSocket$1 from 'ws';
5
+
6
+ export type JsonPrimitive = string | number | boolean | null;
7
+ export type JsonValue = JsonPrimitive | JsonObject | JsonArray;
8
+ export interface JsonObject {
9
+ [key: string]: JsonValue | undefined;
10
+ }
11
+ export type JsonArray = JsonValue[];
12
+ /** Base class for all errors thrown by the Serchat SDK. */
13
+ export declare class SerchatError extends Error {
14
+ constructor(message: string);
15
+ }
16
+ /** Represents an HTTP error response from the Serchat API.
17
+ *
18
+ * @example
19
+ * ```ts
20
+ * try {
21
+ * await client.sendMessage(serverId, channelId, 'Hello!');
22
+ * } catch (err) {
23
+ * if (err instanceof APIError) {
24
+ * console.error(`API returned ${err.status}:`, err.data);
25
+ * }
26
+ * }
27
+ * ```
28
+ */
29
+ export declare class APIError extends SerchatError {
30
+ /** HTTP status code. */
31
+ status: number;
32
+ /** Raw response body. */
33
+ data: JsonValue;
34
+ /** Response headers. */
35
+ headers: Record<string, string>;
36
+ /** Full fetch response object. */
37
+ response?: Response;
38
+ constructor(status: number, data: JsonValue, response?: Response);
39
+ }
40
+ /** Thrown when the API returns HTTP **400 Bad Request**. */
41
+ export declare class BadRequestError extends APIError {
42
+ constructor(data: JsonValue, response?: Response);
43
+ }
44
+ /** Thrown when the API returns HTTP **401 Unauthorized** (invalid or missing token). */
45
+ export declare class UnauthorizedError extends APIError {
46
+ constructor(data: JsonValue, response?: Response);
47
+ }
48
+ /** Thrown when the API returns HTTP **403 Forbidden** (insufficient permissions). */
49
+ export declare class ForbiddenError extends APIError {
50
+ constructor(data: JsonValue, response?: Response);
51
+ }
52
+ /** Thrown when the API returns HTTP **404 Not Found**. */
53
+ export declare class NotFoundError extends APIError {
54
+ constructor(data: JsonValue, response?: Response);
55
+ }
56
+ /** Thrown when the API returns HTTP **429 Too Many Requests**. Back off and retry later. */
57
+ export declare class RateLimitError extends APIError {
58
+ constructor(data: JsonValue, response?: Response);
59
+ }
60
+ /** Thrown when the API returns HTTP **500 Internal Server Error**. */
61
+ export declare class InternalServerError extends APIError {
62
+ constructor(data: JsonValue, response?: Response);
63
+ }
64
+ /** Thrown when the API returns HTTP **502 Bad Gateway**. */
65
+ export declare class BadGatewayError extends APIError {
66
+ constructor(data: JsonValue, response?: Response);
67
+ }
68
+ /** Thrown when the API returns HTTP **503 Service Unavailable**. */
69
+ export declare class ServiceUnavailableError extends APIError {
70
+ constructor(data: JsonValue, response?: Response);
71
+ }
72
+ /** Thrown when the API returns HTTP **504 Gateway Timeout**. */
73
+ export declare class GatewayTimeoutError extends APIError {
74
+ constructor(data: JsonValue, response?: Response);
75
+ }
76
+ export type Primitive = string | number | boolean | null | undefined;
77
+ export type SerializableParamValue = Primitive | SerializableParamValue[] | {
78
+ [key: string]: SerializableParamValue;
79
+ };
80
+ export interface Interceptors {
81
+ request: Array<(config: RequestInit & {
82
+ url: string;
83
+ }) => RequestInit & {
84
+ url: string;
85
+ }>;
86
+ response: Array<(response: Response) => Response | Promise<Response>>;
87
+ /**
88
+ * Interceptors called when a request fails.
89
+ *
90
+ * NOTE: Error interceptors can transform or replace the error, or throw a new one.
91
+ * They cannot "recover" from an error to return a successful response data.
92
+ */
93
+ error: Array<(error: APIError) => APIError | Promise<never>>;
94
+ }
95
+ export type APIResponse<T> = {
96
+ data: T;
97
+ };
98
+ export type EmptyResponse = {
99
+ data: null;
100
+ };
101
+ /**
102
+ * Utility to unwrap an API response, throwing if the data is null (e.g. 204 No Content).
103
+ */
104
+ export declare function unwrap<T>({ data }: APIResponse<T> | EmptyResponse): T;
105
+ /**
106
+ * Options for initializing a {@link RESTClient}.
107
+ */
108
+ export interface RESTOptions {
109
+ /** The base URL for all API requests. */
110
+ baseURL: string;
111
+ /** Default headers to include in every request. */
112
+ headers?: Record<string, string | undefined>;
113
+ /** Credentials mode for fetch requests. */
114
+ credentials?: RequestCredentials;
115
+ /** Default timeout in milliseconds for requests. */
116
+ timeout?: number;
117
+ /** Optional hook to transform response data. */
118
+ transformResponse?: (data: JsonValue, response: Response) => JsonValue;
119
+ /** Cookie name to read CSRF token from. */
120
+ csrfCookieName?: string;
121
+ /** Header name to use for CSRF token. */
122
+ csrfHeaderName?: string;
123
+ /** Controls redirect behaviour. Defaults to 'error' to prevent
124
+ * credential leakage to unexpected origins. */
125
+ redirect?: RequestRedirect;
126
+ /** If set, responses whose body exceeds this value (in bytes) are rejected
127
+ * mid-stream regardless of whether a Content-Length header is present. */
128
+ maxResponseBytes?: number;
129
+ /** Retry configuration for transient failures. */
130
+ retry?: {
131
+ /** Total number of attempts including the first. Defaults to 1 (no retry). */
132
+ maxAttempts: number;
133
+ retryOn?: number[];
134
+ backoff?: (attempt: number) => number;
135
+ };
136
+ }
137
+ /**
138
+ * A wrapper around the Fetch API for interacting with the Serchat REST API.
139
+ *
140
+ * Handles JSON serialization, error mapping, and authentication headers.
141
+ * Supports standard HTTP methods (GET, POST, PUT, PATCH, DELETE).
142
+ */
143
+ export declare class RESTClient {
144
+ private options;
145
+ /**
146
+ * Default headers applied to every request sent by this client.
147
+ */
148
+ private _headers;
149
+ private _pending;
150
+ readonly interceptors: Interceptors;
151
+ constructor(options: RESTOptions, pending?: Set<AbortController>);
152
+ /**
153
+ * Gets the current default headers.
154
+ */
155
+ get headers(): Readonly<Record<string, string>>;
156
+ /**
157
+ * Sets a default header to be included in every request.
158
+ * @param key - The header name.
159
+ * @param value - The header value, or undefined to remove it.
160
+ */
161
+ setDefaultHeader(key: string, value: string | undefined): void;
162
+ /**
163
+ * Creates a new scoped client that inherits configuration, headers, and interceptors
164
+ * but adds a path prefix.
165
+ *
166
+ * NOTE: Both request tracking (_pending) AND interceptors are shared
167
+ * between the parent and scoped instances. Mutations to either propagate
168
+ * in both directions. If you need an independent interceptor chain, call
169
+ * `.interceptors.request = [...parent.interceptors.request]` on the child
170
+ * after scoping.
171
+ */
172
+ scoped(pathPrefix: string): RESTClient;
173
+ /**
174
+ * Aborts all in-flight requests initiated by this client instance (and shared scoped instances).
175
+ */
176
+ abortAll(): void;
177
+ private buildURL;
178
+ private combineSignals;
179
+ private escapeRegExp;
180
+ private limitResponseBody;
181
+ private request;
182
+ private getCookie;
183
+ private serializeParams;
184
+ private mapError;
185
+ /**
186
+ * Performs a GET request.
187
+ *
188
+ * @param path - The API endpoint path.
189
+ * @param config - Optional query parameters and additional headers.
190
+ * @returns The parsed response data.
191
+ */
192
+ get<T = JsonValue>(path: string, config?: {
193
+ params?: Record<string, SerializableParamValue>;
194
+ headers?: Record<string, string | undefined>;
195
+ signal?: AbortSignal;
196
+ timeout?: number;
197
+ }): Promise<APIResponse<T> | EmptyResponse>;
198
+ private mutate;
199
+ /**
200
+ * Performs a POST request.
201
+ *
202
+ * @param path - The API endpoint path.
203
+ * @param body - The request body (JSON, FormData, Blob, ArrayBuffer, or ReadableStream).
204
+ * @param config - Additional headers.
205
+ * @returns The parsed response data.
206
+ */
207
+ post<T = JsonValue>(path: string, body?: JsonValue | FormData | Blob | ArrayBuffer | ReadableStream, config?: {
208
+ headers?: Record<string, string | undefined>;
209
+ signal?: AbortSignal;
210
+ timeout?: number;
211
+ }): Promise<APIResponse<T> | EmptyResponse>;
212
+ /**
213
+ * Performs a PUT request.
214
+ *
215
+ * @param path - The API endpoint path.
216
+ * @param body - The request body (JSON, FormData, Blob, ArrayBuffer, or ReadableStream).
217
+ * @param config - Additional headers.
218
+ * @returns The parsed response data.
219
+ */
220
+ put<T = JsonValue>(path: string, body?: JsonValue | FormData | Blob | ArrayBuffer | ReadableStream, config?: {
221
+ headers?: Record<string, string | undefined>;
222
+ signal?: AbortSignal;
223
+ timeout?: number;
224
+ }): Promise<APIResponse<T> | EmptyResponse>;
225
+ /**
226
+ * Performs a PATCH request.
227
+ *
228
+ * @param path - The API endpoint path.
229
+ * @param body - The request body (JSON, FormData, Blob, ArrayBuffer, or ReadableStream).
230
+ * @param config - Additional headers.
231
+ * @returns The parsed response data.
232
+ */
233
+ patch<T = JsonValue>(path: string, body?: JsonValue | FormData | Blob | ArrayBuffer | ReadableStream, config?: {
234
+ headers?: Record<string, string | undefined>;
235
+ signal?: AbortSignal;
236
+ timeout?: number;
237
+ }): Promise<APIResponse<T> | EmptyResponse>;
238
+ /**
239
+ * Performs a DELETE request.
240
+ *
241
+ * @param path - The API endpoint path.
242
+ * @param body - Optional body (JSON, FormData, Blob, ArrayBuffer, or ReadableStream).
243
+ * @param config - Additional headers.
244
+ * @returns The parsed response data.
245
+ */
246
+ delete<T = JsonValue>(path: string, body?: JsonValue | FormData | Blob | ArrayBuffer | ReadableStream, config?: {
247
+ headers?: Record<string, string | undefined>;
248
+ signal?: AbortSignal;
249
+ timeout?: number;
250
+ }): Promise<APIResponse<T> | EmptyResponse>;
251
+ }
252
+ /** Manages the bot's WebSocket connection to the Serchat gateway. */
253
+ export declare class WebSocketManager {
254
+ /** The underlying `ws` WebSocket instance, or `null` when disconnected. */
255
+ ws: WebSocket$1 | null;
256
+ private client;
257
+ /** Correlates request IDs with their resolve/reject handlers. */
258
+ private pendingRequests;
259
+ /**
260
+ * @param client - The owning {@link Client} instance.
261
+ */
262
+ constructor(client: Client);
263
+ private reconnectAttempts;
264
+ private reconnectTimeout;
265
+ private connectionPromise;
266
+ private connectionResolve;
267
+ private connectionReject;
268
+ private heartbeatInterval;
269
+ private heartbeatTimeout;
270
+ private heartbeatRequestId;
271
+ private readonly heartbeatIntervalMs;
272
+ private readonly heartbeatTimeoutMs;
273
+ /** Establishes the WebSocket connection. */
274
+ connect(): Promise<void>;
275
+ /**
276
+ * Internal method that creates and configures the raw WebSocket instance.
277
+ * Called by {@link connect} and by the reconnect scheduler.
278
+ */
279
+ private _connect;
280
+ private startHeartbeat;
281
+ private stopHeartbeat;
282
+ private sendHeartbeat;
283
+ private handleHeartbeatPong;
284
+ /** Reconnects with exponential backoff. */
285
+ private scheduleReconnect;
286
+ /** Sends a join_server event and waits for confirmation. */
287
+ joinServer(serverId: string): Promise<void>;
288
+ }
289
+ export interface InteractionResolvedUser {
290
+ _id: string;
291
+ id: string;
292
+ username: string;
293
+ displayName?: string;
294
+ profilePicture?: string;
295
+ isBot?: boolean;
296
+ }
297
+ export interface InteractionResolvedChannel {
298
+ _id: string;
299
+ id: string;
300
+ name: string;
301
+ type: string;
302
+ }
303
+ export interface InteractionResolvedRole {
304
+ _id: string;
305
+ id: string;
306
+ name: string;
307
+ color?: string;
308
+ }
309
+ export type InteractionValue = string | number | boolean | InteractionResolvedUser | InteractionResolvedChannel | InteractionResolvedRole;
310
+ export declare enum SlashCommandOptionType {
311
+ SUB_COMMAND = 1,
312
+ STRING = 3,
313
+ INTEGER = 4,
314
+ BOOLEAN = 5,
315
+ USER = 6,
316
+ CHANNEL = 7,
317
+ ROLE = 8
318
+ }
319
+ export interface SlashCommandOption extends JsonObject {
320
+ type: SlashCommandOptionType;
321
+ name: string;
322
+ description: string;
323
+ required?: boolean;
324
+ }
325
+ export interface SlashCommandData extends JsonObject {
326
+ id?: string;
327
+ name: string;
328
+ description: string;
329
+ options?: SlashCommandOption[];
330
+ shouldReply?: boolean;
331
+ }
332
+ export interface InteractionOption {
333
+ name: string;
334
+ value: InteractionValue;
335
+ type?: SlashCommandOptionType;
336
+ }
337
+ export type EmbedType = "rich" | "image" | "video" | "gifv" | "article" | "link";
338
+ export interface IEmbedField {
339
+ name: string;
340
+ value: string;
341
+ inline?: boolean;
342
+ }
343
+ export interface IEmbedAuthor {
344
+ name: string;
345
+ url?: string;
346
+ icon_url?: string;
347
+ }
348
+ export interface IEmbedFooter {
349
+ text: string;
350
+ icon_url?: string;
351
+ }
352
+ export interface IEmbedMedia {
353
+ url: string;
354
+ width?: number;
355
+ height?: number;
356
+ }
357
+ export interface IEmbedProvider {
358
+ name?: string;
359
+ url?: string;
360
+ }
361
+ export interface IEmbed {
362
+ type?: EmbedType;
363
+ color?: number;
364
+ title?: string;
365
+ url?: string;
366
+ description?: string;
367
+ timestamp?: string;
368
+ author?: IEmbedAuthor;
369
+ footer?: IEmbedFooter;
370
+ thumbnail?: IEmbedMedia;
371
+ image?: IEmbedMedia;
372
+ video?: IEmbedMedia;
373
+ provider?: IEmbedProvider;
374
+ fields?: IEmbedField[];
375
+ }
376
+ export interface IPollOption {
377
+ id: string;
378
+ text: string;
379
+ emoji?: string;
380
+ emojiType?: "unicode" | "custom";
381
+ emojiId?: string;
382
+ votes: string[];
383
+ }
384
+ export interface IPoll {
385
+ title: string;
386
+ options: IPollOption[];
387
+ multiSelect: boolean;
388
+ expiresAt?: string;
389
+ }
390
+ export type MessageAttachmentType = "image" | "video" | "audio" | "text" | "file";
391
+ export interface IMessageAttachment {
392
+ attachmentId: string;
393
+ type: MessageAttachmentType;
394
+ mimeType: string;
395
+ name: string;
396
+ size: number;
397
+ width?: number;
398
+ height?: number;
399
+ spoiler?: boolean;
400
+ }
401
+ export interface IMessageServer {
402
+ messageId: string;
403
+ _id?: string;
404
+ serverId: string;
405
+ channelId: string;
406
+ senderId: string;
407
+ senderUsername: string;
408
+ text: string;
409
+ createdAt: string;
410
+ replyToId?: string;
411
+ repliedTo?: {
412
+ messageId: string;
413
+ senderId: string;
414
+ senderUsername: string;
415
+ text: string;
416
+ };
417
+ isEdited: boolean;
418
+ isPinned: boolean;
419
+ isSticky: boolean;
420
+ isWebhook: boolean;
421
+ webhookUsername?: string;
422
+ webhookAvatarUrl?: string;
423
+ embeds?: IEmbed[];
424
+ attachments?: IMessageAttachment[];
425
+ interaction?: {
426
+ command: string;
427
+ options: {
428
+ name: string;
429
+ value: InteractionValue;
430
+ }[];
431
+ user: {
432
+ id: string;
433
+ username: string;
434
+ };
435
+ };
436
+ poll?: IPoll;
437
+ stickerId?: string;
438
+ senderIsBot?: boolean;
439
+ }
440
+ export interface IPollInput {
441
+ title: string;
442
+ options: {
443
+ text: string;
444
+ emoji?: string;
445
+ emojiType?: "unicode" | "custom";
446
+ emojiId?: string;
447
+ }[];
448
+ multiSelect?: boolean;
449
+ expiresAt?: string;
450
+ }
451
+ export interface ISendMessageRequest {
452
+ content?: string;
453
+ text?: string;
454
+ replyToId?: string;
455
+ noEmbedsUrls?: string[];
456
+ embeds?: IEmbed[];
457
+ attachments?: IMessageAttachment[];
458
+ interaction?: {
459
+ command: string;
460
+ options: {
461
+ name: string;
462
+ value: InteractionValue;
463
+ }[];
464
+ user: {
465
+ id: string;
466
+ username: string;
467
+ };
468
+ };
469
+ poll?: IPollInput | {
470
+ toJSON(): IPollInput;
471
+ };
472
+ }
473
+ export interface IMessageWithEmbeds {
474
+ embeds?: (IEmbed | {
475
+ toJSON(): IEmbed;
476
+ })[];
477
+ }
478
+ export interface IBulkDeleteMessagesRequest {
479
+ messageIds: string[];
480
+ }
481
+ export declare const PERMISSION_KEYS: readonly [
482
+ "viewChannels",
483
+ "sendMessages",
484
+ "addReactions",
485
+ "connect",
486
+ "manageMessages",
487
+ "deleteMessagesOfOthers",
488
+ "manageChannels",
489
+ "manageRoles",
490
+ "banMembers",
491
+ "kickMembers",
492
+ "manageInvites",
493
+ "manageServer",
494
+ "administrator",
495
+ "manageWebhooks",
496
+ "pingRolesAndEveryone",
497
+ "manageReactions",
498
+ "exportChannelMessages",
499
+ "bypassSlowmode",
500
+ "pinMessages",
501
+ "seeDeletedMessages",
502
+ "moderateMembers",
503
+ "manageStickers"
504
+ ];
505
+ export type PermissionKey = (typeof PERMISSION_KEYS)[number];
506
+ export type ServerPermissions = Partial<Record<PermissionKey, boolean>>;
507
+ export interface PollVoteUpdatePayload {
508
+ messageId: string;
509
+ poll: IPoll;
510
+ serverId?: string;
511
+ channelId?: string;
512
+ }
513
+ export interface Server {
514
+ _id: string;
515
+ id: string;
516
+ name: string;
517
+ ownerId: string;
518
+ icon?: string;
519
+ banner?: string;
520
+ }
521
+ export interface Channel {
522
+ _id: string;
523
+ id: string;
524
+ name: string;
525
+ type: string;
526
+ serverId: string;
527
+ categoryId?: string;
528
+ position: number;
529
+ }
530
+ export interface Category {
531
+ _id: string;
532
+ id: string;
533
+ name: string;
534
+ serverId: string;
535
+ position: number;
536
+ }
537
+ export interface Role {
538
+ _id: string;
539
+ id: string;
540
+ name: string;
541
+ color?: string;
542
+ position: number;
543
+ permissions: string;
544
+ }
545
+ export interface ServerMember {
546
+ _id: string;
547
+ userId: string;
548
+ serverId: string;
549
+ nickname?: string;
550
+ roles: string[];
551
+ }
552
+ export interface MessageUpdatePayload {
553
+ messageId: string;
554
+ serverId: string;
555
+ channelId: string;
556
+ text: string;
557
+ isEdited: boolean;
558
+ editedAt: string;
559
+ }
560
+ export interface MessageDeletePayload {
561
+ messageId: string;
562
+ serverId: string;
563
+ channelId: string;
564
+ hard?: boolean;
565
+ }
566
+ export interface MessageBulkDeletePayload {
567
+ messageIds: string[];
568
+ serverId: string;
569
+ channelId: string;
570
+ hard?: boolean;
571
+ }
572
+ export interface ReactionPayload {
573
+ messageId: string;
574
+ userId: string;
575
+ username: string;
576
+ emoji: string;
577
+ emojiType: "unicode" | "custom";
578
+ emojiId?: string;
579
+ messageType: "dm" | "server";
580
+ serverId?: string;
581
+ channelId?: string;
582
+ }
583
+ export interface MemberAddedPayload {
584
+ serverId: string;
585
+ userId: string;
586
+ username: string;
587
+ }
588
+ export interface MemberRemovedPayload {
589
+ serverId: string;
590
+ userId: string;
591
+ }
592
+ export interface MemberUpdatedPayload {
593
+ serverId: string;
594
+ userId: string;
595
+ member: ServerMember;
596
+ }
597
+ export interface ChannelCreatedPayload {
598
+ serverId: string;
599
+ channel: Channel;
600
+ }
601
+ export interface ChannelUpdatedPayload {
602
+ serverId: string;
603
+ channel: Channel;
604
+ }
605
+ export interface ChannelDeletedPayload {
606
+ serverId: string;
607
+ channelId: string;
608
+ }
609
+ export interface CategoryCreatedPayload {
610
+ serverId: string;
611
+ category: Category;
612
+ }
613
+ export interface CategoryUpdatedPayload {
614
+ serverId: string;
615
+ category: Category;
616
+ }
617
+ export interface CategoryDeletedPayload {
618
+ serverId: string;
619
+ categoryId: string;
620
+ }
621
+ export interface ServerUpdatedPayload {
622
+ serverId: string;
623
+ server: Partial<Server>;
624
+ senderId: string;
625
+ }
626
+ export interface ServerDeletedPayload {
627
+ serverId: string;
628
+ senderId: string;
629
+ }
630
+ export interface RoleCreatedPayload {
631
+ serverId: string;
632
+ role: Role;
633
+ }
634
+ export interface RoleUpdatedPayload {
635
+ serverId: string;
636
+ role: Role;
637
+ }
638
+ export interface RoleDeletedPayload {
639
+ serverId: string;
640
+ roleId: string;
641
+ }
642
+ export interface InviteCreatedPayload {
643
+ serverId: string;
644
+ code: string;
645
+ maxUses: number | null;
646
+ expiresAt: string | null;
647
+ senderId: string;
648
+ }
649
+ export interface InviteDeletedPayload {
650
+ serverId: string;
651
+ code: string;
652
+ senderId: string;
653
+ }
654
+ export interface InteractionCreatePayload {
655
+ command: string;
656
+ options: InteractionOption[];
657
+ serverId: string;
658
+ channelId: string;
659
+ senderId: string;
660
+ senderUsername: string;
661
+ senderPermissions?: ServerPermissions;
662
+ user?: {
663
+ id: string;
664
+ username: string;
665
+ };
666
+ invocationId?: string;
667
+ commandId?: string;
668
+ }
669
+ export interface ServerJoinedPayload {
670
+ serverId: string;
671
+ voiceStates?: Record<string, string[]>;
672
+ }
673
+ export interface PresenceSyncPayload {
674
+ online: Array<{
675
+ userId: string;
676
+ username: string;
677
+ status?: {
678
+ text: string;
679
+ emoji: string | null;
680
+ expiresAt: string | null;
681
+ updatedAt: string;
682
+ } | null;
683
+ }>;
684
+ }
685
+ export interface UserPresencePayload {
686
+ userId: string;
687
+ username: string;
688
+ status?: {
689
+ text: string;
690
+ emoji: string | null;
691
+ expiresAt: string | null;
692
+ updatedAt: string;
693
+ } | null;
694
+ }
695
+ export interface UserOfflinePayload {
696
+ userId: string;
697
+ username: string;
698
+ }
699
+ export interface UserUpdatedPayload {
700
+ userId: string;
701
+ username?: string;
702
+ displayName?: string | null;
703
+ profilePicture?: string | null;
704
+ bio?: string | null;
705
+ pronouns?: string | null;
706
+ badges?: string[];
707
+ oldUsername?: string;
708
+ newUsername?: string;
709
+ usernameFont?: string;
710
+ usernameGradient?: {
711
+ enabled: boolean;
712
+ colors: string[];
713
+ angle: number;
714
+ };
715
+ usernameGlow?: {
716
+ enabled: boolean;
717
+ color: string;
718
+ intensity: number;
719
+ };
720
+ settings?: {
721
+ muteNotifications?: boolean;
722
+ useDiscordStyleMessages?: boolean;
723
+ ownMessagesAlign?: "left" | "right";
724
+ otherMessagesAlign?: "left" | "right";
725
+ showYouLabel?: boolean;
726
+ ownMessageColor?: string;
727
+ otherMessageColor?: string;
728
+ disableCustomUsernameFonts?: boolean;
729
+ disableCustomUsernameColors?: boolean;
730
+ disableCustomUsernameGlow?: boolean;
731
+ };
732
+ senderId?: string;
733
+ }
734
+ export interface MemberBannedPayload {
735
+ serverId: string;
736
+ userId: string;
737
+ }
738
+ export interface MemberUnbannedPayload {
739
+ serverId: string;
740
+ userId: string;
741
+ }
742
+ export interface OwnershipTransferredPayload {
743
+ serverId: string;
744
+ oldOwnerId: string;
745
+ newOwnerId: string;
746
+ senderId?: string;
747
+ }
748
+ export interface ChannelsReorderedPayload {
749
+ serverId: string;
750
+ channelPositions: {
751
+ channelId: string;
752
+ position: number;
753
+ }[];
754
+ senderId?: string;
755
+ }
756
+ export interface CategoriesReorderedPayload {
757
+ serverId: string;
758
+ categoryPositions: {
759
+ categoryId: string;
760
+ position: number;
761
+ }[];
762
+ senderId?: string;
763
+ }
764
+ export interface RolesReorderedPayload {
765
+ serverId: string;
766
+ rolePositions: {
767
+ roleId: string;
768
+ position: number;
769
+ }[];
770
+ senderId?: string;
771
+ }
772
+ export interface ChannelPermissionsUpdatedPayload {
773
+ serverId: string;
774
+ channelId: string;
775
+ permissions: Record<string, Record<string, boolean>>;
776
+ senderId?: string;
777
+ }
778
+ export interface CategoryPermissionsUpdatedPayload {
779
+ serverId: string;
780
+ categoryId: string;
781
+ permissions: Record<string, Record<string, boolean>>;
782
+ senderId?: string;
783
+ }
784
+ /**
785
+ * Builder for constructing rich embed objects.
786
+ *
787
+ * @example
788
+ * ```ts
789
+ * const embed = new EmbedBuilder()
790
+ * .setTitle('Hello!')
791
+ * .setDescription('This is a rich embed.')
792
+ * .setColor(0x5865f2);
793
+ *
794
+ * await client.sendMessage(serverId, channelId, embed);
795
+ * ```
796
+ */
797
+ export declare class EmbedBuilder {
798
+ private data;
799
+ /**
800
+ * @param data - Optional seed data to pre-populate the embed.
801
+ * Useful when editing an existing embed returned from the API.
802
+ */
803
+ constructor(data?: IEmbed);
804
+ /** Sets the embed title. */
805
+ setTitle(title: string): this;
806
+ /** Sets the embed description (supports markdown). */
807
+ setDescription(description: string): this;
808
+ /** Sets the URL the title links to. */
809
+ setURL(url: string): this;
810
+ /** Sets the sidebar accent colour. */
811
+ setColor(color: number): this;
812
+ /** Sets the embed timestamp. Defaults to now. */
813
+ setTimestamp(timestamp?: string | number | Date): this;
814
+ /** Sets the embed author. */
815
+ setAuthor(author: IEmbedAuthor | null): this;
816
+ /** Sets the embed footer. */
817
+ setFooter(footer: IEmbedFooter | null): this;
818
+ /** Sets the embed thumbnail. */
819
+ setThumbnail(url: string | null, width?: number, height?: number): this;
820
+ /** Sets the main embed image. */
821
+ setImage(url: string | null, width?: number, height?: number): this;
822
+ /** Appends fields to the embed. */
823
+ addFields(...fields: IEmbedField[]): this;
824
+ /** Replaces all fields. */
825
+ setFields(...fields: IEmbedField[]): this;
826
+ /** Serialises the embed to a plain JSON object. */
827
+ toJSON(): IEmbed;
828
+ }
829
+ /**
830
+ * Represents a message received from the Serchat server.
831
+ *
832
+ * Wraps the raw API payload and exposes helper methods for common actions
833
+ * like replying, reacting, and deleting.
834
+ */
835
+ export declare class Message implements IMessageServer {
836
+ /** Primary message identifier. Normalised from either `messageId` or `_id`. */
837
+ messageId: string;
838
+ /** Legacy MongoDB `_id` field, present on older messages. */
839
+ _id?: string;
840
+ /** ID of the server this message belongs to. */
841
+ serverId: string;
842
+ /** ID of the channel this message was posted in. */
843
+ channelId: string;
844
+ /** ID of the user who sent the message. */
845
+ senderId: string;
846
+ /** Display name of the user who sent the message. */
847
+ senderUsername: string;
848
+ /** Plain text content of the message. */
849
+ text: string;
850
+ /** ISO 8601 timestamp of when the message was created. */
851
+ createdAt: string;
852
+ /** ID of the message this message is replying to, if any. */
853
+ replyToId?: string;
854
+ /** Partial snapshot of the message being replied to, if any. */
855
+ repliedTo?: {
856
+ messageId: string;
857
+ senderId: string;
858
+ senderUsername: string;
859
+ text: string;
860
+ };
861
+ /** Whether the message has been edited since it was first sent. */
862
+ isEdited: boolean;
863
+ /** Whether the message is pinned in its channel. */
864
+ isPinned: boolean;
865
+ /** Whether the message is stickied at the top of the channel. */
866
+ isSticky: boolean;
867
+ /** Whether the message was sent via a webhook integration. */
868
+ isWebhook: boolean;
869
+ /** Display name override for webhook messages. */
870
+ webhookUsername?: string;
871
+ /** Avatar URL override for webhook messages. */
872
+ webhookAvatarUrl?: string;
873
+ /** Rich embed objects attached to this message. */
874
+ embeds?: IEmbed[];
875
+ /** Structured file attachments on this message. */
876
+ attachments?: IMessageAttachment[];
877
+ /** Interaction metadata if this message was sent in response to a slash command. */
878
+ interaction?: {
879
+ command: string;
880
+ options: {
881
+ name: string;
882
+ value: InteractionValue;
883
+ }[];
884
+ user: {
885
+ id: string;
886
+ username: string;
887
+ };
888
+ };
889
+ /** Poll attached to this message, if any. */
890
+ poll?: IPoll;
891
+ /** Sticker attached to this message, if any. */
892
+ stickerId?: string;
893
+ /** Whether the message sender is a bot account. */
894
+ senderIsBot: boolean;
895
+ private client;
896
+ constructor(client: Client, data: IMessageServer);
897
+ /** Sends a reply to this message. */
898
+ reply(content: string | ISendMessageRequest | EmbedBuilder): Promise<Message>;
899
+ /** Adds a reaction to this message. */
900
+ react(emoji: string): Promise<void>;
901
+ /** Deletes this message. */
902
+ delete(): Promise<void>;
903
+ /** Votes on a poll option in this message. */
904
+ vote(optionId: string): Promise<void>;
905
+ /** Checks if this message has any attachments. */
906
+ hasAttachments(): boolean;
907
+ /** Resolves the full public download URL of the given attachment. */
908
+ getAttachmentUrl(attachment: IMessageAttachment): string;
909
+ /** Filters and returns attachments belonging to a specific file/media type. */
910
+ getAttachmentsByType(type: MessageAttachmentType): IMessageAttachment[];
911
+ /** Returns whether the message plain text is empty or consists only of whitespace. */
912
+ get isEmpty(): boolean;
913
+ /** Checks if this message was sent by the currently authenticated client user. */
914
+ get isOwnMessage(): boolean;
915
+ /** Checks if this message was sent by any bot account (including this client). */
916
+ get isFromBot(): boolean;
917
+ }
918
+ /** Callback used by {@link MermaidBuilder.subgraph} to build nested content. */
919
+ export type MermaidCallback = (b: MermaidBuilder) => MermaidBuilder;
920
+ /**
921
+ * Builder for constructing Mermaid diagrams.
922
+ *
923
+ * @example
924
+ * ```ts
925
+ * const diagram = new MermaidBuilder('graph TD')
926
+ * .node('A', 'Start')
927
+ * .node('B', 'Stop')
928
+ * .edge('A', 'B', 'Go to')
929
+ * .build();
930
+ * ```
931
+ */
932
+ export declare class MermaidBuilder {
933
+ private content;
934
+ private indentation;
935
+ /**
936
+ * @param header - The diagram type header (e.g., 'graph TD', 'sequenceDiagram').
937
+ */
938
+ constructor(header?: string);
939
+ private get indent();
940
+ /**
941
+ * Adds a raw line to the diagram.
942
+ */
943
+ add(line: string): this;
944
+ /**
945
+ * Adds a node to the diagram.
946
+ *
947
+ * @param id - The node ID.
948
+ * @param text - Optional display text.
949
+ * @param shape - Optional shape: 'box', 'round', 'stadium', 'subroutine', 'cylindrical', 'circle', 'asymmetric', 'rhombus', 'hexagon'.
950
+ */
951
+ node(id: string, text?: string, shape?: "box" | "round" | "stadium" | "subroutine" | "cylindrical" | "circle" | "asymmetric" | "rhombus" | "hexagon"): this;
952
+ /**
953
+ * Adds an edge between two nodes.
954
+ *
955
+ * @param from - Starting node ID.
956
+ * @param to - Ending node ID.
957
+ * @param text - Optional label text.
958
+ * @param type - Edge style: 'arrow' (-->), 'line' (---), 'dotted' (-.->), 'thick' (==>).
959
+ */
960
+ edge(from: string, to: string, text?: string, type?: "arrow" | "line" | "dotted" | "thick"): this;
961
+ /**
962
+ * Adds a subgraph.
963
+ *
964
+ * @param name - Subgraph display name.
965
+ * @param callback - Function to build subgraph content.
966
+ */
967
+ subgraph(name: string, callback: MermaidCallback): this;
968
+ /**
969
+ * Sets a style for a node or class.
970
+ */
971
+ style(id: string, style: string): this;
972
+ /**
973
+ * Adds a comment.
974
+ */
975
+ comment(text: string): this;
976
+ /**
977
+ * Returns the final Mermaid string.
978
+ */
979
+ build(): string;
980
+ /**
981
+ * Alias of {@link build}.
982
+ */
983
+ toString(): string;
984
+ }
985
+ /** Callback used by {@link MessageBuilder.p} to build inline content. */
986
+ export type InlineCallback = (t: InlineBuilder) => InlineBuilder;
987
+ /**
988
+ * Builder for constructing inline Serchat markdown.
989
+ *
990
+ * Methods append text to a buffer and return `this` for chaining.
991
+ * Call {@link build} to get the final string.
992
+ *
993
+ * @example
994
+ * ```ts
995
+ * const text = new InlineBuilder()
996
+ * .text('Hello, ')
997
+ * .bold('world')
998
+ * .text('!')
999
+ * .build();
1000
+ * // => 'Hello, **world**!'
1001
+ * ```
1002
+ */
1003
+ export declare class InlineBuilder {
1004
+ protected content: string;
1005
+ /**
1006
+ * @param initialContent - Optional string to seed the builder with.
1007
+ */
1008
+ constructor(initialContent?: string);
1009
+ protected wrap(start: string, end: string, text: string): this;
1010
+ /** Appends plain text. */
1011
+ text(text: string): this;
1012
+ /** Appends italic text. */
1013
+ italic(text: string): this;
1014
+ /** Appends bold text. */
1015
+ bold(text: string): this;
1016
+ /** Appends bold-italic text. */
1017
+ boldItalic(text: string): this;
1018
+ /** Appends strikethrough text. */
1019
+ strikethrough(text: string): this;
1020
+ /** Appends underlined text. */
1021
+ underline(text: string): this;
1022
+ /** Appends double-underlined text (`___text___`). */
1023
+ doubleUnderline(text: string): this;
1024
+ /** Appends curly-underlined text (`_~text~_`). */
1025
+ curlyUnderline(text: string): this;
1026
+ /** Appends jagged-underlined text (`_^text^_`). */
1027
+ jaggedUnderline(text: string): this;
1028
+ /** Appends doubly curly-underlined text (`_~~text~~_`). */
1029
+ doubleCurlyUnderline(text: string): this;
1030
+ /** Appends dashed-underlined text (`_-text-_`). */
1031
+ dashedUnderline(text: string): this;
1032
+ /** Appends dotted-underlined text (`_.text._`). */
1033
+ dottedUnderline(text: string): this;
1034
+ /** Appends rhythm-underlined text (`_-.text.-_`). */
1035
+ rhythmUnderline(text: string): this;
1036
+ /** Appends spoiler text. */
1037
+ spoiler(text: string): this;
1038
+ /** Appends inline code. */
1039
+ inlineCode(text: string): this;
1040
+ /** Appends inline LaTeX. */
1041
+ inlineLatex(text: string): this;
1042
+ /**
1043
+ * Appends superscript text (`^text^`).
1044
+ *
1045
+ * @example `.superscript('2')` → `^2^`
1046
+ */
1047
+ superscript(text: string): this;
1048
+ /**
1049
+ * Appends subscript text (`~text~`).
1050
+ *
1051
+ * @example `.subscript('2')` → `~2~`
1052
+ */
1053
+ subscript(text: string): this;
1054
+ /**
1055
+ * Appends stacked superscript/subscript (`^sup|sub^`).
1056
+ *
1057
+ * @param sup - The text displayed above (superscript position).
1058
+ * @param sub - The text displayed below (subscript position).
1059
+ *
1060
+ * @example `.stackedScript('top', 'bottom')` → `^top|bottom^`
1061
+ */
1062
+ stackedScript(sup: string, sub: string): this;
1063
+ /** Appends a hyperlink. */
1064
+ link(text: string, url: string): this;
1065
+ /** Appends a user mention. */
1066
+ userMention(userId: string): this;
1067
+ /** Appends a role mention. */
1068
+ roleMention(roleId: string): this;
1069
+ /** Appends a channel mention. */
1070
+ channelMention(serverId: string, channelId: string): this;
1071
+ /** Appends an \@everyone mention. */
1072
+ everyoneMention(): this;
1073
+ /** Appends a server emoji. */
1074
+ customEmoji(id: string): this;
1075
+ /**
1076
+ * Returns the accumulated markdown string.
1077
+ *
1078
+ * @returns The final formatted string.
1079
+ */
1080
+ build(): string;
1081
+ /**
1082
+ * Alias of {@link build} - allows the builder to be used directly in
1083
+ * template literals.
1084
+ *
1085
+ * @returns The final formatted string.
1086
+ */
1087
+ toString(): string;
1088
+ }
1089
+ /** Builder for constructing full chat messages with block elements.
1090
+ *
1091
+ * @example
1092
+ * ```ts
1093
+ * const msg = new MessageBuilder()
1094
+ * .h1('Release Notes')
1095
+ * .p('Version 1.0 is here!')
1096
+ * .codeBlock('ts', 'console.log("hello")')
1097
+ * .build();
1098
+ *
1099
+ * await client.sendMessage(serverId, channelId, msg);
1100
+ * ```
1101
+ */
1102
+ export declare class MessageBuilder extends InlineBuilder {
1103
+ /** Appends a paragraph or inline content. */
1104
+ p(content: string | InlineCallback): this;
1105
+ /** Appends an H1 heading. */
1106
+ h1(text: string): this;
1107
+ /** Appends an H2 heading. */
1108
+ h2(text: string): this;
1109
+ /** Appends an H3 heading. */
1110
+ h3(text: string): this;
1111
+ /** Appends a horizontal rule. */
1112
+ hr(): this;
1113
+ /** Appends a code block. */
1114
+ codeBlock(language: string, text: string, options?: {
1115
+ label?: string;
1116
+ }): this;
1117
+ /** Appends a blockquote. */
1118
+ blockquote(text: string, options?: {
1119
+ label?: string;
1120
+ }): this;
1121
+ /** Appends an admonition block. */
1122
+ admonition(type: string, text: string, options?: {
1123
+ label?: string;
1124
+ title?: string;
1125
+ }): this;
1126
+ /** Appends subtext. */
1127
+ subtext(text: string): this;
1128
+ /** Appends a LaTeX block. */
1129
+ latexBlock(text: string, options?: {
1130
+ label?: string;
1131
+ }): this;
1132
+ /** Appends a heading at the given level. */
1133
+ heading(level: 1 | 2 | 3, text: string): this;
1134
+ /** Alias of {@link hr}. */
1135
+ thematicBreak(): this;
1136
+ /** Appends raw text. */
1137
+ append(text: string): this;
1138
+ /** Appends text with a newline. */
1139
+ appendLine(text?: string): this;
1140
+ /** Appends an unordered list. */
1141
+ unorderedList(items: string[], depth?: number): this;
1142
+ /** Appends an ordered list. */
1143
+ orderedList(items: string[], depth?: number): this;
1144
+ /** Appends a checklist. */
1145
+ checklist(items: {
1146
+ text: string;
1147
+ checked: boolean;
1148
+ }[], depth?: number): this;
1149
+ /** Appends a table. */
1150
+ table(headers: string[], rows: string[][]): this;
1151
+ /** Appends a mermaid diagram. */
1152
+ mermaid(content: string | MermaidBuilder | MermaidCallback): this;
1153
+ /** Appends a file. */
1154
+ file(url: string): this;
1155
+ }
1156
+ /**
1157
+ * Represents a slash-command interaction received from the Serchat gateway.
1158
+ *
1159
+ * Provides typed accessors for each option type and a {@link reply} method
1160
+ * for responding to the interaction in the originating channel.
1161
+ */
1162
+ export declare class Interaction {
1163
+ /** Name of the slash command that was invoked (e.g. `"ping"`). */
1164
+ command: string;
1165
+ /** Unique ID of the slash command, if provided. */
1166
+ commandId?: string;
1167
+ /** Raw list of option values provided by the user. */
1168
+ options: InteractionOption[];
1169
+ /** ID of the server where the interaction occurred. */
1170
+ serverId: string;
1171
+ /** ID of the channel where the interaction occurred. */
1172
+ channelId: string;
1173
+ /** ID of the user who triggered the interaction. */
1174
+ senderId: string;
1175
+ /** Display name of the user who triggered the interaction. */
1176
+ senderUsername: string;
1177
+ /** Permission set of the invoking user at the time of the interaction. */
1178
+ permissions: ServerPermissions;
1179
+ /** Unique ID for correlating this invocation across events, if provided. */
1180
+ invocationId?: string;
1181
+ private client;
1182
+ constructor(client: Client, data: InteractionCreatePayload);
1183
+ /** Retrieves a raw option by name. */
1184
+ getOption(name: string): InteractionOption | undefined;
1185
+ private getTypedOption;
1186
+ /** Returns the string value of a named option. */
1187
+ getString(name: string): string | undefined;
1188
+ /** Returns the integer value of a named option. */
1189
+ getInteger(name: string): number | undefined;
1190
+ /** Returns the boolean value of a named option. */
1191
+ getBoolean(name: string): boolean | undefined;
1192
+ /** Returns the user ID value of a named user option. */
1193
+ getUser(name: string): string | undefined;
1194
+ /** Returns the channel ID value of a named channel option. */
1195
+ getChannel(name: string): string | undefined;
1196
+ /** Returns the role ID value of a named role option. */
1197
+ getRole(name: string): string | undefined;
1198
+ /** Checks if the user has a specific permission. */
1199
+ hasPermission(permission: PermissionKey): boolean;
1200
+ /** Sends a reply to this interaction. */
1201
+ reply(content: string | ISendMessageRequest | EmbedBuilder | IMessageWithEmbeds | MessageBuilder): Promise<Message>;
1202
+ }
1203
+ /** Union of supported slash-command option value types. */
1204
+ export type CommandOptionType = "string" | "integer" | "boolean" | "user" | "channel" | "role";
1205
+ /** Descriptor for a single slash-command option. */
1206
+ export interface CommandOption {
1207
+ /** The type of value this option accepts. */
1208
+ type: CommandOptionType;
1209
+ /** Short description shown in the command picker UI. */
1210
+ description: string;
1211
+ /** Whether the user must provide this option. Defaults to `false`. */
1212
+ required?: boolean;
1213
+ }
1214
+ /**
1215
+ * Abstract base class for all bot slash commands.
1216
+ *
1217
+ * @example
1218
+ * ```ts
1219
+ * class PingCommand extends BotCommand {
1220
+ * name = 'ping';
1221
+ * description = 'Replies with Pong!';
1222
+ *
1223
+ * async execute(interaction: Interaction) {
1224
+ * await interaction.reply('Pong!');
1225
+ * }
1226
+ * }
1227
+ * ```
1228
+ */
1229
+ export declare abstract class BotCommand {
1230
+ /** The unique command ID populated after registration sync. */
1231
+ id?: string;
1232
+ /** The command name as it appears in the slash-command picker (lowercase, no spaces). */
1233
+ abstract name: string;
1234
+ /** Short description displayed in the command picker UI. */
1235
+ abstract description: string;
1236
+ /** Optional map of option names to their descriptors. */
1237
+ options?: Record<string, CommandOption>;
1238
+ /** Called when a user invokes this command. */
1239
+ abstract execute(interaction: Interaction): Promise<void>;
1240
+ /** Serialises the command to the API payload format. */
1241
+ toJSON(): SlashCommandData;
1242
+ private mapType;
1243
+ }
1244
+ /**
1245
+ * Manages slash-command registration, deduplication, and dispatching for a bot.
1246
+ *
1247
+ * Accessed via {@link Client.commands} or {@link Client.application}.
1248
+ *
1249
+ * @example
1250
+ * ```ts
1251
+ * client.commands.register(new PingCommand());
1252
+ * await client.commands.sync(); // push commands to the API
1253
+ * ```
1254
+ */
1255
+ export declare class ApplicationCommandManager {
1256
+ private rest;
1257
+ /** Map of command name → {@link BotCommand} instance. */
1258
+ private registeredCommands;
1259
+ /** Map of command ID → {@link BotCommand} instance. */
1260
+ private registeredCommandsById;
1261
+ /**
1262
+ * @param rest - Authenticated REST client used to push commands to the API.
1263
+ */
1264
+ constructor(rest: RESTClient);
1265
+ /**
1266
+ * Registers a {@link BotCommand} locally so it can be dispatched when an
1267
+ * interaction arrives.
1268
+ *
1269
+ * @param command - The command to register.
1270
+ * @throws {Error} If a command with the same name is already registered.
1271
+ */
1272
+ register(command: BotCommand): void;
1273
+ /**
1274
+ * Handles an incoming interaction by looking up the matching registered
1275
+ * command and calling its `execute` method.
1276
+ *
1277
+ * @param interaction - The interaction to dispatch.
1278
+ */
1279
+ handleInteraction(interaction: Interaction): Promise<void>;
1280
+ /**
1281
+ * Returns the JSON representation of all locally registered commands,
1282
+ * suitable for passing to {@link set}.
1283
+ *
1284
+ * @returns Array of {@link SlashCommandData} objects.
1285
+ */
1286
+ getCommandsData(): SlashCommandData[];
1287
+ /**
1288
+ * Pushes all locally registered commands to the API, replacing the
1289
+ * current command list. Equivalent to calling
1290
+ * `set(this.getCommandsData())`.
1291
+ */
1292
+ sync(): Promise<void>;
1293
+ /**
1294
+ * Replaces the bot's command list on the API with the provided commands.
1295
+ *
1296
+ * @param commands - Array of command definitions to upload.
1297
+ * @returns The updated list of commands as confirmed by the API.
1298
+ * @throws {Error} If `commands` contains duplicate command names.
1299
+ */
1300
+ set(commands: SlashCommandData[]): Promise<SlashCommandData[]>;
1301
+ }
1302
+ export interface ISticker {
1303
+ id: string;
1304
+ name: string;
1305
+ imageUrl: string;
1306
+ serverId: string;
1307
+ createdBy: string;
1308
+ createdAt?: string;
1309
+ }
1310
+ export declare class StickerManager {
1311
+ private rest;
1312
+ constructor(rest: RESTClient);
1313
+ /**
1314
+ * Gets all globally accessible stickers for the authenticated user.
1315
+ */
1316
+ getStickers(): Promise<ISticker[]>;
1317
+ /**
1318
+ * Gets all stickers for a specific server.
1319
+ */
1320
+ getServerStickers(serverId: string): Promise<ISticker[]>;
1321
+ /**
1322
+ * Creates a new sticker in a server.
1323
+ */
1324
+ createSticker(serverId: string, formData: FormData): Promise<ISticker>;
1325
+ /**
1326
+ * Deletes a sticker from a server.
1327
+ */
1328
+ deleteSticker(serverId: string, stickerId: string): Promise<void>;
1329
+ }
1330
+ export interface IWebhook {
1331
+ _id: string;
1332
+ serverId?: string;
1333
+ channelId?: string;
1334
+ name: string;
1335
+ token: string;
1336
+ avatarUrl?: string;
1337
+ createdBy: string;
1338
+ createdAt?: string;
1339
+ }
1340
+ export interface ICreateWebhookRequest {
1341
+ name: string;
1342
+ avatarUrl?: string;
1343
+ }
1344
+ export interface IExecuteWebhookRequest {
1345
+ content?: string;
1346
+ username?: string;
1347
+ avatarUrl?: string;
1348
+ noEmbedsUrls?: string[];
1349
+ embeds?: IEmbed[];
1350
+ }
1351
+ export interface IExecuteWebhookResponse {
1352
+ id: string;
1353
+ timestamp: string;
1354
+ }
1355
+ export interface IWebhookAvatarResponse {
1356
+ avatarUrl: string;
1357
+ }
1358
+ export declare class WebhookManager {
1359
+ private rest;
1360
+ constructor(rest: RESTClient);
1361
+ private embedToJSON;
1362
+ /**
1363
+ * Gets webhooks for a channel.
1364
+ */
1365
+ getWebhooks(serverId: string, channelId: string): Promise<IWebhook[]>;
1366
+ /**
1367
+ * Creates a webhook for a channel.
1368
+ */
1369
+ createWebhook(serverId: string, channelId: string, data: ICreateWebhookRequest): Promise<IWebhook>;
1370
+ /**
1371
+ * Deletes a webhook from a channel.
1372
+ */
1373
+ deleteWebhook(serverId: string, channelId: string, webhookId: string): Promise<void>;
1374
+ /**
1375
+ * Uploads or replaces a webhook avatar.
1376
+ */
1377
+ uploadWebhookAvatar(serverId: string, channelId: string, webhookId: string, avatar: Blob): Promise<IWebhookAvatarResponse>;
1378
+ /**
1379
+ * Executes a webhook using its public token.
1380
+ */
1381
+ executeWebhook(token: string, data: IExecuteWebhookRequest): Promise<IExecuteWebhookResponse>;
1382
+ /**
1383
+ * Edits a previously sent webhook message.
1384
+ */
1385
+ editWebhookMessage(token: string, messageId: string, data: IExecuteWebhookRequest): Promise<void>;
1386
+ /**
1387
+ * Deletes a previously sent webhook message.
1388
+ */
1389
+ deleteWebhookMessage(token: string, messageId: string): Promise<void>;
1390
+ }
1391
+ export type CallbackNames<K extends string> = K extends "messageCreate" ? "onMessage" | "onMessageCreate" : K extends "interactionCreate" ? "onInteraction" | "onInteractionCreate" : `on${Capitalize<K>}`;
1392
+ export type AnyArray = readonly (string | number | boolean | symbol | bigint | object | null | undefined)[];
1393
+ export type EventSubscriber<Events extends Record<keyof Events, AnyArray>> = {
1394
+ [K in keyof Events & string as CallbackNames<K>]?: (...args: Events[K]) => void | Promise<void>;
1395
+ };
1396
+ export interface EventBusOptions<Events extends Record<keyof Events, AnyArray>> {
1397
+ logger?: {
1398
+ error(message: string): void;
1399
+ };
1400
+ errorEvent?: keyof Events;
1401
+ }
1402
+ /**
1403
+ * Event dispatcher to fan gateway events out.
1404
+ */
1405
+ export declare class EventBus<Events extends Record<keyof Events, AnyArray>> {
1406
+ private listeners;
1407
+ private logger?;
1408
+ private errorEvent?;
1409
+ private subscriberListeners;
1410
+ constructor(options?: EventBusOptions<Events>);
1411
+ /**
1412
+ * Registers all event handler methods on an object.
1413
+ */
1414
+ register(subscriber: EventSubscriber<Events>): void;
1415
+ /**
1416
+ * Unregisters all event handler methods previously registered for the given subscriber.
1417
+ */
1418
+ unregister(subscriber: EventSubscriber<Events>): void;
1419
+ private getEventNamesForCallback;
1420
+ private getMethods;
1421
+ on<K extends keyof Events>(event: K, listener: (...args: Events[K]) => void | Promise<void>): this;
1422
+ once<K extends keyof Events>(event: K, listener: (...args: Events[K]) => void | Promise<void>): this;
1423
+ off<K extends keyof Events>(event: K, listener: (...args: Events[K]) => void | Promise<void>): this;
1424
+ emit<K extends keyof Events>(event: K, ...args: Events[K]): boolean;
1425
+ private handleListenerError;
1426
+ private emitError;
1427
+ }
1428
+ export interface ClientUser {
1429
+ id: string;
1430
+ username: string;
1431
+ displayName: string | null;
1432
+ profilePicture: string | null;
1433
+ status?: string;
1434
+ }
1435
+ export interface ClientModule {
1436
+ name: string;
1437
+ register?(client: Client): void | Promise<void>;
1438
+ onReady?(user: ClientUser): void | Promise<void>;
1439
+ onMessage?(message: Message): void | Promise<void>;
1440
+ onMessageCreate?(message: Message): void | Promise<void>;
1441
+ onMessageUpdate?(payload: MessageUpdatePayload): void | Promise<void>;
1442
+ onMessageDelete?(payload: MessageDeletePayload): void | Promise<void>;
1443
+ onMessageBulkDelete?(payload: MessageBulkDeletePayload): void | Promise<void>;
1444
+ onInteraction?(interaction: Interaction): void | Promise<void>;
1445
+ onInteractionCreate?(interaction: Interaction): void | Promise<void>;
1446
+ onMessageReactionAdd?(payload: ReactionPayload): void | Promise<void>;
1447
+ onMessageReactionRemove?(payload: ReactionPayload): void | Promise<void>;
1448
+ onPollVoteUpdate?(payload: PollVoteUpdatePayload): void | Promise<void>;
1449
+ onServerMemberAdd?(payload: MemberAddedPayload): void | Promise<void>;
1450
+ onServerMemberRemove?(payload: MemberRemovedPayload): void | Promise<void>;
1451
+ onServerMemberUpdate?(payload: MemberUpdatedPayload): void | Promise<void>;
1452
+ onChannelCreate?(payload: ChannelCreatedPayload): void | Promise<void>;
1453
+ onChannelUpdate?(payload: ChannelUpdatedPayload): void | Promise<void>;
1454
+ onChannelDelete?(payload: ChannelDeletedPayload): void | Promise<void>;
1455
+ onChannelsReordered?(payload: ChannelsReorderedPayload): void | Promise<void>;
1456
+ onCategoryCreate?(payload: CategoryCreatedPayload): void | Promise<void>;
1457
+ onCategoryUpdate?(payload: CategoryUpdatedPayload): void | Promise<void>;
1458
+ onCategoryDelete?(payload: CategoryDeletedPayload): void | Promise<void>;
1459
+ onCategoriesReordered?(payload: CategoriesReorderedPayload): void | Promise<void>;
1460
+ onChannelPermissionsUpdate?(payload: ChannelPermissionsUpdatedPayload): void | Promise<void>;
1461
+ onCategoryPermissionsUpdate?(payload: CategoryPermissionsUpdatedPayload): void | Promise<void>;
1462
+ onServerUpdate?(payload: ServerUpdatedPayload): void | Promise<void>;
1463
+ onServerDelete?(payload: ServerDeletedPayload): void | Promise<void>;
1464
+ onServerIconUpdate?(payload: {
1465
+ serverId: string;
1466
+ icon: string;
1467
+ }): void | Promise<void>;
1468
+ onServerBannerUpdate?(payload: {
1469
+ serverId: string;
1470
+ banner: {
1471
+ type: "image";
1472
+ value: string;
1473
+ };
1474
+ }): void | Promise<void>;
1475
+ onRoleCreate?(payload: RoleCreatedPayload): void | Promise<void>;
1476
+ onRoleUpdate?(payload: RoleUpdatedPayload): void | Promise<void>;
1477
+ onRoleDelete?(payload: RoleDeletedPayload): void | Promise<void>;
1478
+ onRolesReordered?(payload: RolesReorderedPayload): void | Promise<void>;
1479
+ onInviteCreate?(payload: InviteCreatedPayload): void | Promise<void>;
1480
+ onInviteDelete?(payload: InviteDeletedPayload): void | Promise<void>;
1481
+ onServerMemberBan?(payload: MemberBannedPayload): void | Promise<void>;
1482
+ onServerMemberUnban?(payload: MemberUnbannedPayload): void | Promise<void>;
1483
+ onOwnershipTransfer?(payload: OwnershipTransferredPayload): void | Promise<void>;
1484
+ onPresenceSync?(payload: PresenceSyncPayload): void | Promise<void>;
1485
+ onUserOnline?(payload: UserPresencePayload): void | Promise<void>;
1486
+ onUserOffline?(payload: UserOfflinePayload): void | Promise<void>;
1487
+ onUserUpdate?(payload: UserUpdatedPayload): void | Promise<void>;
1488
+ onError?(error: Error): void | Promise<void>;
1489
+ onDisconnect?(): void | Promise<void>;
1490
+ onReconnected?(): void | Promise<void>;
1491
+ }
1492
+ export declare class ModuleManager {
1493
+ private client;
1494
+ private registeredModules;
1495
+ constructor(client: Client);
1496
+ register(module: ClientModule): Promise<void>;
1497
+ }
1498
+ export interface PollOptionBuilderData {
1499
+ text: string;
1500
+ emoji?: string;
1501
+ emojiType?: "unicode" | "custom";
1502
+ emojiId?: string;
1503
+ }
1504
+ /**
1505
+ * Builder for constructing Serchat polls.
1506
+ *
1507
+ * Use this to define poll questions, options, and settings.
1508
+ *
1509
+ * @example
1510
+ * ```ts
1511
+ * const poll = new PollBuilder()
1512
+ * .setTitle('What is your favorite food?')
1513
+ * .addOption('Pizza', '🍕')
1514
+ * .addOption('Sushi', '🍣')
1515
+ * .setMultiSelect(true);
1516
+ * ```
1517
+ */
1518
+ export declare class PollBuilder {
1519
+ private title;
1520
+ private options;
1521
+ private multiSelect;
1522
+ private expiresAt?;
1523
+ /**
1524
+ * Sets the title of the poll.
1525
+ * @param title - The question or title to display.
1526
+ */
1527
+ setTitle(title: string): this;
1528
+ /**
1529
+ * Adds an option to the poll.
1530
+ * @param text - The text of the option.
1531
+ * @param emoji - Optional emoji to display next to the option.
1532
+ */
1533
+ addOption(text: string, emoji?: string): this;
1534
+ /**
1535
+ * Adds a custom emoji option to the poll.
1536
+ * @param text - The text of the option.
1537
+ * @param emojiId - The ID of the custom emoji.
1538
+ */
1539
+ addCustomEmojiOption(text: string, emojiId: string): this;
1540
+ /**
1541
+ * Sets whether the poll allows multiple selections.
1542
+ * @param multiSelect - True if multiple options can be selected.
1543
+ */
1544
+ setMultiSelect(multiSelect: boolean): this;
1545
+ /**
1546
+ * Sets the expiration date of the poll.
1547
+ * @param date - The date when the poll expires.
1548
+ */
1549
+ setExpiresAt(date: Date | string): this;
1550
+ /**
1551
+ * Converts the builder to a plain object for API transmission.
1552
+ * @internal
1553
+ */
1554
+ toJSON(): IPollInput;
1555
+ }
1556
+ /**
1557
+ * Numeric log level thresholds. A logger will emit messages at or above its
1558
+ * configured level, and drop everything below it.
1559
+ *
1560
+ * @example
1561
+ * ```ts
1562
+ * const client = new Client({ logLevel: LogLevel.DEBUG });
1563
+ * ```
1564
+ */
1565
+ export declare enum LogLevel {
1566
+ /** Verbose diagnostic information. */
1567
+ DEBUG = 0,
1568
+ /** General operational messages. */
1569
+ INFO = 1,
1570
+ /** Potentially harmful situations that are not yet errors. */
1571
+ WARN = 2,
1572
+ /** Runtime errors that are recoverable. */
1573
+ ERROR = 3,
1574
+ /** Severe errors that may cause the process to abort. */
1575
+ CRITICAL = 4,
1576
+ /** Suppress all output. */
1577
+ NONE = 5
1578
+ }
1579
+ /**
1580
+ * Colorised, tagged logger used internally by the SDK.
1581
+ *
1582
+ * Each emitted line is prefixed with the SDK tag, the source file region, the
1583
+ * severity, and the current ISO timestamp.
1584
+ */
1585
+ export declare class Logger {
1586
+ /** The minimum {@link LogLevel} at which this logger will emit output. */
1587
+ level: LogLevel;
1588
+ /**
1589
+ * @param level - Minimum severity to output. Defaults to {@link LogLevel.INFO}.
1590
+ */
1591
+ constructor(level?: LogLevel);
1592
+ /**
1593
+ * Introspects the call stack to determine the file name of the caller.
1594
+ * Used to tag log lines with their origin for easier debugging.
1595
+ */
1596
+ private getRegion;
1597
+ /**
1598
+ * Formats a log message with ANSI colours, severity tag, region tag, and
1599
+ * timestamp.
1600
+ *
1601
+ * @param severity - Human-readable severity label (e.g. `"info"`).
1602
+ * @param message - The message body to format.
1603
+ * @returns The fully formatted, colour-coded log string.
1604
+ */
1605
+ private format;
1606
+ /** Emits a debug message. */
1607
+ debug(message: string): void;
1608
+ /** Emits an info message. */
1609
+ info(message: string): void;
1610
+ /** Emits a warning message. */
1611
+ warn(message: string): void;
1612
+ /** Emits an error message. */
1613
+ error(message: string): void;
1614
+ /** Emits a critical message. */
1615
+ critical(message: string): void;
1616
+ }
1617
+ /**
1618
+ * Configuration options passed to the {@link Client} constructor.
1619
+ */
1620
+ export interface ClientOptions {
1621
+ /**
1622
+ * Base URL of the Serchat REST API.
1623
+ * @defaultValue `'https://ser.chat/api/v1'`
1624
+ */
1625
+ apiBaseUrl?: string;
1626
+ /**
1627
+ * Minimum log severity to emit. Defaults to {@link LogLevel.INFO}.
1628
+ */
1629
+ logLevel?: LogLevel;
1630
+ }
1631
+ /**
1632
+ * Map of all events the {@link Client} can emit, keyed by event name with
1633
+ * a tuple of the listener argument types as the value.
1634
+ *
1635
+ * Use these with `client.on(event, listener)`.
1636
+ */
1637
+ export interface ClientEvents {
1638
+ /** Fired once the bot has authenticated and is ready to receive events. */
1639
+ ready: [
1640
+ ClientUser
1641
+ ];
1642
+ /** A new message was posted in a channel the bot can see. */
1643
+ messageCreate: [
1644
+ Message
1645
+ ];
1646
+ /** An existing message was edited. */
1647
+ messageUpdate: [
1648
+ MessageUpdatePayload
1649
+ ];
1650
+ /** A message was deleted. */
1651
+ messageDelete: [
1652
+ MessageDeletePayload
1653
+ ];
1654
+ /** Multiple messages were deleted in bulk. */
1655
+ messageBulkDelete: [
1656
+ MessageBulkDeletePayload
1657
+ ];
1658
+ /** A user invoked a slash command. */
1659
+ interactionCreate: [
1660
+ Interaction
1661
+ ];
1662
+ /** A reaction was added to a message. */
1663
+ messageReactionAdd: [
1664
+ ReactionPayload
1665
+ ];
1666
+ /** A reaction was removed from a message. */
1667
+ messageReactionRemove: [
1668
+ ReactionPayload
1669
+ ];
1670
+ /** A poll vote was updated. */
1671
+ pollVoteUpdate: [
1672
+ PollVoteUpdatePayload
1673
+ ];
1674
+ /** A member joined a server. */
1675
+ serverMemberAdd: [
1676
+ MemberAddedPayload
1677
+ ];
1678
+ /** A member left or was removed from a server. */
1679
+ serverMemberRemove: [
1680
+ MemberRemovedPayload
1681
+ ];
1682
+ /** A server member's profile (e.g. nickname, roles) was updated. */
1683
+ serverMemberUpdate: [
1684
+ MemberUpdatedPayload
1685
+ ];
1686
+ /** A new channel was created. */
1687
+ channelCreate: [
1688
+ ChannelCreatedPayload
1689
+ ];
1690
+ /** A channel's settings were updated. */
1691
+ channelUpdate: [
1692
+ ChannelUpdatedPayload
1693
+ ];
1694
+ /** A channel was deleted. */
1695
+ channelDelete: [
1696
+ ChannelDeletedPayload
1697
+ ];
1698
+ /** The channel order within a server was changed. */
1699
+ channelsReordered: [
1700
+ ChannelsReorderedPayload
1701
+ ];
1702
+ /** A new category was created. */
1703
+ categoryCreate: [
1704
+ CategoryCreatedPayload
1705
+ ];
1706
+ /** A category's settings were updated. */
1707
+ categoryUpdate: [
1708
+ CategoryUpdatedPayload
1709
+ ];
1710
+ /** A category was deleted. */
1711
+ categoryDelete: [
1712
+ CategoryDeletedPayload
1713
+ ];
1714
+ /** The category order within a server was changed. */
1715
+ categoriesReordered: [
1716
+ CategoriesReorderedPayload
1717
+ ];
1718
+ /** Permission overrides for a channel were updated. */
1719
+ channelPermissionsUpdate: [
1720
+ ChannelPermissionsUpdatedPayload
1721
+ ];
1722
+ /** Permission overrides for a category were updated. */
1723
+ categoryPermissionsUpdate: [
1724
+ CategoryPermissionsUpdatedPayload
1725
+ ];
1726
+ /** Server-level settings were updated. */
1727
+ serverUpdate: [
1728
+ ServerUpdatedPayload
1729
+ ];
1730
+ /** A server was deleted. */
1731
+ serverDelete: [
1732
+ ServerDeletedPayload
1733
+ ];
1734
+ /** The server icon was changed. */
1735
+ serverIconUpdate: [
1736
+ {
1737
+ serverId: string;
1738
+ icon: string;
1739
+ }
1740
+ ];
1741
+ /** The server banner was changed. */
1742
+ serverBannerUpdate: [
1743
+ {
1744
+ serverId: string;
1745
+ banner: {
1746
+ type: "image";
1747
+ value: string;
1748
+ };
1749
+ }
1750
+ ];
1751
+ /** A new role was created. */
1752
+ roleCreate: [
1753
+ RoleCreatedPayload
1754
+ ];
1755
+ /** An existing role was updated. */
1756
+ roleUpdate: [
1757
+ RoleUpdatedPayload
1758
+ ];
1759
+ /** A role was deleted. */
1760
+ roleDelete: [
1761
+ RoleDeletedPayload
1762
+ ];
1763
+ /** The role order within a server was changed. */
1764
+ rolesReordered: [
1765
+ RolesReorderedPayload
1766
+ ];
1767
+ /** A new server invite was created. */
1768
+ inviteCreate: [
1769
+ InviteCreatedPayload
1770
+ ];
1771
+ /** A server invite was deleted or expired. */
1772
+ inviteDelete: [
1773
+ InviteDeletedPayload
1774
+ ];
1775
+ /** A member was banned from a server. */
1776
+ serverMemberBan: [
1777
+ MemberBannedPayload
1778
+ ];
1779
+ /** A banned member was unbanned. */
1780
+ serverMemberUnban: [
1781
+ MemberUnbannedPayload
1782
+ ];
1783
+ /** Server ownership was transferred to another member. */
1784
+ ownershipTransfer: [
1785
+ OwnershipTransferredPayload
1786
+ ];
1787
+ /** A batch of online-presence data was received from the gateway. */
1788
+ presenceSync: [
1789
+ PresenceSyncPayload
1790
+ ];
1791
+ /** A user came online. */
1792
+ userOnline: [
1793
+ UserPresencePayload
1794
+ ];
1795
+ /** A user went offline. */
1796
+ userOffline: [
1797
+ UserOfflinePayload
1798
+ ];
1799
+ /** A user's profile was updated. */
1800
+ userUpdate: [
1801
+ UserUpdatedPayload
1802
+ ];
1803
+ /** An unhandled error occurred (mirrors Node's `EventEmitter` convention). */
1804
+ error: [
1805
+ Error
1806
+ ];
1807
+ /** The WebSocket connection was closed. */
1808
+ disconnect: [
1809
+ ];
1810
+ /** The WebSocket connection successfully reconnected. */
1811
+ reconnected: [
1812
+ ];
1813
+ }
1814
+ /**
1815
+ * Typed augmentation of `EventEmitter` that constrains `on`, `once`, and
1816
+ * `emit` to the keys and argument tuples defined in {@link ClientEvents}.
1817
+ */
1818
+ export interface Client extends EventEmitter {
1819
+ on<K extends keyof ClientEvents>(event: K, listener: (...args: ClientEvents[K]) => void): this;
1820
+ once<K extends keyof ClientEvents>(event: K, listener: (...args: ClientEvents[K]) => void): this;
1821
+ off<K extends keyof ClientEvents>(event: K, listener: (...args: ClientEvents[K]) => void): this;
1822
+ emit<K extends keyof ClientEvents>(event: K, ...args: ClientEvents[K]): boolean;
1823
+ }
1824
+ /**
1825
+ * Main entry point for the Serchat bot SDK.
1826
+ *
1827
+ * Extends Node's `EventEmitter` with typed events (see {@link ClientEvents}).
1828
+ * Manages a REST client, a WebSocket gateway connection, and an
1829
+ * {@link ApplicationCommandManager} for slash commands.
1830
+ *
1831
+ * @example
1832
+ * ```ts
1833
+ * import { Client, LogLevel } from 'serchat.ts';
1834
+ *
1835
+ * const client = new Client({ logLevel: LogLevel.DEBUG });
1836
+ *
1837
+ * client.on('ready', (user) => console.log(`Logged in as ${user.username}`));
1838
+ * client.on('messageCreate', (msg) => {
1839
+ * if (msg.text === '!ping') msg.reply('Pong!');
1840
+ * });
1841
+ *
1842
+ * await client.login(process.env.BOT_TOKEN!);
1843
+ * ```
1844
+ */
1845
+ export declare class Client extends EventEmitter {
1846
+ /** The {@link WebSocketManager} handling the gateway connection. */
1847
+ ws: WebSocketManager;
1848
+ /** Slash-command registry and dispatcher. */
1849
+ commands: ApplicationCommandManager;
1850
+ /** Manager for sticker endpoints. */
1851
+ stickers: StickerManager;
1852
+ /** Manager for webhook endpoints. */
1853
+ webhooks: WebhookManager;
1854
+ /** Typed event bus used for SDK internals, modules, and public listeners. */
1855
+ events: EventBus<ClientEvents>;
1856
+ /** Module registry for self-contained bot features. */
1857
+ modules: ModuleManager;
1858
+ /** The authenticated bot user, populated after the `ready` event fires. */
1859
+ user: ClientUser | null;
1860
+ /** Whether the client has emitted the ready event at least once. */
1861
+ isReady: boolean;
1862
+ /** Resolved options for this client instance. */
1863
+ options: ClientOptions;
1864
+ /** Logger instance used throughout the SDK. */
1865
+ logger: Logger;
1866
+ private rest;
1867
+ private token;
1868
+ constructor(options?: ClientOptions);
1869
+ /** Accessor for the application command manager. */
1870
+ get application(): {
1871
+ commands: ApplicationCommandManager;
1872
+ };
1873
+ /** Returns the bot token currently in use. */
1874
+ getToken(): string | null;
1875
+ /** Returns the internal REST client. */
1876
+ getRest(): RESTClient;
1877
+ /** Returns the origin of the API base URL (e.g. https://ser.chat). */
1878
+ getApiOrigin(): string;
1879
+ /** Authenticates the client and connects to the gateway. */
1880
+ login(token: string, callback?: () => Promise<void>): Promise<void>;
1881
+ /** Exchanges client ID/secret for a token and logs in. */
1882
+ loginWithSecret(clientId: string, clientSecret: string): Promise<string>;
1883
+ /** Connects to the WebSocket gateway. */
1884
+ connectWS(): Promise<void>;
1885
+ /** Sends a message to a channel. */
1886
+ sendMessage(serverId: string, channelId: string, content: string | ISendMessageRequest | EmbedBuilder | IMessageWithEmbeds | MessageBuilder | PollBuilder): Promise<Message>;
1887
+ /** Votes on a poll option. */
1888
+ votePoll(serverId: string, channelId: string, messageId: string, optionId: string): Promise<void>;
1889
+ /** Fetches recent messages from a channel. */
1890
+ getMessages(serverId: string, channelId: string, limit?: number): Promise<Message[]>;
1891
+ /** Deletes multiple messages in a single request. */
1892
+ bulkDeleteMessages(serverId: string, channelId: string, messageIds: string[]): Promise<number>;
1893
+ /** Adds a reaction to a message. */
1894
+ reactToMessage(serverId: string, channelId: string, messageId: string, emoji: string): Promise<void>;
1895
+ /** Deletes a single message. */
1896
+ deleteMessage(serverId: string, channelId: string, messageId: string): Promise<void>;
1897
+ /** Bans a member from a server. */
1898
+ banMember(serverId: string, userId: string, reason?: string, deleteMessageDays?: number): Promise<void>;
1899
+ /** Lifts a ban from a user. */
1900
+ unbanMember(serverId: string, userId: string, reason?: string): Promise<void>;
1901
+ /** Kicks a member from a server. */
1902
+ kickMember(serverId: string, userId: string, reason?: string): Promise<void>;
1903
+ /** Times out a member. */
1904
+ timeoutMember(serverId: string, userId: string, duration: number, reason?: string): Promise<void>;
1905
+ /** Updates a channel's properties. */
1906
+ updateChannel(serverId: string, channelId: string, data: Record<string, JsonValue>): Promise<void>;
1907
+ /** Retrieves a server's details. */
1908
+ getServer(serverId: string): Promise<Record<string, JsonValue>>;
1909
+ /** Retrieves channel statistics. */
1910
+ getChannelStats(serverId: string, channelId: string): Promise<{
1911
+ messageCount: number;
1912
+ channelName: string;
1913
+ }>;
1914
+ /** Retrieves server statistics. */
1915
+ getServerStats(serverId: string): Promise<{
1916
+ totalCount: number;
1917
+ onlineCount: number;
1918
+ }>;
1919
+ /** Fetches all roles in a server. */
1920
+ getRoles(serverId: string): Promise<Role[]>;
1921
+ /** Checks if a user has a specific permission in a server. */
1922
+ hasPermission(serverId: string, userId: string, permission: string): Promise<boolean>;
1923
+ }
1924
+ export type WsErrorCode = "AUTHENTICATION_FAILED" | "INTERNAL_ERROR" | "MALFORMED_MESSAGE" | "UNAUTHORIZED" | "DUPLICATE_MESSAGE" | "RATE_LIMIT" | "TIMEOUT" | "FORBIDDEN" | "BAD_REQUEST" | "NOT_FOUND" | "CONFLICT";
1925
+ export type WsEvent = {
1926
+ type: "authenticated";
1927
+ payload: {
1928
+ user: ClientUser;
1929
+ instanceId: string;
1930
+ };
1931
+ } | {
1932
+ type: "error";
1933
+ payload: {
1934
+ code: WsErrorCode;
1935
+ details?: string | Record<string, string>;
1936
+ };
1937
+ } | {
1938
+ type: "message_server";
1939
+ payload: IMessageServer;
1940
+ } | {
1941
+ type: "interaction_create_server";
1942
+ payload: InteractionCreatePayload;
1943
+ } | {
1944
+ type: "message_server_edited";
1945
+ payload: MessageUpdatePayload;
1946
+ } | {
1947
+ type: "message_server_deleted";
1948
+ payload: MessageDeletePayload;
1949
+ } | {
1950
+ type: "messages_server_bulk_deleted";
1951
+ payload: {
1952
+ messageIds: string[];
1953
+ serverId: string;
1954
+ channelId: string;
1955
+ hard?: boolean;
1956
+ };
1957
+ } | {
1958
+ type: "reaction_added";
1959
+ payload: ReactionPayload;
1960
+ } | {
1961
+ type: "reaction_removed";
1962
+ payload: ReactionPayload;
1963
+ } | {
1964
+ type: "poll_vote_updated_server";
1965
+ payload: PollVoteUpdatePayload;
1966
+ } | {
1967
+ type: "poll_vote_updated_dm";
1968
+ payload: PollVoteUpdatePayload;
1969
+ } | {
1970
+ type: "member_added";
1971
+ payload: MemberAddedPayload;
1972
+ } | {
1973
+ type: "member_removed";
1974
+ payload: MemberRemovedPayload;
1975
+ } | {
1976
+ type: "member_updated";
1977
+ payload: MemberUpdatedPayload;
1978
+ } | {
1979
+ type: "channel_created";
1980
+ payload: ChannelCreatedPayload;
1981
+ } | {
1982
+ type: "channel_updated";
1983
+ payload: ChannelUpdatedPayload;
1984
+ } | {
1985
+ type: "channel_deleted";
1986
+ payload: ChannelDeletedPayload;
1987
+ } | {
1988
+ type: "channels_reordered";
1989
+ payload: ChannelsReorderedPayload;
1990
+ } | {
1991
+ type: "category_created";
1992
+ payload: CategoryCreatedPayload;
1993
+ } | {
1994
+ type: "category_updated";
1995
+ payload: CategoryUpdatedPayload;
1996
+ } | {
1997
+ type: "category_deleted";
1998
+ payload: CategoryDeletedPayload;
1999
+ } | {
2000
+ type: "categories_reordered";
2001
+ payload: CategoriesReorderedPayload;
2002
+ } | {
2003
+ type: "channel_permissions_updated";
2004
+ payload: ChannelPermissionsUpdatedPayload;
2005
+ } | {
2006
+ type: "category_permissions_updated";
2007
+ payload: CategoryPermissionsUpdatedPayload;
2008
+ } | {
2009
+ type: "server_updated";
2010
+ payload: ServerUpdatedPayload;
2011
+ } | {
2012
+ type: "server_deleted";
2013
+ payload: ServerDeletedPayload;
2014
+ } | {
2015
+ type: "server_icon_updated";
2016
+ payload: {
2017
+ serverId: string;
2018
+ icon: string;
2019
+ };
2020
+ } | {
2021
+ type: "server_banner_updated";
2022
+ payload: {
2023
+ serverId: string;
2024
+ banner: {
2025
+ type: "image";
2026
+ value: string;
2027
+ };
2028
+ };
2029
+ } | {
2030
+ type: "role_created";
2031
+ payload: RoleCreatedPayload;
2032
+ } | {
2033
+ type: "role_updated";
2034
+ payload: RoleUpdatedPayload;
2035
+ } | {
2036
+ type: "role_deleted";
2037
+ payload: RoleDeletedPayload;
2038
+ } | {
2039
+ type: "roles_reordered";
2040
+ payload: RolesReorderedPayload;
2041
+ } | {
2042
+ type: "server_invite_created";
2043
+ payload: InviteCreatedPayload;
2044
+ } | {
2045
+ type: "server_invite_deleted";
2046
+ payload: InviteDeletedPayload;
2047
+ } | {
2048
+ type: "member_banned";
2049
+ payload: MemberBannedPayload;
2050
+ } | {
2051
+ type: "member_unbanned";
2052
+ payload: MemberUnbannedPayload;
2053
+ } | {
2054
+ type: "ownership_transferred";
2055
+ payload: OwnershipTransferredPayload;
2056
+ } | {
2057
+ type: "server_joined";
2058
+ payload: ServerJoinedPayload;
2059
+ } | {
2060
+ type: "presence_sync";
2061
+ payload: PresenceSyncPayload;
2062
+ } | {
2063
+ type: "user_online";
2064
+ payload: UserPresencePayload;
2065
+ } | {
2066
+ type: "user_offline";
2067
+ payload: UserOfflinePayload;
2068
+ } | {
2069
+ type: "user_updated";
2070
+ payload: UserUpdatedPayload;
2071
+ } | {
2072
+ type: "ping";
2073
+ payload: Record<string, never>;
2074
+ } | {
2075
+ type: "pong";
2076
+ payload: Record<string, never>;
2077
+ };
2078
+ export interface IWsIncomingMessage {
2079
+ id?: string;
2080
+ event?: WsEvent;
2081
+ meta?: {
2082
+ replyTo?: string;
2083
+ };
2084
+ }
2085
+
2086
+ export {
2087
+ Interaction as CommandInteraction,
2088
+ };
2089
+
2090
+ export {};