@fluxerjs/core 1.1.3 → 1.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -6,10 +6,10 @@ import {
6
6
  LinkChannel,
7
7
  TextChannel,
8
8
  VoiceChannel
9
- } from "./chunk-ZKKBIQBA.mjs";
9
+ } from "./chunk-NNZUZLG3.mjs";
10
10
  import "./chunk-PU73YRKJ.mjs";
11
11
  import "./chunk-AH7KYH2Z.mjs";
12
- import "./chunk-PM2IUGNR.mjs";
12
+ import "./chunk-VJDH54HJ.mjs";
13
13
  import "./chunk-XNS4O6QJ.mjs";
14
14
  export {
15
15
  CategoryChannel,
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  ClientUser
3
- } from "./chunk-5GTFNBZT.mjs";
3
+ } from "./chunk-4S42USSG.mjs";
4
4
  import "./chunk-HQMYRYMY.mjs";
5
5
  import "./chunk-XNS4O6QJ.mjs";
6
6
  export {
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  Guild
3
- } from "./chunk-Q4LJQGF6.mjs";
3
+ } from "./chunk-CREI4MOS.mjs";
4
4
  import "./chunk-PU73YRKJ.mjs";
5
5
  import "./chunk-DUQAD7F6.mjs";
6
6
  import "./chunk-X6K3ZD62.mjs";
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  Message
3
- } from "./chunk-V7LPVPGH.mjs";
3
+ } from "./chunk-VZPN7FNH.mjs";
4
4
  import "./chunk-AH7KYH2Z.mjs";
5
- import "./chunk-PM2IUGNR.mjs";
5
+ import "./chunk-VJDH54HJ.mjs";
6
6
  import "./chunk-XNS4O6QJ.mjs";
7
7
  export {
8
8
  Message
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  MessageReaction
3
- } from "./chunk-YL5S4W6R.mjs";
3
+ } from "./chunk-E6SU3TR5.mjs";
4
4
  import "./chunk-PU73YRKJ.mjs";
5
5
  import "./chunk-XNS4O6QJ.mjs";
6
6
  export {
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  Webhook
3
- } from "./chunk-CJVQNARM.mjs";
4
- import "./chunk-PM2IUGNR.mjs";
3
+ } from "./chunk-FSXTONUR.mjs";
4
+ import "./chunk-VJDH54HJ.mjs";
5
5
  import "./chunk-X6K3ZD62.mjs";
6
6
  import "./chunk-HQMYRYMY.mjs";
7
7
  import "./chunk-XNS4O6QJ.mjs";
@@ -82,7 +82,7 @@ var User = class extends Base {
82
82
  * Returns the DM channel; use {@link DMChannel.send} to send messages.
83
83
  */
84
84
  async createDM() {
85
- const { DMChannel: DMChannelClass } = await import("./Channel-YB3LWDHZ.mjs");
85
+ const { DMChannel: DMChannelClass } = await import("./Channel-HBKXUNL5.mjs");
86
86
  const data = await this.client.rest.post(Routes.userMeChannels(), {
87
87
  body: { recipient_id: this.id },
88
88
  auth: true
@@ -110,7 +110,7 @@ var ClientUser = class extends User {
110
110
  * @returns Array of Guild objects (cached in client.guilds)
111
111
  */
112
112
  async fetchGuilds() {
113
- const { Guild } = await import("./Guild-BL7JEF2B.mjs");
113
+ const { Guild } = await import("./Guild-3ETPHHF5.mjs");
114
114
  const data = await this.client.rest.get(Routes2.currentUserGuilds());
115
115
  const list = Array.isArray(data) ? data : data?.guilds ?? [];
116
116
  const guilds = [];
@@ -345,7 +345,7 @@ var Guild = class extends Base {
345
345
  }
346
346
  /** Fetch all webhooks in this guild. Returned webhooks do not include the token (cannot send). */
347
347
  async fetchWebhooks() {
348
- const { Webhook } = await import("./Webhook-RWDDYW2Q.mjs");
348
+ const { Webhook } = await import("./Webhook-WIF6OGPA.mjs");
349
349
  const data = await this.client.rest.get(Routes.guildWebhooks(this.id));
350
350
  const list = Array.isArray(data) ? data : Object.values(data ?? {});
351
351
  return list.map((w) => new Webhook(this.client, w));
@@ -356,7 +356,7 @@ var Guild = class extends Base {
356
356
  * Requires Manage Channels permission.
357
357
  */
358
358
  async createChannel(data) {
359
- const { Channel } = await import("./Channel-YB3LWDHZ.mjs");
359
+ const { Channel } = await import("./Channel-HBKXUNL5.mjs");
360
360
  const created = await this.client.rest.post(Routes.guildChannels(this.id), {
361
361
  body: data,
362
362
  auth: true
@@ -373,7 +373,7 @@ var Guild = class extends Base {
373
373
  * @returns Array of GuildChannel objects (cached in guild.channels and client.channels)
374
374
  */
375
375
  async fetchChannels() {
376
- const { Channel } = await import("./Channel-YB3LWDHZ.mjs");
376
+ const { Channel } = await import("./Channel-HBKXUNL5.mjs");
377
377
  const data = await this.client.rest.get(Routes.guildChannels(this.id));
378
378
  const list = Array.isArray(data) ? data : Object.values(data ?? {});
379
379
  const channels = [];
@@ -41,7 +41,7 @@ var MessageReaction = class extends Base {
41
41
  */
42
42
  async fetchMessage() {
43
43
  try {
44
- const { Message } = await import("./Message-OFIVTTAZ.mjs");
44
+ const { Message } = await import("./Message-DXBXIQIJ.mjs");
45
45
  const data = await this.client.rest.get(
46
46
  Routes.channelMessage(this.channelId, this.messageId)
47
47
  );
@@ -1,6 +1,7 @@
1
1
  import {
2
- buildSendBody
3
- } from "./chunk-PM2IUGNR.mjs";
2
+ buildSendBody,
3
+ resolveMessageFiles
4
+ } from "./chunk-VJDH54HJ.mjs";
4
5
  import {
5
6
  cdnAvatarURL
6
7
  } from "./chunk-X6K3ZD62.mjs";
@@ -99,13 +100,14 @@ var Webhook = class _Webhook extends Base {
99
100
  if (opts.avatar_url !== void 0) body.avatar_url = opts.avatar_url;
100
101
  if (opts.tts !== void 0) body.tts = opts.tts;
101
102
  const route = Routes.webhookExecute(this.id, this.token) + (wait ? "?wait=true" : "");
102
- const postOptions = opts.files?.length ? { body, files: opts.files, auth: false } : { body, auth: false };
103
+ const files = opts.files?.length ? await resolveMessageFiles(opts.files) : void 0;
104
+ const postOptions = files?.length ? { body, files, auth: false } : { body, auth: false };
103
105
  const data = await this.client.rest.post(
104
106
  route,
105
107
  postOptions
106
108
  );
107
109
  if (wait && data) {
108
- const { Message } = await import("./Message-OFIVTTAZ.mjs");
110
+ const { Message } = await import("./Message-DXBXIQIJ.mjs");
109
111
  return new Message(this.client, data);
110
112
  }
111
113
  return void 0;
@@ -6,8 +6,9 @@ import {
6
6
  Events
7
7
  } from "./chunk-AH7KYH2Z.mjs";
8
8
  import {
9
- buildSendBody
10
- } from "./chunk-PM2IUGNR.mjs";
9
+ buildSendBody,
10
+ resolveMessageFiles
11
+ } from "./chunk-VJDH54HJ.mjs";
11
12
  import {
12
13
  Base
13
14
  } from "./chunk-XNS4O6QJ.mjs";
@@ -28,7 +29,7 @@ var MessageManager = class {
28
29
  */
29
30
  async fetch(messageId) {
30
31
  try {
31
- const { Message } = await import("./Message-OFIVTTAZ.mjs");
32
+ const { Message } = await import("./Message-DXBXIQIJ.mjs");
32
33
  const data = await this.client.rest.get(
33
34
  Routes.channelMessage(this.channelId, messageId)
34
35
  );
@@ -199,7 +200,7 @@ var GuildChannel = class extends Channel {
199
200
  * @returns The webhook with token (required for send()). Requires Manage Webhooks permission.
200
201
  */
201
202
  async createWebhook(options) {
202
- const { Webhook } = await import("./Webhook-RWDDYW2Q.mjs");
203
+ const { Webhook } = await import("./Webhook-WIF6OGPA.mjs");
203
204
  const data = await this.client.rest.post(Routes2.channelWebhooks(this.id), {
204
205
  body: options,
205
206
  auth: true
@@ -211,7 +212,7 @@ var GuildChannel = class extends Channel {
211
212
  * @returns Webhooks (includes token when listing from channel; can send via send())
212
213
  */
213
214
  async fetchWebhooks() {
214
- const { Webhook } = await import("./Webhook-RWDDYW2Q.mjs");
215
+ const { Webhook } = await import("./Webhook-WIF6OGPA.mjs");
215
216
  const data = await this.client.rest.get(Routes2.channelWebhooks(this.id));
216
217
  const list = Array.isArray(data) ? data : Object.values(data ?? {});
217
218
  return list.map((w) => new Webhook(this.client, w));
@@ -264,8 +265,9 @@ var TextChannel = class extends GuildChannel {
264
265
  async send(options) {
265
266
  const opts = typeof options === "string" ? { content: options } : options;
266
267
  const body = buildSendBody(options);
267
- const { Message } = await import("./Message-OFIVTTAZ.mjs");
268
- const postOptions = opts.files?.length ? { body, files: opts.files } : { body };
268
+ const { Message } = await import("./Message-DXBXIQIJ.mjs");
269
+ const files = opts.files?.length ? await resolveMessageFiles(opts.files) : void 0;
270
+ const postOptions = files?.length ? { body, files } : { body };
269
271
  const data = await this.client.rest.post(Routes2.channelMessages(this.id), postOptions);
270
272
  return new Message(this.client, data);
271
273
  }
@@ -290,7 +292,7 @@ var TextChannel = class extends GuildChannel {
290
292
  * @returns Pinned messages
291
293
  */
292
294
  async fetchPinnedMessages() {
293
- const { Message } = await import("./Message-OFIVTTAZ.mjs");
295
+ const { Message } = await import("./Message-DXBXIQIJ.mjs");
294
296
  const data = await this.client.rest.get(Routes2.channelPins(this.id));
295
297
  const list = Array.isArray(data) ? data : data?.items ?? [];
296
298
  return list.map((item) => {
@@ -356,8 +358,9 @@ var DMChannel = class extends Channel {
356
358
  async send(options) {
357
359
  const opts = typeof options === "string" ? { content: options } : options;
358
360
  const body = buildSendBody(options);
359
- const { Message } = await import("./Message-OFIVTTAZ.mjs");
360
- const postOptions = opts.files?.length ? { body, files: opts.files } : { body };
361
+ const { Message } = await import("./Message-DXBXIQIJ.mjs");
362
+ const files = opts.files?.length ? await resolveMessageFiles(opts.files) : void 0;
363
+ const postOptions = files?.length ? { body, files } : { body };
361
364
  const data = await this.client.rest.post(Routes2.channelMessages(this.id), postOptions);
362
365
  return new Message(this.client, data);
363
366
  }
@@ -377,7 +380,7 @@ var DMChannel = class extends Channel {
377
380
  * @returns Pinned messages
378
381
  */
379
382
  async fetchPinnedMessages() {
380
- const { Message } = await import("./Message-OFIVTTAZ.mjs");
383
+ const { Message } = await import("./Message-DXBXIQIJ.mjs");
381
384
  const data = await this.client.rest.get(Routes2.channelPins(this.id));
382
385
  const list = Array.isArray(data) ? data : data?.items ?? [];
383
386
  return list.map((item) => {
@@ -0,0 +1,56 @@
1
+ // src/util/messageUtils.ts
2
+ import { EmbedBuilder } from "@fluxerjs/builders";
3
+ var FILE_FETCH_TIMEOUT_MS = 3e4;
4
+ async function resolveMessageFiles(files) {
5
+ const result = [];
6
+ for (let i = 0; i < files.length; i++) {
7
+ const f = files[i];
8
+ const filename = f.filename ?? f.name;
9
+ if ("url" in f && f.url) {
10
+ if (!URL.canParse(f.url)) {
11
+ throw new Error(`Invalid file URL at index ${i}: ${f.url}`);
12
+ }
13
+ const res = await fetch(f.url, {
14
+ signal: AbortSignal.timeout(FILE_FETCH_TIMEOUT_MS)
15
+ });
16
+ if (!res.ok) {
17
+ throw new Error(`Failed to fetch file from ${f.url}: ${res.status} ${res.statusText}`);
18
+ }
19
+ const data = await res.arrayBuffer();
20
+ result.push({ name: f.name, data, filename });
21
+ } else if ("data" in f && f.data != null) {
22
+ result.push({ name: f.name, data: f.data, filename });
23
+ } else {
24
+ throw new Error(`File at index ${i} must have either "data" or "url"`);
25
+ }
26
+ }
27
+ return result;
28
+ }
29
+ function buildSendBody(options) {
30
+ const body = typeof options === "string" ? { content: options } : options;
31
+ const result = {};
32
+ if (body.content !== void 0) result.content = body.content;
33
+ if (body.embeds?.length) {
34
+ result.embeds = body.embeds.map((e) => e instanceof EmbedBuilder ? e.toJSON() : e);
35
+ }
36
+ if (body.files?.length && body.attachments) {
37
+ result.attachments = body.attachments.map((a) => ({
38
+ id: a.id,
39
+ filename: a.filename,
40
+ ...a.title != null && { title: a.title },
41
+ ...a.description != null && { description: a.description },
42
+ ...a.flags != null && { flags: a.flags }
43
+ }));
44
+ } else if (body.files?.length) {
45
+ result.attachments = body.files.map((f, i) => ({
46
+ id: i,
47
+ filename: f.filename ?? f.name
48
+ }));
49
+ }
50
+ return result;
51
+ }
52
+
53
+ export {
54
+ resolveMessageFiles,
55
+ buildSendBody
56
+ };
@@ -2,8 +2,9 @@ import {
2
2
  Events
3
3
  } from "./chunk-AH7KYH2Z.mjs";
4
4
  import {
5
- buildSendBody
6
- } from "./chunk-PM2IUGNR.mjs";
5
+ buildSendBody,
6
+ resolveMessageFiles
7
+ } from "./chunk-VJDH54HJ.mjs";
7
8
  import {
8
9
  Base
9
10
  } from "./chunk-XNS4O6QJ.mjs";
@@ -148,7 +149,8 @@ var Message = class _Message extends Base {
148
149
  async send(options) {
149
150
  const opts = typeof options === "string" ? { content: options } : options;
150
151
  const body = buildSendBody(options);
151
- const postOptions = opts.files?.length ? { body, files: opts.files } : { body };
152
+ const files = opts.files?.length ? await resolveMessageFiles(opts.files) : void 0;
153
+ const postOptions = files?.length ? { body, files } : { body };
152
154
  const data = await this.client.rest.post(Routes.channelMessages(this.channelId), postOptions);
153
155
  return new _Message(this.client, data);
154
156
  }
@@ -178,7 +180,8 @@ var Message = class _Message extends Base {
178
180
  guild_id: this.guildId ?? void 0
179
181
  }
180
182
  };
181
- const postOptions = opts.files?.length ? { body, files: opts.files } : { body };
183
+ const files = opts.files?.length ? await resolveMessageFiles(opts.files) : void 0;
184
+ const postOptions = files?.length ? { body, files } : { body };
182
185
  const data = await this.client.rest.post(Routes.channelMessages(this.channelId), postOptions);
183
186
  return new _Message(this.client, data);
184
187
  }
package/dist/index.d.mts CHANGED
@@ -69,12 +69,16 @@ declare class MessageCollector extends EventEmitter {
69
69
  emit<K extends keyof MessageCollectorEvents>(event: K, ...args: MessageCollectorEvents[K]): boolean;
70
70
  }
71
71
 
72
- /** File data for message attachment uploads (Buffer supported in Node.js). */
73
- interface MessageFileData {
72
+ /** File data for message attachment uploads. Use `data` for buffers or `url` to fetch from a URL. */
73
+ type MessageFileData = {
74
74
  name: string;
75
75
  data: Blob | ArrayBuffer | Uint8Array | Buffer;
76
76
  filename?: string;
77
- }
77
+ } | {
78
+ name: string;
79
+ url: string;
80
+ filename?: string;
81
+ };
78
82
  /** Attachment metadata for file uploads (id matches FormData index). */
79
83
  interface MessageAttachmentMeta {
80
84
  id: number;
@@ -94,12 +98,8 @@ type MessageSendOptions = string | {
94
98
  attachments?: MessageAttachmentMeta[];
95
99
  };
96
100
 
97
- /** File data for webhook attachment uploads (Buffer supported in Node.js). */
98
- interface WebhookFileData {
99
- name: string;
100
- data: Blob | ArrayBuffer | Uint8Array | Buffer;
101
- filename?: string;
102
- }
101
+ /** File data for webhook attachment uploads. Use `data` for buffers or `url` to fetch from a URL. */
102
+ type WebhookFileData = MessageFileData;
103
103
  /** Attachment metadata for webhook file uploads (id matches FormData index). */
104
104
  interface WebhookAttachmentMeta {
105
105
  id: number;
package/dist/index.d.ts CHANGED
@@ -69,12 +69,16 @@ declare class MessageCollector extends EventEmitter {
69
69
  emit<K extends keyof MessageCollectorEvents>(event: K, ...args: MessageCollectorEvents[K]): boolean;
70
70
  }
71
71
 
72
- /** File data for message attachment uploads (Buffer supported in Node.js). */
73
- interface MessageFileData {
72
+ /** File data for message attachment uploads. Use `data` for buffers or `url` to fetch from a URL. */
73
+ type MessageFileData = {
74
74
  name: string;
75
75
  data: Blob | ArrayBuffer | Uint8Array | Buffer;
76
76
  filename?: string;
77
- }
77
+ } | {
78
+ name: string;
79
+ url: string;
80
+ filename?: string;
81
+ };
78
82
  /** Attachment metadata for file uploads (id matches FormData index). */
79
83
  interface MessageAttachmentMeta {
80
84
  id: number;
@@ -94,12 +98,8 @@ type MessageSendOptions = string | {
94
98
  attachments?: MessageAttachmentMeta[];
95
99
  };
96
100
 
97
- /** File data for webhook attachment uploads (Buffer supported in Node.js). */
98
- interface WebhookFileData {
99
- name: string;
100
- data: Blob | ArrayBuffer | Uint8Array | Buffer;
101
- filename?: string;
102
- }
101
+ /** File data for webhook attachment uploads. Use `data` for buffers or `url` to fetch from a URL. */
102
+ type WebhookFileData = MessageFileData;
103
103
  /** Attachment metadata for webhook file uploads (id matches FormData index). */
104
104
  interface WebhookAttachmentMeta {
105
105
  id: number;
package/dist/index.js CHANGED
@@ -56,6 +56,31 @@ var init_ErrorCodes = __esm({
56
56
  });
57
57
 
58
58
  // src/util/messageUtils.ts
59
+ async function resolveMessageFiles(files) {
60
+ const result = [];
61
+ for (let i = 0; i < files.length; i++) {
62
+ const f = files[i];
63
+ const filename = f.filename ?? f.name;
64
+ if ("url" in f && f.url) {
65
+ if (!URL.canParse(f.url)) {
66
+ throw new Error(`Invalid file URL at index ${i}: ${f.url}`);
67
+ }
68
+ const res = await fetch(f.url, {
69
+ signal: AbortSignal.timeout(FILE_FETCH_TIMEOUT_MS)
70
+ });
71
+ if (!res.ok) {
72
+ throw new Error(`Failed to fetch file from ${f.url}: ${res.status} ${res.statusText}`);
73
+ }
74
+ const data = await res.arrayBuffer();
75
+ result.push({ name: f.name, data, filename });
76
+ } else if ("data" in f && f.data != null) {
77
+ result.push({ name: f.name, data: f.data, filename });
78
+ } else {
79
+ throw new Error(`File at index ${i} must have either "data" or "url"`);
80
+ }
81
+ }
82
+ return result;
83
+ }
59
84
  function buildSendBody(options) {
60
85
  const body = typeof options === "string" ? { content: options } : options;
61
86
  const result = {};
@@ -79,11 +104,12 @@ function buildSendBody(options) {
79
104
  }
80
105
  return result;
81
106
  }
82
- var import_builders;
107
+ var import_builders, FILE_FETCH_TIMEOUT_MS;
83
108
  var init_messageUtils = __esm({
84
109
  "src/util/messageUtils.ts"() {
85
110
  "use strict";
86
111
  import_builders = require("@fluxerjs/builders");
112
+ FILE_FETCH_TIMEOUT_MS = 3e4;
87
113
  }
88
114
  });
89
115
 
@@ -306,7 +332,8 @@ var init_Message = __esm({
306
332
  async send(options) {
307
333
  const opts = typeof options === "string" ? { content: options } : options;
308
334
  const body = buildSendBody(options);
309
- const postOptions = opts.files?.length ? { body, files: opts.files } : { body };
335
+ const files = opts.files?.length ? await resolveMessageFiles(opts.files) : void 0;
336
+ const postOptions = files?.length ? { body, files } : { body };
310
337
  const data = await this.client.rest.post(import_types.Routes.channelMessages(this.channelId), postOptions);
311
338
  return new _Message(this.client, data);
312
339
  }
@@ -336,7 +363,8 @@ var init_Message = __esm({
336
363
  guild_id: this.guildId ?? void 0
337
364
  }
338
365
  };
339
- const postOptions = opts.files?.length ? { body, files: opts.files } : { body };
366
+ const files = opts.files?.length ? await resolveMessageFiles(opts.files) : void 0;
367
+ const postOptions = files?.length ? { body, files } : { body };
340
368
  const data = await this.client.rest.post(import_types.Routes.channelMessages(this.channelId), postOptions);
341
369
  return new _Message(this.client, data);
342
370
  }
@@ -718,7 +746,8 @@ var init_Webhook = __esm({
718
746
  if (opts.avatar_url !== void 0) body.avatar_url = opts.avatar_url;
719
747
  if (opts.tts !== void 0) body.tts = opts.tts;
720
748
  const route = import_types3.Routes.webhookExecute(this.id, this.token) + (wait ? "?wait=true" : "");
721
- const postOptions = opts.files?.length ? { body, files: opts.files, auth: false } : { body, auth: false };
749
+ const files = opts.files?.length ? await resolveMessageFiles(opts.files) : void 0;
750
+ const postOptions = files?.length ? { body, files, auth: false } : { body, auth: false };
722
751
  const data = await this.client.rest.post(
723
752
  route,
724
753
  postOptions
@@ -1012,7 +1041,8 @@ var init_Channel = __esm({
1012
1041
  const opts = typeof options === "string" ? { content: options } : options;
1013
1042
  const body = buildSendBody(options);
1014
1043
  const { Message: Message2 } = await Promise.resolve().then(() => (init_Message(), Message_exports));
1015
- const postOptions = opts.files?.length ? { body, files: opts.files } : { body };
1044
+ const files = opts.files?.length ? await resolveMessageFiles(opts.files) : void 0;
1045
+ const postOptions = files?.length ? { body, files } : { body };
1016
1046
  const data = await this.client.rest.post(import_types5.Routes.channelMessages(this.id), postOptions);
1017
1047
  return new Message2(this.client, data);
1018
1048
  }
@@ -1104,7 +1134,8 @@ var init_Channel = __esm({
1104
1134
  const opts = typeof options === "string" ? { content: options } : options;
1105
1135
  const body = buildSendBody(options);
1106
1136
  const { Message: Message2 } = await Promise.resolve().then(() => (init_Message(), Message_exports));
1107
- const postOptions = opts.files?.length ? { body, files: opts.files } : { body };
1137
+ const files = opts.files?.length ? await resolveMessageFiles(opts.files) : void 0;
1138
+ const postOptions = files?.length ? { body, files } : { body };
1108
1139
  const data = await this.client.rest.post(import_types5.Routes.channelMessages(this.id), postOptions);
1109
1140
  return new Message2(this.client, data);
1110
1141
  }
@@ -2254,7 +2285,8 @@ var ChannelManager = class extends import_collection4.Collection {
2254
2285
  const opts = typeof payload === "string" ? { content: payload } : payload;
2255
2286
  const body = buildSendBody(payload);
2256
2287
  const { Message: Message2 } = await Promise.resolve().then(() => (init_Message(), Message_exports));
2257
- const postOptions = opts.files?.length ? { body, files: opts.files } : { body };
2288
+ const files = opts.files?.length ? await resolveMessageFiles(opts.files) : void 0;
2289
+ const postOptions = files?.length ? { body, files } : { body };
2258
2290
  const data = await this.client.rest.post(import_types6.Routes.channelMessages(channelId), postOptions);
2259
2291
  return new Message2(this.client, data);
2260
2292
  }
package/dist/index.mjs CHANGED
@@ -1,21 +1,21 @@
1
1
  import {
2
2
  Guild,
3
3
  GuildMemberManager
4
- } from "./chunk-Q4LJQGF6.mjs";
4
+ } from "./chunk-CREI4MOS.mjs";
5
5
  import {
6
6
  MessageReaction
7
- } from "./chunk-YL5S4W6R.mjs";
7
+ } from "./chunk-E6SU3TR5.mjs";
8
8
  import {
9
9
  ClientUser,
10
10
  User
11
- } from "./chunk-5GTFNBZT.mjs";
11
+ } from "./chunk-4S42USSG.mjs";
12
12
  import {
13
13
  Message,
14
14
  ReactionCollector
15
- } from "./chunk-V7LPVPGH.mjs";
15
+ } from "./chunk-VZPN7FNH.mjs";
16
16
  import {
17
17
  Webhook
18
- } from "./chunk-CJVQNARM.mjs";
18
+ } from "./chunk-FSXTONUR.mjs";
19
19
  import {
20
20
  Invite
21
21
  } from "./chunk-QEXIYXXU.mjs";
@@ -29,7 +29,7 @@ import {
29
29
  MessageManager,
30
30
  TextChannel,
31
31
  VoiceChannel
32
- } from "./chunk-ZKKBIQBA.mjs";
32
+ } from "./chunk-NNZUZLG3.mjs";
33
33
  import {
34
34
  ErrorCodes,
35
35
  FluxerError
@@ -38,8 +38,9 @@ import {
38
38
  Events
39
39
  } from "./chunk-AH7KYH2Z.mjs";
40
40
  import {
41
- buildSendBody
42
- } from "./chunk-PM2IUGNR.mjs";
41
+ buildSendBody,
42
+ resolveMessageFiles
43
+ } from "./chunk-VJDH54HJ.mjs";
43
44
  import {
44
45
  GuildMember
45
46
  } from "./chunk-DUQAD7F6.mjs";
@@ -93,7 +94,7 @@ var ChannelManager = class extends Collection {
93
94
  const cached = this.get(channelId);
94
95
  if (cached) return cached;
95
96
  try {
96
- const { Channel: Channel2 } = await import("./Channel-YB3LWDHZ.mjs");
97
+ const { Channel: Channel2 } = await import("./Channel-HBKXUNL5.mjs");
97
98
  const data = await this.client.rest.get(
98
99
  Routes.channel(channelId)
99
100
  );
@@ -133,7 +134,7 @@ var ChannelManager = class extends Collection {
133
134
  "Use channel.messages.fetch(messageId). Prefer (await client.channels.fetch(channelId))?.messages?.fetch(messageId)."
134
135
  );
135
136
  try {
136
- const { Message: Message2 } = await import("./Message-OFIVTTAZ.mjs");
137
+ const { Message: Message2 } = await import("./Message-DXBXIQIJ.mjs");
137
138
  const data = await this.client.rest.get(
138
139
  Routes.channelMessage(channelId, messageId)
139
140
  );
@@ -163,8 +164,9 @@ var ChannelManager = class extends Collection {
163
164
  async send(channelId, payload) {
164
165
  const opts = typeof payload === "string" ? { content: payload } : payload;
165
166
  const body = buildSendBody(payload);
166
- const { Message: Message2 } = await import("./Message-OFIVTTAZ.mjs");
167
- const postOptions = opts.files?.length ? { body, files: opts.files } : { body };
167
+ const { Message: Message2 } = await import("./Message-DXBXIQIJ.mjs");
168
+ const files = opts.files?.length ? await resolveMessageFiles(opts.files) : void 0;
169
+ const postOptions = files?.length ? { body, files } : { body };
168
170
  const data = await this.client.rest.post(Routes.channelMessages(channelId), postOptions);
169
171
  return new Message2(this.client, data);
170
172
  }
@@ -190,7 +192,7 @@ var GuildManager = class extends Collection2 {
190
192
  const cached = this.get(guildId);
191
193
  if (cached) return cached;
192
194
  try {
193
- const { Guild: Guild2 } = await import("./Guild-BL7JEF2B.mjs");
195
+ const { Guild: Guild2 } = await import("./Guild-3ETPHHF5.mjs");
194
196
  const data = await this.client.rest.get(
195
197
  Routes2.guild(guildId)
196
198
  );
@@ -275,7 +277,7 @@ var UsersManager = class extends Collection3 {
275
277
  // src/client/EventHandlerRegistry.ts
276
278
  var handlers = /* @__PURE__ */ new Map();
277
279
  handlers.set("MESSAGE_CREATE", async (client, d) => {
278
- const { Message: Message2 } = await import("./Message-OFIVTTAZ.mjs");
280
+ const { Message: Message2 } = await import("./Message-DXBXIQIJ.mjs");
279
281
  const { GuildMember: GuildMember2 } = await import("./GuildMember-43B5E5CH.mjs");
280
282
  const data = d;
281
283
  if (data.guild_id && data.member && data.author) {
@@ -289,7 +291,7 @@ handlers.set("MESSAGE_CREATE", async (client, d) => {
289
291
  client.emit(Events.MessageCreate, new Message2(client, data));
290
292
  });
291
293
  handlers.set("MESSAGE_UPDATE", async (client, d) => {
292
- const { Message: Message2 } = await import("./Message-OFIVTTAZ.mjs");
294
+ const { Message: Message2 } = await import("./Message-DXBXIQIJ.mjs");
293
295
  client.emit(Events.MessageUpdate, null, new Message2(client, d));
294
296
  });
295
297
  handlers.set("MESSAGE_DELETE", async (client, d) => {
@@ -303,7 +305,7 @@ handlers.set("MESSAGE_DELETE", async (client, d) => {
303
305
  });
304
306
  handlers.set("MESSAGE_REACTION_ADD", async (client, d) => {
305
307
  const data = d;
306
- const { MessageReaction: MessageReaction2 } = await import("./MessageReaction-GYQNJ6GX.mjs");
308
+ const { MessageReaction: MessageReaction2 } = await import("./MessageReaction-NIAHV3EM.mjs");
307
309
  const reaction = new MessageReaction2(client, data);
308
310
  const user = client.getOrCreateUser({
309
311
  id: data.user_id,
@@ -322,7 +324,7 @@ handlers.set("MESSAGE_REACTION_ADD", async (client, d) => {
322
324
  });
323
325
  handlers.set("MESSAGE_REACTION_REMOVE", async (client, d) => {
324
326
  const data = d;
325
- const { MessageReaction: MessageReaction2 } = await import("./MessageReaction-GYQNJ6GX.mjs");
327
+ const { MessageReaction: MessageReaction2 } = await import("./MessageReaction-NIAHV3EM.mjs");
326
328
  const reaction = new MessageReaction2(client, data);
327
329
  const user = client.getOrCreateUser({
328
330
  id: data.user_id,
@@ -349,8 +351,8 @@ handlers.set("MESSAGE_REACTION_REMOVE_EMOJI", async (client, d) => {
349
351
  );
350
352
  });
351
353
  handlers.set("GUILD_CREATE", async (client, d) => {
352
- const { Guild: Guild2 } = await import("./Guild-BL7JEF2B.mjs");
353
- const { Channel: Channel2 } = await import("./Channel-YB3LWDHZ.mjs");
354
+ const { Guild: Guild2 } = await import("./Guild-3ETPHHF5.mjs");
355
+ const { Channel: Channel2 } = await import("./Channel-HBKXUNL5.mjs");
354
356
  const { GuildMember: GuildMember2 } = await import("./GuildMember-43B5E5CH.mjs");
355
357
  const raw = d;
356
358
  const guildData = raw?.properties != null ? { ...raw.properties, roles: raw.roles } : raw;
@@ -374,7 +376,7 @@ handlers.set("GUILD_CREATE", async (client, d) => {
374
376
  }
375
377
  });
376
378
  handlers.set("GUILD_UPDATE", async (client, d) => {
377
- const { Guild: Guild2 } = await import("./Guild-BL7JEF2B.mjs");
379
+ const { Guild: Guild2 } = await import("./Guild-3ETPHHF5.mjs");
378
380
  const raw = d;
379
381
  const guildData = raw?.properties != null ? { ...raw.properties, roles: raw.roles } : raw;
380
382
  const old = client.guilds.get(guildData.id);
@@ -391,7 +393,7 @@ handlers.set("GUILD_DELETE", async (client, d) => {
391
393
  }
392
394
  });
393
395
  handlers.set("CHANNEL_CREATE", async (client, d) => {
394
- const { Channel: Channel2 } = await import("./Channel-YB3LWDHZ.mjs");
396
+ const { Channel: Channel2 } = await import("./Channel-HBKXUNL5.mjs");
395
397
  const ch = Channel2.from(client, d);
396
398
  if (ch) {
397
399
  client.channels.set(ch.id, ch);
@@ -399,7 +401,7 @@ handlers.set("CHANNEL_CREATE", async (client, d) => {
399
401
  }
400
402
  });
401
403
  handlers.set("CHANNEL_UPDATE", async (client, d) => {
402
- const { Channel: Channel2 } = await import("./Channel-YB3LWDHZ.mjs");
404
+ const { Channel: Channel2 } = await import("./Channel-HBKXUNL5.mjs");
403
405
  const ch = d;
404
406
  const oldCh = client.channels.get(ch.id);
405
407
  const newCh = Channel2.from(client, ch);
@@ -734,9 +736,9 @@ var Client = class extends EventEmitter {
734
736
  async ({
735
737
  data
736
738
  }) => {
737
- const { ClientUser: ClientUser2 } = await import("./ClientUser-URMZ5DEV.mjs");
738
- const { Guild: Guild2 } = await import("./Guild-BL7JEF2B.mjs");
739
- const { Channel: Channel2 } = await import("./Channel-YB3LWDHZ.mjs");
739
+ const { ClientUser: ClientUser2 } = await import("./ClientUser-RXOB6K6C.mjs");
740
+ const { Guild: Guild2 } = await import("./Guild-3ETPHHF5.mjs");
741
+ const { Channel: Channel2 } = await import("./Channel-HBKXUNL5.mjs");
740
742
  this.user = new ClientUser2(this, data.user);
741
743
  for (const g of data.guilds ?? []) {
742
744
  const guildData = g && typeof g === "object" && "properties" in g && g.properties ? {
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "1.1.3",
6
+ "version": "1.1.4",
7
7
  "description": "A fully-featured SDK for Fluxer bots",
8
8
  "repository": {
9
9
  "type": "git",
@@ -34,12 +34,12 @@
34
34
  "dist"
35
35
  ],
36
36
  "dependencies": {
37
- "@fluxerjs/ws": "1.1.3",
38
- "@fluxerjs/rest": "1.1.3",
39
- "@fluxerjs/collection": "1.1.3",
40
- "@fluxerjs/util": "1.1.3",
41
- "@fluxerjs/types": "1.1.3",
42
- "@fluxerjs/builders": "1.1.3"
37
+ "@fluxerjs/rest": "1.1.4",
38
+ "@fluxerjs/builders": "1.1.4",
39
+ "@fluxerjs/collection": "1.1.4",
40
+ "@fluxerjs/ws": "1.1.4",
41
+ "@fluxerjs/util": "1.1.4",
42
+ "@fluxerjs/types": "1.1.4"
43
43
  },
44
44
  "devDependencies": {
45
45
  "@types/node": "^20.0.0",
@@ -1,29 +0,0 @@
1
- // src/util/messageUtils.ts
2
- import { EmbedBuilder } from "@fluxerjs/builders";
3
- function buildSendBody(options) {
4
- const body = typeof options === "string" ? { content: options } : options;
5
- const result = {};
6
- if (body.content !== void 0) result.content = body.content;
7
- if (body.embeds?.length) {
8
- result.embeds = body.embeds.map((e) => e instanceof EmbedBuilder ? e.toJSON() : e);
9
- }
10
- if (body.files?.length && body.attachments) {
11
- result.attachments = body.attachments.map((a) => ({
12
- id: a.id,
13
- filename: a.filename,
14
- ...a.title != null && { title: a.title },
15
- ...a.description != null && { description: a.description },
16
- ...a.flags != null && { flags: a.flags }
17
- }));
18
- } else if (body.files?.length) {
19
- result.attachments = body.files.map((f, i) => ({
20
- id: i,
21
- filename: f.filename ?? f.name
22
- }));
23
- }
24
- return result;
25
- }
26
-
27
- export {
28
- buildSendBody
29
- };