@fluxerjs/core 1.1.4 → 1.1.6

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.
@@ -4,7 +4,7 @@ import {
4
4
  } from "./chunk-PU73YRKJ.mjs";
5
5
  import {
6
6
  GuildMember
7
- } from "./chunk-DUQAD7F6.mjs";
7
+ } from "./chunk-5JEDVRKU.mjs";
8
8
  import {
9
9
  CDN_URL
10
10
  } from "./chunk-HQMYRYMY.mjs";
@@ -25,6 +25,7 @@ import { Collection as Collection2 } from "@fluxerjs/collection";
25
25
 
26
26
  // src/client/GuildMemberManager.ts
27
27
  import { Collection } from "@fluxerjs/collection";
28
+ import { Routes } from "@fluxerjs/types";
28
29
  var GuildMemberManager = class extends Collection {
29
30
  constructor(guild) {
30
31
  super();
@@ -59,10 +60,32 @@ var GuildMemberManager = class extends Collection {
59
60
  }
60
61
  return this.guild.fetchMember(userId);
61
62
  }
63
+ /**
64
+ * Fetch guild members with pagination. GET /guilds/{id}/members.
65
+ * @param options - limit (1-1000), after (user ID for pagination)
66
+ * @returns Array of GuildMember objects (cached in guild.members)
67
+ */
68
+ async fetch(options) {
69
+ const params = new URLSearchParams();
70
+ if (options?.limit != null) params.set("limit", String(options.limit));
71
+ if (options?.after) params.set("after", options.after);
72
+ const qs = params.toString();
73
+ const url = Routes.guildMembers(this.guild.id) + (qs ? `?${qs}` : "");
74
+ const data = await this.guild.client.rest.get(url, { auth: true });
75
+ const list = Array.isArray(data) ? data : data?.members ?? [];
76
+ const { GuildMember: GuildMember2 } = await import("./GuildMember-F5FZJOHD.mjs");
77
+ const members = [];
78
+ for (const m of list) {
79
+ const member = new GuildMember2(this.guild.client, { ...m, guild_id: this.guild.id }, this.guild);
80
+ this.set(member.id, member);
81
+ members.push(member);
82
+ }
83
+ return members;
84
+ }
62
85
  };
63
86
 
64
87
  // src/structures/Guild.ts
65
- import { Routes } from "@fluxerjs/types";
88
+ import { Routes as Routes2 } from "@fluxerjs/types";
66
89
  var Guild = class extends Base {
67
90
  client;
68
91
  id;
@@ -155,7 +178,7 @@ var Guild = class extends Base {
155
178
  * Requires Manage Roles permission.
156
179
  */
157
180
  async addRoleToMember(userId, roleId) {
158
- await this.client.rest.put(Routes.guildMemberRole(this.id, userId, roleId));
181
+ await this.client.rest.put(Routes2.guildMemberRole(this.id, userId, roleId));
159
182
  }
160
183
  /**
161
184
  * Remove a role from a member by user ID. Does not require fetching the member first.
@@ -164,7 +187,7 @@ var Guild = class extends Base {
164
187
  * Requires Manage Roles permission.
165
188
  */
166
189
  async removeRoleFromMember(userId, roleId) {
167
- await this.client.rest.delete(Routes.guildMemberRole(this.id, userId, roleId));
190
+ await this.client.rest.delete(Routes2.guildMemberRole(this.id, userId, roleId));
168
191
  }
169
192
  /**
170
193
  * Create a role in this guild.
@@ -186,7 +209,7 @@ var Guild = class extends Base {
186
209
  if (options.unicode_emoji !== void 0) body.unicode_emoji = options.unicode_emoji;
187
210
  if (options.position !== void 0) body.position = options.position;
188
211
  if (options.hoist_position !== void 0) body.hoist_position = options.hoist_position;
189
- const data = await this.client.rest.post(Routes.guildRoles(this.id), {
212
+ const data = await this.client.rest.post(Routes2.guildRoles(this.id), {
190
213
  body: Object.keys(body).length ? body : void 0,
191
214
  auth: true
192
215
  });
@@ -200,7 +223,7 @@ var Guild = class extends Base {
200
223
  */
201
224
  async fetchRoles() {
202
225
  const data = await this.client.rest.get(
203
- Routes.guildRoles(this.id)
226
+ Routes2.guildRoles(this.id)
204
227
  );
205
228
  const list = Array.isArray(data) ? data : Object.values(data ?? {});
206
229
  const roles = [];
@@ -219,7 +242,7 @@ var Guild = class extends Base {
219
242
  */
220
243
  async fetchRole(roleId) {
221
244
  try {
222
- const data = await this.client.rest.get(Routes.guildRole(this.id, roleId));
245
+ const data = await this.client.rest.get(Routes2.guildRole(this.id, roleId));
223
246
  const role = new Role(this.client, data, this.id);
224
247
  this.roles.set(role.id, role);
225
248
  return role;
@@ -248,7 +271,7 @@ var Guild = class extends Base {
248
271
  (r) => !!(r.name && r.name.toLowerCase() === arg.trim().toLowerCase())
249
272
  );
250
273
  if (cached) return cached.id;
251
- const roles = await this.client.rest.get(Routes.guildRoles(this.id));
274
+ const roles = await this.client.rest.get(Routes2.guildRoles(this.id));
252
275
  const list = Array.isArray(roles) ? roles : Object.values(roles ?? {});
253
276
  const role = list.find((r) => !!(r.name && r.name.toLowerCase() === arg.trim().toLowerCase()));
254
277
  if (role) {
@@ -271,7 +294,7 @@ var Guild = class extends Base {
271
294
  body.delete_message_days = options.delete_message_days;
272
295
  if (options?.ban_duration_seconds != null)
273
296
  body.ban_duration_seconds = options.ban_duration_seconds;
274
- await this.client.rest.put(Routes.guildBan(this.id, userId), {
297
+ await this.client.rest.put(Routes2.guildBan(this.id, userId), {
275
298
  body: Object.keys(body).length ? body : void 0,
276
299
  auth: true
277
300
  });
@@ -282,7 +305,7 @@ var Guild = class extends Base {
282
305
  */
283
306
  async fetchBans() {
284
307
  const { GuildBan } = await import("./GuildBan-7CXLTPKY.mjs");
285
- const data = await this.client.rest.get(Routes.guildBans(this.id));
308
+ const data = await this.client.rest.get(Routes2.guildBans(this.id));
286
309
  const list = Array.isArray(data) ? data : data?.bans ?? [];
287
310
  return list.map((b) => new GuildBan(this.client, { ...b, guild_id: this.id }, this.id));
288
311
  }
@@ -292,7 +315,7 @@ var Guild = class extends Base {
292
315
  * Requires Ban Members permission.
293
316
  */
294
317
  async unban(userId) {
295
- await this.client.rest.delete(Routes.guildBan(this.id, userId), { auth: true });
318
+ await this.client.rest.delete(Routes2.guildBan(this.id, userId), { auth: true });
296
319
  }
297
320
  /**
298
321
  * Kick a member from this guild.
@@ -300,7 +323,7 @@ var Guild = class extends Base {
300
323
  * Requires Kick Members permission.
301
324
  */
302
325
  async kick(userId) {
303
- await this.client.rest.delete(Routes.guildMember(this.id, userId), { auth: true });
326
+ await this.client.rest.delete(Routes2.guildMember(this.id, userId), { auth: true });
304
327
  }
305
328
  /**
306
329
  * Fetch a guild member by user ID.
@@ -312,7 +335,7 @@ var Guild = class extends Base {
312
335
  async fetchMember(userId) {
313
336
  try {
314
337
  const data = await this.client.rest.get(
315
- Routes.guildMember(this.id, userId)
338
+ Routes2.guildMember(this.id, userId)
316
339
  );
317
340
  const member = new GuildMember(this.client, { ...data, guild_id: this.id }, this);
318
341
  this.members.set(member.id, member);
@@ -340,13 +363,13 @@ var Guild = class extends Base {
340
363
  if (options?.userId) params.set("user_id", options.userId);
341
364
  if (options?.actionType != null) params.set("action_type", String(options.actionType));
342
365
  const qs = params.toString();
343
- const url = Routes.guildAuditLogs(this.id) + (qs ? `?${qs}` : "");
366
+ const url = Routes2.guildAuditLogs(this.id) + (qs ? `?${qs}` : "");
344
367
  return this.client.rest.get(url);
345
368
  }
346
369
  /** Fetch all webhooks in this guild. Returned webhooks do not include the token (cannot send). */
347
370
  async fetchWebhooks() {
348
- const { Webhook } = await import("./Webhook-WIF6OGPA.mjs");
349
- const data = await this.client.rest.get(Routes.guildWebhooks(this.id));
371
+ const { Webhook } = await import("./Webhook-IWPKKMWD.mjs");
372
+ const data = await this.client.rest.get(Routes2.guildWebhooks(this.id));
350
373
  const list = Array.isArray(data) ? data : Object.values(data ?? {});
351
374
  return list.map((w) => new Webhook(this.client, w));
352
375
  }
@@ -356,8 +379,8 @@ var Guild = class extends Base {
356
379
  * Requires Manage Channels permission.
357
380
  */
358
381
  async createChannel(data) {
359
- const { Channel } = await import("./Channel-HBKXUNL5.mjs");
360
- const created = await this.client.rest.post(Routes.guildChannels(this.id), {
382
+ const { Channel } = await import("./Channel-L6UE2MAF.mjs");
383
+ const created = await this.client.rest.post(Routes2.guildChannels(this.id), {
361
384
  body: data,
362
385
  auth: true
363
386
  });
@@ -373,8 +396,8 @@ var Guild = class extends Base {
373
396
  * @returns Array of GuildChannel objects (cached in guild.channels and client.channels)
374
397
  */
375
398
  async fetchChannels() {
376
- const { Channel } = await import("./Channel-HBKXUNL5.mjs");
377
- const data = await this.client.rest.get(Routes.guildChannels(this.id));
399
+ const { Channel } = await import("./Channel-L6UE2MAF.mjs");
400
+ const data = await this.client.rest.get(Routes2.guildChannels(this.id));
378
401
  const list = Array.isArray(data) ? data : Object.values(data ?? {});
379
402
  const channels = [];
380
403
  for (const ch of list) {
@@ -387,17 +410,163 @@ var Guild = class extends Base {
387
410
  }
388
411
  return channels;
389
412
  }
413
+ /**
414
+ * Edit this guild. PATCH /guilds/{id}.
415
+ * Requires guild owner or Administrator.
416
+ */
417
+ async edit(options) {
418
+ const data = await this.client.rest.patch(Routes2.guild(this.id), {
419
+ body: options,
420
+ auth: true
421
+ });
422
+ this.name = data.name;
423
+ this.icon = data.icon ?? this.icon;
424
+ this.banner = data.banner ?? this.banner;
425
+ this.splash = data.splash ?? this.splash;
426
+ this.systemChannelId = data.system_channel_id ?? this.systemChannelId;
427
+ this.afkChannelId = data.afk_channel_id ?? this.afkChannelId;
428
+ this.afkTimeout = data.afk_timeout ?? this.afkTimeout;
429
+ this.verificationLevel = data.verification_level ?? this.verificationLevel;
430
+ this.mfaLevel = data.mfa_level ?? this.mfaLevel;
431
+ this.explicitContentFilter = data.explicit_content_filter ?? this.explicitContentFilter;
432
+ this.defaultMessageNotifications = data.default_message_notifications ?? this.defaultMessageNotifications;
433
+ this.features = data.features ?? this.features;
434
+ return this;
435
+ }
436
+ /**
437
+ * Delete this guild. POST /guilds/{id}/delete.
438
+ * Must be the guild owner.
439
+ */
440
+ async delete() {
441
+ await this.client.rest.post(Routes2.guildDelete(this.id), { auth: true });
442
+ this.client.guilds.delete(this.id);
443
+ }
444
+ /**
445
+ * Fetch vanity URL for this guild. GET /guilds/{id}/vanity-url.
446
+ * Requires Manage Guild permission.
447
+ */
448
+ async fetchVanityURL() {
449
+ return this.client.rest.get(Routes2.guildVanityUrl(this.id), { auth: true });
450
+ }
451
+ /**
452
+ * Transfer guild ownership to another user. POST /guilds/{id}/transfer-ownership.
453
+ * Must be the guild owner.
454
+ */
455
+ async transferOwnership(newOwnerId, password) {
456
+ await this.client.rest.post(Routes2.guildTransferOwnership(this.id), {
457
+ body: { new_owner_id: newOwnerId, ...password != null && { password } },
458
+ auth: true
459
+ });
460
+ }
461
+ /**
462
+ * Set text channel flexible names feature. PATCH /guilds/{id}/text-channel-flexible-names.
463
+ */
464
+ setTextChannelFlexibleNames(enabled) {
465
+ return this.client.rest.patch(Routes2.guildTextChannelFlexibleNames(this.id), {
466
+ body: { enabled },
467
+ auth: true
468
+ }).then(() => this);
469
+ }
470
+ /**
471
+ * Set detached banner feature. PATCH /guilds/{id}/detached-banner.
472
+ */
473
+ setDetachedBanner(enabled) {
474
+ return this.client.rest.patch(Routes2.guildDetachedBanner(this.id), {
475
+ body: { enabled },
476
+ auth: true
477
+ }).then(() => this);
478
+ }
479
+ /**
480
+ * Set disallow unclaimed accounts. PATCH /guilds/{id}/disallow-unclaimed-accounts.
481
+ */
482
+ setDisallowUnclaimedAccounts(enabled) {
483
+ return this.client.rest.patch(Routes2.guildDisallowUnclaimedAccounts(this.id), {
484
+ body: { enabled },
485
+ auth: true
486
+ }).then(() => this);
487
+ }
488
+ /**
489
+ * Update role positions. PATCH /guilds/{id}/roles.
490
+ * @param updates - Array of { id, position? }
491
+ */
492
+ async setRolePositions(updates) {
493
+ const data = await this.client.rest.patch(
494
+ Routes2.guildRoles(this.id),
495
+ { body: updates, auth: true }
496
+ );
497
+ const list = Array.isArray(data) ? data : Object.values(data ?? {});
498
+ for (const r of list) {
499
+ this.roles.set(r.id, new Role(this.client, r, this.id));
500
+ }
501
+ return list;
502
+ }
503
+ /**
504
+ * Update role hoist positions. PATCH /guilds/{id}/roles/hoist-positions.
505
+ */
506
+ async setRoleHoistPositions(updates) {
507
+ const data = await this.client.rest.patch(
508
+ Routes2.guildRolesHoistPositions(this.id),
509
+ { body: updates, auth: true }
510
+ );
511
+ const list = Array.isArray(data) ? data : Object.values(data ?? {});
512
+ for (const r of list) {
513
+ this.roles.set(r.id, new Role(this.client, r, this.id));
514
+ }
515
+ return list;
516
+ }
517
+ /**
518
+ * Reset role hoist positions. DELETE /guilds/{id}/roles/hoist-positions.
519
+ */
520
+ async resetRoleHoistPositions() {
521
+ const data = await this.client.rest.delete(
522
+ Routes2.guildRolesHoistPositions(this.id),
523
+ { auth: true }
524
+ );
525
+ const list = Array.isArray(data) ? data : Object.values(data ?? {});
526
+ for (const r of list) {
527
+ this.roles.set(r.id, new Role(this.client, r, this.id));
528
+ }
529
+ return list;
530
+ }
390
531
  /**
391
532
  * Update channel positions.
392
533
  * @param updates - Array of { id, position?, parent_id?, lock_permissions? }
393
534
  * Requires Manage Channels permission.
394
535
  */
395
536
  async setChannelPositions(updates) {
396
- await this.client.rest.patch(Routes.guildChannels(this.id), {
537
+ await this.client.rest.patch(Routes2.guildChannels(this.id), {
397
538
  body: updates,
398
539
  auth: true
399
540
  });
400
541
  }
542
+ /**
543
+ * Bulk create emojis. POST /guilds/{id}/emojis/bulk.
544
+ * @param emojis - Array of { name, image } (base64), 1-50 emojis
545
+ * @returns Array of created GuildEmoji objects
546
+ */
547
+ async createEmojisBulk(emojis) {
548
+ const { GuildEmoji } = await import("./GuildEmoji-SOGQ4C32.mjs");
549
+ const data = await this.client.rest.post(Routes2.guildEmojisBulk(this.id), {
550
+ body: { emojis },
551
+ auth: true
552
+ });
553
+ const list = Array.isArray(data) ? data : data?.emojis ?? [];
554
+ return list.map((e) => new GuildEmoji(this.client, { ...e, guild_id: this.id }, this.id));
555
+ }
556
+ /**
557
+ * Bulk create stickers. POST /guilds/{id}/stickers/bulk.
558
+ * @param stickers - Array of { name, image, description?, tags? }, 1-50 stickers
559
+ * @returns Array of created GuildSticker objects
560
+ */
561
+ async createStickersBulk(stickers) {
562
+ const { GuildSticker } = await import("./GuildSticker-3QYT6ZIY.mjs");
563
+ const data = await this.client.rest.post(Routes2.guildStickersBulk(this.id), {
564
+ body: { stickers },
565
+ auth: true
566
+ });
567
+ const list = Array.isArray(data) ? data : data?.stickers ?? [];
568
+ return list.map((s) => new GuildSticker(this.client, { ...s, guild_id: this.id }, this.id));
569
+ }
401
570
  };
402
571
 
403
572
  export {
@@ -0,0 +1,58 @@
1
+ import {
2
+ CDN_URL
3
+ } from "./chunk-HQMYRYMY.mjs";
4
+ import {
5
+ Base
6
+ } from "./chunk-XNS4O6QJ.mjs";
7
+
8
+ // src/structures/GuildSticker.ts
9
+ import { Routes } from "@fluxerjs/types";
10
+ var GuildSticker = class extends Base {
11
+ client;
12
+ id;
13
+ guildId;
14
+ name;
15
+ description;
16
+ tags;
17
+ animated;
18
+ /** @param data - API sticker from GET /guilds/{id}/stickers or guild sticker events */
19
+ constructor(client, data, guildId) {
20
+ super();
21
+ this.client = client;
22
+ this.id = data.id;
23
+ this.guildId = data.guild_id ?? guildId;
24
+ this.name = data.name;
25
+ this.description = data.description ?? "";
26
+ this.tags = data.tags ?? [];
27
+ this.animated = data.animated ?? false;
28
+ }
29
+ /** CDN URL for this sticker image. */
30
+ get url() {
31
+ const ext = this.animated ? "gif" : "png";
32
+ return `${CDN_URL}/stickers/${this.id}.${ext}`;
33
+ }
34
+ /** Delete this sticker. Requires Manage Emojis and Stickers permission. */
35
+ async delete() {
36
+ await this.client.rest.delete(Routes.guildSticker(this.guildId, this.id), {
37
+ auth: true
38
+ });
39
+ }
40
+ /**
41
+ * Edit this sticker's name and/or description.
42
+ * Requires Manage Emojis and Stickers permission.
43
+ */
44
+ async edit(options) {
45
+ const data = await this.client.rest.patch(Routes.guildSticker(this.guildId, this.id), {
46
+ body: options,
47
+ auth: true
48
+ });
49
+ const s = data;
50
+ this.name = s.name;
51
+ this.description = s.description ?? "";
52
+ return this;
53
+ }
54
+ };
55
+
56
+ export {
57
+ GuildSticker
58
+ };
@@ -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-HBKXUNL5.mjs");
85
+ const { DMChannel: DMChannelClass } = await import("./Channel-L6UE2MAF.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-3ETPHHF5.mjs");
113
+ const { Guild } = await import("./Guild-NNMSFIA6.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 = [];