@stoatx/client 0.3.0 → 0.5.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.
package/dist/index.d.cts CHANGED
@@ -1,4 +1,7 @@
1
1
  import { EventEmitter } from 'events';
2
+ import { APIRoutes, File, User as User$1, Member as Member$1, Channel, Message as Message$1, Role as Role$1, Invite, ServerBan as ServerBan$1, Server as Server$1, Emoji as Emoji$1, Category, Embed } from 'stoat-api';
3
+ import * as stoatApi from 'stoat-api';
4
+ export { stoatApi as API };
2
5
  import * as util from 'node:util';
3
6
 
4
7
  declare class GatewayManager {
@@ -18,6 +21,40 @@ declare class GatewayManager {
18
21
  disconnect(): void;
19
22
  }
20
23
 
24
+ type CDNTag = "attachments" | "avatars" | "backgrounds" | "icons" | "banners" | "emojis";
25
+ declare class AttachmentBuilder {
26
+ readonly filename: string | undefined;
27
+ readonly file: Buffer | Blob;
28
+ /**
29
+ * Creates a new AttachmentBuilder with the given file and optional filename.
30
+ * @param file The file data as a Buffer or Blob.
31
+ * @param filename An optional filename to use for the uploaded file. If not provided, the CDN will assign a default name.
32
+ * Providing a filename can help with organization and debugging, but is not strictly required.
33
+ * @example
34
+ * // Create an attachment from a Buffer with a custom filename
35
+ * const buffer = Buffer.from("Hello, world!");
36
+ * const attachment = new AttachmentBuilder(buffer, "greeting.txt");
37
+ */
38
+ constructor(file: Buffer | Blob, filename?: string);
39
+ /**
40
+ * Uploads this attachment to the Stoat CDN and returns the resulting file ID.
41
+ * @internal — use `resolveAttachment()` instead of calling this directly.
42
+ */
43
+ upload(rest: RESTManager, tag: CDNTag): Promise<string>;
44
+ }
45
+
46
+ type ValidPath<M extends APIRoutes["method"]> = Extract<APIRoutes, {
47
+ method: M;
48
+ }>["path"];
49
+ type RouteResponse<M extends APIRoutes["method"], P extends string> = Extract<APIRoutes, {
50
+ method: M;
51
+ path: P;
52
+ }>["response"];
53
+ type RouteParams<M extends APIRoutes["method"], P extends string> = Extract<APIRoutes, {
54
+ method: M;
55
+ path: P;
56
+ }>["params"];
57
+
21
58
  /**
22
59
  * Custom Error class for Stoat API failures
23
60
  */
@@ -41,17 +78,17 @@ declare class RESTManager {
41
78
  * Generates a local identifier for the bucket based on method and path.
42
79
  */
43
80
  private getRouteKey;
44
- makeRequest(method: string, endpoint: string, body?: any): Promise<any>;
81
+ makeRequest<M extends APIRoutes["method"], P extends ValidPath<M>>(method: M, endpoint: P, params?: RouteParams<M, P>): Promise<RouteResponse<M, P>>;
45
82
  private execute;
46
83
  /**
47
84
  * Uploads a file to Stoat's CDN and returns the File ID
48
85
  */
49
- uploadFile(filename: string, fileBuffer: Buffer | Blob): Promise<string>;
50
- get(endpoint: string): Promise<any>;
51
- post(endpoint: string, body?: any): Promise<any>;
52
- patch(endpoint: string, body?: any): Promise<any>;
53
- delete(endpoint: string, body?: any): Promise<any>;
54
- put(endpoint: string, body?: any): Promise<any>;
86
+ uploadFile(tag: CDNTag, fileBuffer: Buffer | Blob, filename?: string): Promise<string>;
87
+ get<P extends ValidPath<"get">>(endpoint: P, params?: RouteParams<"get", P>): Promise<RouteResponse<"get", P>>;
88
+ post<P extends ValidPath<"post">>(endpoint: P, params?: RouteParams<"post", P>): Promise<RouteResponse<"post", P>>;
89
+ patch<P extends ValidPath<"patch">>(endpoint: P, params?: RouteParams<"patch", P>): Promise<RouteResponse<"patch", P>>;
90
+ delete<P extends ValidPath<"delete">>(endpoint: P, params?: RouteParams<"delete", P>): Promise<RouteResponse<"delete", P>>;
91
+ put<P extends ValidPath<"put">>(endpoint: P, params?: RouteParams<"put", P>): Promise<RouteResponse<"put", P>>;
55
92
  }
56
93
 
57
94
  /**
@@ -61,7 +98,7 @@ declare abstract class Base {
61
98
  readonly id: string;
62
99
  cachedAt: number;
63
100
  protected readonly client: Client;
64
- constructor(client: Client, data: {
101
+ protected constructor(client: Client, data: {
65
102
  _id: string;
66
103
  });
67
104
  /**
@@ -88,8 +125,8 @@ type AttachmentMetadata = {
88
125
  type: "Image";
89
126
  width: number;
90
127
  height: number;
91
- thumbhash?: number[];
92
- animated?: boolean;
128
+ thumbhash?: number[] | null;
129
+ animated?: boolean | null;
93
130
  } | {
94
131
  type: "Video";
95
132
  width: number;
@@ -104,11 +141,11 @@ declare class Attachment extends Base {
104
141
  size: number;
105
142
  deleted?: boolean;
106
143
  reported?: boolean;
107
- messageId?: string;
108
- userId?: string;
109
- serverId?: string;
110
- objectId?: string;
111
- constructor(client: Client, data: any);
144
+ messageId?: string | null | undefined;
145
+ userId?: string | null | undefined;
146
+ serverId?: string | null | undefined;
147
+ objectId?: string | null | undefined;
148
+ constructor(client: Client, data: File);
112
149
  /**
113
150
  * Automatically constructs the direct CDN URL for this file
114
151
  */
@@ -119,29 +156,12 @@ declare class Attachment extends Base {
119
156
  get isImage(): boolean;
120
157
  }
121
158
 
122
- declare enum UserRelationship {
123
- None = "None",
124
- User = "User",
125
- Friend = "Friend",
126
- Outgoing = "Outgoing",
127
- Incoming = "Incoming",
128
- Blocked = "Blocked",
129
- BlockedOther = "BlockedOther"
130
- }
131
- declare enum UserPresence {
132
- Online = "Online",
133
- Idle = "Idle",
134
- Focus = "Focus",
135
- Busy = "Busy",
136
- Invisible = "Invisible"
137
- }
159
+ type UserRelationShip = "None" | "User" | "Friend" | "Outgoing" | "Incoming" | "Blocked" | "BlockedOther";
138
160
  interface BotInformation {
139
161
  owner: string;
140
162
  }
141
- interface UserStatus {
142
- presence: UserPresence;
143
- text?: string | null;
144
- }
163
+ type UserStatus = NonNullable<User$1["status"]>;
164
+ type UserPresence = NonNullable<UserStatus["presence"]>;
145
165
  interface UserProfile {
146
166
  background?: string | null;
147
167
  content?: string | null;
@@ -149,7 +169,7 @@ interface UserProfile {
149
169
  declare class User extends Base {
150
170
  discriminator: string;
151
171
  online: boolean;
152
- relationship: UserRelationship;
172
+ relationship: UserRelationShip;
153
173
  username: string;
154
174
  avatar?: Attachment | null;
155
175
  badges?: number;
@@ -158,8 +178,8 @@ declare class User extends Base {
158
178
  flags?: number;
159
179
  privileged?: boolean;
160
180
  status?: UserStatus | null;
161
- constructor(client: Client, data: any);
162
- _patch(data: any, clear?: string[]): void;
181
+ constructor(client: Client, data: User$1);
182
+ _patch(data: User$1, clear?: string[]): void;
163
183
  /**
164
184
  * Convenience getter to return the user's tag (username#discriminator)
165
185
  */
@@ -249,7 +269,8 @@ interface MemberBanOptions {
249
269
  deleteMessageSeconds?: number;
250
270
  }
251
271
  interface FetchMembersOptions {
252
- exclude_offline?: boolean;
272
+ /** Whether to exclude offline users from the fetch */
273
+ excludeOffline?: boolean;
253
274
  }
254
275
  declare class MemberManager extends BaseManager<string, Member> {
255
276
  server: Server;
@@ -258,12 +279,12 @@ declare class MemberManager extends BaseManager<string, Member> {
258
279
  * Tell BaseManager how to handle Revolt's Member IDs
259
280
  * @internal
260
281
  */
261
- protected extractId(data: any): string;
282
+ protected extractId(data: Member$1): string;
262
283
  /**
263
284
  * Tell BaseManager how to build a Member
264
285
  * @internal
265
286
  */
266
- protected construct(data: any): Member;
287
+ protected construct(data: Member$1): Member;
267
288
  /**
268
289
  * Resolve a string or mention to Member
269
290
  * @param member The MemberResolvable to resolve
@@ -346,6 +367,141 @@ declare class MemberManager extends BaseManager<string, Member> {
346
367
  [util.inspect.custom](): Collection<string, Member>;
347
368
  }
348
369
 
370
+ type BitFieldResolvable = number | string | bigint | BitField | BitFieldResolvable[];
371
+ declare class BitField {
372
+ static Flags: Record<string, number | bigint>;
373
+ static DefaultBit: number | bigint;
374
+ bitfield: number | bigint;
375
+ constructor(bits?: BitFieldResolvable);
376
+ /**
377
+ * Checks whether this bitfield has any of the given bits set.
378
+ *
379
+ * @param bit The bit(s) to test against.
380
+ * @returns `true` if at least one of the provided bits is set.
381
+ *
382
+ * @example
383
+ * perms.any(['SendMessage', 'ManageChannel']); // true if either is set
384
+ */
385
+ any(bit: BitFieldResolvable): boolean;
386
+ /**
387
+ * Checks whether this bitfield is exactly equal to the given bit value.
388
+ *
389
+ * @param bit The bit(s) to compare against.
390
+ * @returns `true` if the resolved bit value is identical to this bitfield.
391
+ *
392
+ * @example
393
+ * new Permissions(0n).equals(0n); // true
394
+ */
395
+ equals(bit: BitFieldResolvable): boolean;
396
+ /**
397
+ * Checks whether this bitfield has *all* of the given bits set.
398
+ *
399
+ * @param bit The bit(s) to check for.
400
+ * @returns `true` if every provided bit is set in this bitfield.
401
+ *
402
+ * @example
403
+ * perms.has('SendMessage');
404
+ * perms.has(['SendMessage', 'ViewChannel']); // true only if both are set
405
+ */
406
+ has(bit: BitFieldResolvable, ..._hasParams: any[]): boolean;
407
+ /**
408
+ * Returns the flag names present in `bits` that are *missing* from this bitfield.
409
+ *
410
+ * @param bits The bits to check against.
411
+ * @returns An array of flag name strings that are in `bits` but not in this bitfield.
412
+ *
413
+ * @example
414
+ * // If perms only has SendMessage:
415
+ * perms.missing(['SendMessage', 'ManageChannel']); // ['ManageChannel']
416
+ */
417
+ missing(bits: BitFieldResolvable, ...hasParams: any[]): string[];
418
+ /**
419
+ * Freezes this BitField instance, making it immutable.
420
+ * Subsequent calls to `add()` or `remove()` will return a new instance instead of mutating this one.
421
+ *
422
+ * @returns This instance, frozen.
423
+ */
424
+ freeze(): Readonly<this>;
425
+ /**
426
+ * Adds one or more bits to this bitfield.
427
+ * If the instance is frozen, returns a new BitField with the bits added.
428
+ *
429
+ * @param bits The bit(s) to add.
430
+ * @returns This instance (or a new one if frozen), with the bits added.
431
+ *
432
+ * @example
433
+ * perms.add('SendMessage', 'ViewChannel');
434
+ */
435
+ add(...bits: BitFieldResolvable[]): this;
436
+ /**
437
+ * Removes one or more bits from this bitfield.
438
+ * If the instance is frozen, returns a new BitField with the bits removed.
439
+ *
440
+ * @param bits The bit(s) to remove.
441
+ * @returns This instance (or a new one if frozen), with the bits cleared.
442
+ *
443
+ * @example
444
+ * perms.remove('ManageChannel');
445
+ */
446
+ remove(...bits: BitFieldResolvable[]): this;
447
+ /**
448
+ * Serializes this bitfield to a plain object mapping each flag name to a boolean
449
+ * indicating whether that flag is set.
450
+ *
451
+ * @returns A record of `{ [flagName]: boolean }` for all defined flags.
452
+ *
453
+ * @example
454
+ * perms.serialize();
455
+ * // { SendMessage: true, ManageChannel: false, ... }
456
+ */
457
+ serialize(...hasParams: any[]): Record<string, boolean>;
458
+ /**
459
+ * Returns an array of flag names that are set in this bitfield.
460
+ *
461
+ * @returns An array of string flag names.
462
+ *
463
+ * @example
464
+ * perms.toArray(); // ['SendMessage', 'ViewChannel']
465
+ */
466
+ toArray(...hasParams: any[]): string[];
467
+ /**
468
+ * Returns the bitfield value as a JSON-safe primitive.
469
+ * Numbers are returned as-is; bigints are converted to their string representation
470
+ * to avoid JSON serialization errors.
471
+ */
472
+ toJSON(): number | string;
473
+ /**
474
+ * Returns the underlying numeric value of this bitfield.
475
+ * Allows BitField instances to be used directly in arithmetic expressions.
476
+ */
477
+ valueOf(): number | bigint;
478
+ /**
479
+ * Iterates over the names of all flags that are set in this bitfield.
480
+ *
481
+ * @example
482
+ * for (const flag of perms) {
483
+ * console.log(flag); // 'SendMessage', 'ViewChannel', etc.
484
+ * }
485
+ */
486
+ [Symbol.iterator](...hasParams: any[]): IterableIterator<string>;
487
+ /**
488
+ * Resolves a {@link BitFieldResolvable} into a raw `number | bigint`.
489
+ *
490
+ * Resolution rules (in order):
491
+ * - `undefined` → `DefaultBit`
492
+ * - A number or bigint matching `DefaultBit`'s type and >= 0 → returned as-is
493
+ * - A `BitField` instance → its `.bitfield` value
494
+ * - An array → each element resolved and OR'd together
495
+ * - A numeric string → parsed as `BigInt` or `Number` depending on `DefaultBit`'s type
496
+ * - A named string flag → looked up in `Flags`
497
+ * - Anything else → throws `RangeError`
498
+ *
499
+ * @param bit The value to resolve.
500
+ * @throws {RangeError} If the value cannot be resolved to a valid bit.
501
+ */
502
+ static resolve(bit?: BitFieldResolvable): number | bigint;
503
+ }
504
+
349
505
  declare const PermissionFlags: {
350
506
  readonly ManageChannel: bigint;
351
507
  readonly ManageServer: bigint;
@@ -383,26 +539,32 @@ declare const PermissionFlags: {
383
539
  readonly GrantAllSafe: 4503599627370495n;
384
540
  };
385
541
  type PermissionString = keyof typeof PermissionFlags;
386
- type PermissionResolvable = bigint | PermissionString | PermissionResolvable[];
387
- declare class Permissions {
388
- /**
389
- * Converts a string, BigInt, or array of strings into a single BigInt
390
- */
391
- static resolve(permission: PermissionResolvable): bigint;
392
- /**
393
- * Checks if a specific permission bit exists
394
- */
395
- static has(totalPermissions: bigint, permissionToCheck: PermissionResolvable): boolean;
542
+ type PermissionResolvable = PermissionString | bigint | number | Permissions | PermissionResolvable[];
543
+ declare class Permissions extends BitField {
544
+ static Flags: Record<string, number | bigint>;
545
+ static DefaultBit: bigint;
546
+ static resolve(bit?: PermissionResolvable): bigint;
547
+ has(bit: PermissionResolvable): boolean;
548
+ any(bit: PermissionResolvable): boolean;
549
+ missing(bits: PermissionResolvable): PermissionString[];
550
+ add(...bits: PermissionResolvable[]): this;
551
+ remove(...bits: PermissionResolvable[]): this;
396
552
  }
397
553
 
554
+ type RawDMChannel = Extract<Channel, {
555
+ channel_type: "DirectMessage";
556
+ }>;
398
557
  declare class DMChannel extends BaseChannel {
399
558
  active: boolean;
400
559
  recipients: string[];
401
560
  lastMessageId: string | null;
402
- constructor(client: any, data: any);
403
- _patch(data: any): void;
561
+ constructor(client: Client, data: RawDMChannel);
562
+ _patch(data: RawDMChannel): void;
404
563
  }
405
564
 
565
+ type RawGroupChannel = Extract<Channel, {
566
+ channel_type: "Group";
567
+ }>;
406
568
  declare class GroupChannel extends BaseChannel {
407
569
  name: string;
408
570
  ownerId: string;
@@ -411,8 +573,8 @@ declare class GroupChannel extends BaseChannel {
411
573
  icon: Attachment | null;
412
574
  lastMessageId?: string | null;
413
575
  nsfw: boolean;
414
- constructor(client: Client, data: any);
415
- _patch(data: any, clear?: string[]): void;
576
+ constructor(client: Client, data: RawGroupChannel);
577
+ _patch(data: RawGroupChannel, clear?: string[]): void;
416
578
  /** Gets the User object of the person who owns this group */
417
579
  get owner(): User | undefined;
418
580
  /** Resolves the recipient IDs into an array of cached User objects */
@@ -443,11 +605,11 @@ declare class UserManager extends BaseManager<string, User> {
443
605
  /**
444
606
  * Tell BaseManager how to find the ID for Users
445
607
  */
446
- protected extractId(data: any): string;
608
+ protected extractId(data: User$1): string;
447
609
  /**
448
610
  * Tell BaseManager how to build a User
449
611
  */
450
- protected construct(data: any): User;
612
+ protected construct(data: User$1): User;
451
613
  /**
452
614
  * Resolves a UserResolvable to a User object from the cache.
453
615
  */
@@ -547,11 +709,11 @@ declare class MessageManager extends BaseManager<string, Message> {
547
709
  /**
548
710
  * Tell BaseManager how to find the ID for Messages
549
711
  */
550
- protected extractId(data: any): string;
712
+ protected extractId(data: Message$1): string;
551
713
  /**
552
714
  * Tell BaseManager how to build a Message
553
715
  */
554
- protected construct(data: any): Message;
716
+ protected construct(data: Message$1): Message;
555
717
  fetch(id: string): Promise<Message>;
556
718
  /**
557
719
  * Fetches multiple messages from the channel using specific filter parameters.
@@ -639,7 +801,7 @@ interface ChannelEditOptions {
639
801
  name?: string;
640
802
  description?: string | null;
641
803
  owner?: string;
642
- icon?: string | null;
804
+ icon?: string | AttachmentBuilder | null;
643
805
  nsfw?: boolean;
644
806
  archived?: boolean;
645
807
  voice?: {
@@ -658,8 +820,8 @@ declare class ChannelManager extends BaseManager<string, BaseChannel> {
658
820
  * @param limit The maximum number of channels to hold in the cache.
659
821
  */
660
822
  constructor(client: Client, limit?: number);
661
- protected extractId(data: any): string;
662
- protected construct(data: any): BaseChannel;
823
+ protected extractId(data: Channel): string;
824
+ protected construct(data: Channel): BaseChannel;
663
825
  /**
664
826
  * Resolves a ChannelResolvable to a cached BaseChannel object.
665
827
  * @param channel The ChannelResolvable to resolve.
@@ -763,21 +925,24 @@ declare class ChannelManager extends BaseManager<string, BaseChannel> {
763
925
  bulkDelete(id: string, messages: MessageResolvable[]): Promise<void>;
764
926
  }
765
927
 
928
+ type RawTextChannel = Extract<Channel, {
929
+ channel_type: "TextChannel";
930
+ }>;
766
931
  declare class TextChannel extends BaseChannel {
767
932
  name: string;
768
933
  serverId: string;
769
934
  defaultPermissions?: {
770
935
  a: number;
771
936
  d: number;
772
- };
773
- description?: string | null;
937
+ } | null | undefined;
938
+ description?: string | null | undefined;
774
939
  icon?: Attachment | null;
775
- lastMessageId?: string | null;
940
+ lastMessageId?: string | null | undefined;
776
941
  nsfw?: boolean;
777
942
  slowmode?: number;
778
943
  voice?: any;
779
- constructor(client: Client, data: any);
780
- _patch(data: any, clear?: string[]): void;
944
+ constructor(client: Client, data: RawTextChannel);
945
+ _patch(data: RawTextChannel, clear?: string[]): void;
781
946
  /**
782
947
  * Updates the permission overrides for the channel.
783
948
  * @param roleId The raw string ID of the role to update.
@@ -971,11 +1136,7 @@ declare class MessageCollector extends Collector<string, Message> {
971
1136
  endReason(): string | null;
972
1137
  }
973
1138
 
974
- declare enum ChannelType {
975
- TEXT = "TextChannel",
976
- DM = "DirectMessage",
977
- GROUP = "Group"
978
- }
1139
+ type ChannelType = "SavedMessages" | "DirectMessage" | "Group" | "TextChannel";
979
1140
  interface ChannelCreateOptions {
980
1141
  name: string;
981
1142
  type: "Text" | "Voice";
@@ -988,7 +1149,7 @@ interface ChannelCreateOptions {
988
1149
  declare abstract class BaseChannel extends Base {
989
1150
  type: ChannelType;
990
1151
  messages: MessageManager;
991
- protected constructor(client: Client, data: any);
1152
+ protected constructor(client: Client, data: Channel);
992
1153
  /**
993
1154
  * Sends a message to this channel.
994
1155
  * @param contentOrOptions The string content or message options payload.
@@ -1101,27 +1262,26 @@ declare class ServerChannelManager {
1101
1262
  declare class Role extends Base {
1102
1263
  serverId: string;
1103
1264
  name: string;
1104
- color: string | null;
1265
+ color: string | null | undefined;
1105
1266
  hoist: boolean;
1106
1267
  rank: number;
1107
- permissions: bigint;
1108
- constructor(client: Client, data: any, serverId: string);
1268
+ icon: Attachment | null;
1269
+ private _permissions;
1270
+ constructor(client: Client, data: Role$1, serverId: string);
1109
1271
  /**
1110
1272
  * Updates the role instance with new data without losing the object reference.
1111
1273
  * @internal
1112
1274
  */
1113
- _patch(data: any): void;
1275
+ _patch(data: Role$1): void;
1114
1276
  /**
1115
1277
  * The server this role belongs to.
1116
1278
  * Pulls dynamically from the cache to prevent massive memory duplication.
1117
1279
  */
1118
1280
  get server(): Server | undefined;
1119
1281
  /**
1120
- * Checks whether this role has a specific permission.
1121
- * @param permission The permission to check for.
1122
- * @returns True if the role has the permission.
1282
+ * Permissions for this role
1123
1283
  */
1124
- hasPermission(permission: PermissionResolvable): boolean;
1284
+ get permissions(): Permissions;
1125
1285
  /**
1126
1286
  * Fetches this role directly from the API to ensure data is up to date.
1127
1287
  * @param force Whether to skip the cache check and force a direct API request. Defaults to false.
@@ -1133,7 +1293,7 @@ declare class Role extends Base {
1133
1293
  * await role.fetch();
1134
1294
  * console.log(`Role updated, current name: ${role.name}`);
1135
1295
  */
1136
- fetch(force?: boolean): Promise<this>;
1296
+ fetch(force?: boolean): Promise<Role>;
1137
1297
  /**
1138
1298
  * Edits the role with the given options. Only the fields provided in the options will be updated; all other fields will remain unchanged.
1139
1299
  * @param options The fields to update.
@@ -1142,12 +1302,12 @@ declare class Role extends Base {
1142
1302
  * @throws {Error} If the API request fails (e.g., lack of permissions).
1143
1303
  * @example
1144
1304
  * // Change the role's name and color
1145
- * await role.edit({ name: "Senior Admin", colour: "#FFD700" });
1305
+ * await role.edit({ name: "Senior Admin", color: "#FFD700" });
1146
1306
  *
1147
1307
  * // Remove the custom color from the role
1148
- * await role.edit({ colour: null });
1308
+ * await role.edit({ color: null });
1149
1309
  */
1150
- edit(options: RoleEditOptions): Promise<this>;
1310
+ edit(options: RoleEditOptions): Promise<Role>;
1151
1311
  /**
1152
1312
  * Deletes this Role from the server.
1153
1313
  * @throws {Error} If the role cannot be deleted (e.g., lack of permissions).
@@ -1168,7 +1328,7 @@ declare class Role extends Base {
1168
1328
  * allow: ["ManageChannel", "SendMessage"]
1169
1329
  * });
1170
1330
  */
1171
- setPermissions(options: RolePermissionOptions): Promise<this>;
1331
+ setPermissions(options: RolePermissionOptions): Promise<Role>;
1172
1332
  /**
1173
1333
  * Updates the hierarchical position of this role.
1174
1334
  * Automatically reconstructs the role array and performs a bulk update.
@@ -1180,7 +1340,66 @@ declare class Role extends Base {
1180
1340
  * await role.setPosition(2);
1181
1341
  * console.log(`Role moved to rank: ${role.rank}`);
1182
1342
  */
1183
- setPosition(newPosition: number): Promise<this>;
1343
+ setPosition(newPosition: number): Promise<Role>;
1344
+ /**
1345
+ * Change the name for this role
1346
+ * @param name The new name for the role
1347
+ * @returns A promise that resolves to this updated Role object.
1348
+ * @throws {Error} If API request fails.
1349
+ * @example
1350
+ * // Change the role's name
1351
+ * await role.setName("New Role Name");
1352
+ * console.log(`Role's new name: ${role.name}`);
1353
+ */
1354
+ setName(name: string): Promise<Role>;
1355
+ /**
1356
+ * Change the color for this role, it can be a HEX or CSS colours
1357
+ * @param {[string]} color The new color for the role
1358
+ * @returns A promise that resolves to this updated Role object.
1359
+ * @throws {Error} If API request fails
1360
+ * @example
1361
+ * // Change the role's color
1362
+ * await role.setColour("#FF0000");
1363
+ * console.log(`Role's new color: ${role.color}`);
1364
+ *
1365
+ * // Use CSS color linear-graident
1366
+ * await role.setColour("linear-gradient(90deg, #FF0000, #0000FF)");
1367
+ * console.log(`Role's new color: ${role.color}`);
1368
+ *
1369
+ * // Remove the custom color from the role
1370
+ * await role.setColour(null);
1371
+ * console.log(`Role's color removed, current color: ${role.color}`);
1372
+ */
1373
+ setColor(color: string | null): Promise<Role>;
1374
+ /**
1375
+ * Edit the icon of this role
1376
+ * @param icon Autumn ID for the new icon, or null to remove the custom icon
1377
+ * @returns A promise that resolves to this updated Role object.
1378
+ * @throws {Error} If API request fails
1379
+ * @example
1380
+ * // Set a new icon for the role
1381
+ * await role.setIcon("AUTUMN_ID_FOR_ICON");
1382
+ * console.log(`Role's new icon: ${role.icon}`);
1383
+ *
1384
+ * // Use AttachmentBuilder to upload a new icon file
1385
+ * import { readFile } from "node:fs/promises";
1386
+ * const iconFile = await readFile("./a.jpg");
1387
+ * const attachment = new AttachmentBuilder(iconFile, "a.jpg");
1388
+ * await role.setIcon(attachment);
1389
+ * console.log(`Role's new icon: ${role.icon}`);
1390
+ */
1391
+ setIcon(icon: string | AttachmentBuilder | null): Promise<Role>;
1392
+ /**
1393
+ * Change the hoist status for this role
1394
+ * @param hoist The new hoist status for the role
1395
+ * @returns A promise that resolves to this updated Role object.
1396
+ * @throws {Error} If API request fails
1397
+ * @example
1398
+ * // Enable hoisting for the role
1399
+ * await role.setHoist(true);
1400
+ * console.log(`Role is now hoisted: ${role.hoist}`);
1401
+ */
1402
+ setHoist(hoist: boolean): Promise<Role>;
1184
1403
  /**
1185
1404
  * Customizer for Node.js `console.log` and `util.inspect`.
1186
1405
  * Hides the cyclic client reference and raw serverId for a cleaner output.
@@ -1194,8 +1413,9 @@ interface RoleCreateOptions {
1194
1413
  }
1195
1414
  interface RoleEditOptions {
1196
1415
  name?: string;
1197
- colour?: string | null;
1416
+ color?: string | null;
1198
1417
  hoist?: boolean;
1418
+ icon?: string | AttachmentBuilder | null;
1199
1419
  }
1200
1420
  interface RolePermissionOptions {
1201
1421
  allow?: PermissionResolvable;
@@ -1211,11 +1431,11 @@ declare class RoleManager extends BaseManager<string, Role> {
1211
1431
  /**
1212
1432
  * Tell BaseManager how to find the ID for Roles
1213
1433
  */
1214
- protected extractId(data: any): string;
1434
+ protected extractId(data: Role$1): string;
1215
1435
  /**
1216
1436
  * Tell BaseManager how to build a Role
1217
1437
  */
1218
- protected construct(data: any): Role;
1438
+ protected construct(data: Role$1): Role;
1219
1439
  /**
1220
1440
  * Adds or updates a role in the local cache.
1221
1441
  * @internal
@@ -1223,7 +1443,7 @@ declare class RoleManager extends BaseManager<string, Role> {
1223
1443
  * @param idParam An optional ID parameter if the payload wraps the role object.
1224
1444
  * @returns The newly created or updated Role object.
1225
1445
  */
1226
- _add(data: any, idParam?: string): Role;
1446
+ _add(data: Role$1, idParam?: string): Role;
1227
1447
  [util.inspect.custom](): Collection<string, Role>;
1228
1448
  /**
1229
1449
  * Resolves a RoleResolvable to a Role object from the cache.
@@ -1273,7 +1493,7 @@ declare class RoleManager extends BaseManager<string, Role> {
1273
1493
  fetch(role: RoleResolvable, force?: boolean): Promise<Role>;
1274
1494
  /**
1275
1495
  * Edits an existing role in the server.
1276
- * @param role The RoleResolvable to edit.
1496
+ * @param role The {@link RoleResolvable} to edit.
1277
1497
  * @param options The fields to update.
1278
1498
  * @returns A promise that resolves to the updated Role.
1279
1499
  * @throws {TypeError} If invalid options or RoleResolvable are provided.
@@ -1338,15 +1558,15 @@ declare class ServerInvite {
1338
1558
  code: string;
1339
1559
  creatorId: string;
1340
1560
  channelId: string;
1341
- constructor(data: any);
1342
- _patch(data: any): void;
1561
+ constructor(data: Invite);
1562
+ _patch(data: Invite): void;
1343
1563
  }
1344
1564
 
1345
1565
  declare class ServerInviteManager extends BaseManager<string, ServerInvite> {
1346
1566
  server: Server;
1347
1567
  constructor(client: Client, server: Server, limit?: number);
1348
- protected extractId(data: any): string;
1349
- protected construct(data: any): ServerInvite;
1568
+ protected extractId(data: Invite): string;
1569
+ protected construct(data: Invite): ServerInvite;
1350
1570
  /**
1351
1571
  * Fetches all active invites for this server.
1352
1572
  */
@@ -1356,8 +1576,8 @@ declare class ServerInviteManager extends BaseManager<string, ServerInvite> {
1356
1576
  declare class ServerBan {
1357
1577
  userId: string;
1358
1578
  reason: string | null;
1359
- constructor(data: any);
1360
- _patch(data: any): void;
1579
+ constructor(data: ServerBan$1);
1580
+ _patch(data: ServerBan$1): void;
1361
1581
  }
1362
1582
 
1363
1583
  declare class ServerBanManager extends BaseManager<string, ServerBan> {
@@ -1402,11 +1622,11 @@ declare class ServerManager extends BaseManager<string, Server> {
1402
1622
  /**
1403
1623
  * Tell BaseManager how to find the ID for Servers
1404
1624
  */
1405
- protected extractId(data: any): string;
1625
+ protected extractId(data: Server$1): string;
1406
1626
  /**
1407
1627
  * Tell BaseManager how to build a Server
1408
1628
  */
1409
- protected construct(data: any): Server;
1629
+ protected construct(data: Server$1): Server;
1410
1630
  /**
1411
1631
  * Fetches a server from the API.
1412
1632
  * @param id The server ID.
@@ -1417,18 +1637,20 @@ declare class ServerManager extends BaseManager<string, Server> {
1417
1637
  [util.inspect.custom](): Collection<string, Server>;
1418
1638
  }
1419
1639
 
1420
- interface EmojiParent {
1421
- id: string;
1640
+ type EmojiParent = {
1422
1641
  type: "Server";
1423
- }
1642
+ id: string;
1643
+ } | {
1644
+ type: "Detached";
1645
+ };
1424
1646
  declare class Emoji extends Base {
1425
1647
  creatorId: string;
1426
1648
  name: string;
1427
1649
  parent: EmojiParent;
1428
1650
  animated: boolean;
1429
1651
  nsfw: boolean;
1430
- constructor(client: Client, data: any);
1431
- _patch(data: any): void;
1652
+ constructor(client: Client, data: Emoji$1);
1653
+ _patch(data: Emoji$1): void;
1432
1654
  }
1433
1655
 
1434
1656
  declare class EmojiManager extends BaseManager<string, Emoji> {
@@ -1446,11 +1668,6 @@ declare class EmojiManager extends BaseManager<string, Emoji> {
1446
1668
  [util.inspect.custom](): Collection<string, Emoji>;
1447
1669
  }
1448
1670
 
1449
- interface Categories {
1450
- channels: string[];
1451
- id: string;
1452
- title: string;
1453
- }
1454
1671
  declare class Server extends Base {
1455
1672
  channelIds: string[];
1456
1673
  defaultPermissions: bigint;
@@ -1458,7 +1675,7 @@ declare class Server extends Base {
1458
1675
  ownerId: string;
1459
1676
  analytics: boolean;
1460
1677
  banner: Attachment | null;
1461
- categories: Categories[];
1678
+ categories: Category[] | null;
1462
1679
  description: string | null;
1463
1680
  discoverable: boolean;
1464
1681
  flags: number;
@@ -1470,11 +1687,11 @@ declare class Server extends Base {
1470
1687
  bans: ServerBanManager;
1471
1688
  invites: ServerInviteManager;
1472
1689
  emojis: EmojiManager;
1473
- constructor(client: Client, data: any);
1690
+ constructor(client: Client, data: Server$1);
1474
1691
  /**
1475
1692
  * Updates the server instance with new data without losing the object reference.
1476
1693
  */
1477
- _patch(data: any, clear?: string[]): void;
1694
+ _patch(data: Server$1, clear?: string[]): void;
1478
1695
  /**
1479
1696
  * Edits this server.
1480
1697
  * @param options The fields to update.
@@ -1483,7 +1700,7 @@ declare class Server extends Base {
1483
1700
  /**
1484
1701
  * Leaves the server
1485
1702
  */
1486
- leave(): Promise<any>;
1703
+ leave(): Promise<never>;
1487
1704
  /**
1488
1705
  * Fetches multiple members from this server.
1489
1706
  * @param options Filter options for the fetch request.
@@ -1541,8 +1758,8 @@ declare class Member extends Base {
1541
1758
  canPublish: boolean;
1542
1759
  canRecieve: boolean;
1543
1760
  roles: MemberRoleManager;
1544
- constructor(client: Client, data: any);
1545
- _patch(data: any): void;
1761
+ constructor(client: Client, data: Member$1, serverId?: string);
1762
+ _patch(data: Member$1): void;
1546
1763
  /**
1547
1764
  * Get member role IDs
1548
1765
  */
@@ -1552,7 +1769,7 @@ declare class Member extends Base {
1552
1769
  /** Gets the Server object this member belongs to */
1553
1770
  get server(): Server | undefined;
1554
1771
  /** Calculates the member's total permissions using BigInt */
1555
- get permissions(): bigint;
1772
+ get permissions(): Permissions;
1556
1773
  /** Get avatar URL for this member, or null if they don't have one.
1557
1774
  * @example
1558
1775
  * // Get a member's avatar URL
@@ -1599,8 +1816,6 @@ declare class Member extends Base {
1599
1816
  */
1600
1817
  send(options: string | MessageOptions): Promise<Message>;
1601
1818
  setNickname(nickname: string): Promise<Member>;
1602
- /** Checks if the member has a specific permission */
1603
- hasPermission(permission: PermissionResolvable): boolean;
1604
1819
  /**
1605
1820
  * Edit this member.
1606
1821
  * @param options The options to edit the member with (nickname, roles, timeout, etc.)
@@ -1692,16 +1907,16 @@ declare class ReactionCollector extends Collector<string, MessageReaction> {
1692
1907
  interface MessageOptions {
1693
1908
  content?: string;
1694
1909
  embeds?: (TextEmbedData | EmbedBuilder)[];
1695
- attachments?: string[];
1910
+ attachments?: string[] | AttachmentBuilder[];
1696
1911
  interactions?: any[];
1697
1912
  flags?: number;
1698
1913
  masquerade?: Masquerade;
1699
1914
  replies?: ReplyIntent[];
1700
1915
  }
1701
1916
  interface Masquerade {
1702
- avatar?: string;
1703
- name?: string;
1704
- colour?: string;
1917
+ avatar?: string | null;
1918
+ name?: string | null;
1919
+ colour?: string | null;
1705
1920
  }
1706
1921
  interface ReplyIntent {
1707
1922
  id: string;
@@ -1716,19 +1931,19 @@ declare class Message extends Base {
1716
1931
  content: string | null;
1717
1932
  authorId: string;
1718
1933
  channelId: string;
1719
- embeds: any[];
1934
+ embeds: Embed[] | null;
1720
1935
  attachments: Attachment[];
1721
1936
  editedAt: Date | null;
1722
1937
  createdAt: Date | null;
1723
1938
  flags: number;
1724
1939
  interactions: Interaction | null;
1725
1940
  masquerade: Masquerade | null;
1726
- mentions: string[];
1727
- pinned: boolean;
1941
+ mentions: string[] | null;
1942
+ pinned: null | boolean;
1728
1943
  reactions: Record<string, string[]>;
1729
- replies: string[];
1730
- role_mentions: string[];
1731
- constructor(client: Client, data: any);
1944
+ replies: string[] | null;
1945
+ role_mentions: string[] | null;
1946
+ constructor(client: Client, data: Message$1);
1732
1947
  reply(contentOrOptions: string | MessageOptions): Promise<Message>;
1733
1948
  /**
1734
1949
  * Edits this message.
@@ -1810,7 +2025,7 @@ declare class Message extends Base {
1810
2025
  get serverId(): string | undefined;
1811
2026
  /** Gets the Server object from cache */
1812
2027
  get server(): Server | undefined;
1813
- _patch(data: any): void;
2028
+ _patch(data: Message$1): void;
1814
2029
  [util.inspect.custom](depth: number, options: util.InspectOptions, inspect: typeof util.inspect): string;
1815
2030
  }
1816
2031
 
@@ -1818,7 +2033,7 @@ declare class Message extends Base {
1818
2033
  * Represents the authenticated bot's user object.
1819
2034
  */
1820
2035
  declare class ClientUser extends User {
1821
- constructor(client: Client, data: any);
2036
+ constructor(client: Client, data: User$1);
1822
2037
  }
1823
2038
 
1824
2039
  interface SweeperOptions {
@@ -1868,7 +2083,18 @@ interface ClientEvents {
1868
2083
  serverDelete: [server: Server | string];
1869
2084
  userUpdate: [oldUser: User, newUser: User];
1870
2085
  serverMemberJoin: [member: Member];
1871
- serverMemberLeave: [member: Member];
2086
+ serverMemberLeave: [member: Member | {
2087
+ serverId: string;
2088
+ userId: string;
2089
+ }];
2090
+ serverBanAdd: [member: Member | {
2091
+ serverId: string;
2092
+ userId: string;
2093
+ }];
2094
+ serverMemberKick: [member: Member | {
2095
+ serverId: string;
2096
+ userId: string;
2097
+ }];
1872
2098
  }
1873
2099
  interface ClientOptions {
1874
2100
  sweepers?: SweeperOptions;
@@ -1903,7 +2129,7 @@ declare class Client extends EventEmitter {
1903
2129
  * A fallback class for channel types that are not yet officially supported by the library.
1904
2130
  */
1905
2131
  declare class UnknownChannel extends BaseChannel {
1906
- constructor(client: Client, data: any);
2132
+ constructor(client: Client, data: Channel);
1907
2133
  }
1908
2134
 
1909
- export { Attachment, type AttachmentMetadata, Base, BaseChannel, type BotInformation, type Categories, type ChannelCreateOptions, type ChannelEditOptions, ChannelManager, type ChannelResolvable, type ChannelRolePermissionOptions, ChannelType, Client, type ClientEvents, type ClientOptions, ClientUser, Collection, Collector, type CollectorOptions, DMChannel, EmbedBuilder, Emoji, EmojiManager, type EmojiParent, type FetchMembersOptions, GatewayManager, type Interaction, type Masquerade, Member, type MemberBanOptions, type MemberEditOptions, MemberManager, type MemberResolvable, Message, MessageCollector, type MessageCollectorOptions, type MessageFetchOptions, MessageManager, type MessageOptions, MessageReaction, type MessageResolvable, PermissionFlags, type PermissionResolvable, type PermissionString, Permissions, RESTManager, ReactionCollector, type ReactionCollectorOptions, type ReplyIntent, Role, type RoleCreateOptions, type RoleEditOptions, RoleManager, type RolePermissionOptions, type RoleResolvable, Server, ServerChannelManager, type ServerEditOptions, ServerManager, StoatAPIError, SweeperManager, type SweeperOptions, TextChannel, type TextEmbedData, UnknownChannel, User, type UserEditOptions, UserManager, UserPresence, type UserProfile, UserRelationship, type UserResolvable, type UserStatus };
2135
+ export { Attachment, AttachmentBuilder, type AttachmentMetadata, Base, BaseChannel, BitField, type BitFieldResolvable, type BotInformation, type CDNTag, type ChannelCreateOptions, type ChannelEditOptions, ChannelManager, type ChannelResolvable, type ChannelRolePermissionOptions, type ChannelType, Client, type ClientEvents, type ClientOptions, ClientUser, Collection, Collector, type CollectorOptions, DMChannel, EmbedBuilder, Emoji, EmojiManager, type EmojiParent, type FetchMembersOptions, GatewayManager, type Interaction, type Masquerade, Member, type MemberBanOptions, type MemberEditOptions, MemberManager, type MemberResolvable, Message, MessageCollector, type MessageCollectorOptions, type MessageFetchOptions, MessageManager, type MessageOptions, MessageReaction, type MessageResolvable, PermissionFlags, type PermissionResolvable, type PermissionString, Permissions, RESTManager, type RawDMChannel, type RawTextChannel, ReactionCollector, type ReactionCollectorOptions, type ReplyIntent, Role, type RoleCreateOptions, type RoleEditOptions, RoleManager, type RolePermissionOptions, type RoleResolvable, Server, ServerChannelManager, type ServerEditOptions, ServerManager, StoatAPIError, SweeperManager, type SweeperOptions, TextChannel, type TextEmbedData, UnknownChannel, User, type UserEditOptions, UserManager, type UserPresence, type UserProfile, type UserRelationShip, type UserResolvable, type UserStatus };