@fluxerjs/core 1.0.9 → 1.1.0

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 (33) hide show
  1. package/dist/{Channel-ICWNKXBR.mjs → Channel-WJZZSNML.mjs} +3 -1
  2. package/dist/{ClientUser-WWXUMO5O.mjs → ClientUser-DJO2FS7P.mjs} +1 -1
  3. package/dist/Guild-2P77HBQM.mjs +11 -0
  4. package/dist/{GuildBan-M4PA3HAA.mjs → GuildBan-7CXLTPKY.mjs} +1 -1
  5. package/dist/GuildMember-43B5E5CH.mjs +9 -0
  6. package/dist/Message-OFIVTTAZ.mjs +9 -0
  7. package/dist/{MessageReaction-XRPYZDSC.mjs → MessageReaction-V4UZ7OXE.mjs} +1 -1
  8. package/dist/{Role-SVLWIAMN.mjs → Role-5MWSGL66.mjs} +1 -1
  9. package/dist/Webhook-RWDDYW2Q.mjs +10 -0
  10. package/dist/chunk-4XJIM6SC.mjs +315 -0
  11. package/dist/chunk-AH7KYH2Z.mjs +50 -0
  12. package/dist/{chunk-HBF5QEDH.mjs → chunk-CEABHTAF.mjs} +1 -0
  13. package/dist/{chunk-53Y37KRG.mjs → chunk-CJVQNARM.mjs} +44 -10
  14. package/dist/chunk-DQ4TNBPG.mjs +63 -0
  15. package/dist/chunk-DUQAD7F6.mjs +173 -0
  16. package/dist/{chunk-GCIJYVRC.mjs → chunk-JHNKZIHY.mjs} +54 -3
  17. package/dist/{chunk-FJS5FBXO.mjs → chunk-LU2SNC5G.mjs} +172 -13
  18. package/dist/chunk-PM2IUGNR.mjs +29 -0
  19. package/dist/{chunk-RCP27MRC.mjs → chunk-UXIF75BV.mjs} +3 -0
  20. package/dist/{chunk-DSPSRPHF.mjs → chunk-V7LPVPGH.mjs} +123 -18
  21. package/dist/chunk-X6K3ZD62.mjs +53 -0
  22. package/dist/index.d.mts +603 -113
  23. package/dist/index.d.ts +603 -113
  24. package/dist/index.js +1278 -410
  25. package/dist/index.mjs +183 -124
  26. package/package.json +7 -7
  27. package/dist/Guild-TM6YGJWB.mjs +0 -10
  28. package/dist/GuildMember-RZWZ3OCG.mjs +0 -7
  29. package/dist/Message-6IYEYSV6.mjs +0 -7
  30. package/dist/Webhook-32VJD4AL.mjs +0 -7
  31. package/dist/chunk-GFUJVQ7L.mjs +0 -64
  32. package/dist/chunk-SQVCCSNN.mjs +0 -41
  33. package/dist/chunk-X77DFNE3.mjs +0 -136
package/dist/index.mjs CHANGED
@@ -1,44 +1,62 @@
1
1
  import {
2
- GuildBan
3
- } from "./chunk-RCP27MRC.mjs";
2
+ ErrorCodes,
3
+ FluxerError,
4
+ Guild
5
+ } from "./chunk-4XJIM6SC.mjs";
4
6
  import {
5
- Invite
6
- } from "./chunk-QEXIYXXU.mjs";
7
+ MessageReaction
8
+ } from "./chunk-CEABHTAF.mjs";
7
9
  import {
8
10
  ClientUser,
9
11
  User
10
- } from "./chunk-GCIJYVRC.mjs";
12
+ } from "./chunk-JHNKZIHY.mjs";
13
+ import {
14
+ Message,
15
+ ReactionCollector
16
+ } from "./chunk-V7LPVPGH.mjs";
11
17
  import {
12
18
  Webhook
13
- } from "./chunk-53Y37KRG.mjs";
19
+ } from "./chunk-CJVQNARM.mjs";
14
20
  import {
15
- Message
16
- } from "./chunk-DSPSRPHF.mjs";
21
+ Invite
22
+ } from "./chunk-QEXIYXXU.mjs";
17
23
  import {
18
24
  CategoryChannel,
19
25
  Channel,
20
26
  DMChannel,
21
27
  GuildChannel,
22
28
  LinkChannel,
29
+ MessageCollector,
23
30
  MessageManager,
24
31
  TextChannel,
25
32
  VoiceChannel
26
- } from "./chunk-FJS5FBXO.mjs";
33
+ } from "./chunk-LU2SNC5G.mjs";
27
34
  import {
28
- Guild
29
- } from "./chunk-X77DFNE3.mjs";
35
+ Events
36
+ } from "./chunk-AH7KYH2Z.mjs";
30
37
  import {
31
- CDN_URL
32
- } from "./chunk-HQMYRYMY.mjs";
38
+ buildSendBody
39
+ } from "./chunk-PM2IUGNR.mjs";
33
40
  import {
34
41
  GuildMember
35
- } from "./chunk-GFUJVQ7L.mjs";
42
+ } from "./chunk-DUQAD7F6.mjs";
43
+ import {
44
+ cdnAvatarURL,
45
+ cdnBannerURL,
46
+ cdnDefaultAvatarURL,
47
+ cdnDisplayAvatarURL,
48
+ cdnMemberAvatarURL,
49
+ cdnMemberBannerURL
50
+ } from "./chunk-X6K3ZD62.mjs";
51
+ import {
52
+ CDN_URL
53
+ } from "./chunk-HQMYRYMY.mjs";
36
54
  import {
37
55
  Role
38
- } from "./chunk-SQVCCSNN.mjs";
56
+ } from "./chunk-DQ4TNBPG.mjs";
39
57
  import {
40
- MessageReaction
41
- } from "./chunk-HBF5QEDH.mjs";
58
+ GuildBan
59
+ } from "./chunk-UXIF75BV.mjs";
42
60
  import {
43
61
  Base
44
62
  } from "./chunk-XNS4O6QJ.mjs";
@@ -53,6 +71,8 @@ import { Collection as Collection3 } from "@fluxerjs/collection";
53
71
  // src/client/ChannelManager.ts
54
72
  import { Collection } from "@fluxerjs/collection";
55
73
  import { Routes } from "@fluxerjs/types";
74
+ import { emitDeprecationWarning } from "@fluxerjs/util";
75
+ import { FluxerAPIError, RateLimitError } from "@fluxerjs/rest";
56
76
  var ChannelManager = class extends Collection {
57
77
  constructor(client) {
58
78
  super();
@@ -61,7 +81,8 @@ var ChannelManager = class extends Collection {
61
81
  /**
62
82
  * Fetch a channel by ID from the API (or return from cache if present).
63
83
  * @param channelId - Snowflake of the channel
64
- * @returns The channel, or null if not found
84
+ * @returns The channel
85
+ * @throws FluxerError with CHANNEL_NOT_FOUND if the channel does not exist
65
86
  * @example
66
87
  * const channel = await client.channels.fetch(channelId);
67
88
  * if (channel?.isSendable()) await channel.send('Hello!');
@@ -70,52 +91,79 @@ var ChannelManager = class extends Collection {
70
91
  const cached = this.get(channelId);
71
92
  if (cached) return cached;
72
93
  try {
73
- const { Channel: Channel2 } = await import("./Channel-ICWNKXBR.mjs");
94
+ const { Channel: Channel2 } = await import("./Channel-WJZZSNML.mjs");
74
95
  const data = await this.client.rest.get(
75
96
  Routes.channel(channelId)
76
97
  );
77
98
  const channel = Channel2.fromOrCreate(this.client, data);
78
- if (channel) this.set(channel.id, channel);
99
+ if (!channel) {
100
+ throw new FluxerError("Channel data invalid or unsupported type", {
101
+ code: ErrorCodes.ChannelNotFound
102
+ });
103
+ }
104
+ this.set(channel.id, channel);
79
105
  return channel;
80
- } catch {
81
- return null;
106
+ } catch (err) {
107
+ if (err instanceof RateLimitError) throw err;
108
+ if (err instanceof FluxerAPIError && err.statusCode === 404) {
109
+ throw new FluxerError(`Channel ${channelId} not found`, {
110
+ code: ErrorCodes.ChannelNotFound,
111
+ cause: err
112
+ });
113
+ }
114
+ throw err instanceof FluxerError ? err : new FluxerError(String(err), { cause: err });
82
115
  }
83
116
  }
84
117
  /**
85
118
  * Fetch a message by ID from the API.
86
119
  * @param channelId - Snowflake of the channel
87
120
  * @param messageId - Snowflake of the message
88
- * @returns The message, or null if not found
121
+ * @returns The message
122
+ * @throws FluxerError with MESSAGE_NOT_FOUND if the message does not exist
89
123
  * @deprecated Use channel.messages.fetch(messageId). Prefer (await client.channels.fetch(channelId))?.messages?.fetch(messageId).
90
124
  * @example
91
125
  * const channel = await client.channels.fetch(channelId);
92
126
  * const message = await channel?.messages?.fetch(messageId);
93
127
  */
94
128
  async fetchMessage(channelId, messageId) {
129
+ emitDeprecationWarning(
130
+ "ChannelManager.fetchMessage()",
131
+ "Use channel.messages.fetch(messageId). Prefer (await client.channels.fetch(channelId))?.messages?.fetch(messageId)."
132
+ );
95
133
  try {
96
- const { Message: Message2 } = await import("./Message-6IYEYSV6.mjs");
134
+ const { Message: Message2 } = await import("./Message-OFIVTTAZ.mjs");
97
135
  const data = await this.client.rest.get(
98
136
  Routes.channelMessage(channelId, messageId)
99
137
  );
100
138
  return new Message2(this.client, data);
101
- } catch {
102
- return null;
139
+ } catch (err) {
140
+ if (err instanceof RateLimitError) throw err;
141
+ if (err instanceof FluxerAPIError && err.statusCode === 404) {
142
+ throw new FluxerError(`Message ${messageId} not found in channel ${channelId}`, {
143
+ code: ErrorCodes.MessageNotFound,
144
+ cause: err
145
+ });
146
+ }
147
+ throw err instanceof FluxerError ? err : new FluxerError(String(err), { cause: err });
103
148
  }
104
149
  }
105
150
  /**
106
151
  * Send a message to a channel by ID. Works even when the channel is not cached.
107
152
  * Skips the fetch when you only need to send.
108
153
  * @param channelId - Snowflake of the channel (text channel or DM)
109
- * @param payload - Text content or object with content and/or embeds
154
+ * @param payload - Text content or object with content, embeds, and/or files
110
155
  * @returns The created message
111
156
  * @example
112
157
  * await client.channels.send(logChannelId, 'User joined!');
113
158
  * await client.channels.send(channelId, { embeds: [embed.toJSON()] });
159
+ * await client.channels.send(channelId, { content: 'Report', files: [{ name: 'log.txt', data }] });
114
160
  */
115
161
  async send(channelId, payload) {
116
- const body = typeof payload === "string" ? { content: payload } : payload;
117
- const { Message: Message2 } = await import("./Message-6IYEYSV6.mjs");
118
- const data = await this.client.rest.post(Routes.channelMessages(channelId), { body });
162
+ const opts = typeof payload === "string" ? { content: payload } : payload;
163
+ const body = buildSendBody(payload);
164
+ const { Message: Message2 } = await import("./Message-OFIVTTAZ.mjs");
165
+ const postOptions = opts.files?.length ? { body, files: opts.files } : { body };
166
+ const data = await this.client.rest.post(Routes.channelMessages(channelId), postOptions);
119
167
  return new Message2(this.client, data);
120
168
  }
121
169
  };
@@ -140,7 +188,7 @@ var GuildManager = class extends Collection2 {
140
188
  const cached = this.get(guildId);
141
189
  if (cached) return cached;
142
190
  try {
143
- const { Guild: Guild2 } = await import("./Guild-TM6YGJWB.mjs");
191
+ const { Guild: Guild2 } = await import("./Guild-2P77HBQM.mjs");
144
192
  const data = await this.client.rest.get(
145
193
  Routes2.guild(guildId)
146
194
  );
@@ -153,73 +201,27 @@ var GuildManager = class extends Collection2 {
153
201
  }
154
202
  };
155
203
 
156
- // src/errors/FluxerError.ts
157
- var FluxerError = class _FluxerError extends Error {
158
- constructor(message) {
159
- super(message);
160
- this.name = "FluxerError";
161
- Object.setPrototypeOf(this, _FluxerError.prototype);
162
- }
163
- };
164
-
165
- // src/util/Events.ts
166
- var Events = {
167
- Ready: "ready",
168
- MessageCreate: "messageCreate",
169
- MessageUpdate: "messageUpdate",
170
- MessageDelete: "messageDelete",
171
- MessageDeleteBulk: "messageDeleteBulk",
172
- MessageReactionAdd: "messageReactionAdd",
173
- MessageReactionRemove: "messageReactionRemove",
174
- MessageReactionRemoveAll: "messageReactionRemoveAll",
175
- MessageReactionRemoveEmoji: "messageReactionRemoveEmoji",
176
- InteractionCreate: "interactionCreate",
177
- GuildCreate: "guildCreate",
178
- GuildUpdate: "guildUpdate",
179
- GuildDelete: "guildDelete",
180
- GuildBanAdd: "guildBanAdd",
181
- GuildBanRemove: "guildBanRemove",
182
- GuildEmojisUpdate: "guildEmojisUpdate",
183
- GuildStickersUpdate: "guildStickersUpdate",
184
- GuildIntegrationsUpdate: "guildIntegrationsUpdate",
185
- GuildMemberAdd: "guildMemberAdd",
186
- GuildMemberUpdate: "guildMemberUpdate",
187
- GuildMemberRemove: "guildMemberRemove",
188
- GuildRoleCreate: "guildRoleCreate",
189
- GuildRoleUpdate: "guildRoleUpdate",
190
- GuildRoleDelete: "guildRoleDelete",
191
- GuildScheduledEventCreate: "guildScheduledEventCreate",
192
- GuildScheduledEventUpdate: "guildScheduledEventUpdate",
193
- GuildScheduledEventDelete: "guildScheduledEventDelete",
194
- ChannelCreate: "channelCreate",
195
- ChannelUpdate: "channelUpdate",
196
- ChannelDelete: "channelDelete",
197
- ChannelPinsUpdate: "channelPinsUpdate",
198
- InviteCreate: "inviteCreate",
199
- InviteDelete: "inviteDelete",
200
- TypingStart: "typingStart",
201
- UserUpdate: "userUpdate",
202
- PresenceUpdate: "presenceUpdate",
203
- VoiceStateUpdate: "voiceStateUpdate",
204
- VoiceServerUpdate: "voiceServerUpdate",
205
- VoiceStatesSync: "voiceStatesSync",
206
- WebhooksUpdate: "webhooksUpdate",
207
- Resumed: "resumed",
208
- Error: "error",
209
- Debug: "debug"
210
- };
211
-
212
204
  // src/client/Client.ts
213
- import { formatEmoji, parseEmoji } from "@fluxerjs/util";
205
+ import { emitDeprecationWarning as emitDeprecationWarning2, formatEmoji, parseEmoji } from "@fluxerjs/util";
214
206
 
215
207
  // src/client/EventHandlerRegistry.ts
216
208
  var handlers = /* @__PURE__ */ new Map();
217
209
  handlers.set("MESSAGE_CREATE", async (client, d) => {
218
- const { Message: Message2 } = await import("./Message-6IYEYSV6.mjs");
219
- client.emit(Events.MessageCreate, new Message2(client, d));
210
+ const { Message: Message2 } = await import("./Message-OFIVTTAZ.mjs");
211
+ const { GuildMember: GuildMember2 } = await import("./GuildMember-43B5E5CH.mjs");
212
+ const data = d;
213
+ if (data.guild_id && data.member && data.author) {
214
+ const guild = client.guilds.get(data.guild_id);
215
+ if (guild) {
216
+ const memberData = { ...data.member, user: data.author, guild_id: data.guild_id };
217
+ const member = new GuildMember2(client, memberData, guild);
218
+ guild.members.set(member.id, member);
219
+ }
220
+ }
221
+ client.emit(Events.MessageCreate, new Message2(client, data));
220
222
  });
221
223
  handlers.set("MESSAGE_UPDATE", async (client, d) => {
222
- const { Message: Message2 } = await import("./Message-6IYEYSV6.mjs");
224
+ const { Message: Message2 } = await import("./Message-OFIVTTAZ.mjs");
223
225
  client.emit(Events.MessageUpdate, null, new Message2(client, d));
224
226
  });
225
227
  handlers.set("MESSAGE_DELETE", async (client, d) => {
@@ -233,25 +235,41 @@ handlers.set("MESSAGE_DELETE", async (client, d) => {
233
235
  });
234
236
  handlers.set("MESSAGE_REACTION_ADD", async (client, d) => {
235
237
  const data = d;
236
- const { MessageReaction: MessageReaction2 } = await import("./MessageReaction-XRPYZDSC.mjs");
238
+ const { MessageReaction: MessageReaction2 } = await import("./MessageReaction-V4UZ7OXE.mjs");
237
239
  const reaction = new MessageReaction2(client, data);
238
240
  const user = client.getOrCreateUser({
239
241
  id: data.user_id,
240
242
  username: "Unknown",
241
243
  discriminator: "0"
242
244
  });
243
- client.emit(Events.MessageReactionAdd, reaction, user);
245
+ client.emit(
246
+ Events.MessageReactionAdd,
247
+ reaction,
248
+ user,
249
+ reaction.messageId,
250
+ reaction.channelId,
251
+ reaction.emoji,
252
+ user.id
253
+ );
244
254
  });
245
255
  handlers.set("MESSAGE_REACTION_REMOVE", async (client, d) => {
246
256
  const data = d;
247
- const { MessageReaction: MessageReaction2 } = await import("./MessageReaction-XRPYZDSC.mjs");
257
+ const { MessageReaction: MessageReaction2 } = await import("./MessageReaction-V4UZ7OXE.mjs");
248
258
  const reaction = new MessageReaction2(client, data);
249
259
  const user = client.getOrCreateUser({
250
260
  id: data.user_id,
251
261
  username: "Unknown",
252
262
  discriminator: "0"
253
263
  });
254
- client.emit(Events.MessageReactionRemove, reaction, user);
264
+ client.emit(
265
+ Events.MessageReactionRemove,
266
+ reaction,
267
+ user,
268
+ reaction.messageId,
269
+ reaction.channelId,
270
+ reaction.emoji,
271
+ user.id
272
+ );
255
273
  });
256
274
  handlers.set("MESSAGE_REACTION_REMOVE_ALL", async (client, d) => {
257
275
  client.emit(Events.MessageReactionRemoveAll, d);
@@ -263,9 +281,11 @@ handlers.set("MESSAGE_REACTION_REMOVE_EMOJI", async (client, d) => {
263
281
  );
264
282
  });
265
283
  handlers.set("GUILD_CREATE", async (client, d) => {
266
- const { Guild: Guild2 } = await import("./Guild-TM6YGJWB.mjs");
267
- const { Channel: Channel2 } = await import("./Channel-ICWNKXBR.mjs");
268
- const guild = new Guild2(client, d);
284
+ const { Guild: Guild2 } = await import("./Guild-2P77HBQM.mjs");
285
+ const { Channel: Channel2 } = await import("./Channel-WJZZSNML.mjs");
286
+ const raw = d;
287
+ const guildData = raw?.properties != null ? { ...raw.properties, roles: raw.roles } : raw;
288
+ const guild = new Guild2(client, guildData);
269
289
  client.guilds.set(guild.id, guild);
270
290
  const g = d;
271
291
  for (const ch of g.channels ?? []) {
@@ -278,10 +298,11 @@ handlers.set("GUILD_CREATE", async (client, d) => {
278
298
  }
279
299
  });
280
300
  handlers.set("GUILD_UPDATE", async (client, d) => {
281
- const { Guild: Guild2 } = await import("./Guild-TM6YGJWB.mjs");
282
- const g = d;
283
- const old = client.guilds.get(g.id);
284
- const updated = new Guild2(client, g);
301
+ const { Guild: Guild2 } = await import("./Guild-2P77HBQM.mjs");
302
+ const raw = d;
303
+ const guildData = raw?.properties != null ? { ...raw.properties, roles: raw.roles } : raw;
304
+ const old = client.guilds.get(guildData.id);
305
+ const updated = new Guild2(client, guildData);
285
306
  client.guilds.set(updated.id, updated);
286
307
  client.emit(Events.GuildUpdate, old ?? updated, updated);
287
308
  });
@@ -294,7 +315,7 @@ handlers.set("GUILD_DELETE", async (client, d) => {
294
315
  }
295
316
  });
296
317
  handlers.set("CHANNEL_CREATE", async (client, d) => {
297
- const { Channel: Channel2 } = await import("./Channel-ICWNKXBR.mjs");
318
+ const { Channel: Channel2 } = await import("./Channel-WJZZSNML.mjs");
298
319
  const ch = Channel2.from(client, d);
299
320
  if (ch) {
300
321
  client.channels.set(ch.id, ch);
@@ -302,7 +323,7 @@ handlers.set("CHANNEL_CREATE", async (client, d) => {
302
323
  }
303
324
  });
304
325
  handlers.set("CHANNEL_UPDATE", async (client, d) => {
305
- const { Channel: Channel2 } = await import("./Channel-ICWNKXBR.mjs");
326
+ const { Channel: Channel2 } = await import("./Channel-WJZZSNML.mjs");
306
327
  const ch = d;
307
328
  const oldCh = client.channels.get(ch.id);
308
329
  const newCh = Channel2.from(client, ch);
@@ -320,7 +341,7 @@ handlers.set("CHANNEL_DELETE", async (client, d) => {
320
341
  }
321
342
  });
322
343
  handlers.set("GUILD_MEMBER_ADD", async (client, d) => {
323
- const { GuildMember: GuildMember2 } = await import("./GuildMember-RZWZ3OCG.mjs");
344
+ const { GuildMember: GuildMember2 } = await import("./GuildMember-43B5E5CH.mjs");
324
345
  const data = d;
325
346
  const guild = client.guilds.get(data.guild_id);
326
347
  if (guild) {
@@ -330,7 +351,7 @@ handlers.set("GUILD_MEMBER_ADD", async (client, d) => {
330
351
  }
331
352
  });
332
353
  handlers.set("GUILD_MEMBER_UPDATE", async (client, d) => {
333
- const { GuildMember: GuildMember2 } = await import("./GuildMember-RZWZ3OCG.mjs");
354
+ const { GuildMember: GuildMember2 } = await import("./GuildMember-43B5E5CH.mjs");
334
355
  const data = d;
335
356
  const guild = client.guilds.get(data.guild_id);
336
357
  if (guild) {
@@ -365,13 +386,13 @@ handlers.set("MESSAGE_DELETE_BULK", async (client, d) => {
365
386
  });
366
387
  handlers.set("GUILD_BAN_ADD", async (client, d) => {
367
388
  const data = d;
368
- const { GuildBan: GuildBan2 } = await import("./GuildBan-M4PA3HAA.mjs");
389
+ const { GuildBan: GuildBan2 } = await import("./GuildBan-7CXLTPKY.mjs");
369
390
  const ban = new GuildBan2(client, data, data.guild_id);
370
391
  client.emit(Events.GuildBanAdd, ban);
371
392
  });
372
393
  handlers.set("GUILD_BAN_REMOVE", async (client, d) => {
373
394
  const data = d;
374
- const { GuildBan: GuildBan2 } = await import("./GuildBan-M4PA3HAA.mjs");
395
+ const { GuildBan: GuildBan2 } = await import("./GuildBan-7CXLTPKY.mjs");
375
396
  const ban = new GuildBan2(client, { ...data, reason: null }, data.guild_id);
376
397
  client.emit(Events.GuildBanRemove, ban);
377
398
  });
@@ -388,7 +409,7 @@ handlers.set("GUILD_ROLE_CREATE", async (client, d) => {
388
409
  const data = d;
389
410
  const guild = client.guilds.get(data.guild_id);
390
411
  if (guild) {
391
- const { Role: Role2 } = await import("./Role-SVLWIAMN.mjs");
412
+ const { Role: Role2 } = await import("./Role-5MWSGL66.mjs");
392
413
  guild.roles.set(data.role.id, new Role2(client, data.role, guild.id));
393
414
  }
394
415
  client.emit(Events.GuildRoleCreate, data);
@@ -397,7 +418,7 @@ handlers.set("GUILD_ROLE_UPDATE", async (client, d) => {
397
418
  const data = d;
398
419
  const guild = client.guilds.get(data.guild_id);
399
420
  if (guild) {
400
- const { Role: Role2 } = await import("./Role-SVLWIAMN.mjs");
421
+ const { Role: Role2 } = await import("./Role-5MWSGL66.mjs");
401
422
  guild.roles.set(data.role.id, new Role2(client, data.role, guild.id));
402
423
  }
403
424
  client.emit(Events.GuildRoleUpdate, data);
@@ -450,11 +471,23 @@ handlers.set("RESUMED", async (client) => {
450
471
  var eventHandlers = handlers;
451
472
 
452
473
  // src/client/Client.ts
474
+ function createEventMethods(client) {
475
+ const result = {};
476
+ for (const key of Object.keys(Events)) {
477
+ const eventName = Events[key];
478
+ result[key] = (cb) => {
479
+ client.on(eventName, cb);
480
+ return client;
481
+ };
482
+ }
483
+ return result;
484
+ }
453
485
  var Client = class extends EventEmitter {
454
486
  /** @param options - Token, REST config, WebSocket, presence, etc. */
455
487
  constructor(options = {}) {
456
488
  super();
457
489
  this.options = options;
490
+ this.events = createEventMethods(this);
458
491
  Object.defineProperty(this.channels, "cache", {
459
492
  get: () => this.channels,
460
493
  configurable: true
@@ -473,7 +506,11 @@ var Client = class extends EventEmitter {
473
506
  guilds = new GuildManager(this);
474
507
  channels = new ChannelManager(this);
475
508
  users = new Collection3();
509
+ /** Typed event handlers. Use client.events.MessageReactionAdd((reaction, user, messageId, channelId, emoji, userId) => {...}) or client.on(Events.MessageReactionAdd, ...). */
510
+ events;
511
+ /** The authenticated bot user. Null until READY is received. */
476
512
  user = null;
513
+ /** Timestamp when the client became ready. Null until READY is received. */
477
514
  readyAt = null;
478
515
  _ws = null;
479
516
  /**
@@ -511,13 +548,18 @@ var Client = class extends EventEmitter {
511
548
  * Fetch a message by channel and message ID. Use when you have IDs (e.g. from a DB).
512
549
  * @param channelId - Snowflake of the channel
513
550
  * @param messageId - Snowflake of the message
514
- * @returns The message, or null if not found
551
+ * @returns The message
552
+ * @throws FluxerError with MESSAGE_NOT_FOUND if the message does not exist
515
553
  * @deprecated Use channel.messages.fetch(messageId). For IDs-only: (await client.channels.fetch(channelId))?.messages?.fetch(messageId)
516
554
  * @example
517
555
  * const channel = await client.channels.fetch(channelId);
518
556
  * const message = await channel?.messages?.fetch(messageId);
519
557
  */
520
558
  async fetchMessage(channelId, messageId) {
559
+ emitDeprecationWarning2(
560
+ "Client.fetchMessage()",
561
+ "Use channel.messages.fetch(messageId). For IDs-only: (await client.channels.fetch(channelId))?.messages?.fetch(messageId)"
562
+ );
521
563
  return this.channels.fetchMessage(channelId, messageId);
522
564
  }
523
565
  /**
@@ -570,7 +612,9 @@ var Client = class extends EventEmitter {
570
612
  */
571
613
  async login(token) {
572
614
  if (this._ws) {
573
- throw new FluxerError("Client is already logged in. Call destroy() first.");
615
+ throw new FluxerError("Client is already logged in. Call destroy() first.", {
616
+ code: ErrorCodes.AlreadyLoggedIn
617
+ });
574
618
  }
575
619
  this.rest.setToken(token);
576
620
  let intents = this.options.intents ?? 0;
@@ -602,12 +646,16 @@ var Client = class extends EventEmitter {
602
646
  async ({
603
647
  data
604
648
  }) => {
605
- const { ClientUser: ClientUser2 } = await import("./ClientUser-WWXUMO5O.mjs");
606
- const { Guild: Guild2 } = await import("./Guild-TM6YGJWB.mjs");
607
- const { Channel: Channel2 } = await import("./Channel-ICWNKXBR.mjs");
649
+ const { ClientUser: ClientUser2 } = await import("./ClientUser-DJO2FS7P.mjs");
650
+ const { Guild: Guild2 } = await import("./Guild-2P77HBQM.mjs");
651
+ const { Channel: Channel2 } = await import("./Channel-WJZZSNML.mjs");
608
652
  this.user = new ClientUser2(this, data.user);
609
653
  for (const g of data.guilds ?? []) {
610
- const guild = new Guild2(this, g);
654
+ const guildData = g && typeof g === "object" && "properties" in g && g.properties ? {
655
+ ...g.properties,
656
+ roles: g.roles
657
+ } : g;
658
+ const guild = new Guild2(this, guildData);
611
659
  this.guilds.set(guild.id, guild);
612
660
  const withCh = g;
613
661
  for (const ch of withCh.channels ?? []) {
@@ -746,15 +794,14 @@ var GuildSticker = class extends Base {
746
794
  }
747
795
  };
748
796
 
749
- // src/errors/ErrorCodes.ts
750
- var ErrorCodes = {
751
- ClientNotReady: "CLIENT_NOT_READY",
752
- InvalidToken: "INVALID_TOKEN"
753
- };
754
-
755
797
  // src/index.ts
756
798
  import { EmbedBuilder, MessagePayload, AttachmentBuilder } from "@fluxerjs/builders";
757
- import { Routes as Routes6, GatewayOpcodes } from "@fluxerjs/types";
799
+ import { Routes as Routes6, GatewayOpcodes, MessageAttachmentFlags } from "@fluxerjs/types";
800
+ import { resolveTenorToImageUrl } from "@fluxerjs/util";
801
+ import {
802
+ PermissionsBitField,
803
+ PermissionFlags
804
+ } from "@fluxerjs/util";
758
805
  export {
759
806
  AttachmentBuilder,
760
807
  Base,
@@ -778,13 +825,25 @@ export {
778
825
  Invite,
779
826
  LinkChannel,
780
827
  Message,
828
+ MessageAttachmentFlags,
829
+ MessageCollector,
781
830
  MessageManager,
782
831
  MessagePayload,
783
832
  MessageReaction,
833
+ PermissionFlags,
834
+ PermissionsBitField,
835
+ ReactionCollector,
784
836
  Role,
785
837
  Routes6 as Routes,
786
838
  TextChannel,
787
839
  User,
788
840
  VoiceChannel,
789
- Webhook
841
+ Webhook,
842
+ cdnAvatarURL,
843
+ cdnBannerURL,
844
+ cdnDefaultAvatarURL,
845
+ cdnDisplayAvatarURL,
846
+ cdnMemberAvatarURL,
847
+ cdnMemberBannerURL,
848
+ resolveTenorToImageUrl
790
849
  };
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "1.0.9",
6
+ "version": "1.1.0",
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.0.9",
38
- "@fluxerjs/builders": "1.0.9",
39
- "@fluxerjs/ws": "1.0.9",
40
- "@fluxerjs/collection": "1.0.9",
41
- "@fluxerjs/types": "1.0.9",
42
- "@fluxerjs/util": "1.0.9"
37
+ "@fluxerjs/ws": "1.1.0",
38
+ "@fluxerjs/collection": "1.1.0",
39
+ "@fluxerjs/rest": "1.1.0",
40
+ "@fluxerjs/builders": "1.1.0",
41
+ "@fluxerjs/util": "1.1.0",
42
+ "@fluxerjs/types": "1.1.0"
43
43
  },
44
44
  "devDependencies": {
45
45
  "@types/node": "^20.0.0",
@@ -1,10 +0,0 @@
1
- import {
2
- Guild
3
- } from "./chunk-X77DFNE3.mjs";
4
- import "./chunk-HQMYRYMY.mjs";
5
- import "./chunk-GFUJVQ7L.mjs";
6
- import "./chunk-SQVCCSNN.mjs";
7
- import "./chunk-XNS4O6QJ.mjs";
8
- export {
9
- Guild
10
- };
@@ -1,7 +0,0 @@
1
- import {
2
- GuildMember
3
- } from "./chunk-GFUJVQ7L.mjs";
4
- import "./chunk-XNS4O6QJ.mjs";
5
- export {
6
- GuildMember
7
- };
@@ -1,7 +0,0 @@
1
- import {
2
- Message
3
- } from "./chunk-DSPSRPHF.mjs";
4
- import "./chunk-XNS4O6QJ.mjs";
5
- export {
6
- Message
7
- };
@@ -1,7 +0,0 @@
1
- import {
2
- Webhook
3
- } from "./chunk-53Y37KRG.mjs";
4
- import "./chunk-XNS4O6QJ.mjs";
5
- export {
6
- Webhook
7
- };