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