lunibee 0.2.3 → 0.3.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 (86) hide show
  1. package/README.md +3 -3
  2. package/dist/builders/attachment.d.ts +8 -4
  3. package/dist/builders/commands.d.ts +122 -149
  4. package/dist/builders/components.d.ts +10 -150
  5. package/dist/builders/embed.d.ts +66 -37
  6. package/dist/builders/index.d.ts +0 -4
  7. package/dist/builders/index.js +112 -221
  8. package/dist/builders/index.js.map +10 -9
  9. package/dist/collection/cache.d.ts +15 -6
  10. package/dist/collection/index.d.ts +92 -17
  11. package/dist/collection/index.js +471 -279
  12. package/dist/collection/index.js.map +4 -4
  13. package/dist/core/api.d.ts +130 -0
  14. package/dist/core/channel-create.d.ts +72 -0
  15. package/dist/core/commands.d.ts +232 -0
  16. package/dist/core/events.d.ts +24 -7
  17. package/dist/core/handles.d.ts +157 -0
  18. package/dist/core/index.d.ts +68 -4
  19. package/dist/core/index.js +2639 -493
  20. package/dist/core/index.js.map +47 -37
  21. package/dist/core/permissions.d.ts +7 -7
  22. package/dist/formatters/index.js +9 -5
  23. package/dist/formatters/index.js.map +3 -3
  24. package/dist/handlers/index.js +5 -10
  25. package/dist/handlers/index.js.map +3 -3
  26. package/dist/index.d.ts +2 -2
  27. package/dist/index.js +9527 -7809
  28. package/dist/index.js.map +63 -53
  29. package/dist/managers/advanced.d.ts +29 -1
  30. package/dist/managers/base.d.ts +22 -14
  31. package/dist/managers/emoji.d.ts +0 -2
  32. package/dist/managers/guild-resources.d.ts +13 -5
  33. package/dist/managers/guild.d.ts +40 -4
  34. package/dist/managers/index.d.ts +21 -13
  35. package/dist/managers/index.js +969 -386
  36. package/dist/managers/index.js.map +30 -25
  37. package/dist/managers/member.d.ts +9 -2
  38. package/dist/managers/message.d.ts +10 -15
  39. package/dist/managers/role.d.ts +18 -10
  40. package/dist/managers/thread.d.ts +68 -0
  41. package/dist/managers/user.d.ts +18 -0
  42. package/dist/rest/errors.d.ts +14 -7
  43. package/dist/rest/index.d.ts +24 -12
  44. package/dist/rest/index.js +70 -20
  45. package/dist/rest/index.js.map +9 -9
  46. package/dist/rest/redis.d.ts +1 -1
  47. package/dist/rest/route.d.ts +8 -4
  48. package/dist/rest/routes.d.ts +122 -48
  49. package/dist/rest/transport.d.ts +10 -5
  50. package/dist/rest/webhook.d.ts +9 -5
  51. package/dist/sharding/bus.d.ts +47 -19
  52. package/dist/sharding/cluster.d.ts +11 -0
  53. package/dist/sharding/gateway-bot.d.ts +18 -0
  54. package/dist/sharding/index.d.ts +64 -25
  55. package/dist/sharding/index.js +439 -124
  56. package/dist/sharding/index.js.map +19 -14
  57. package/dist/sharding/supervisor.d.ts +32 -0
  58. package/dist/sharding/transport.d.ts +45 -0
  59. package/dist/structures/audit-log.d.ts +99 -2
  60. package/dist/structures/base.d.ts +40 -23
  61. package/dist/structures/channels.d.ts +45 -14
  62. package/dist/structures/index.d.ts +8 -12
  63. package/dist/structures/index.js +280 -132
  64. package/dist/structures/index.js.map +21 -15
  65. package/dist/structures/interactions.d.ts +91 -63
  66. package/dist/structures/resources.d.ts +99 -52
  67. package/dist/structures/sticker.d.ts +33 -0
  68. package/dist/types/channel-kind.d.ts +26 -0
  69. package/dist/types/gateway.d.ts +24 -12
  70. package/dist/types/index.d.ts +115 -113
  71. package/dist/types/index.js +53 -48
  72. package/dist/types/index.js.map +6 -5
  73. package/dist/voice/index.d.ts +12 -4
  74. package/dist/voice/index.js +14 -18
  75. package/dist/voice/index.js.map +3 -3
  76. package/dist/ws/decoder.d.ts +6 -2
  77. package/dist/ws/dispatcher.d.ts +19 -0
  78. package/dist/ws/index.d.ts +61 -15
  79. package/dist/ws/index.js +194 -77
  80. package/dist/ws/index.js.map +13 -11
  81. package/dist/ws/protocol.d.ts +10 -2
  82. package/dist/ws/reconnect.d.ts +10 -0
  83. package/dist/ws/send-budget.d.ts +6 -2
  84. package/dist/ws/session.d.ts +14 -4
  85. package/dist/ws/state.d.ts +22 -11
  86. package/package.json +20 -16
@@ -0,0 +1,32 @@
1
+ /** How a crashed cluster is restarted. The defaults restart every crash after a fixed delay. */
2
+ export interface SupervisorOptions {
3
+ /** Delay before the first restart, in milliseconds (default 5000). */
4
+ restartDelay?: number;
5
+ /** Each further crash in the window multiplies the delay by this (default 1: a fixed delay). */
6
+ backoff?: number;
7
+ /** The longest delay (default 5 minutes). */
8
+ maxDelay?: number;
9
+ /** Random spread added to each delay, as a fraction of it (0-1, default 0). */
10
+ jitter?: number;
11
+ /** Give up after this many restarts inside `window` (default unlimited). */
12
+ maxRestarts?: number;
13
+ /** The time over which restarts are counted, and after which a stable cluster is forgiven (default 60,000). */
14
+ window?: number;
15
+ }
16
+ /**
17
+ * Decides when, and whether, a crashed cluster comes back. It only does
18
+ * arithmetic on timestamps (pass `now` in tests), so `ClusterManager` stays in
19
+ * charge of forking.
20
+ */
21
+ export declare class ShardSupervisor {
22
+ #private;
23
+ constructor(options?: SupervisorOptions, random?: () => number);
24
+ /**
25
+ * A cluster exited. @returns How many milliseconds to wait before
26
+ * restarting it, or `null` to give up because it crashed more than
27
+ * `maxRestarts` times inside `window`.
28
+ */
29
+ next(id: number, now?: number): number | null;
30
+ /** Forgets a cluster's crashes, e.g. after a deliberate respawn. */
31
+ reset(id?: number): void;
32
+ }
@@ -0,0 +1,45 @@
1
+ import type { ShardMessage } from "./bus.js";
2
+ /** Carries {@link ShardMessage}s between the processes or threads that run shards. */
3
+ export interface ShardBusTransport {
4
+ /** Sends a message to the other shards. Delivery to the sender itself is not required. */
5
+ post(message: ShardMessage): void;
6
+ /** Listens for messages from other shards. */
7
+ onMessage(listener: (message: ShardMessage) => void): void;
8
+ /** Listens for the shards of a cluster that died, so pending requests to them can fail early. */
9
+ onPeerDown?(listener: (shardIds: readonly number[]) => void): void;
10
+ /** Stops listening and releases the channel. */
11
+ close(): void;
12
+ }
13
+ /** One process: shards in the same process (or worker threads of it) talk over a `BroadcastChannel`. */
14
+ export declare class BroadcastChannelTransport implements ShardBusTransport {
15
+ #private;
16
+ constructor(name: string);
17
+ post(message: ShardMessage): void;
18
+ onMessage(listener: (message: ShardMessage) => void): void;
19
+ close(): void;
20
+ }
21
+ /** Marks a bus message on the IPC channel, so it cannot be confused with the bot's own `process.send()` traffic. */
22
+ export declare const BUS_FRAME = "__lunibeeBus";
23
+ /** Marks the parent's notice that a cluster's shards are gone. */
24
+ export declare const PEER_DOWN_FRAME = "__lunibeePeerDown";
25
+ /** The part of `process` (or a child process handle) the IPC transport uses. */
26
+ export interface IpcEndpoint {
27
+ send?(message: unknown): unknown;
28
+ on(event: "message", listener: (message: unknown) => void): unknown;
29
+ off(event: "message", listener: (message: unknown) => void): unknown;
30
+ }
31
+ /**
32
+ * Forked clusters: a worker `send()`s to its parent, and the parent
33
+ * ({@link ClusterManager}) relays to every other worker. Selected
34
+ * automatically in a worker forked by `ClusterManager`.
35
+ */
36
+ export declare class IpcTransport implements ShardBusTransport {
37
+ #private;
38
+ constructor(endpoint?: IpcEndpoint);
39
+ post(message: ShardMessage): void;
40
+ onMessage(listener: (message: ShardMessage) => void): void;
41
+ onPeerDown(listener: (shardIds: readonly number[]) => void): void;
42
+ close(): void;
43
+ }
44
+ /** Picks the transport for a bus: IPC inside a forked cluster, `BroadcastChannel` otherwise. */
45
+ export declare function defaultTransport(name: string): ShardBusTransport;
@@ -1,21 +1,114 @@
1
1
  import { BaseStructure } from "./base.js";
2
2
  import type { APIAuditLog, APIAuditLogEntry, APIAuditLogChange, APIAuditLogOptions } from "@lunibee/types";
3
+ /** What `info` holds for each action type that carries extra details (numbers are parsed from Discord's strings). */
4
+ export interface AuditLogInfoByType {
5
+ /** Overwrite created, updated or deleted: a role (`type` 0) or a member (`type` 1). */
6
+ 13: AuditLogOverwriteInfo;
7
+ 14: AuditLogOverwriteInfo;
8
+ 15: AuditLogOverwriteInfo;
9
+ /** Member prune. */
10
+ 21: {
11
+ deleteMemberDays: number;
12
+ membersRemoved: number;
13
+ };
14
+ /** Members moved between voice channels. */
15
+ 26: {
16
+ channelId: string;
17
+ count: number;
18
+ };
19
+ /** Members disconnected from voice. */
20
+ 27: {
21
+ count: number;
22
+ };
23
+ /** Message deleted in a channel. */
24
+ 72: {
25
+ channelId: string;
26
+ count: number;
27
+ };
28
+ /** Messages bulk deleted. */
29
+ 73: {
30
+ count: number;
31
+ };
32
+ /** Message pinned or unpinned. */
33
+ 74: {
34
+ channelId: string;
35
+ messageId: string;
36
+ };
37
+ 75: {
38
+ channelId: string;
39
+ messageId: string;
40
+ };
41
+ /** Stage instance created, updated or deleted. */
42
+ 83: {
43
+ channelId: string;
44
+ };
45
+ 84: {
46
+ channelId: string;
47
+ };
48
+ 85: {
49
+ channelId: string;
50
+ };
51
+ /** Application command permissions updated. */
52
+ 121: {
53
+ applicationId: string;
54
+ };
55
+ /** AutoMod blocked a message, flagged it, or timed a member out. */
56
+ 143: AuditLogAutoModInfo;
57
+ 144: AuditLogAutoModInfo;
58
+ 145: AuditLogAutoModInfo;
59
+ }
60
+ /** The overwrite an audit entry is about. */
61
+ export interface AuditLogOverwriteInfo {
62
+ /** The role or user the overwrite is for. */
63
+ id: string;
64
+ /** 0 role, 1 member. */
65
+ type: number;
66
+ roleName?: string;
67
+ }
68
+ /** The rule behind an AutoMod audit entry. */
69
+ export interface AuditLogAutoModInfo {
70
+ ruleName: string;
71
+ ruleTriggerType: number;
72
+ channelId?: string;
73
+ }
74
+ /** The details object of an action type, or `undefined` when the type has none. */
75
+ export type AuditLogInfo<T extends number> = number extends T ? AuditLogInfoByType[keyof AuditLogInfoByType] | undefined : T extends keyof AuditLogInfoByType ? AuditLogInfoByType[T] : undefined;
3
76
  /** Represents a single entry in a Discord audit log. */
4
- export declare class AuditLogEntry extends BaseStructure {
77
+ export declare class AuditLogEntry<T extends number = number> extends BaseStructure {
5
78
  /** The ID of the affected entity. */
6
79
  readonly targetId: string | null;
7
80
  /** The ID of the user who made the changes. */
8
81
  readonly userId: string | null;
9
82
  /** The action type of this entry. */
10
- readonly actionType: number;
83
+ readonly actionType: T;
11
84
  /** The changes made to the target. */
12
85
  readonly changes: APIAuditLogChange[];
13
86
  /** Additional info for certain action types. */
14
87
  readonly options: APIAuditLogOptions | null;
88
+ /** The action's details with numbers parsed, typed by action type (`undefined` for types that have none). `options` is Discord's raw object. */
89
+ readonly info: AuditLogInfo<T>;
15
90
  /** The reason for the change, if any. */
16
91
  readonly reason: string | null;
17
92
  /** Creates an audit log entry. */
18
93
  constructor(data: APIAuditLogEntry);
94
+ /** Narrows the entry to one action type, so `info` is typed for it. */
95
+ is<K extends number>(type: K): this is AuditLogEntry<K>;
96
+ /** One change by its key (`"nick"`, `"permissions"`...), or `undefined`. */
97
+ change(key: string): {
98
+ old: unknown;
99
+ new: unknown;
100
+ } | undefined;
101
+ }
102
+ /** Which entries {@link AuditLog.find} and {@link AuditLog.filter} keep. Every field given must match. */
103
+ export interface AuditLogQuery<T extends number = number> {
104
+ /** One action type, or any of several. */
105
+ type?: T | readonly T[];
106
+ /** The affected entity. */
107
+ targetId?: string;
108
+ /** Who did it. */
109
+ userId?: string;
110
+ /** Only entries created at or after this time (a Date, an ISO string or milliseconds). */
111
+ since?: Date | string | number;
19
112
  }
20
113
  /** Represents a Discord audit log. */
21
114
  export declare class AuditLog {
@@ -23,4 +116,8 @@ export declare class AuditLog {
23
116
  readonly entries: Map<string, AuditLogEntry>;
24
117
  /** Creates an audit log. */
25
118
  constructor(data: APIAuditLog);
119
+ /** The entries that match `query`, newest first (the order Discord returns them in). */
120
+ filter<T extends number = number>(query: AuditLogQuery<T>): AuditLogEntry<T>[];
121
+ /** The newest entry that matches `query`, or `undefined`. */
122
+ find<T extends number = number>(query: AuditLogQuery<T>): AuditLogEntry<T> | undefined;
26
123
  }
@@ -1,19 +1,19 @@
1
+ import { type ChannelKind, type MessageCreateOptions, type MessageEditOptions, type UnknownChannelKind } from "@lunibee/types";
2
+ import type { ChannelOfKind } from "./channels.js";
1
3
  /** Common Discord snowflake-backed structure. */
2
4
  export declare class BaseStructure {
3
5
  readonly id: string;
4
6
  constructor(id: string);
5
7
  /** Returns the snowflake ID as a string. */
6
8
  toString(): string;
9
+ /** Milliseconds since the Unix epoch at which this snowflake was created. */
10
+ get createdTimestamp(): number;
7
11
  /** Returns the timestamp this snowflake was created at. */
8
12
  get createdAt(): Date;
9
13
  }
10
14
  export interface ResourceContext {
11
- sendMessage(channelId: string, options: Record<string, unknown> & {
12
- content?: string;
13
- }): Promise<import("./index.js").Message>;
14
- editMessage(channelId: string, messageId: string, options: Record<string, unknown> & {
15
- content?: string;
16
- }): Promise<import("./index.js").Message>;
15
+ sendMessage(channelId: string, options: MessageCreateOptions): Promise<import("./index.js").Message>;
16
+ editMessage(channelId: string, messageId: string, options: MessageEditOptions): Promise<import("./index.js").Message>;
17
17
  deleteMessage(channelId: string, messageId: string, reason?: string): Promise<void>;
18
18
  crosspostMessage(channelId: string, messageId: string): Promise<import("./index.js").Message>;
19
19
  editChannel?(channelId: string, options: Record<string, unknown>): Promise<import("./base.js").Channel>;
@@ -29,7 +29,7 @@ export interface ResourceContext {
29
29
  * (with overwrites) when a channel ID is given. Null when the guild (or
30
30
  * channel) is not cached.
31
31
  */
32
- memberPermissions?(guildId: string, memberId: string, roleIds: readonly string[], channelId?: string): import("@lunibee/core").PermissionSet | null;
32
+ memberPermissions?(guildId: string, memberId: string, roleIds: readonly string[], channelId?: string, timedOutUntil?: Date | null): import("@lunibee/core").PermissionSet | null;
33
33
  kickMember?(guildId: string, userId: string, reason?: string): Promise<void>;
34
34
  banMember?(guildId: string, userId: string, options?: {
35
35
  reason?: string;
@@ -97,13 +97,7 @@ export declare class Channel extends BaseStructure {
97
97
  /** Creates a channel structure from Discord channel data. */
98
98
  constructor(data: import("@lunibee/types").APIChannel, context?: ResourceContext);
99
99
  /** Sends a message to this channel. @param options Message payload. @returns The created message. @throws {Error} If the channel is not attached to a client. */
100
- send(options: Record<string, unknown> & {
101
- content?: string;
102
- }): Promise<import("./index.js").Message>;
103
- /** @deprecated Use {@link Channel.send}. Removed in 0.3.0. */
104
- sendMessage(options: Record<string, unknown> & {
105
- content?: string;
106
- }): Promise<import("./index.js").Message>;
100
+ send(options: MessageCreateOptions): Promise<import("./index.js").Message>;
107
101
  /** Edits this channel. @param options Channel fields to change. @returns The updated channel. @throws {Error} If the channel is not attached to a client. */
108
102
  edit(options: Record<string, unknown>): Promise<Channel>;
109
103
  /** Changes only this channel's name. @param name New channel name. @returns The updated channel. @throws {TypeError} If the name is empty. @throws {Error} If the channel is not attached to a client. */
@@ -127,6 +121,18 @@ export declare class Channel extends BaseStructure {
127
121
  delete(reason?: string): Promise<void>;
128
122
  /** Updates this channel using the same resource operation as edit. @param options Channel fields to change. @returns The updated channel. @throws {Error} If the channel is not attached to a client. */
129
123
  update(options: Record<string, unknown>): Promise<Channel>;
124
+ /** What kind of channel this is: `"text"`, `"voice"`, `"thread"`, `"forum"`… (`"unknown"` for a type this version does not know). */
125
+ get kind(): ChannelKind | UnknownChannelKind;
126
+ /**
127
+ * Whether this channel is one of `kinds`, narrowing its type to match.
128
+ * @example if (channel.is("text", "announcement")) await channel.send("hi");
129
+ */
130
+ is<K extends ChannelKind | UnknownChannelKind>(...kinds: K[]): this is ChannelOfKind<K>;
131
+ /**
132
+ * Returns this channel typed as one of `kinds`.
133
+ * @throws {TypeError} If it is a different kind.
134
+ */
135
+ as<K extends ChannelKind | UnknownChannelKind>(...kinds: K[]): ChannelOfKind<K>;
130
136
  /** Whether this is a thread (announcement, public or private). */
131
137
  isThread(): boolean;
132
138
  /** Whether messages can be sent in this channel (text, DM, announcement, voice, stage, threads). */
@@ -170,15 +176,26 @@ export declare class Guild extends BaseStructure {
170
176
  explicitContentFilter: number;
171
177
  /** Default notification level for new members. */
172
178
  defaultMessageNotifications: number;
173
- /** AFK voice channel, or null. */ afkChannelId: string | null;
174
- /** Seconds before a silent member is moved to the AFK channel. */ afkTimeout?: number;
175
- /** Whether the server widget is on. */ widgetEnabled: boolean;
176
- /** Channel the widget invites to, or null. */ widgetChannelId: string | null;
177
- /** Application that created the guild, if a bot did. */ applicationId: string | null;
178
- /** Channel for Discord's community updates, or null. */ publicUpdatesChannelId: string | null;
179
- /** Channel for safety alerts, or null. */ safetyAlertsChannelId: string | null;
180
- /** Maximum presences (null for the default limit). */ maxPresences: number | null;
181
- /** Maximum users in a video channel. */ maxVideoChannelUsers?: number;
179
+ /** AFK voice channel, or null. */
180
+ afkChannelId: string | null;
181
+ /** Seconds before a silent member is moved to the AFK channel. */
182
+ afkTimeout?: number;
183
+ /** Whether the server widget is on. */
184
+ widgetEnabled: boolean;
185
+ /** Channel the widget invites to, or null. */
186
+ widgetChannelId: string | null;
187
+ /** Application that created the guild, if a bot did. */
188
+ applicationId: string | null;
189
+ /** Channel for Discord's community updates, or null. */
190
+ publicUpdatesChannelId: string | null;
191
+ /** Channel for safety alerts, or null. */
192
+ safetyAlertsChannelId: string | null;
193
+ /** Maximum presences (null for the default limit). */
194
+ maxPresences: number | null;
195
+ /** Maximum users in a video channel. */
196
+ maxVideoChannelUsers?: number;
197
+ /** Whether the boost progress bar shows. */
198
+ premiumProgressBarEnabled: boolean;
182
199
  constructor(data: import("@lunibee/types").APIGuild);
183
200
  /** Returns the guild icon URL, or null if no icon is set. */
184
201
  iconURL(options?: ImageURLOptions): string | null;
@@ -6,16 +6,22 @@ export declare class NewsChannel extends TextChannel {
6
6
  }
7
7
  /** A direct-message or group DM channel. */
8
8
  export declare class DMChannel extends Channel {
9
- /** Users in the conversation. */ readonly recipients: User[];
10
- /** Owner of a group DM. */ readonly ownerId: string | null;
9
+ /** Users in the conversation. */
10
+ readonly recipients: User[];
11
+ /** Owner of a group DM. */
12
+ readonly ownerId: string | null;
11
13
  constructor(data: APIChannel, context?: ResourceContext);
12
14
  }
13
15
  /** A guild voice channel. */
14
16
  export declare class VoiceChannel extends Channel {
15
- /** Bitrate in bits per second. */ bitrate: number;
16
- /** User limit (0 = unlimited). */ userLimit: number;
17
- /** Voice region override, or null for automatic. */ rtcRegion: string | null;
18
- /** Camera video quality mode. */ videoQualityMode: number;
17
+ /** Bitrate in bits per second. */
18
+ bitrate: number;
19
+ /** User limit (0 = unlimited). */
20
+ userLimit: number;
21
+ /** Voice region override, or null for automatic. */
22
+ rtcRegion: string | null;
23
+ /** Camera video quality mode. */
24
+ videoQualityMode: number;
19
25
  constructor(data: APIChannel, context?: ResourceContext);
20
26
  }
21
27
  /** A guild stage channel. */
@@ -26,10 +32,14 @@ export declare class CategoryChannel extends Channel {
26
32
  }
27
33
  /** A thread (announcement, public or private). */
28
34
  export declare class ThreadChannel extends Channel {
29
- /** User who created the thread. */ readonly ownerId: string | null;
30
- /** Approximate message count. */ messageCount: number;
31
- /** Approximate member count (stops counting at 50). */ memberCount: number;
32
- /** Thread metadata. */ metadata: APIThreadMetadata | null;
35
+ /** User who created the thread. */
36
+ readonly ownerId: string | null;
37
+ /** Approximate message count. */
38
+ messageCount: number;
39
+ /** Approximate member count (stops counting at 50). */
40
+ memberCount: number;
41
+ /** Thread metadata. */
42
+ metadata: APIThreadMetadata | null;
33
43
  constructor(data: APIChannel, context?: ResourceContext);
34
44
  /** Whether the thread is archived. */
35
45
  get archived(): boolean;
@@ -40,10 +50,14 @@ export declare class ThreadChannel extends Channel {
40
50
  }
41
51
  /** A guild forum channel. */
42
52
  export declare class ForumChannel extends Channel {
43
- /** Tags that threads can apply. */ availableTags: APIForumTag[];
44
- /** Default reaction for new threads. */ defaultReactionEmoji: APIPartialEmoji | null;
45
- /** Default slowmode for new threads. */ defaultThreadRateLimitPerUser: number;
46
- /** Default auto-archive duration for new threads. */ defaultAutoArchiveDuration: number | null;
53
+ /** Tags that threads can apply. */
54
+ availableTags: APIForumTag[];
55
+ /** Default reaction for new threads. */
56
+ defaultReactionEmoji: APIPartialEmoji | null;
57
+ /** Default slowmode for new threads. */
58
+ defaultThreadRateLimitPerUser: number;
59
+ /** Default auto-archive duration for new threads. */
60
+ defaultAutoArchiveDuration: number | null;
47
61
  constructor(data: APIChannel, context?: ResourceContext);
48
62
  }
49
63
  /** A guild media channel. */
@@ -54,3 +68,20 @@ export declare class MediaChannel extends ForumChannel {
54
68
  * to {@link Channel} for types without a dedicated class.
55
69
  */
56
70
  export declare function createChannel(data: APIChannel, context?: ResourceContext): Channel;
71
+ /** The class of each channel kind, so `channel.is("voice")` can narrow to `VoiceChannel`. */
72
+ export interface ChannelsByKind {
73
+ text: TextChannel;
74
+ announcement: NewsChannel;
75
+ voice: VoiceChannel;
76
+ stage: StageChannel;
77
+ category: CategoryChannel;
78
+ thread: ThreadChannel;
79
+ forum: ForumChannel;
80
+ media: MediaChannel;
81
+ dm: DMChannel;
82
+ "group-dm": DMChannel;
83
+ directory: Channel;
84
+ unknown: Channel;
85
+ }
86
+ /** The channel class for a kind (or a union of them). */
87
+ export type ChannelOfKind<K extends keyof ChannelsByKind> = ChannelsByKind[K];
@@ -1,4 +1,5 @@
1
1
  /** Resource structures for Discord messages and related entities. */
2
+ import type { MessageCreateOptions, MessageEditOptions } from "@lunibee/types";
2
3
  import { BaseStructure, Channel, User } from "./base.js";
3
4
  import { GuildMember } from "./resources.js";
4
5
  import type { ComponentInteraction } from "./interactions.js";
@@ -54,19 +55,13 @@ export declare class Message extends BaseStructure {
54
55
  * snowflake-only `BaseStructure.createdAt` to honour the message `timestamp`. */
55
56
  get createdAt(): Date;
56
57
  /** Edits this message. @param options Message fields to change. @returns The updated message. @throws {Error} If the message is not attached to a client. */
57
- edit(options: Record<string, unknown> & {
58
- content?: string;
59
- }): Promise<Message>;
58
+ edit(options: MessageEditOptions): Promise<Message>;
60
59
  /** Updates this message using the same resource operation as edit. @param options Message fields to change. @returns The updated message. @throws {Error} If the message is not attached to a client. */
61
- update(options: Record<string, unknown> & {
62
- content?: string;
63
- }): Promise<Message>;
60
+ update(options: MessageEditOptions): Promise<Message>;
64
61
  /** Deletes this message. @param reason Audit-log reason (shown when deleting someone else's message). @returns A promise fulfilled when Discord confirms deletion. @throws {Error} If the message is not attached to a client. */
65
62
  delete(reason?: string): Promise<void>;
66
63
  /** Replies to this message. @param options Message content or payload. @returns The created reply message. @throws {Error} If the message is not attached to a client. */
67
- reply(options: string | (Record<string, unknown> & {
68
- content?: string;
69
- })): Promise<Message>;
64
+ reply(options: string | MessageCreateOptions): Promise<Message>;
70
65
  /** Crossposts this message. @returns The resulting message. @throws {Error} If the message is not attached to a client. */
71
66
  crosspost(): Promise<Message>;
72
67
  /**
@@ -115,9 +110,10 @@ export declare class Message extends BaseStructure {
115
110
  /** Returns a plain-object snapshot of all message fields. */
116
111
  toJSON(): Record<string, unknown>;
117
112
  }
118
- export { GuildMember, Role, TextChannel, Invite, Webhook, WebhookEnum, WebhookType, Emoji, AutoModerationRule, WelcomeScreenChannel, GuildWelcomeScreen, OnboardingPromptOption, OnboardingPrompt, GuildOnboarding, } from "./resources.js";
119
- export { NewsChannel, DMChannel, VoiceChannel, StageChannel, CategoryChannel, ThreadChannel, ForumChannel, MediaChannel, createChannel, } from "./channels.js";
113
+ export { GuildMember, Role, TextChannel, Invite, Webhook, WebhookEnum, Emoji, AutoModerationRule, WelcomeScreenChannel, GuildWelcomeScreen, OnboardingPromptOption, OnboardingPrompt, GuildOnboarding, } from "./resources.js";
114
+ export { NewsChannel, DMChannel, VoiceChannel, StageChannel, CategoryChannel, ThreadChannel, ForumChannel, MediaChannel, createChannel, type ChannelOfKind, type ChannelsByKind, } from "./channels.js";
120
115
  export * from "./interactions.js";
121
116
  export { Embed } from "./embed.js";
122
- export { AuditLog, AuditLogEntry } from "./audit-log.js";
117
+ export { AuditLog, AuditLogEntry, type AuditLogAutoModInfo, type AuditLogInfo, type AuditLogInfoByType, type AuditLogOverwriteInfo, type AuditLogQuery, } from "./audit-log.js";
118
+ export { Sticker, stickerURL } from "./sticker.js";
123
119
  export { PermissionsBitField } from "@lunibee/core";