@fluxerjs/core 1.1.1 → 1.1.2

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,8 +6,8 @@ import {
6
6
  LinkChannel,
7
7
  TextChannel,
8
8
  VoiceChannel
9
- } from "./chunk-RWFKZ3DF.mjs";
10
- import "./chunk-V6T5VMWD.mjs";
9
+ } from "./chunk-ZKKBIQBA.mjs";
10
+ import "./chunk-PU73YRKJ.mjs";
11
11
  import "./chunk-AH7KYH2Z.mjs";
12
12
  import "./chunk-PM2IUGNR.mjs";
13
13
  import "./chunk-XNS4O6QJ.mjs";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  ClientUser
3
- } from "./chunk-4F765HVV.mjs";
3
+ } from "./chunk-G2YVDCRB.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-FRVZ7D6D.mjs";
4
- import "./chunk-V6T5VMWD.mjs";
3
+ } from "./chunk-KOTF4TTZ.mjs";
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-DQ4TNBPG.mjs";
8
+ import "./chunk-5I54OXBG.mjs";
9
9
  import "./chunk-XNS4O6QJ.mjs";
10
10
  export {
11
11
  Guild
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  MessageReaction
3
- } from "./chunk-K6NLD6SB.mjs";
4
- import "./chunk-V6T5VMWD.mjs";
3
+ } from "./chunk-YL5S4W6R.mjs";
4
+ import "./chunk-PU73YRKJ.mjs";
5
5
  import "./chunk-XNS4O6QJ.mjs";
6
6
  export {
7
7
  MessageReaction
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  Role
3
- } from "./chunk-DQ4TNBPG.mjs";
3
+ } from "./chunk-5I54OXBG.mjs";
4
4
  import "./chunk-XNS4O6QJ.mjs";
5
5
  export {
6
6
  Role
@@ -0,0 +1,111 @@
1
+ import {
2
+ Base
3
+ } from "./chunk-XNS4O6QJ.mjs";
4
+
5
+ // src/structures/Role.ts
6
+ import { Routes } from "@fluxerjs/types";
7
+ import { PermissionFlags, resolvePermissionsToBitfield } from "@fluxerjs/util";
8
+ var Role = class extends Base {
9
+ client;
10
+ id;
11
+ guildId;
12
+ name;
13
+ color;
14
+ position;
15
+ permissions;
16
+ hoist;
17
+ mentionable;
18
+ unicodeEmoji;
19
+ /** Separately sorted position for hoisted roles. Null if not set. */
20
+ hoistPosition;
21
+ /** @param client - The client instance */
22
+ /** @param data - API role from GET /guilds/{id}/roles or gateway role events */
23
+ /** @param guildId - The guild this role belongs to */
24
+ constructor(client, data, guildId) {
25
+ super();
26
+ this.client = client;
27
+ this.id = data.id;
28
+ this.guildId = guildId;
29
+ this.name = data.name;
30
+ this.color = data.color;
31
+ this.position = data.position;
32
+ this.permissions = data.permissions;
33
+ this.hoist = !!data.hoist;
34
+ this.mentionable = !!data.mentionable;
35
+ this.unicodeEmoji = data.unicode_emoji ?? null;
36
+ this.hoistPosition = data.hoist_position ?? null;
37
+ }
38
+ /** Update mutable fields from fresh API data. Used by edit and gateway events. */
39
+ _patch(data) {
40
+ if (data.name !== void 0) this.name = data.name;
41
+ if (data.color !== void 0) this.color = data.color;
42
+ if (data.position !== void 0) this.position = data.position;
43
+ if (data.permissions !== void 0) this.permissions = data.permissions;
44
+ if (data.hoist !== void 0) this.hoist = !!data.hoist;
45
+ if (data.mentionable !== void 0) this.mentionable = !!data.mentionable;
46
+ if (data.unicode_emoji !== void 0) this.unicodeEmoji = data.unicode_emoji ?? null;
47
+ if (data.hoist_position !== void 0) this.hoistPosition = data.hoist_position ?? null;
48
+ }
49
+ /** Returns a mention string (e.g. `<@&123456>`). */
50
+ toString() {
51
+ return `<@&${this.id}>`;
52
+ }
53
+ /**
54
+ * Check if this role has a permission. Administrator grants all permissions.
55
+ * @param permission - Permission flag, name, or resolvable
56
+ * @returns true if the role has the permission
57
+ * @example
58
+ * if (role.has(PermissionFlags.BanMembers)) { ... }
59
+ * if (role.has('ManageChannels')) { ... }
60
+ */
61
+ has(permission) {
62
+ const perm = typeof permission === "number" ? permission : PermissionFlags[permission];
63
+ if (perm === void 0) return false;
64
+ const permNum = Number(perm);
65
+ const rolePerms = BigInt(this.permissions);
66
+ const permBig = BigInt(permNum);
67
+ if (permBig < 0) return false;
68
+ if ((rolePerms & BigInt(PermissionFlags.Administrator)) !== 0n) return true;
69
+ return (rolePerms & permBig) === permBig;
70
+ }
71
+ /**
72
+ * Edit this role.
73
+ * Requires Manage Roles permission.
74
+ * @param options - Role updates (permissions accepts PermissionResolvable for convenience)
75
+ * @returns This role (updated in place)
76
+ * @example
77
+ * await role.edit({ name: 'Moderator', permissions: ['BanMembers', 'KickMembers'] });
78
+ */
79
+ async edit(options) {
80
+ const body = {};
81
+ if (options.name !== void 0) body.name = options.name;
82
+ if (options.permissions !== void 0) {
83
+ body.permissions = typeof options.permissions === "string" ? options.permissions : resolvePermissionsToBitfield(options.permissions);
84
+ }
85
+ if (options.color !== void 0) body.color = options.color;
86
+ if (options.hoist !== void 0) body.hoist = options.hoist;
87
+ if (options.mentionable !== void 0) body.mentionable = options.mentionable;
88
+ if (options.unicode_emoji !== void 0) body.unicode_emoji = options.unicode_emoji;
89
+ if (options.position !== void 0) body.position = options.position;
90
+ if (options.hoist_position !== void 0) body.hoist_position = options.hoist_position;
91
+ const data = await this.client.rest.patch(Routes.guildRole(this.guildId, this.id), {
92
+ body: Object.keys(body).length ? body : void 0,
93
+ auth: true
94
+ });
95
+ this._patch(data);
96
+ return this;
97
+ }
98
+ /**
99
+ * Delete this role.
100
+ * Requires Manage Roles permission.
101
+ */
102
+ async delete() {
103
+ await this.client.rest.delete(Routes.guildRole(this.guildId, this.id), { auth: true });
104
+ const guild = this.client.guilds.get(this.guildId);
105
+ if (guild) guild.roles.delete(this.id);
106
+ }
107
+ };
108
+
109
+ export {
110
+ Role
111
+ };
@@ -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-4WVFDOCG.mjs");
85
+ const { DMChannel: DMChannelClass } = await import("./Channel-YB3LWDHZ.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-FMBCTAV4.mjs");
113
+ const { Guild } = await import("./Guild-MDW7KF33.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 = [];
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  ErrorCodes,
3
3
  FluxerError
4
- } from "./chunk-V6T5VMWD.mjs";
4
+ } from "./chunk-PU73YRKJ.mjs";
5
5
  import {
6
6
  GuildMember
7
7
  } from "./chunk-DUQAD7F6.mjs";
@@ -10,15 +10,55 @@ import {
10
10
  } from "./chunk-HQMYRYMY.mjs";
11
11
  import {
12
12
  Role
13
- } from "./chunk-DQ4TNBPG.mjs";
13
+ } from "./chunk-5I54OXBG.mjs";
14
14
  import {
15
15
  Base
16
16
  } from "./chunk-XNS4O6QJ.mjs";
17
17
 
18
18
  // src/structures/Guild.ts
19
- import { parseRoleMention } from "@fluxerjs/util";
19
+ import { parseRoleMention, resolvePermissionsToBitfield } from "@fluxerjs/util";
20
20
  import { FluxerAPIError } from "@fluxerjs/rest";
21
+ import { Collection as Collection2 } from "@fluxerjs/collection";
22
+
23
+ // src/client/GuildMemberManager.ts
21
24
  import { Collection } from "@fluxerjs/collection";
25
+ var GuildMemberManager = class extends Collection {
26
+ constructor(guild) {
27
+ super();
28
+ this.guild = guild;
29
+ }
30
+ /**
31
+ * The current bot user as a GuildMember in this guild.
32
+ * Returns null if the bot's member is not cached or client.user is null.
33
+ * Use fetchMe() to load the bot's member when not cached.
34
+ *
35
+ * @example
36
+ * const perms = guild.members.me?.permissions;
37
+ * if (perms?.has(PermissionFlags.BanMembers)) { ... }
38
+ */
39
+ get me() {
40
+ const userId = this.guild.client.user?.id;
41
+ return userId ? this.get(userId) ?? null : null;
42
+ }
43
+ /**
44
+ * Fetch the current bot user as a GuildMember in this guild.
45
+ * Caches the result in guild.members.
46
+ *
47
+ * @throws Error if client.user is null (client not ready)
48
+ * @example
49
+ * const me = await guild.members.fetchMe();
50
+ * console.log(me.displayName);
51
+ */
52
+ async fetchMe() {
53
+ const userId = this.guild.client.user?.id;
54
+ if (!userId) {
55
+ throw new Error("Cannot fetch me: client.user is null (client not ready)");
56
+ }
57
+ return this.guild.fetchMember(userId);
58
+ }
59
+ };
60
+
61
+ // src/structures/Guild.ts
22
62
  import { Routes } from "@fluxerjs/types";
23
63
  var Guild = class extends Base {
24
64
  client;
@@ -54,14 +94,15 @@ var Guild = class extends Base {
54
94
  splashWidth;
55
95
  /** Splash image height. Optional. */
56
96
  splashHeight;
57
- members = new Collection();
58
- channels = new Collection();
59
- roles = new Collection();
97
+ members;
98
+ channels = new Collection2();
99
+ roles = new Collection2();
60
100
  /** @param data - API guild from GET /guilds/{id} or gateway GUILD_CREATE */
61
101
  constructor(client, data) {
62
102
  super();
63
103
  this.client = client;
64
104
  this.id = data.id;
105
+ this.members = new GuildMemberManager(this);
65
106
  this.name = data.name;
66
107
  this.icon = data.icon ?? null;
67
108
  this.banner = data.banner ?? null;
@@ -122,6 +163,74 @@ var Guild = class extends Base {
122
163
  async removeRoleFromMember(userId, roleId) {
123
164
  await this.client.rest.delete(Routes.guildMemberRole(this.id, userId, roleId));
124
165
  }
166
+ /**
167
+ * Create a role in this guild.
168
+ * Requires Manage Roles permission.
169
+ * @param options - Role data (permissions accepts PermissionResolvable for convenience)
170
+ * @returns The created role
171
+ * @example
172
+ * const role = await guild.createRole({ name: 'Mod', permissions: ['KickMembers', 'BanMembers'] });
173
+ */
174
+ async createRole(options) {
175
+ const body = {};
176
+ if (options.name !== void 0) body.name = options.name;
177
+ if (options.permissions !== void 0) {
178
+ body.permissions = typeof options.permissions === "string" ? options.permissions : resolvePermissionsToBitfield(options.permissions);
179
+ }
180
+ if (options.color !== void 0) body.color = options.color;
181
+ if (options.hoist !== void 0) body.hoist = options.hoist;
182
+ if (options.mentionable !== void 0) body.mentionable = options.mentionable;
183
+ if (options.unicode_emoji !== void 0) body.unicode_emoji = options.unicode_emoji;
184
+ if (options.position !== void 0) body.position = options.position;
185
+ if (options.hoist_position !== void 0) body.hoist_position = options.hoist_position;
186
+ const data = await this.client.rest.post(Routes.guildRoles(this.id), {
187
+ body: Object.keys(body).length ? body : void 0,
188
+ auth: true
189
+ });
190
+ const role = new Role(this.client, data, this.id);
191
+ this.roles.set(role.id, role);
192
+ return role;
193
+ }
194
+ /**
195
+ * Fetch all roles in this guild.
196
+ * @returns Array of Role objects (cached in guild.roles)
197
+ */
198
+ async fetchRoles() {
199
+ const data = await this.client.rest.get(
200
+ Routes.guildRoles(this.id)
201
+ );
202
+ const list = Array.isArray(data) ? data : Object.values(data ?? {});
203
+ const roles = [];
204
+ for (const r of list) {
205
+ const role = new Role(this.client, r, this.id);
206
+ this.roles.set(role.id, role);
207
+ roles.push(role);
208
+ }
209
+ return roles;
210
+ }
211
+ /**
212
+ * Fetch a role by ID.
213
+ * @param roleId - The role ID to fetch
214
+ * @returns The role
215
+ * @throws FluxerError with ROLE_NOT_FOUND if role does not exist (404)
216
+ */
217
+ async fetchRole(roleId) {
218
+ try {
219
+ const data = await this.client.rest.get(Routes.guildRole(this.id, roleId));
220
+ const role = new Role(this.client, data, this.id);
221
+ this.roles.set(role.id, role);
222
+ return role;
223
+ } catch (err) {
224
+ const statusCode = err instanceof FluxerAPIError ? err.statusCode : err?.statusCode;
225
+ if (statusCode === 404) {
226
+ throw new FluxerError(`Role ${roleId} not found in guild`, {
227
+ code: ErrorCodes.RoleNotFound,
228
+ cause: err
229
+ });
230
+ }
231
+ throw err instanceof FluxerError ? err : new FluxerError("Failed to fetch guild role", { cause: err });
232
+ }
233
+ }
125
234
  /**
126
235
  * Resolve a role ID from an argument (role mention, raw ID, or name).
127
236
  * Fetches guild roles if name is provided.
@@ -244,7 +353,7 @@ var Guild = class extends Base {
244
353
  * Requires Manage Channels permission.
245
354
  */
246
355
  async createChannel(data) {
247
- const { Channel } = await import("./Channel-4WVFDOCG.mjs");
356
+ const { Channel } = await import("./Channel-YB3LWDHZ.mjs");
248
357
  const created = await this.client.rest.post(Routes.guildChannels(this.id), {
249
358
  body: data,
250
359
  auth: true
@@ -261,7 +370,7 @@ var Guild = class extends Base {
261
370
  * @returns Array of GuildChannel objects (cached in guild.channels and client.channels)
262
371
  */
263
372
  async fetchChannels() {
264
- const { Channel } = await import("./Channel-4WVFDOCG.mjs");
373
+ const { Channel } = await import("./Channel-YB3LWDHZ.mjs");
265
374
  const data = await this.client.rest.get(Routes.guildChannels(this.id));
266
375
  const list = Array.isArray(data) ? data : Object.values(data ?? {});
267
376
  const channels = [];
@@ -289,5 +398,6 @@ var Guild = class extends Base {
289
398
  };
290
399
 
291
400
  export {
401
+ GuildMemberManager,
292
402
  Guild
293
403
  };
@@ -17,7 +17,8 @@ var ErrorCodes = {
17
17
  ChannelNotFound: "CHANNEL_NOT_FOUND",
18
18
  MessageNotFound: "MESSAGE_NOT_FOUND",
19
19
  GuildNotFound: "GUILD_NOT_FOUND",
20
- MemberNotFound: "MEMBER_NOT_FOUND"
20
+ MemberNotFound: "MEMBER_NOT_FOUND",
21
+ RoleNotFound: "ROLE_NOT_FOUND"
21
22
  };
22
23
 
23
24
  export {
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  ErrorCodes,
3
3
  FluxerError
4
- } from "./chunk-V6T5VMWD.mjs";
4
+ } from "./chunk-PU73YRKJ.mjs";
5
5
  import {
6
6
  Base
7
7
  } from "./chunk-XNS4O6QJ.mjs";
@@ -49,10 +49,10 @@ var MessageReaction = class extends Base {
49
49
  } catch (err) {
50
50
  if (err instanceof RateLimitError) throw err;
51
51
  if (err instanceof FluxerAPIError && err.statusCode === 404) {
52
- throw new FluxerError(
53
- `Message ${this.messageId} not found in channel ${this.channelId}`,
54
- { code: ErrorCodes.MessageNotFound, cause: err }
55
- );
52
+ throw new FluxerError(`Message ${this.messageId} not found in channel ${this.channelId}`, {
53
+ code: ErrorCodes.MessageNotFound,
54
+ cause: err
55
+ });
56
56
  }
57
57
  throw err instanceof FluxerError ? err : new FluxerError(String(err), { cause: err });
58
58
  }
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  ErrorCodes,
3
3
  FluxerError
4
- } from "./chunk-V6T5VMWD.mjs";
4
+ } from "./chunk-PU73YRKJ.mjs";
5
5
  import {
6
6
  Events
7
7
  } from "./chunk-AH7KYH2Z.mjs";
package/dist/index.d.mts CHANGED
@@ -1,12 +1,12 @@
1
1
  import * as _fluxerjs_types from '@fluxerjs/types';
2
- import { APIEmbed, APIWebhook, APIWebhookUpdateRequest, APIWebhookTokenUpdateRequest, APIChannelOverwrite, APIChannel, APIChannelPartial, ChannelType, GatewayReactionEmoji, GatewayMessageReactionAddDispatchData, GatewayMessageReactionRemoveDispatchData, APIMessageAttachment, MessageType, APIMessageSticker, APIMessageReaction, APIMessageReference, APIMessageSnapshot, APIMessageCall, APIMessage, APIUserPartial, APIGuildMember, APIRole, APIBan, GuildFeature, GuildVerificationLevel, DefaultMessageNotifications, GuildExplicitContentFilter, GuildMFALevel, APIGuild, APIGuildAuditLog, APIGuildPartial, APIInvite, GatewayPresenceUpdateData, GatewayMessageReactionRemoveAllDispatchData, GatewayMessageReactionRemoveEmojiDispatchData, GatewayVoiceStateUpdateDispatchData, GatewayVoiceServerUpdateDispatchData, GatewayGuildEmojisUpdateDispatchData, GatewayGuildStickersUpdateDispatchData, GatewayGuildIntegrationsUpdateDispatchData, GatewayGuildScheduledEventCreateDispatchData, GatewayGuildScheduledEventUpdateDispatchData, GatewayGuildScheduledEventDeleteDispatchData, GatewayChannelPinsUpdateDispatchData, GatewayPresenceUpdateDispatchData, GatewayWebhooksUpdateDispatchData, GatewaySendPayload, Routes, APIEmoji, APISticker } from '@fluxerjs/types';
2
+ import { APIEmbed, APIWebhook, APIWebhookUpdateRequest, APIWebhookTokenUpdateRequest, APIChannelOverwrite, APIChannel, APIChannelPartial, ChannelType, GatewayReactionEmoji, GatewayMessageReactionAddDispatchData, GatewayMessageReactionRemoveDispatchData, APIMessageAttachment, MessageType, APIMessageSticker, APIMessageReaction, APIMessageReference, APIMessageSnapshot, APIMessageCall, APIMessage, APIUserPartial, APIGuildMember, APIRole, RESTUpdateRoleBody, APIBan, GuildFeature, GuildVerificationLevel, DefaultMessageNotifications, GuildExplicitContentFilter, GuildMFALevel, APIGuild, RESTCreateRoleBody, APIGuildAuditLog, APIGuildPartial, APIInvite, GatewayPresenceUpdateData, APIProfileResponse, GatewayMessageReactionRemoveAllDispatchData, GatewayMessageReactionRemoveEmojiDispatchData, GatewayVoiceStateUpdateDispatchData, GatewayVoiceServerUpdateDispatchData, GatewayGuildEmojisUpdateDispatchData, GatewayGuildStickersUpdateDispatchData, GatewayGuildIntegrationsUpdateDispatchData, GatewayGuildScheduledEventCreateDispatchData, GatewayGuildScheduledEventUpdateDispatchData, GatewayGuildScheduledEventDeleteDispatchData, GatewayChannelPinsUpdateDispatchData, GatewayPresenceUpdateDispatchData, GatewayWebhooksUpdateDispatchData, GatewaySendPayload, Routes, APIEmoji, APISticker } from '@fluxerjs/types';
3
3
  export { GatewayOpcodes, MessageAttachmentFlags, Routes } from '@fluxerjs/types';
4
+ import { PermissionResolvable } from '@fluxerjs/util';
5
+ export { PermissionFlags, PermissionResolvable, PermissionString, PermissionsBitField, UserFlagsBitField, UserFlagsBits, UserFlagsResolvable, UserFlagsString, resolvePermissionsToBitfield, resolveTenorToImageUrl } from '@fluxerjs/util';
4
6
  import { Collection } from '@fluxerjs/collection';
5
7
  import { EmbedBuilder } from '@fluxerjs/builders';
6
8
  export { AttachmentBuilder, EmbedBuilder, MessagePayload } from '@fluxerjs/builders';
7
9
  import { EventEmitter } from 'events';
8
- import { PermissionResolvable } from '@fluxerjs/util';
9
- export { PermissionFlags, PermissionResolvable, PermissionString, PermissionsBitField, resolveTenorToImageUrl } from '@fluxerjs/util';
10
10
  import { REST } from '@fluxerjs/rest';
11
11
  import { WebSocketManager } from '@fluxerjs/ws';
12
12
 
@@ -715,6 +715,36 @@ declare class GuildMember extends Base {
715
715
  private _computeBasePermissions;
716
716
  }
717
717
 
718
+ /**
719
+ * Manages guild members with a Collection-like API.
720
+ * Extends Collection so you can use .get(), .set(), .filter(), etc.
721
+ * Provides guild.members.me for Discord.js parity.
722
+ */
723
+ declare class GuildMemberManager extends Collection<string, GuildMember> {
724
+ private readonly guild;
725
+ constructor(guild: Guild);
726
+ /**
727
+ * The current bot user as a GuildMember in this guild.
728
+ * Returns null if the bot's member is not cached or client.user is null.
729
+ * Use fetchMe() to load the bot's member when not cached.
730
+ *
731
+ * @example
732
+ * const perms = guild.members.me?.permissions;
733
+ * if (perms?.has(PermissionFlags.BanMembers)) { ... }
734
+ */
735
+ get me(): GuildMember | null;
736
+ /**
737
+ * Fetch the current bot user as a GuildMember in this guild.
738
+ * Caches the result in guild.members.
739
+ *
740
+ * @throws Error if client.user is null (client not ready)
741
+ * @example
742
+ * const me = await guild.members.fetchMe();
743
+ * console.log(me.displayName);
744
+ */
745
+ fetchMe(): Promise<GuildMember>;
746
+ }
747
+
718
748
  /** Represents a role in a guild. */
719
749
  declare class Role extends Base {
720
750
  readonly client: Client;
@@ -733,6 +763,8 @@ declare class Role extends Base {
733
763
  /** @param data - API role from GET /guilds/{id}/roles or gateway role events */
734
764
  /** @param guildId - The guild this role belongs to */
735
765
  constructor(client: Client, data: APIRole, guildId: string);
766
+ /** Update mutable fields from fresh API data. Used by edit and gateway events. */
767
+ _patch(data: Partial<APIRole>): void;
736
768
  /** Returns a mention string (e.g. `<@&123456>`). */
737
769
  toString(): string;
738
770
  /**
@@ -744,6 +776,22 @@ declare class Role extends Base {
744
776
  * if (role.has('ManageChannels')) { ... }
745
777
  */
746
778
  has(permission: PermissionResolvable): boolean;
779
+ /**
780
+ * Edit this role.
781
+ * Requires Manage Roles permission.
782
+ * @param options - Role updates (permissions accepts PermissionResolvable for convenience)
783
+ * @returns This role (updated in place)
784
+ * @example
785
+ * await role.edit({ name: 'Moderator', permissions: ['BanMembers', 'KickMembers'] });
786
+ */
787
+ edit(options: RESTUpdateRoleBody & {
788
+ permissions?: string | PermissionResolvable;
789
+ }): Promise<Role>;
790
+ /**
791
+ * Delete this role.
792
+ * Requires Manage Roles permission.
793
+ */
794
+ delete(): Promise<void>;
747
795
  }
748
796
 
749
797
  /** Represents a ban in a guild. */
@@ -800,7 +848,7 @@ declare class Guild extends Base {
800
848
  splashWidth?: number | null;
801
849
  /** Splash image height. Optional. */
802
850
  splashHeight?: number | null;
803
- members: Collection<string, GuildMember>;
851
+ members: GuildMemberManager;
804
852
  channels: Collection<string, GuildChannel>;
805
853
  roles: Collection<string, Role>;
806
854
  /** @param data - API guild from GET /guilds/{id} or gateway GUILD_CREATE */
@@ -834,6 +882,29 @@ declare class Guild extends Base {
834
882
  * Requires Manage Roles permission.
835
883
  */
836
884
  removeRoleFromMember(userId: string, roleId: string): Promise<void>;
885
+ /**
886
+ * Create a role in this guild.
887
+ * Requires Manage Roles permission.
888
+ * @param options - Role data (permissions accepts PermissionResolvable for convenience)
889
+ * @returns The created role
890
+ * @example
891
+ * const role = await guild.createRole({ name: 'Mod', permissions: ['KickMembers', 'BanMembers'] });
892
+ */
893
+ createRole(options: RESTCreateRoleBody & {
894
+ permissions?: string | PermissionResolvable;
895
+ }): Promise<Role>;
896
+ /**
897
+ * Fetch all roles in this guild.
898
+ * @returns Array of Role objects (cached in guild.roles)
899
+ */
900
+ fetchRoles(): Promise<Role[]>;
901
+ /**
902
+ * Fetch a role by ID.
903
+ * @param roleId - The role ID to fetch
904
+ * @returns The role
905
+ * @throws FluxerError with ROLE_NOT_FOUND if role does not exist (404)
906
+ */
907
+ fetchRole(roleId: string): Promise<Role>;
837
908
  /**
838
909
  * Resolve a role ID from an argument (role mention, raw ID, or name).
839
910
  * Fetches guild roles if name is provided.
@@ -1106,6 +1177,62 @@ declare const Events: {
1106
1177
  readonly Debug: "debug";
1107
1178
  };
1108
1179
 
1180
+ /** Result of {@link UsersManager.fetchWithProfile}. */
1181
+ interface FetchedUserWithProfile {
1182
+ /** The user (cached in client.users). */
1183
+ user: User;
1184
+ /** Raw user data from GET /users/{id}. */
1185
+ userData: APIUserPartial;
1186
+ /** Global profile (bio, pronouns, mutual guilds, etc.). Null if unavailable. */
1187
+ globalProfile: APIProfileResponse | null;
1188
+ /** Server-specific profile when guildId was provided. Null if unavailable. */
1189
+ serverProfile: APIProfileResponse | null;
1190
+ /** Guild member when guildId was provided and user is in the guild. Null otherwise. */
1191
+ member: GuildMember | null;
1192
+ /** Raw member data when member exists (for premium_since, etc.). */
1193
+ memberData: (APIGuildMember & {
1194
+ user: {
1195
+ id: string;
1196
+ };
1197
+ }) | null;
1198
+ }
1199
+ /**
1200
+ * Manages users with fetch and profile helpers.
1201
+ * Extends Collection so you can use .get(), .set(), .filter(), etc.
1202
+ */
1203
+ declare class UsersManager extends Collection<string, User> {
1204
+ private readonly client;
1205
+ constructor(client: Client);
1206
+ /**
1207
+ * Fetch a user by ID from the API.
1208
+ * Updates cache if user already exists.
1209
+ * @param userId - Snowflake of the user
1210
+ * @returns The user
1211
+ * @throws FluxerError (or REST error) if user not found
1212
+ * @example
1213
+ * const user = await client.users.fetch(userId);
1214
+ * console.log(user.username);
1215
+ */
1216
+ fetch(userId: string): Promise<User>;
1217
+ /**
1218
+ * Fetch a user with full profile and optional guild context.
1219
+ * Returns user, global profile, server profile (when guildId), and member (when guildId).
1220
+ * Ideal for userinfo commands.
1221
+ * @param userId - Snowflake of the user
1222
+ * @param options - Optional guildId for server profile and member data
1223
+ * @returns User, raw data, profiles, and member (when in guild)
1224
+ * @throws FluxerError (or REST error) if user not found
1225
+ * @example
1226
+ * const { user, globalProfile, serverProfile, member } = await client.users.fetchWithProfile(
1227
+ * userId,
1228
+ * { guildId: message.guildId ?? undefined },
1229
+ * );
1230
+ */
1231
+ fetchWithProfile(userId: string, options?: {
1232
+ guildId?: string | null;
1233
+ }): Promise<FetchedUserWithProfile>;
1234
+ }
1235
+
1109
1236
  /**
1110
1237
  * Callback parameter types for client events. Use with client.on(Events.X, handler).
1111
1238
  * @see Events
@@ -1197,7 +1324,7 @@ declare class Client extends EventEmitter {
1197
1324
  readonly rest: REST;
1198
1325
  readonly guilds: GuildManager;
1199
1326
  readonly channels: ChannelManager;
1200
- readonly users: Collection<string, User>;
1327
+ readonly users: UsersManager;
1201
1328
  /** Typed event handlers. Use client.events.MessageReactionAdd((reaction, user, messageId, channelId, emoji, userId) => {...}) or client.on(Events.MessageReactionAdd, ...). */
1202
1329
  readonly events: ClientEventMethods;
1203
1330
  /** The authenticated bot user. Null until READY is received. */
@@ -1338,6 +1465,7 @@ declare const ErrorCodes: {
1338
1465
  readonly MessageNotFound: "MESSAGE_NOT_FOUND";
1339
1466
  readonly GuildNotFound: "GUILD_NOT_FOUND";
1340
1467
  readonly MemberNotFound: "MEMBER_NOT_FOUND";
1468
+ readonly RoleNotFound: "ROLE_NOT_FOUND";
1341
1469
  };
1342
1470
 
1343
1471
  interface CdnUrlOptions {
@@ -1401,4 +1529,4 @@ declare function cdnMemberBannerURL(guildId: string, userId: string, bannerHash:
1401
1529
  */
1402
1530
  declare function cdnDefaultAvatarURL(discriminatorIndex?: number): string;
1403
1531
 
1404
- export { Base, CategoryChannel, type CdnUrlOptions, Channel, ChannelManager, Client, type ClientEventMethods, type ClientEvents, ClientUser, type CollectedReaction, DMChannel, ErrorCodes, Events, FluxerError, type FluxerErrorOptions, Guild, GuildBan, GuildChannel, GuildEmoji, GuildMember, GuildSticker, Invite, LinkChannel, Message, MessageCollector, type MessageCollectorEndReason, type MessageCollectorOptions, type MessageEditOptions, MessageManager, MessageReaction, type MessageSendOptions, type PartialMessage, ReactionCollector, type ReactionCollectorEndReason, type ReactionCollectorOptions, Role, TextChannel, User, VoiceChannel, Webhook, type WebhookSendOptions, cdnAvatarURL, cdnBannerURL, cdnDefaultAvatarURL, cdnDisplayAvatarURL, cdnMemberAvatarURL, cdnMemberBannerURL };
1532
+ export { Base, CategoryChannel, type CdnUrlOptions, Channel, ChannelManager, Client, type ClientEventMethods, type ClientEvents, ClientUser, type CollectedReaction, DMChannel, ErrorCodes, Events, type FetchedUserWithProfile, FluxerError, type FluxerErrorOptions, Guild, GuildBan, GuildChannel, GuildEmoji, GuildMember, GuildMemberManager, GuildSticker, Invite, LinkChannel, Message, MessageCollector, type MessageCollectorEndReason, type MessageCollectorOptions, type MessageEditOptions, MessageManager, MessageReaction, type MessageSendOptions, type PartialMessage, ReactionCollector, type ReactionCollectorEndReason, type ReactionCollectorOptions, Role, TextChannel, User, UsersManager, VoiceChannel, Webhook, type WebhookSendOptions, cdnAvatarURL, cdnBannerURL, cdnDefaultAvatarURL, cdnDisplayAvatarURL, cdnMemberAvatarURL, cdnMemberBannerURL };