@fluxerjs/core 1.0.5 → 1.0.7

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.
Files changed (69) hide show
  1. package/dist/Channel-BEZOW4VC.mjs +17 -0
  2. package/dist/Channel-DPLLHL7Y.mjs +19 -0
  3. package/dist/Channel-IKL3SJXN.mjs +17 -0
  4. package/dist/Channel-KOTARBSF.mjs +17 -0
  5. package/dist/Channel-ON7O3D3M.mjs +17 -0
  6. package/dist/Channel-OSOB6ELO.mjs +19 -0
  7. package/dist/Channel-YVGPVOVB.mjs +17 -0
  8. package/dist/ClientUser-6HBAPU6H.mjs +8 -0
  9. package/dist/ClientUser-ALGC4FNY.mjs +8 -0
  10. package/dist/ClientUser-LLL6WX35.mjs +8 -0
  11. package/dist/ClientUser-N7ZXYAQ3.mjs +8 -0
  12. package/dist/Guild-5UBZNIGD.mjs +9 -0
  13. package/dist/Guild-GIXJJBFM.mjs +9 -0
  14. package/dist/Guild-S436SLOP.mjs +9 -0
  15. package/dist/Guild-WAFXK2EX.mjs +9 -0
  16. package/dist/Guild-XPOMHZZG.mjs +9 -0
  17. package/dist/GuildMember-BJJNCL6W.mjs +8 -0
  18. package/dist/GuildMember-FX2JAWES.mjs +8 -0
  19. package/dist/GuildMember-K5FLBNHV.mjs +8 -0
  20. package/dist/GuildMember-UBNHZBCO.mjs +8 -0
  21. package/dist/GuildMember-UU26WJGN.mjs +8 -0
  22. package/dist/Message-33APPS76.mjs +9 -0
  23. package/dist/Message-6RSAGIRP.mjs +8 -0
  24. package/dist/Message-OXTQHFCF.mjs +8 -0
  25. package/dist/Message-QXPHQOVC.mjs +8 -0
  26. package/dist/Message-R7GZYIQQ.mjs +8 -0
  27. package/dist/Message-W624MHJF.mjs +8 -0
  28. package/dist/Message-ZCS7IGJX.mjs +8 -0
  29. package/dist/Webhook-AG6QFM2I.mjs +7 -0
  30. package/dist/Webhook-TGAZZRQQ.mjs +7 -0
  31. package/dist/chunk-2FIZRRSO.mjs +88 -0
  32. package/dist/chunk-3CNUPFDI.mjs +59 -0
  33. package/dist/chunk-5HQRX3KJ.mjs +70 -0
  34. package/dist/chunk-62S4AB2S.mjs +54 -0
  35. package/dist/chunk-7SIS5CUA.mjs +14 -0
  36. package/dist/chunk-BGJSL6JI.mjs +14 -0
  37. package/dist/chunk-BYTAODAO.mjs +70 -0
  38. package/dist/chunk-CQ5ZVTLX.mjs +71 -0
  39. package/dist/chunk-DJBCSVZX.mjs +102 -0
  40. package/dist/chunk-DLROMCIJ.mjs +50 -0
  41. package/dist/chunk-DPZHAYCK.mjs +71 -0
  42. package/dist/chunk-E75ZVY3I.mjs +14 -0
  43. package/dist/chunk-FK5X6HFL.mjs +111 -0
  44. package/dist/chunk-FNFID6QB.mjs +45 -0
  45. package/dist/chunk-G4L7WAJS.mjs +64 -0
  46. package/dist/chunk-IPHFDI2L.mjs +68 -0
  47. package/dist/chunk-J3EIGOXQ.mjs +72 -0
  48. package/dist/chunk-JJHZBWZM.mjs +118 -0
  49. package/dist/chunk-LVMFPATK.mjs +54 -0
  50. package/dist/chunk-NISGA2YZ.mjs +55 -0
  51. package/dist/chunk-NOLYW3V4.mjs +140 -0
  52. package/dist/chunk-OHIHIQAS.mjs +102 -0
  53. package/dist/chunk-PO5JZQVN.mjs +111 -0
  54. package/dist/chunk-PYYXC7US.mjs +76 -0
  55. package/dist/chunk-QXJNV5EJ.mjs +110 -0
  56. package/dist/chunk-RXHJYGSJ.mjs +53 -0
  57. package/dist/chunk-T2NSVWBH.mjs +77 -0
  58. package/dist/chunk-TMDZALIN.mjs +110 -0
  59. package/dist/chunk-WYSHH4LR.mjs +141 -0
  60. package/dist/chunk-WZVY7DA6.mjs +44 -0
  61. package/dist/chunk-XTDZQD4A.mjs +110 -0
  62. package/dist/chunk-YKP7JHV2.mjs +102 -0
  63. package/dist/chunk-YSKZR66G.mjs +102 -0
  64. package/dist/chunk-ZMIMAMO2.mjs +14 -0
  65. package/dist/index.d.mts +208 -51
  66. package/dist/index.d.ts +208 -51
  67. package/dist/index.js +361 -177
  68. package/dist/index.mjs +38 -25
  69. package/package.json +7 -7
package/dist/index.d.ts CHANGED
@@ -1,63 +1,28 @@
1
+ import { Collection } from '@fluxerjs/collection';
1
2
  import * as _fluxerjs_types from '@fluxerjs/types';
2
- import { APIUserPartial, APIMessageAttachment, APIMessage, APIEmbed, APIWebhook, ChannelType, APIChannelPartial, APIChannel, APIGuild, APIGuildMember, GatewayPresenceUpdateData, GatewaySendPayload, Routes, GatewayMessageReactionAddDispatchData, GatewayMessageReactionRemoveDispatchData, GatewayMessageReactionRemoveAllDispatchData, GatewayMessageReactionRemoveEmojiDispatchData, GatewayVoiceStateUpdateDispatchData, GatewayVoiceServerUpdateDispatchData } from '@fluxerjs/types';
3
+ import { APIWebhook, APIChannelPartial, ChannelType, APIChannel, APIMessageAttachment, APIMessage, APIEmbed, APIUserPartial, APIGuild, APIGuildMember, GatewayPresenceUpdateData, GatewaySendPayload, Routes, GatewayMessageReactionAddDispatchData, GatewayMessageReactionRemoveDispatchData, GatewayMessageReactionRemoveAllDispatchData, GatewayMessageReactionRemoveEmojiDispatchData, GatewayVoiceStateUpdateDispatchData, GatewayVoiceServerUpdateDispatchData } from '@fluxerjs/types';
3
4
  export { GatewayOpcodes, Routes } from '@fluxerjs/types';
4
- import { Collection } from '@fluxerjs/collection';
5
+ import { EmbedBuilder } from '@fluxerjs/builders';
6
+ export { AttachmentBuilder, EmbedBuilder, MessagePayload } from '@fluxerjs/builders';
5
7
  import { EventEmitter } from 'events';
6
8
  import { REST } from '@fluxerjs/rest';
7
9
  import { WebSocketManager } from '@fluxerjs/ws';
8
- export { AttachmentBuilder, EmbedBuilder, MessagePayload } from '@fluxerjs/builders';
9
10
 
10
11
  declare abstract class Base {
11
12
  abstract readonly client: Client;
12
13
  }
13
14
 
14
- declare class User extends Base {
15
- readonly client: Client;
16
- readonly id: string;
17
- username: string;
18
- discriminator: string;
19
- globalName: string | null;
20
- avatar: string | null;
21
- readonly bot: boolean;
22
- constructor(client: Client, data: APIUserPartial);
23
- avatarURL(options?: {
24
- size?: number;
25
- extension?: string;
26
- }): string | null;
27
- displayAvatarURL(options?: {
28
- size?: number;
29
- }): string;
30
- toString(): string;
31
- }
32
-
33
- declare class Message extends Base {
34
- readonly client: Client;
35
- readonly id: string;
36
- readonly channelId: string;
37
- readonly guildId: string | null;
38
- readonly author: User;
39
- content: string;
40
- readonly createdAt: Date;
41
- readonly editedAt: Date | null;
42
- pinned: boolean;
43
- readonly attachments: Collection<string, APIMessageAttachment>;
44
- channel?: Channel;
45
- constructor(client: Client, data: APIMessage);
46
- reply(options: string | {
47
- content?: string;
48
- embeds?: APIEmbed[];
49
- }): Promise<Message>;
50
- edit(options: {
51
- content?: string;
52
- }): Promise<Message>;
53
- delete(): Promise<void>;
54
- }
55
-
15
+ /** Options for sending a message via webhook. */
56
16
  interface WebhookSendOptions {
17
+ /** Message text content */
57
18
  content?: string;
19
+ /** Embed objects (use EmbedBuilder.toJSON()) */
58
20
  embeds?: Array<Record<string, unknown>>;
21
+ /** Override the webhook's default username */
59
22
  username?: string;
23
+ /** Override the webhook's default avatar URL */
60
24
  avatar_url?: string;
25
+ /** Text-to-speech */
61
26
  tts?: boolean;
62
27
  }
63
28
  /**
@@ -73,6 +38,7 @@ declare class Webhook extends Base {
73
38
  avatar: string | null;
74
39
  /** Present only when webhook was created via createWebhook(); not returned when fetching. */
75
40
  readonly token: string | null;
41
+ /** @param data - API webhook from POST /channels/{id}/webhooks (has token) or GET /webhooks/{id} (no token) */
76
42
  constructor(client: Client, data: APIWebhook & {
77
43
  token?: string | null;
78
44
  });
@@ -84,12 +50,18 @@ declare class Webhook extends Base {
84
50
  */
85
51
  send(options: string | WebhookSendOptions): Promise<void>;
86
52
  /**
87
- * Fetch a webhook by ID using bot auth. The returned webhook will not have a token (cannot send).
53
+ * Fetch a webhook by ID using bot auth.
54
+ * @param client - The client instance
55
+ * @param webhookId - The webhook ID
56
+ * @returns Webhook without token (cannot send)
88
57
  */
89
58
  static fetch(client: Client, webhookId: string): Promise<Webhook>;
90
59
  /**
91
60
  * Create a Webhook instance from an ID and token (e.g. from a stored webhook URL).
92
- * Useful when you have the token from a previous createWebhook() call.
61
+ * @param client - The client instance
62
+ * @param webhookId - The webhook ID
63
+ * @param token - The webhook token (from createWebhook or stored)
64
+ * @param options - Optional channelId, guildId, name for display
93
65
  */
94
66
  static fromToken(client: Client, webhookId: string, token: string, options?: {
95
67
  channelId?: string;
@@ -98,11 +70,20 @@ declare class Webhook extends Base {
98
70
  }): Webhook;
99
71
  }
100
72
 
73
+ /** Base class for all channel types. */
101
74
  declare abstract class Channel extends Base {
75
+ /** Create a DM channel from API data (type DM or GroupDM). */
76
+ static createDM(client: Client, data: APIChannelPartial): DMChannel;
102
77
  readonly client: Client;
103
78
  readonly id: string;
104
79
  type: ChannelType;
80
+ /** @param data - API channel from GET /channels/{id} or GET /guilds/{id}/channels */
105
81
  constructor(client: Client, data: APIChannelPartial);
82
+ /**
83
+ * Create the appropriate channel subclass from API data.
84
+ * @param client - The client instance
85
+ * @param data - Channel data from the API
86
+ */
106
87
  static from(client: Client, data: APIChannel | APIChannelPartial): GuildChannel | TextChannel | null;
107
88
  }
108
89
  declare class GuildChannel extends Channel {
@@ -111,12 +92,19 @@ declare class GuildChannel extends Channel {
111
92
  position?: number;
112
93
  parentId: string | null;
113
94
  constructor(client: Client, data: APIChannel);
114
- /** Create a webhook in this channel. Returns the webhook with token (required for send()). */
95
+ /**
96
+ * Create a webhook in this channel.
97
+ * @param options - Webhook name and optional avatar URL
98
+ * @returns The webhook with token (required for send()). Requires Manage Webhooks permission.
99
+ */
115
100
  createWebhook(options: {
116
101
  name: string;
117
102
  avatar?: string | null;
118
103
  }): Promise<Webhook>;
119
- /** Fetch all webhooks in this channel. Returned webhooks do not include the token (cannot send). */
104
+ /**
105
+ * Fetch all webhooks in this channel.
106
+ * @returns Webhooks (includes token when listing from channel; can send via send())
107
+ */
120
108
  fetchWebhooks(): Promise<Webhook[]>;
121
109
  }
122
110
  declare class TextChannel extends GuildChannel {
@@ -125,6 +113,10 @@ declare class TextChannel extends GuildChannel {
125
113
  rateLimitPerUser?: number;
126
114
  lastMessageId?: string | null;
127
115
  constructor(client: Client, data: APIChannel);
116
+ /**
117
+ * Send a message to this channel.
118
+ * @param options - Text content or object with `content` and/or `embeds`
119
+ */
128
120
  send(options: string | {
129
121
  content?: string;
130
122
  embeds?: unknown[];
@@ -142,7 +134,135 @@ declare class LinkChannel extends GuildChannel {
142
134
  url?: string | null;
143
135
  constructor(client: Client, data: APIChannel);
144
136
  }
137
+ /** DM channel (direct message between bot and a user). */
138
+ declare class DMChannel extends Channel {
139
+ lastMessageId?: string | null;
140
+ constructor(client: Client, data: APIChannelPartial);
141
+ /**
142
+ * Send a message to this DM channel.
143
+ * @param options - Text content or object with `content` and/or `embeds`
144
+ */
145
+ send(options: string | {
146
+ content?: string;
147
+ embeds?: unknown[];
148
+ }): Promise<Message>;
149
+ }
145
150
 
151
+ /** Options for editing a message (content and/or embeds). */
152
+ interface MessageEditOptions {
153
+ /** New text content */
154
+ content?: string;
155
+ /** New embeds (replaces existing) */
156
+ embeds?: (APIEmbed | EmbedBuilder)[];
157
+ }
158
+ /** Represents a message in a channel. */
159
+ declare class Message extends Base {
160
+ readonly client: Client;
161
+ readonly id: string;
162
+ readonly channelId: string;
163
+ readonly guildId: string | null;
164
+ readonly author: User;
165
+ content: string;
166
+ readonly createdAt: Date;
167
+ readonly editedAt: Date | null;
168
+ pinned: boolean;
169
+ readonly attachments: Collection<string, APIMessageAttachment>;
170
+ channel?: Channel;
171
+ /** @param data - API message from POST/PATCH /channels/{id}/messages or gateway MESSAGE_CREATE */
172
+ constructor(client: Client, data: APIMessage);
173
+ /**
174
+ * Reply to this message.
175
+ * @param options - Text content or object with content and/or embeds
176
+ */
177
+ reply(options: string | {
178
+ content?: string;
179
+ embeds?: APIEmbed[];
180
+ }): Promise<Message>;
181
+ /**
182
+ * Edit this message. Only the author (or admins) can edit.
183
+ * @param options - New content and/or embeds
184
+ */
185
+ edit(options: MessageEditOptions): Promise<Message>;
186
+ /** Delete this message. */
187
+ delete(): Promise<void>;
188
+ /**
189
+ * Format emoji for reaction API: unicode string or "name:id" for custom.
190
+ * @param emoji - Unicode emoji (e.g. "👍") or custom { name, id } or "name:id" string
191
+ */
192
+ private static formatEmoji;
193
+ /**
194
+ * Add a reaction to this message (as the bot).
195
+ * @param emoji - Unicode emoji (e.g. `👍`) or custom emoji `{ name, id }`
196
+ */
197
+ react(emoji: string | {
198
+ name: string;
199
+ id: string;
200
+ }): Promise<void>;
201
+ /**
202
+ * Remove the bot's reaction, or a specific user's reaction if userId is provided.
203
+ * @param emoji - Unicode emoji or custom `{ name, id }`
204
+ * @param userId - If provided, removes that user's reaction (requires moderator permissions)
205
+ */
206
+ removeReaction(emoji: string | {
207
+ name: string;
208
+ id: string;
209
+ }, userId?: string): Promise<void>;
210
+ /**
211
+ * Remove all reactions from this message.
212
+ * Requires moderator permissions.
213
+ */
214
+ removeAllReactions(): Promise<void>;
215
+ /**
216
+ * Remove all reactions of a specific emoji from this message.
217
+ * @param emoji - Unicode emoji or custom `{ name, id }`. Requires moderator permissions.
218
+ */
219
+ removeReactionEmoji(emoji: string | {
220
+ name: string;
221
+ id: string;
222
+ }): Promise<void>;
223
+ }
224
+
225
+ /** Represents a user (or bot) on Fluxer. */
226
+ declare class User extends Base {
227
+ readonly client: Client;
228
+ readonly id: string;
229
+ username: string;
230
+ discriminator: string;
231
+ globalName: string | null;
232
+ avatar: string | null;
233
+ readonly bot: boolean;
234
+ /** @param data - API user from message author, GET /users/{id}, or GET /users/@me */
235
+ constructor(client: Client, data: APIUserPartial);
236
+ /**
237
+ * Get the URL for this user's avatar.
238
+ * @param options - Optional `size` and `extension` (default: `png`)
239
+ */
240
+ avatarURL(options?: {
241
+ size?: number;
242
+ extension?: string;
243
+ }): string | null;
244
+ /** Get the avatar URL, or the default avatar if none set. */
245
+ displayAvatarURL(options?: {
246
+ size?: number;
247
+ }): string;
248
+ /** Returns a mention string (e.g. `<@123456>`). */
249
+ toString(): string;
250
+ /**
251
+ * Create or get a DM channel with this user.
252
+ * Returns the DM channel; use {@link DMChannel.send} to send messages.
253
+ */
254
+ createDM(): Promise<DMChannel>;
255
+ /**
256
+ * Send a DM to this user.
257
+ * Convenience method that creates the DM channel and sends the message.
258
+ */
259
+ send(options: string | {
260
+ content?: string;
261
+ embeds?: unknown[];
262
+ }): Promise<Message>;
263
+ }
264
+
265
+ /** Represents a Fluxer guild (server). */
146
266
  declare class Guild extends Base {
147
267
  readonly client: Client;
148
268
  readonly id: string;
@@ -152,17 +272,27 @@ declare class Guild extends Base {
152
272
  readonly ownerId: string;
153
273
  members: Collection<string, GuildMember>;
154
274
  channels: Collection<string, GuildChannel>;
275
+ /** @param data - API guild from GET /guilds/{id} or gateway GUILD_CREATE */
155
276
  constructor(client: Client, data: APIGuild);
277
+ /** Get the guild icon URL, or null if no icon. */
156
278
  iconURL(options?: {
157
279
  size?: number;
158
280
  }): string | null;
281
+ /** Get the guild banner URL, or null if no banner. */
159
282
  bannerURL(options?: {
160
283
  size?: number;
161
284
  }): string | null;
285
+ /**
286
+ * Fetch a guild member by user ID.
287
+ * @param userId - The user ID of the member to fetch
288
+ * @returns The guild member, or null if not found
289
+ */
290
+ fetchMember(userId: string): Promise<GuildMember | null>;
162
291
  /** Fetch all webhooks in this guild. Returned webhooks do not include the token (cannot send). */
163
292
  fetchWebhooks(): Promise<Webhook[]>;
164
293
  }
165
294
 
295
+ /** Represents a member of a guild. */
166
296
  declare class GuildMember extends Base {
167
297
  readonly client: Client;
168
298
  readonly id: string;
@@ -172,10 +302,24 @@ declare class GuildMember extends Base {
172
302
  readonly roles: string[];
173
303
  readonly joinedAt: Date;
174
304
  communicationDisabledUntil: Date | null;
305
+ /** @param data - API guild member from GET /guilds/{id}/members or GET /guilds/{id}/members/{user_id} */
175
306
  constructor(client: Client, data: APIGuildMember & {
176
307
  guild_id?: string;
177
308
  }, guild: Guild);
309
+ /** Nickname, or global name, or username. */
178
310
  get displayName(): string;
311
+ /**
312
+ * Add a role to this member.
313
+ * @param roleId - The role ID to add
314
+ * Requires Manage Roles permission.
315
+ */
316
+ addRole(roleId: string): Promise<void>;
317
+ /**
318
+ * Remove a role from this member.
319
+ * @param roleId - The role ID to remove
320
+ * Requires Manage Roles permission.
321
+ */
322
+ removeRole(roleId: string): Promise<void>;
179
323
  }
180
324
 
181
325
  interface ClientOptions {
@@ -258,6 +402,7 @@ interface ClientEvents {
258
402
  [Events.Error]: [error: Error];
259
403
  [Events.Debug]: [message: string];
260
404
  }
405
+ /** Main Fluxer bot client. Connects to the gateway, emits events, and provides REST access. */
261
406
  declare class Client extends EventEmitter {
262
407
  readonly options: ClientOptions;
263
408
  readonly rest: REST;
@@ -267,13 +412,25 @@ declare class Client extends EventEmitter {
267
412
  user: ClientUser | null;
268
413
  readyAt: Date | null;
269
414
  private _ws;
415
+ /** @param options - Token, REST config, WebSocket, presence, etc. */
270
416
  constructor(options?: ClientOptions);
417
+ /** WebSocket manager. Throws if not logged in. */
271
418
  get ws(): WebSocketManager;
272
- /** Send a payload to the gateway (e.g. Voice State Update). Uses shard 0 when single-shard. */
419
+ /**
420
+ * Send a payload to the gateway (e.g. Voice State Update).
421
+ * @param shardId - Shard ID (use 0 for single-shard)
422
+ * @param payload - Gateway payload to send
423
+ */
273
424
  sendToGateway(shardId: number, payload: GatewaySendPayload): void;
274
425
  private handleDispatch;
426
+ /**
427
+ * Connect to the Fluxer gateway and authenticate.
428
+ * @param token - Bot token (e.g. from FLUXER_BOT_TOKEN)
429
+ */
275
430
  login(token: string): Promise<string>;
431
+ /** Disconnect from the gateway and clear cached data. */
276
432
  destroy(): Promise<void>;
433
+ /** Returns true if the client has received Ready and `user` is set. */
277
434
  isReady(): this is Client & {
278
435
  user: NonNullable<Client['user']>;
279
436
  };
@@ -289,4 +446,4 @@ declare const ErrorCodes: {
289
446
  readonly InvalidToken: "INVALID_TOKEN";
290
447
  };
291
448
 
292
- export { Base, CategoryChannel, Channel, Client, type ClientEvents, ClientUser, ErrorCodes, Events, FluxerError, Guild, GuildChannel, GuildMember, LinkChannel, Message, TextChannel, User, VoiceChannel, Webhook, type WebhookSendOptions };
449
+ export { Base, CategoryChannel, Channel, Client, type ClientEvents, ClientUser, DMChannel, ErrorCodes, Events, FluxerError, Guild, GuildChannel, GuildMember, LinkChannel, Message, type MessageEditOptions, TextChannel, User, VoiceChannel, Webhook, type WebhookSendOptions };