@fluxerjs/core 1.0.6 → 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 (65) hide show
  1. package/dist/Channel-BEZOW4VC.mjs +17 -0
  2. package/dist/Channel-DPLLHL7Y.mjs +19 -0
  3. package/dist/Channel-KOTARBSF.mjs +17 -0
  4. package/dist/Channel-ON7O3D3M.mjs +17 -0
  5. package/dist/Channel-OSOB6ELO.mjs +19 -0
  6. package/dist/Channel-YVGPVOVB.mjs +17 -0
  7. package/dist/ClientUser-6HBAPU6H.mjs +8 -0
  8. package/dist/ClientUser-ALGC4FNY.mjs +8 -0
  9. package/dist/ClientUser-LLL6WX35.mjs +8 -0
  10. package/dist/ClientUser-N7ZXYAQ3.mjs +8 -0
  11. package/dist/Guild-5UBZNIGD.mjs +9 -0
  12. package/dist/Guild-GIXJJBFM.mjs +9 -0
  13. package/dist/Guild-S436SLOP.mjs +9 -0
  14. package/dist/Guild-WAFXK2EX.mjs +9 -0
  15. package/dist/Guild-XPOMHZZG.mjs +9 -0
  16. package/dist/GuildMember-BJJNCL6W.mjs +8 -0
  17. package/dist/GuildMember-FX2JAWES.mjs +8 -0
  18. package/dist/GuildMember-K5FLBNHV.mjs +8 -0
  19. package/dist/GuildMember-UBNHZBCO.mjs +8 -0
  20. package/dist/GuildMember-UU26WJGN.mjs +8 -0
  21. package/dist/Message-6RSAGIRP.mjs +8 -0
  22. package/dist/Message-OXTQHFCF.mjs +8 -0
  23. package/dist/Message-QXPHQOVC.mjs +8 -0
  24. package/dist/Message-R7GZYIQQ.mjs +8 -0
  25. package/dist/Message-W624MHJF.mjs +8 -0
  26. package/dist/Message-ZCS7IGJX.mjs +8 -0
  27. package/dist/Webhook-AG6QFM2I.mjs +7 -0
  28. package/dist/Webhook-TGAZZRQQ.mjs +7 -0
  29. package/dist/chunk-2FIZRRSO.mjs +88 -0
  30. package/dist/chunk-5HQRX3KJ.mjs +70 -0
  31. package/dist/chunk-62S4AB2S.mjs +54 -0
  32. package/dist/chunk-7SIS5CUA.mjs +14 -0
  33. package/dist/chunk-BGJSL6JI.mjs +14 -0
  34. package/dist/chunk-BYTAODAO.mjs +70 -0
  35. package/dist/chunk-CQ5ZVTLX.mjs +71 -0
  36. package/dist/chunk-DJBCSVZX.mjs +102 -0
  37. package/dist/chunk-DLROMCIJ.mjs +50 -0
  38. package/dist/chunk-DPZHAYCK.mjs +71 -0
  39. package/dist/chunk-E75ZVY3I.mjs +14 -0
  40. package/dist/chunk-FK5X6HFL.mjs +111 -0
  41. package/dist/chunk-FNFID6QB.mjs +45 -0
  42. package/dist/chunk-G4L7WAJS.mjs +64 -0
  43. package/dist/chunk-IPHFDI2L.mjs +68 -0
  44. package/dist/chunk-J3EIGOXQ.mjs +72 -0
  45. package/dist/chunk-JJHZBWZM.mjs +118 -0
  46. package/dist/chunk-LVMFPATK.mjs +54 -0
  47. package/dist/chunk-NISGA2YZ.mjs +55 -0
  48. package/dist/chunk-NOLYW3V4.mjs +140 -0
  49. package/dist/chunk-PO5JZQVN.mjs +111 -0
  50. package/dist/chunk-PYYXC7US.mjs +76 -0
  51. package/dist/chunk-QXJNV5EJ.mjs +110 -0
  52. package/dist/chunk-RXHJYGSJ.mjs +53 -0
  53. package/dist/chunk-T2NSVWBH.mjs +77 -0
  54. package/dist/chunk-TMDZALIN.mjs +110 -0
  55. package/dist/chunk-WYSHH4LR.mjs +141 -0
  56. package/dist/chunk-WZVY7DA6.mjs +44 -0
  57. package/dist/chunk-XTDZQD4A.mjs +110 -0
  58. package/dist/chunk-YKP7JHV2.mjs +102 -0
  59. package/dist/chunk-YSKZR66G.mjs +102 -0
  60. package/dist/chunk-ZMIMAMO2.mjs +14 -0
  61. package/dist/index.d.mts +206 -53
  62. package/dist/index.d.ts +206 -53
  63. package/dist/index.js +357 -179
  64. package/dist/index.mjs +38 -25
  65. package/package.json +7 -7
package/dist/index.js CHANGED
@@ -39,119 +39,17 @@ var init_Constants = __esm({
39
39
  }
40
40
  });
41
41
 
42
- // src/structures/User.ts
43
- var User;
44
- var init_User = __esm({
45
- "src/structures/User.ts"() {
46
- "use strict";
47
- init_Base();
48
- init_Constants();
49
- User = class extends Base {
50
- client;
51
- id;
52
- username;
53
- discriminator;
54
- globalName;
55
- avatar;
56
- bot;
57
- constructor(client, data) {
58
- super();
59
- this.client = client;
60
- this.id = data.id;
61
- this.username = data.username;
62
- this.discriminator = data.discriminator;
63
- this.globalName = data.global_name ?? null;
64
- this.avatar = data.avatar ?? null;
65
- this.bot = !!data.bot;
66
- }
67
- avatarURL(options) {
68
- if (!this.avatar) return null;
69
- const ext = options?.extension ?? "png";
70
- const size = options?.size ? `?size=${options.size}` : "";
71
- return `${CDN_URL}/avatars/${this.id}/${this.avatar}.${ext}${size}`;
72
- }
73
- displayAvatarURL(options) {
74
- return this.avatarURL(options) ?? `${CDN_URL}/avatars/0/0.png`;
75
- }
76
- toString() {
77
- return `<@${this.id}>`;
78
- }
79
- };
80
- }
81
- });
82
-
83
- // src/structures/Message.ts
84
- var Message_exports = {};
85
- __export(Message_exports, {
86
- Message: () => Message
87
- });
88
- var import_collection, import_types, import_builders, Message;
89
- var init_Message = __esm({
90
- "src/structures/Message.ts"() {
91
- "use strict";
92
- init_Base();
93
- import_collection = require("@fluxerjs/collection");
94
- import_types = require("@fluxerjs/types");
95
- import_builders = require("@fluxerjs/builders");
96
- init_User();
97
- Message = class _Message extends Base {
98
- client;
99
- id;
100
- channelId;
101
- guildId;
102
- author;
103
- content;
104
- createdAt;
105
- editedAt;
106
- pinned;
107
- attachments;
108
- channel;
109
- constructor(client, data) {
110
- super();
111
- this.client = client;
112
- this.id = data.id;
113
- this.channelId = data.channel_id;
114
- this.guildId = data.guild_id ?? null;
115
- this.author = new User(client, data.author);
116
- this.content = data.content;
117
- this.createdAt = new Date(data.timestamp);
118
- this.editedAt = data.edited_timestamp ? new Date(data.edited_timestamp) : null;
119
- this.pinned = data.pinned;
120
- this.attachments = new import_collection.Collection();
121
- for (const a of data.attachments ?? []) this.attachments.set(a.id, a);
122
- }
123
- async reply(options) {
124
- const body = typeof options === "string" ? { content: options, message_reference: { channel_id: this.channelId, message_id: this.id, guild_id: this.guildId ?? void 0 } } : { ...options, message_reference: { channel_id: this.channelId, message_id: this.id, guild_id: this.guildId ?? void 0 } };
125
- const data = await this.client.rest.post(import_types.Routes.channelMessages(this.channelId), { body });
126
- return new _Message(this.client, data);
127
- }
128
- async edit(options) {
129
- const body = {};
130
- if (options.content !== void 0) body.content = options.content;
131
- if (options.embeds?.length) {
132
- body.embeds = options.embeds.map((e) => e instanceof import_builders.EmbedBuilder ? e.toJSON() : e);
133
- }
134
- const data = await this.client.rest.patch(import_types.Routes.channelMessage(this.channelId, this.id), { body });
135
- return new _Message(this.client, data);
136
- }
137
- async delete() {
138
- await this.client.rest.delete(import_types.Routes.channelMessage(this.channelId, this.id));
139
- }
140
- };
141
- }
142
- });
143
-
144
42
  // src/structures/Webhook.ts
145
43
  var Webhook_exports = {};
146
44
  __export(Webhook_exports, {
147
45
  Webhook: () => Webhook
148
46
  });
149
- var import_types2, Webhook;
47
+ var import_types, Webhook;
150
48
  var init_Webhook = __esm({
151
49
  "src/structures/Webhook.ts"() {
152
50
  "use strict";
153
51
  init_Base();
154
- import_types2 = require("@fluxerjs/types");
52
+ import_types = require("@fluxerjs/types");
155
53
  Webhook = class _Webhook extends Base {
156
54
  client;
157
55
  id;
@@ -161,6 +59,7 @@ var init_Webhook = __esm({
161
59
  avatar;
162
60
  /** Present only when webhook was created via createWebhook(); not returned when fetching. */
163
61
  token;
62
+ /** @param data - API webhook from POST /channels/{id}/webhooks (has token) or GET /webhooks/{id} (no token) */
164
63
  constructor(client, data) {
165
64
  super();
166
65
  this.client = client;
@@ -173,7 +72,7 @@ var init_Webhook = __esm({
173
72
  }
174
73
  /** Delete this webhook. Requires bot token with Manage Webhooks permission. */
175
74
  async delete() {
176
- await this.client.rest.delete(import_types2.Routes.webhook(this.id), { auth: true });
75
+ await this.client.rest.delete(import_types.Routes.webhook(this.id), { auth: true });
177
76
  }
178
77
  /**
179
78
  * Send a message via this webhook. Requires the webhook token (only present when created, not when fetched).
@@ -184,21 +83,27 @@ var init_Webhook = __esm({
184
83
  throw new Error("Webhook token is required to send. The token is only returned when creating a webhook; fetched webhooks cannot send.");
185
84
  }
186
85
  const body = typeof options === "string" ? { content: options } : options;
187
- await this.client.rest.post(import_types2.Routes.webhookExecute(this.id, this.token), {
86
+ await this.client.rest.post(import_types.Routes.webhookExecute(this.id, this.token), {
188
87
  body,
189
88
  auth: false
190
89
  });
191
90
  }
192
91
  /**
193
- * Fetch a webhook by ID using bot auth. The returned webhook will not have a token (cannot send).
92
+ * Fetch a webhook by ID using bot auth.
93
+ * @param client - The client instance
94
+ * @param webhookId - The webhook ID
95
+ * @returns Webhook without token (cannot send)
194
96
  */
195
97
  static async fetch(client, webhookId) {
196
- const data = await client.rest.get(import_types2.Routes.webhook(webhookId));
98
+ const data = await client.rest.get(import_types.Routes.webhook(webhookId));
197
99
  return new _Webhook(client, data);
198
100
  }
199
101
  /**
200
102
  * Create a Webhook instance from an ID and token (e.g. from a stored webhook URL).
201
- * Useful when you have the token from a previous createWebhook() call.
103
+ * @param client - The client instance
104
+ * @param webhookId - The webhook ID
105
+ * @param token - The webhook token (from createWebhook or stored)
106
+ * @param options - Optional channelId, guildId, name for display
202
107
  */
203
108
  static fromToken(client, webhookId, token, options) {
204
109
  return new _Webhook(client, {
@@ -215,90 +120,49 @@ var init_Webhook = __esm({
215
120
  }
216
121
  });
217
122
 
218
- // src/structures/Guild.ts
219
- var Guild_exports = {};
220
- __export(Guild_exports, {
221
- Guild: () => Guild
222
- });
223
- var import_collection2, import_types3, Guild;
224
- var init_Guild = __esm({
225
- "src/structures/Guild.ts"() {
226
- "use strict";
227
- init_Base();
228
- import_collection2 = require("@fluxerjs/collection");
229
- init_Constants();
230
- import_types3 = require("@fluxerjs/types");
231
- Guild = class extends Base {
232
- client;
233
- id;
234
- name;
235
- icon;
236
- banner;
237
- ownerId;
238
- members = new import_collection2.Collection();
239
- channels = new import_collection2.Collection();
240
- constructor(client, data) {
241
- super();
242
- this.client = client;
243
- this.id = data.id;
244
- this.name = data.name;
245
- this.icon = data.icon ?? null;
246
- this.banner = data.banner ?? null;
247
- this.ownerId = data.owner_id;
248
- }
249
- iconURL(options) {
250
- if (!this.icon) return null;
251
- const size = options?.size ? `?size=${options.size}` : "";
252
- return `${CDN_URL}/icons/${this.id}/${this.icon}.png${size}`;
253
- }
254
- bannerURL(options) {
255
- if (!this.banner) return null;
256
- const size = options?.size ? `?size=${options.size}` : "";
257
- return `${CDN_URL}/banners/${this.id}/${this.banner}.png${size}`;
258
- }
259
- /** Fetch all webhooks in this guild. Returned webhooks do not include the token (cannot send). */
260
- async fetchWebhooks() {
261
- const { Webhook: Webhook2 } = await Promise.resolve().then(() => (init_Webhook(), Webhook_exports));
262
- const data = await this.client.rest.get(import_types3.Routes.guildWebhooks(this.id));
263
- const list = Array.isArray(data) ? data : Object.values(data ?? {});
264
- return list.map((w) => new Webhook2(this.client, w));
265
- }
266
- };
267
- }
268
- });
269
-
270
123
  // src/structures/Channel.ts
271
124
  var Channel_exports = {};
272
125
  __export(Channel_exports, {
273
126
  CategoryChannel: () => CategoryChannel,
274
127
  Channel: () => Channel,
128
+ DMChannel: () => DMChannel,
275
129
  GuildChannel: () => GuildChannel,
276
130
  LinkChannel: () => LinkChannel,
277
131
  TextChannel: () => TextChannel,
278
132
  VoiceChannel: () => VoiceChannel
279
133
  });
280
- var import_types4, Channel, GuildChannel, TextChannel, CategoryChannel, VoiceChannel, LinkChannel;
134
+ var import_types2, Channel, GuildChannel, TextChannel, CategoryChannel, VoiceChannel, LinkChannel, DMChannel;
281
135
  var init_Channel = __esm({
282
136
  "src/structures/Channel.ts"() {
283
137
  "use strict";
284
138
  init_Base();
285
- import_types4 = require("@fluxerjs/types");
139
+ import_types2 = require("@fluxerjs/types");
286
140
  Channel = class extends Base {
141
+ /** Create a DM channel from API data (type DM or GroupDM). */
142
+ static createDM(client, data) {
143
+ return new DMChannel(client, data);
144
+ }
287
145
  client;
288
146
  id;
289
147
  type;
148
+ /** @param data - API channel from GET /channels/{id} or GET /guilds/{id}/channels */
290
149
  constructor(client, data) {
291
150
  super();
292
151
  this.client = client;
293
152
  this.id = data.id;
294
153
  this.type = data.type;
295
154
  }
155
+ /**
156
+ * Create the appropriate channel subclass from API data.
157
+ * @param client - The client instance
158
+ * @param data - Channel data from the API
159
+ */
296
160
  static from(client, data) {
297
161
  const type = data.type ?? 0;
298
- if (type === import_types4.ChannelType.GuildText) return new TextChannel(client, data);
299
- if (type === import_types4.ChannelType.GuildCategory) return new CategoryChannel(client, data);
300
- if (type === import_types4.ChannelType.GuildVoice) return new VoiceChannel(client, data);
301
- if (type === import_types4.ChannelType.GuildLink) return new LinkChannel(client, data);
162
+ if (type === import_types2.ChannelType.GuildText) return new TextChannel(client, data);
163
+ if (type === import_types2.ChannelType.GuildCategory) return new CategoryChannel(client, data);
164
+ if (type === import_types2.ChannelType.GuildVoice) return new VoiceChannel(client, data);
165
+ if (type === import_types2.ChannelType.GuildLink || type === import_types2.ChannelType.GuildLinkExtended) return new LinkChannel(client, data);
302
166
  return new GuildChannel(client, data);
303
167
  }
304
168
  };
@@ -314,19 +178,26 @@ var init_Channel = __esm({
314
178
  this.position = data.position;
315
179
  this.parentId = data.parent_id ?? null;
316
180
  }
317
- /** Create a webhook in this channel. Returns the webhook with token (required for send()). */
181
+ /**
182
+ * Create a webhook in this channel.
183
+ * @param options - Webhook name and optional avatar URL
184
+ * @returns The webhook with token (required for send()). Requires Manage Webhooks permission.
185
+ */
318
186
  async createWebhook(options) {
319
187
  const { Webhook: Webhook2 } = await Promise.resolve().then(() => (init_Webhook(), Webhook_exports));
320
- const data = await this.client.rest.post(import_types4.Routes.channelWebhooks(this.id), {
188
+ const data = await this.client.rest.post(import_types2.Routes.channelWebhooks(this.id), {
321
189
  body: options,
322
190
  auth: true
323
191
  });
324
192
  return new Webhook2(this.client, data);
325
193
  }
326
- /** Fetch all webhooks in this channel. Returned webhooks do not include the token (cannot send). */
194
+ /**
195
+ * Fetch all webhooks in this channel.
196
+ * @returns Webhooks (includes token when listing from channel; can send via send())
197
+ */
327
198
  async fetchWebhooks() {
328
199
  const { Webhook: Webhook2 } = await Promise.resolve().then(() => (init_Webhook(), Webhook_exports));
329
- const data = await this.client.rest.get(import_types4.Routes.channelWebhooks(this.id));
200
+ const data = await this.client.rest.get(import_types2.Routes.channelWebhooks(this.id));
330
201
  const list = Array.isArray(data) ? data : Object.values(data ?? {});
331
202
  return list.map((w) => new Webhook2(this.client, w));
332
203
  }
@@ -343,10 +214,14 @@ var init_Channel = __esm({
343
214
  this.rateLimitPerUser = data.rate_limit_per_user ?? 0;
344
215
  this.lastMessageId = data.last_message_id ?? null;
345
216
  }
217
+ /**
218
+ * Send a message to this channel.
219
+ * @param options - Text content or object with `content` and/or `embeds`
220
+ */
346
221
  async send(options) {
347
222
  const body = typeof options === "string" ? { content: options } : options;
348
223
  const { Message: Message2 } = await Promise.resolve().then(() => (init_Message(), Message_exports));
349
- const data = await this.client.rest.post(import_types4.Routes.channelMessages(this.id), { body });
224
+ const data = await this.client.rest.post(import_types2.Routes.channelMessages(this.id), { body });
350
225
  return new Message2(this.client, data);
351
226
  }
352
227
  };
@@ -370,6 +245,205 @@ var init_Channel = __esm({
370
245
  this.url = data.url ?? null;
371
246
  }
372
247
  };
248
+ DMChannel = class extends Channel {
249
+ lastMessageId;
250
+ constructor(client, data) {
251
+ super(client, data);
252
+ this.lastMessageId = data.last_message_id ?? null;
253
+ }
254
+ /**
255
+ * Send a message to this DM channel.
256
+ * @param options - Text content or object with `content` and/or `embeds`
257
+ */
258
+ async send(options) {
259
+ const body = typeof options === "string" ? { content: options } : options;
260
+ const { Message: Message2 } = await Promise.resolve().then(() => (init_Message(), Message_exports));
261
+ const data = await this.client.rest.post(import_types2.Routes.channelMessages(this.id), { body });
262
+ return new Message2(this.client, data);
263
+ }
264
+ };
265
+ }
266
+ });
267
+
268
+ // src/structures/User.ts
269
+ var import_types3, User;
270
+ var init_User = __esm({
271
+ "src/structures/User.ts"() {
272
+ "use strict";
273
+ init_Base();
274
+ import_types3 = require("@fluxerjs/types");
275
+ init_Constants();
276
+ User = class extends Base {
277
+ client;
278
+ id;
279
+ username;
280
+ discriminator;
281
+ globalName;
282
+ avatar;
283
+ bot;
284
+ /** @param data - API user from message author, GET /users/{id}, or GET /users/@me */
285
+ constructor(client, data) {
286
+ super();
287
+ this.client = client;
288
+ this.id = data.id;
289
+ this.username = data.username;
290
+ this.discriminator = data.discriminator;
291
+ this.globalName = data.global_name ?? null;
292
+ this.avatar = data.avatar ?? null;
293
+ this.bot = !!data.bot;
294
+ }
295
+ /**
296
+ * Get the URL for this user's avatar.
297
+ * @param options - Optional `size` and `extension` (default: `png`)
298
+ */
299
+ avatarURL(options) {
300
+ if (!this.avatar) return null;
301
+ const ext = options?.extension ?? "png";
302
+ const size = options?.size ? `?size=${options.size}` : "";
303
+ return `${CDN_URL}/avatars/${this.id}/${this.avatar}.${ext}${size}`;
304
+ }
305
+ /** Get the avatar URL, or the default avatar if none set. */
306
+ displayAvatarURL(options) {
307
+ return this.avatarURL(options) ?? `${CDN_URL}/avatars/0/0.png`;
308
+ }
309
+ /** Returns a mention string (e.g. `<@123456>`). */
310
+ toString() {
311
+ return `<@${this.id}>`;
312
+ }
313
+ /**
314
+ * Create or get a DM channel with this user.
315
+ * Returns the DM channel; use {@link DMChannel.send} to send messages.
316
+ */
317
+ async createDM() {
318
+ const { DMChannel: DMChannelClass } = await Promise.resolve().then(() => (init_Channel(), Channel_exports));
319
+ const data = await this.client.rest.post(import_types3.Routes.userMeChannels(), {
320
+ body: { recipient_id: this.id },
321
+ auth: true
322
+ });
323
+ return new DMChannelClass(this.client, data);
324
+ }
325
+ /**
326
+ * Send a DM to this user.
327
+ * Convenience method that creates the DM channel and sends the message.
328
+ */
329
+ async send(options) {
330
+ const dm = await this.createDM();
331
+ return dm.send(options);
332
+ }
333
+ };
334
+ }
335
+ });
336
+
337
+ // src/structures/Message.ts
338
+ var Message_exports = {};
339
+ __export(Message_exports, {
340
+ Message: () => Message
341
+ });
342
+ var import_collection, import_types4, import_builders, Message;
343
+ var init_Message = __esm({
344
+ "src/structures/Message.ts"() {
345
+ "use strict";
346
+ init_Base();
347
+ import_collection = require("@fluxerjs/collection");
348
+ import_types4 = require("@fluxerjs/types");
349
+ import_builders = require("@fluxerjs/builders");
350
+ init_User();
351
+ Message = class _Message extends Base {
352
+ client;
353
+ id;
354
+ channelId;
355
+ guildId;
356
+ author;
357
+ content;
358
+ createdAt;
359
+ editedAt;
360
+ pinned;
361
+ attachments;
362
+ channel;
363
+ /** @param data - API message from POST/PATCH /channels/{id}/messages or gateway MESSAGE_CREATE */
364
+ constructor(client, data) {
365
+ super();
366
+ this.client = client;
367
+ this.id = data.id;
368
+ this.channelId = data.channel_id;
369
+ this.guildId = data.guild_id ?? null;
370
+ this.author = new User(client, data.author);
371
+ this.content = data.content;
372
+ this.createdAt = new Date(data.timestamp);
373
+ this.editedAt = data.edited_timestamp ? new Date(data.edited_timestamp) : null;
374
+ this.pinned = data.pinned;
375
+ this.attachments = new import_collection.Collection();
376
+ for (const a of data.attachments ?? []) this.attachments.set(a.id, a);
377
+ }
378
+ /**
379
+ * Reply to this message.
380
+ * @param options - Text content or object with content and/or embeds
381
+ */
382
+ async reply(options) {
383
+ const body = typeof options === "string" ? { content: options, message_reference: { channel_id: this.channelId, message_id: this.id, guild_id: this.guildId ?? void 0 } } : { ...options, message_reference: { channel_id: this.channelId, message_id: this.id, guild_id: this.guildId ?? void 0 } };
384
+ const data = await this.client.rest.post(import_types4.Routes.channelMessages(this.channelId), { body });
385
+ return new _Message(this.client, data);
386
+ }
387
+ /**
388
+ * Edit this message. Only the author (or admins) can edit.
389
+ * @param options - New content and/or embeds
390
+ */
391
+ async edit(options) {
392
+ const body = {};
393
+ if (options.content !== void 0) body.content = options.content;
394
+ if (options.embeds?.length) {
395
+ body.embeds = options.embeds.map((e) => e instanceof import_builders.EmbedBuilder ? e.toJSON() : e);
396
+ }
397
+ const data = await this.client.rest.patch(import_types4.Routes.channelMessage(this.channelId, this.id), { body });
398
+ return new _Message(this.client, data);
399
+ }
400
+ /** Delete this message. */
401
+ async delete() {
402
+ await this.client.rest.delete(import_types4.Routes.channelMessage(this.channelId, this.id));
403
+ }
404
+ /**
405
+ * Format emoji for reaction API: unicode string or "name:id" for custom.
406
+ * @param emoji - Unicode emoji (e.g. "👍") or custom { name, id } or "name:id" string
407
+ */
408
+ static formatEmoji(emoji) {
409
+ if (typeof emoji === "string") return emoji;
410
+ return `${emoji.name}:${emoji.id}`;
411
+ }
412
+ /**
413
+ * Add a reaction to this message (as the bot).
414
+ * @param emoji - Unicode emoji (e.g. `👍`) or custom emoji `{ name, id }`
415
+ */
416
+ async react(emoji) {
417
+ const emojiStr = _Message.formatEmoji(emoji);
418
+ const route = `${import_types4.Routes.channelMessageReaction(this.channelId, this.id, emojiStr)}/@me`;
419
+ await this.client.rest.put(route);
420
+ }
421
+ /**
422
+ * Remove the bot's reaction, or a specific user's reaction if userId is provided.
423
+ * @param emoji - Unicode emoji or custom `{ name, id }`
424
+ * @param userId - If provided, removes that user's reaction (requires moderator permissions)
425
+ */
426
+ async removeReaction(emoji, userId) {
427
+ const emojiStr = _Message.formatEmoji(emoji);
428
+ const route = `${import_types4.Routes.channelMessageReaction(this.channelId, this.id, emojiStr)}/${userId ?? "@me"}`;
429
+ await this.client.rest.delete(route);
430
+ }
431
+ /**
432
+ * Remove all reactions from this message.
433
+ * Requires moderator permissions.
434
+ */
435
+ async removeAllReactions() {
436
+ await this.client.rest.delete(import_types4.Routes.channelMessageReactions(this.channelId, this.id));
437
+ }
438
+ /**
439
+ * Remove all reactions of a specific emoji from this message.
440
+ * @param emoji - Unicode emoji or custom `{ name, id }`. Requires moderator permissions.
441
+ */
442
+ async removeReactionEmoji(emoji) {
443
+ const emojiStr = _Message.formatEmoji(emoji);
444
+ await this.client.rest.delete(import_types4.Routes.channelMessageReaction(this.channelId, this.id, emojiStr));
445
+ }
446
+ };
373
447
  }
374
448
  });
375
449
 
@@ -378,12 +452,13 @@ var GuildMember_exports = {};
378
452
  __export(GuildMember_exports, {
379
453
  GuildMember: () => GuildMember
380
454
  });
381
- var GuildMember;
455
+ var import_types5, GuildMember;
382
456
  var init_GuildMember = __esm({
383
457
  "src/structures/GuildMember.ts"() {
384
458
  "use strict";
385
459
  init_Base();
386
460
  init_User();
461
+ import_types5 = require("@fluxerjs/types");
387
462
  GuildMember = class extends Base {
388
463
  client;
389
464
  id;
@@ -393,6 +468,7 @@ var init_GuildMember = __esm({
393
468
  roles;
394
469
  joinedAt;
395
470
  communicationDisabledUntil;
471
+ /** @param data - API guild member from GET /guilds/{id}/members or GET /guilds/{id}/members/{user_id} */
396
472
  constructor(client, data, guild) {
397
473
  super();
398
474
  this.client = client;
@@ -404,9 +480,97 @@ var init_GuildMember = __esm({
404
480
  this.joinedAt = new Date(data.joined_at);
405
481
  this.communicationDisabledUntil = data.communication_disabled_until ? new Date(data.communication_disabled_until) : null;
406
482
  }
483
+ /** Nickname, or global name, or username. */
407
484
  get displayName() {
408
485
  return this.nick ?? this.user.globalName ?? this.user.username;
409
486
  }
487
+ /**
488
+ * Add a role to this member.
489
+ * @param roleId - The role ID to add
490
+ * Requires Manage Roles permission.
491
+ */
492
+ async addRole(roleId) {
493
+ await this.client.rest.put(import_types5.Routes.guildMemberRole(this.guild.id, this.id, roleId));
494
+ }
495
+ /**
496
+ * Remove a role from this member.
497
+ * @param roleId - The role ID to remove
498
+ * Requires Manage Roles permission.
499
+ */
500
+ async removeRole(roleId) {
501
+ await this.client.rest.delete(import_types5.Routes.guildMemberRole(this.guild.id, this.id, roleId));
502
+ }
503
+ };
504
+ }
505
+ });
506
+
507
+ // src/structures/Guild.ts
508
+ var Guild_exports = {};
509
+ __export(Guild_exports, {
510
+ Guild: () => Guild
511
+ });
512
+ var import_collection2, import_types6, Guild;
513
+ var init_Guild = __esm({
514
+ "src/structures/Guild.ts"() {
515
+ "use strict";
516
+ init_Base();
517
+ import_collection2 = require("@fluxerjs/collection");
518
+ init_GuildMember();
519
+ init_Constants();
520
+ import_types6 = require("@fluxerjs/types");
521
+ Guild = class extends Base {
522
+ client;
523
+ id;
524
+ name;
525
+ icon;
526
+ banner;
527
+ ownerId;
528
+ members = new import_collection2.Collection();
529
+ channels = new import_collection2.Collection();
530
+ /** @param data - API guild from GET /guilds/{id} or gateway GUILD_CREATE */
531
+ constructor(client, data) {
532
+ super();
533
+ this.client = client;
534
+ this.id = data.id;
535
+ this.name = data.name;
536
+ this.icon = data.icon ?? null;
537
+ this.banner = data.banner ?? null;
538
+ this.ownerId = data.owner_id;
539
+ }
540
+ /** Get the guild icon URL, or null if no icon. */
541
+ iconURL(options) {
542
+ if (!this.icon) return null;
543
+ const size = options?.size ? `?size=${options.size}` : "";
544
+ return `${CDN_URL}/icons/${this.id}/${this.icon}.png${size}`;
545
+ }
546
+ /** Get the guild banner URL, or null if no banner. */
547
+ bannerURL(options) {
548
+ if (!this.banner) return null;
549
+ const size = options?.size ? `?size=${options.size}` : "";
550
+ return `${CDN_URL}/banners/${this.id}/${this.banner}.png${size}`;
551
+ }
552
+ /**
553
+ * Fetch a guild member by user ID.
554
+ * @param userId - The user ID of the member to fetch
555
+ * @returns The guild member, or null if not found
556
+ */
557
+ async fetchMember(userId) {
558
+ try {
559
+ const data = await this.client.rest.get(
560
+ import_types6.Routes.guildMember(this.id, userId)
561
+ );
562
+ return new GuildMember(this.client, { ...data, guild_id: this.id }, this);
563
+ } catch {
564
+ return null;
565
+ }
566
+ }
567
+ /** Fetch all webhooks in this guild. Returned webhooks do not include the token (cannot send). */
568
+ async fetchWebhooks() {
569
+ const { Webhook: Webhook2 } = await Promise.resolve().then(() => (init_Webhook(), Webhook_exports));
570
+ const data = await this.client.rest.get(import_types6.Routes.guildWebhooks(this.id));
571
+ const list = Array.isArray(data) ? data : Object.values(data ?? {});
572
+ return list.map((w) => new Webhook2(this.client, w));
573
+ }
410
574
  };
411
575
  }
412
576
  });
@@ -438,18 +602,19 @@ __export(index_exports, {
438
602
  Channel: () => Channel,
439
603
  Client: () => Client,
440
604
  ClientUser: () => ClientUser,
605
+ DMChannel: () => DMChannel,
441
606
  EmbedBuilder: () => import_builders2.EmbedBuilder,
442
607
  ErrorCodes: () => ErrorCodes,
443
608
  Events: () => Events,
444
609
  FluxerError: () => FluxerError,
445
- GatewayOpcodes: () => import_types6.GatewayOpcodes,
610
+ GatewayOpcodes: () => import_types8.GatewayOpcodes,
446
611
  Guild: () => Guild,
447
612
  GuildChannel: () => GuildChannel,
448
613
  GuildMember: () => GuildMember,
449
614
  LinkChannel: () => LinkChannel,
450
615
  Message: () => Message,
451
616
  MessagePayload: () => import_builders2.MessagePayload,
452
- Routes: () => import_types6.Routes,
617
+ Routes: () => import_types8.Routes,
453
618
  TextChannel: () => TextChannel,
454
619
  User: () => User,
455
620
  VoiceChannel: () => VoiceChannel,
@@ -461,7 +626,7 @@ module.exports = __toCommonJS(index_exports);
461
626
  var import_events = require("events");
462
627
  var import_rest = require("@fluxerjs/rest");
463
628
  var import_ws = require("@fluxerjs/ws");
464
- var import_types5 = require("@fluxerjs/types");
629
+ var import_types7 = require("@fluxerjs/types");
465
630
  var import_collection3 = require("@fluxerjs/collection");
466
631
 
467
632
  // src/util/Events.ts
@@ -493,6 +658,7 @@ var Events = {
493
658
 
494
659
  // src/client/Client.ts
495
660
  var Client = class extends import_events.EventEmitter {
661
+ /** @param options - Token, REST config, WebSocket, presence, etc. */
496
662
  constructor(options = {}) {
497
663
  super();
498
664
  this.options = options;
@@ -509,11 +675,16 @@ var Client = class extends import_events.EventEmitter {
509
675
  user = null;
510
676
  readyAt = null;
511
677
  _ws = null;
678
+ /** WebSocket manager. Throws if not logged in. */
512
679
  get ws() {
513
680
  if (!this._ws) throw new Error("Client is not logged in");
514
681
  return this._ws;
515
682
  }
516
- /** Send a payload to the gateway (e.g. Voice State Update). Uses shard 0 when single-shard. */
683
+ /**
684
+ * Send a payload to the gateway (e.g. Voice State Update).
685
+ * @param shardId - Shard ID (use 0 for single-shard)
686
+ * @param payload - Gateway payload to send
687
+ */
517
688
  sendToGateway(shardId, payload) {
518
689
  this.ws.send(shardId, payload);
519
690
  }
@@ -664,6 +835,10 @@ var Client = class extends import_events.EventEmitter {
664
835
  this.emit(Events.Error, err instanceof Error ? err : new Error(String(err)));
665
836
  }
666
837
  }
838
+ /**
839
+ * Connect to the Fluxer gateway and authenticate.
840
+ * @param token - Bot token (e.g. from FLUXER_BOT_TOKEN)
841
+ */
667
842
  async login(token) {
668
843
  this.rest.setToken(token);
669
844
  let intents = this.options.intents ?? 0;
@@ -714,6 +889,7 @@ var Client = class extends import_events.EventEmitter {
714
889
  await this._ws.connect();
715
890
  return token;
716
891
  }
892
+ /** Disconnect from the gateway and clear cached data. */
717
893
  async destroy() {
718
894
  if (this._ws) {
719
895
  this._ws.destroy();
@@ -726,11 +902,12 @@ var Client = class extends import_events.EventEmitter {
726
902
  this.channels.clear();
727
903
  this.users.clear();
728
904
  }
905
+ /** Returns true if the client has received Ready and `user` is set. */
729
906
  isReady() {
730
907
  return this.readyAt !== null && this.user !== null;
731
908
  }
732
909
  static get Routes() {
733
- return import_types5.Routes;
910
+ return import_types7.Routes;
734
911
  }
735
912
  };
736
913
 
@@ -761,7 +938,7 @@ var ErrorCodes = {
761
938
 
762
939
  // src/index.ts
763
940
  var import_builders2 = require("@fluxerjs/builders");
764
- var import_types6 = require("@fluxerjs/types");
941
+ var import_types8 = require("@fluxerjs/types");
765
942
  // Annotate the CommonJS export names for ESM import in node:
766
943
  0 && (module.exports = {
767
944
  AttachmentBuilder,
@@ -770,6 +947,7 @@ var import_types6 = require("@fluxerjs/types");
770
947
  Channel,
771
948
  Client,
772
949
  ClientUser,
950
+ DMChannel,
773
951
  EmbedBuilder,
774
952
  ErrorCodes,
775
953
  Events,