@fluxerjs/core 1.1.2 → 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-G2YVDCRB.mjs";
3
+ } from "./chunk-4S42USSG.mjs";
4
4
  import "./chunk-HQMYRYMY.mjs";
5
5
  import "./chunk-XNS4O6QJ.mjs";
6
6
  export {
@@ -1,11 +1,11 @@
1
1
  import {
2
2
  Guild
3
- } from "./chunk-KOTF4TTZ.mjs";
3
+ } from "./chunk-CREI4MOS.mjs";
4
4
  import "./chunk-PU73YRKJ.mjs";
5
5
  import "./chunk-DUQAD7F6.mjs";
6
6
  import "./chunk-X6K3ZD62.mjs";
7
7
  import "./chunk-HQMYRYMY.mjs";
8
- import "./chunk-5I54OXBG.mjs";
8
+ import "./chunk-2ZSMLDEI.mjs";
9
9
  import "./chunk-XNS4O6QJ.mjs";
10
10
  export {
11
11
  Guild
@@ -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,6 +1,6 @@
1
1
  import {
2
2
  Role
3
- } from "./chunk-5I54OXBG.mjs";
3
+ } from "./chunk-2ZSMLDEI.mjs";
4
4
  import "./chunk-XNS4O6QJ.mjs";
5
5
  export {
6
6
  Role
@@ -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";
@@ -4,7 +4,10 @@ import {
4
4
 
5
5
  // src/structures/Role.ts
6
6
  import { Routes } from "@fluxerjs/types";
7
- import { PermissionFlags, resolvePermissionsToBitfield } from "@fluxerjs/util";
7
+ import {
8
+ PermissionFlags,
9
+ resolvePermissionsToBitfield
10
+ } from "@fluxerjs/util";
8
11
  var Role = class extends Base {
9
12
  client;
10
13
  id;
@@ -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-MDW7KF33.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 = [];
@@ -10,13 +10,16 @@ import {
10
10
  } from "./chunk-HQMYRYMY.mjs";
11
11
  import {
12
12
  Role
13
- } from "./chunk-5I54OXBG.mjs";
13
+ } from "./chunk-2ZSMLDEI.mjs";
14
14
  import {
15
15
  Base
16
16
  } from "./chunk-XNS4O6QJ.mjs";
17
17
 
18
18
  // src/structures/Guild.ts
19
- import { parseRoleMention, resolvePermissionsToBitfield } from "@fluxerjs/util";
19
+ import {
20
+ parseRoleMention,
21
+ resolvePermissionsToBitfield
22
+ } from "@fluxerjs/util";
20
23
  import { FluxerAPIError } from "@fluxerjs/rest";
21
24
  import { Collection as Collection2 } from "@fluxerjs/collection";
22
25
 
@@ -342,7 +345,7 @@ var Guild = class extends Base {
342
345
  }
343
346
  /** Fetch all webhooks in this guild. Returned webhooks do not include the token (cannot send). */
344
347
  async fetchWebhooks() {
345
- const { Webhook } = await import("./Webhook-RWDDYW2Q.mjs");
348
+ const { Webhook } = await import("./Webhook-WIF6OGPA.mjs");
346
349
  const data = await this.client.rest.get(Routes.guildWebhooks(this.id));
347
350
  const list = Array.isArray(data) ? data : Object.values(data ?? {});
348
351
  return list.map((w) => new Webhook(this.client, w));
@@ -353,7 +356,7 @@ var Guild = class extends Base {
353
356
  * Requires Manage Channels permission.
354
357
  */
355
358
  async createChannel(data) {
356
- const { Channel } = await import("./Channel-YB3LWDHZ.mjs");
359
+ const { Channel } = await import("./Channel-HBKXUNL5.mjs");
357
360
  const created = await this.client.rest.post(Routes.guildChannels(this.id), {
358
361
  body: data,
359
362
  auth: true
@@ -370,7 +373,7 @@ var Guild = class extends Base {
370
373
  * @returns Array of GuildChannel objects (cached in guild.channels and client.channels)
371
374
  */
372
375
  async fetchChannels() {
373
- const { Channel } = await import("./Channel-YB3LWDHZ.mjs");
376
+ const { Channel } = await import("./Channel-HBKXUNL5.mjs");
374
377
  const data = await this.client.rest.get(Routes.guildChannels(this.id));
375
378
  const list = Array.isArray(data) ? data : Object.values(data ?? {});
376
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
  }
@@ -2352,11 +2384,7 @@ var UsersManager = class extends import_collection8.Collection {
2352
2384
  if (memberData && guildId) {
2353
2385
  const guild = this.client.guilds.get(guildId) ?? await this.client.guilds.fetch(guildId);
2354
2386
  if (guild) {
2355
- member = new GuildMember(
2356
- this.client,
2357
- { ...memberData, guild_id: guildId },
2358
- guild
2359
- );
2387
+ member = new GuildMember(this.client, { ...memberData, guild_id: guildId }, guild);
2360
2388
  guild.members.set(member.id, member);
2361
2389
  }
2362
2390
  }
@@ -2451,6 +2479,7 @@ handlers.set("MESSAGE_REACTION_REMOVE_EMOJI", async (client, d) => {
2451
2479
  handlers.set("GUILD_CREATE", async (client, d) => {
2452
2480
  const { Guild: Guild2 } = await Promise.resolve().then(() => (init_Guild(), Guild_exports));
2453
2481
  const { Channel: Channel2 } = await Promise.resolve().then(() => (init_Channel(), Channel_exports));
2482
+ const { GuildMember: GuildMember2 } = await Promise.resolve().then(() => (init_GuildMember(), GuildMember_exports));
2454
2483
  const raw = d;
2455
2484
  const guildData = raw?.properties != null ? { ...raw.properties, roles: raw.roles } : raw;
2456
2485
  const guild = new Guild2(client, guildData);
@@ -2460,6 +2489,13 @@ handlers.set("GUILD_CREATE", async (client, d) => {
2460
2489
  const channel = Channel2.from(client, ch);
2461
2490
  if (channel) client.channels.set(channel.id, channel);
2462
2491
  }
2492
+ for (const m of g.members ?? []) {
2493
+ if (m?.user?.id) {
2494
+ const memberData = { ...m, guild_id: guild.id };
2495
+ const member = new GuildMember2(client, memberData, guild);
2496
+ guild.members.set(member.id, member);
2497
+ }
2498
+ }
2463
2499
  client.emit(Events.GuildCreate, guild);
2464
2500
  if (g.voice_states?.length) {
2465
2501
  client.emit(Events.VoiceStatesSync, { guildId: guild.id, voiceStates: g.voice_states });
package/dist/index.mjs CHANGED
@@ -1,21 +1,21 @@
1
1
  import {
2
2
  Guild,
3
3
  GuildMemberManager
4
- } from "./chunk-KOTF4TTZ.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-G2YVDCRB.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";
@@ -56,7 +57,7 @@ import {
56
57
  } from "./chunk-HQMYRYMY.mjs";
57
58
  import {
58
59
  Role
59
- } from "./chunk-5I54OXBG.mjs";
60
+ } from "./chunk-2ZSMLDEI.mjs";
60
61
  import {
61
62
  GuildBan
62
63
  } from "./chunk-UXIF75BV.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-MDW7KF33.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
  );
@@ -257,11 +259,7 @@ var UsersManager = class extends Collection3 {
257
259
  if (memberData && guildId) {
258
260
  const guild = this.client.guilds.get(guildId) ?? await this.client.guilds.fetch(guildId);
259
261
  if (guild) {
260
- member = new GuildMember(
261
- this.client,
262
- { ...memberData, guild_id: guildId },
263
- guild
264
- );
262
+ member = new GuildMember(this.client, { ...memberData, guild_id: guildId }, guild);
265
263
  guild.members.set(member.id, member);
266
264
  }
267
265
  }
@@ -279,7 +277,7 @@ var UsersManager = class extends Collection3 {
279
277
  // src/client/EventHandlerRegistry.ts
280
278
  var handlers = /* @__PURE__ */ new Map();
281
279
  handlers.set("MESSAGE_CREATE", async (client, d) => {
282
- const { Message: Message2 } = await import("./Message-OFIVTTAZ.mjs");
280
+ const { Message: Message2 } = await import("./Message-DXBXIQIJ.mjs");
283
281
  const { GuildMember: GuildMember2 } = await import("./GuildMember-43B5E5CH.mjs");
284
282
  const data = d;
285
283
  if (data.guild_id && data.member && data.author) {
@@ -293,7 +291,7 @@ handlers.set("MESSAGE_CREATE", async (client, d) => {
293
291
  client.emit(Events.MessageCreate, new Message2(client, data));
294
292
  });
295
293
  handlers.set("MESSAGE_UPDATE", async (client, d) => {
296
- const { Message: Message2 } = await import("./Message-OFIVTTAZ.mjs");
294
+ const { Message: Message2 } = await import("./Message-DXBXIQIJ.mjs");
297
295
  client.emit(Events.MessageUpdate, null, new Message2(client, d));
298
296
  });
299
297
  handlers.set("MESSAGE_DELETE", async (client, d) => {
@@ -307,7 +305,7 @@ handlers.set("MESSAGE_DELETE", async (client, d) => {
307
305
  });
308
306
  handlers.set("MESSAGE_REACTION_ADD", async (client, d) => {
309
307
  const data = d;
310
- const { MessageReaction: MessageReaction2 } = await import("./MessageReaction-GYQNJ6GX.mjs");
308
+ const { MessageReaction: MessageReaction2 } = await import("./MessageReaction-NIAHV3EM.mjs");
311
309
  const reaction = new MessageReaction2(client, data);
312
310
  const user = client.getOrCreateUser({
313
311
  id: data.user_id,
@@ -326,7 +324,7 @@ handlers.set("MESSAGE_REACTION_ADD", async (client, d) => {
326
324
  });
327
325
  handlers.set("MESSAGE_REACTION_REMOVE", async (client, d) => {
328
326
  const data = d;
329
- const { MessageReaction: MessageReaction2 } = await import("./MessageReaction-GYQNJ6GX.mjs");
327
+ const { MessageReaction: MessageReaction2 } = await import("./MessageReaction-NIAHV3EM.mjs");
330
328
  const reaction = new MessageReaction2(client, data);
331
329
  const user = client.getOrCreateUser({
332
330
  id: data.user_id,
@@ -353,8 +351,9 @@ handlers.set("MESSAGE_REACTION_REMOVE_EMOJI", async (client, d) => {
353
351
  );
354
352
  });
355
353
  handlers.set("GUILD_CREATE", async (client, d) => {
356
- const { Guild: Guild2 } = await import("./Guild-MDW7KF33.mjs");
357
- 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");
356
+ const { GuildMember: GuildMember2 } = await import("./GuildMember-43B5E5CH.mjs");
358
357
  const raw = d;
359
358
  const guildData = raw?.properties != null ? { ...raw.properties, roles: raw.roles } : raw;
360
359
  const guild = new Guild2(client, guildData);
@@ -364,13 +363,20 @@ handlers.set("GUILD_CREATE", async (client, d) => {
364
363
  const channel = Channel2.from(client, ch);
365
364
  if (channel) client.channels.set(channel.id, channel);
366
365
  }
366
+ for (const m of g.members ?? []) {
367
+ if (m?.user?.id) {
368
+ const memberData = { ...m, guild_id: guild.id };
369
+ const member = new GuildMember2(client, memberData, guild);
370
+ guild.members.set(member.id, member);
371
+ }
372
+ }
367
373
  client.emit(Events.GuildCreate, guild);
368
374
  if (g.voice_states?.length) {
369
375
  client.emit(Events.VoiceStatesSync, { guildId: guild.id, voiceStates: g.voice_states });
370
376
  }
371
377
  });
372
378
  handlers.set("GUILD_UPDATE", async (client, d) => {
373
- const { Guild: Guild2 } = await import("./Guild-MDW7KF33.mjs");
379
+ const { Guild: Guild2 } = await import("./Guild-3ETPHHF5.mjs");
374
380
  const raw = d;
375
381
  const guildData = raw?.properties != null ? { ...raw.properties, roles: raw.roles } : raw;
376
382
  const old = client.guilds.get(guildData.id);
@@ -387,7 +393,7 @@ handlers.set("GUILD_DELETE", async (client, d) => {
387
393
  }
388
394
  });
389
395
  handlers.set("CHANNEL_CREATE", async (client, d) => {
390
- const { Channel: Channel2 } = await import("./Channel-YB3LWDHZ.mjs");
396
+ const { Channel: Channel2 } = await import("./Channel-HBKXUNL5.mjs");
391
397
  const ch = Channel2.from(client, d);
392
398
  if (ch) {
393
399
  client.channels.set(ch.id, ch);
@@ -395,7 +401,7 @@ handlers.set("CHANNEL_CREATE", async (client, d) => {
395
401
  }
396
402
  });
397
403
  handlers.set("CHANNEL_UPDATE", async (client, d) => {
398
- const { Channel: Channel2 } = await import("./Channel-YB3LWDHZ.mjs");
404
+ const { Channel: Channel2 } = await import("./Channel-HBKXUNL5.mjs");
399
405
  const ch = d;
400
406
  const oldCh = client.channels.get(ch.id);
401
407
  const newCh = Channel2.from(client, ch);
@@ -481,7 +487,7 @@ handlers.set("GUILD_ROLE_CREATE", async (client, d) => {
481
487
  const data = d;
482
488
  const guild = client.guilds.get(data.guild_id);
483
489
  if (guild) {
484
- const { Role: Role2 } = await import("./Role-N2ZEMRUQ.mjs");
490
+ const { Role: Role2 } = await import("./Role-SERSJFJC.mjs");
485
491
  guild.roles.set(data.role.id, new Role2(client, data.role, guild.id));
486
492
  }
487
493
  client.emit(Events.GuildRoleCreate, data);
@@ -494,7 +500,7 @@ handlers.set("GUILD_ROLE_UPDATE", async (client, d) => {
494
500
  if (existing) {
495
501
  existing._patch(data.role);
496
502
  } else {
497
- const { Role: Role2 } = await import("./Role-N2ZEMRUQ.mjs");
503
+ const { Role: Role2 } = await import("./Role-SERSJFJC.mjs");
498
504
  guild.roles.set(data.role.id, new Role2(client, data.role, guild.id));
499
505
  }
500
506
  }
@@ -730,9 +736,9 @@ var Client = class extends EventEmitter {
730
736
  async ({
731
737
  data
732
738
  }) => {
733
- const { ClientUser: ClientUser2 } = await import("./ClientUser-QQXLZ5WP.mjs");
734
- const { Guild: Guild2 } = await import("./Guild-MDW7KF33.mjs");
735
- 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");
736
742
  this.user = new ClientUser2(this, data.user);
737
743
  for (const g of data.guilds ?? []) {
738
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.2",
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/rest": "1.1.2",
38
- "@fluxerjs/ws": "1.1.2",
39
- "@fluxerjs/builders": "1.1.2",
40
- "@fluxerjs/util": "1.1.2",
41
- "@fluxerjs/types": "1.1.2",
42
- "@fluxerjs/collection": "1.1.2"
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
- };