lunibee 0.3.1 → 0.3.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.
Files changed (79) hide show
  1. package/dist/builders/attachment.d.ts +1 -0
  2. package/dist/builders/clone.d.ts +10 -0
  3. package/dist/builders/commands.d.ts +1 -1
  4. package/dist/builders/components.d.ts +24 -5
  5. package/dist/builders/index.js +64 -17
  6. package/dist/builders/index.js.map +10 -9
  7. package/dist/collection/index.d.ts +1 -0
  8. package/dist/collection/index.js +297 -19
  9. package/dist/collection/index.js.map +5 -4
  10. package/dist/collection/redis.d.ts +98 -0
  11. package/dist/core/collector.d.ts +8 -0
  12. package/dist/core/events.d.ts +1 -0
  13. package/dist/core/index.d.ts +3 -0
  14. package/dist/core/index.js +6213 -4716
  15. package/dist/core/index.js.map +46 -39
  16. package/dist/core/permissions.d.ts +3 -402
  17. package/dist/core/redis-cache.d.ts +85 -0
  18. package/dist/formatters/index.d.ts +5 -1
  19. package/dist/formatters/index.js +7 -3
  20. package/dist/formatters/index.js.map +3 -3
  21. package/dist/handlers/index.js +11 -2
  22. package/dist/handlers/index.js.map +3 -3
  23. package/dist/index.js +8272 -6085
  24. package/dist/index.js.map +64 -58
  25. package/dist/managers/application.d.ts +10 -6
  26. package/dist/managers/base.d.ts +4 -1
  27. package/dist/managers/guild.d.ts +3 -1
  28. package/dist/managers/index.d.ts +6 -1
  29. package/dist/managers/index.js +365 -103
  30. package/dist/managers/index.js.map +19 -22
  31. package/dist/managers/member.d.ts +3 -1
  32. package/dist/managers/message.d.ts +13 -4
  33. package/dist/managers/thread.d.ts +3 -3
  34. package/dist/rest/decoder.d.ts +2 -0
  35. package/dist/rest/errors.d.ts +5 -2
  36. package/dist/rest/headers.d.ts +31 -0
  37. package/dist/rest/identity.d.ts +31 -0
  38. package/dist/rest/index.d.ts +97 -6
  39. package/dist/rest/index.js +1350 -220
  40. package/dist/rest/index.js.map +16 -13
  41. package/dist/rest/limiter.d.ts +75 -10
  42. package/dist/rest/redis.d.ts +103 -22
  43. package/dist/rest/scheduler.d.ts +13 -0
  44. package/dist/rest/store.d.ts +135 -12
  45. package/dist/rest/telemetry.d.ts +151 -0
  46. package/dist/rest/webhook.d.ts +18 -6
  47. package/dist/sharding/bus.d.ts +4 -2
  48. package/dist/sharding/cluster.d.ts +1 -1
  49. package/dist/sharding/health.d.ts +1 -1
  50. package/dist/sharding/host.d.ts +6 -0
  51. package/dist/sharding/identify.d.ts +2 -0
  52. package/dist/sharding/index.d.ts +6 -0
  53. package/dist/sharding/index.js +205 -39
  54. package/dist/sharding/index.js.map +14 -14
  55. package/dist/sharding/remote.d.ts +18 -2
  56. package/dist/sharding/supervisor.d.ts +1 -1
  57. package/dist/sharding/transport.d.ts +6 -5
  58. package/dist/sharding/worker.d.ts +11 -1
  59. package/dist/structures/base.d.ts +16 -5
  60. package/dist/structures/index.d.ts +1 -1
  61. package/dist/structures/index.js +57 -91
  62. package/dist/structures/index.js.map +10 -18
  63. package/dist/structures/options.d.ts +3 -2
  64. package/dist/structures/permissions.d.ts +409 -0
  65. package/dist/structures/resources.d.ts +4 -1
  66. package/dist/types/gateway.d.ts +4 -0
  67. package/dist/types/index.d.ts +14 -4
  68. package/dist/types/index.js.map +3 -3
  69. package/dist/utils/args.d.ts +3 -1
  70. package/dist/utils/index.d.ts +6 -1
  71. package/dist/utils/index.js +17 -10
  72. package/dist/utils/index.js.map +4 -4
  73. package/dist/voice/index.d.ts +7 -1
  74. package/dist/voice/index.js +33 -10
  75. package/dist/voice/index.js.map +3 -3
  76. package/dist/ws/index.d.ts +2 -0
  77. package/dist/ws/index.js +32 -4
  78. package/dist/ws/index.js.map +5 -5
  79. package/package.json +19 -16
@@ -1,5 +1,9 @@
1
1
  import { REST } from "@lunibee/rest";
2
2
  import type { APIApplicationCommand, ApplicationCommandData } from "@lunibee/types";
3
+ /** Command data, or a builder such as `CreateSlashCommand` (its `toJSON()` is sent). */
4
+ export type ApplicationCommandInput = ApplicationCommandData | {
5
+ toJSON(): Record<string, unknown>;
6
+ };
3
7
  /** Manages global and guild-scoped application commands for a Discord application. */
4
8
  export declare class ApplicationCommandManager {
5
9
  #private;
@@ -8,21 +12,21 @@ export declare class ApplicationCommandManager {
8
12
  /** Fetches all global application commands. @returns Array of registered commands. */
9
13
  fetch(): Promise<APIApplicationCommand[]>;
10
14
  /** Creates a single global application command. @param data Command data. @returns Created command. */
11
- create(data: ApplicationCommandData): Promise<APIApplicationCommand>;
15
+ create(data: ApplicationCommandInput): Promise<APIApplicationCommand>;
12
16
  /** Overwrites all global application commands atomically. @param commands Array of command data. @returns New full command list. */
13
- set(commands: ApplicationCommandData[]): Promise<APIApplicationCommand[]>;
17
+ set(commands: readonly ApplicationCommandInput[]): Promise<APIApplicationCommand[]>;
14
18
  /** Edits a global application command. @param commandId Command identifier. @param data Partial command data. @returns Updated command. */
15
- edit(commandId: string, data: Partial<ApplicationCommandData>): Promise<APIApplicationCommand>;
19
+ edit(commandId: string, data: Partial<ApplicationCommandData> | ApplicationCommandInput): Promise<APIApplicationCommand>;
16
20
  /** Deletes a global application command. @param commandId Command identifier. @returns Nothing. */
17
21
  delete(commandId: string): Promise<void>;
18
22
  /** Fetches all guild-scoped application commands. @param guildId Guild identifier. @returns Array of registered guild commands. */
19
23
  fetchGuild(guildId: string): Promise<APIApplicationCommand[]>;
20
24
  /** Creates a single guild-scoped application command. @param guildId Guild identifier. @param data Command data. @returns Created command. */
21
- createGuild(guildId: string, data: ApplicationCommandData): Promise<APIApplicationCommand>;
25
+ createGuild(guildId: string, data: ApplicationCommandInput): Promise<APIApplicationCommand>;
22
26
  /** Overwrites all guild-scoped application commands atomically. @param guildId Guild identifier. @param commands Array of command data. @returns New full command list. */
23
- setGuild(guildId: string, commands: ApplicationCommandData[]): Promise<APIApplicationCommand[]>;
27
+ setGuild(guildId: string, commands: readonly ApplicationCommandInput[]): Promise<APIApplicationCommand[]>;
24
28
  /** Edits a guild-scoped application command. @param guildId Guild identifier. @param commandId Command identifier. @param data Partial command data. @returns Updated command. */
25
- editGuild(guildId: string, commandId: string, data: Partial<ApplicationCommandData>): Promise<APIApplicationCommand>;
29
+ editGuild(guildId: string, commandId: string, data: Partial<ApplicationCommandData> | ApplicationCommandInput): Promise<APIApplicationCommand>;
26
30
  /** Deletes a guild-scoped application command. @param guildId Guild identifier. @param commandId Command identifier. @returns Nothing. */
27
31
  deleteGuild(guildId: string, commandId: string): Promise<void>;
28
32
  }
@@ -8,6 +8,8 @@ export declare class Manager<K, V> {
8
8
  #private;
9
9
  /** Authoritative resource state. Entries never expire: see {@link Manager.set}. */
10
10
  readonly cache: Collection<K, V>;
11
+ /** @param maxSize Most entries kept; the least recently used go first. Default: unbounded. */
12
+ constructor(maxSize?: number);
11
13
  /** Gets a cached value. @param id Cache key. @returns Cached value. */
12
14
  get(id: K): V | undefined;
13
15
  /** Checks whether a value is cached. @param id Cache key. @returns True when cached. */
@@ -41,8 +43,9 @@ export declare class Manager<K, V> {
41
43
  /** Generic REST-backed resource manager. @typeParam K Resource key type. @typeParam V Resource type. */
42
44
  export declare class ResourceManager<K, V> extends Manager<K, V> {
43
45
  #private;
44
- constructor(fetcher: (id: K) => Promise<V>, key: (value: V) => K);
46
+ constructor(fetcher: (id: K) => Promise<V>, key: (value: V) => K, maxSize?: number);
45
47
  resolve(id: K): Promise<V>;
48
+ /** Fetches from Discord; a cached instance is updated in place, so references to it stay current. */
46
49
  fetch(id: K): Promise<V>;
47
50
  fetchMany(ids: Iterable<K>): Promise<V[]>;
48
51
  /** Stores a resource, merging into the cached instance when there is one so existing references stay current. @returns The canonical instance. */
@@ -19,7 +19,9 @@ export declare class GuildManager extends ResourceManager<string, Guild> {
19
19
  #private;
20
20
  /** Lets members from this manager act through a client (`member.kick()`...). Called by the client. */
21
21
  attachContext(context: ResourceContext): void;
22
- constructor(rest: REST);
22
+ constructor(rest: REST, options?: {
23
+ maxMembers?: number;
24
+ });
23
25
  /** Ban manager for a guild (one instance per guild). */
24
26
  bans(guildId: string): GuildBanManager;
25
27
  /** Scheduled-event manager for a guild (one instance per guild). */
@@ -12,20 +12,24 @@ export { GuildManager } from "./guild.js";
12
12
  export type { AuditLogEntry, AuditLogResponse } from "./guild.js";
13
13
  export { AuditLogEvent } from "./guild.js";
14
14
  export type { MessageCreateOptions, MessageEditOptions } from "./message.js";
15
+ /** Options for fetching one message; `cache: false` skips storing it. */
15
16
  export interface MessageFetchOptions {
16
17
  cache?: boolean;
17
18
  }
19
+ /** Pagination for fetching a channel's messages: `before`, `after` or `around` an ID, and a `limit`. */
18
20
  export interface MessageQueryOptions {
19
21
  before?: string;
20
22
  after?: string;
21
23
  around?: string;
22
24
  limit?: number;
23
25
  }
26
+ /** Options for starting a thread from a message. */
24
27
  export interface MessageThreadOptions {
25
28
  name: string;
26
29
  autoArchiveDuration?: 60 | 1440 | 4320 | 10080;
27
30
  rateLimitPerUser?: number;
28
31
  }
32
+ /** Pagination for listing the users who reacted with an emoji. */
29
33
  export interface ReactionFetchOptions {
30
34
  limit?: number;
31
35
  after?: string;
@@ -159,12 +163,13 @@ export declare class ChannelManager extends Manager<string, Channel> {
159
163
  }>;
160
164
  clear(): void;
161
165
  }
166
+ /** Discord.js-familiar name for `MessageCreateOptions`. */
162
167
  export type CreateMessageOptions = MessageCreateOptions;
163
168
  export { MessageManager, toRequest, type MessageCacheOptions, type MessageFile, } from "./message.js";
164
169
  export { ThreadManager } from "./thread.js";
165
170
  export { RoleManager, type RoleCreateOptions, type RoleEditOptions, } from "./role.js";
166
171
  export { GuildMemberManager, type MemberEditOptions, type BanOptions, } from "./member.js";
167
- export { ApplicationCommandManager } from "./application.js";
172
+ export { ApplicationCommandManager, type ApplicationCommandInput, } from "./application.js";
168
173
  export { GuildBanManager, GuildScheduledEventManager, StageInstanceManager, PermissionOverwriteManager, type APIBan, type GuildBanCreateOptions, type GuildScheduledEventOptions, type StageInstanceCreateOptions, type PermissionOverwriteOptions, type PermissionOverwriteTargetType, type PermissionOverwriteUpdate, } from "./guild-resources.js";
169
174
  export { EmojiManager, type EmojiCreateOptions, type EmojiEditOptions, } from "./emoji.js";
170
175
  export { GuildStickerManager, GuildSoundboardManager, MonetizationManager, ApplicationEmojiManager, type APIEntitlement, type APISKU, type APISoundboardSound, type APISubscription, type EntitlementQuery, type GuildStickerCreateOptions, type SoundboardSoundCreateOptions, } from "./advanced.js";