lunibee 0.1.0 → 0.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.
Files changed (67) hide show
  1. package/README.md +229 -0
  2. package/dist/builders/attachment.d.ts +20 -0
  3. package/dist/builders/commands.d.ts +118 -0
  4. package/dist/builders/components.d.ts +151 -0
  5. package/dist/builders/embed.d.ts +59 -0
  6. package/dist/builders/index.d.ts +5 -0
  7. package/dist/builders/index.js +828 -0
  8. package/dist/builders/index.js.map +13 -0
  9. package/dist/collection/cache.d.ts +37 -0
  10. package/dist/collection/index.d.ts +47 -0
  11. package/dist/collection/index.js +214 -0
  12. package/dist/collection/index.js.map +11 -0
  13. package/dist/core/client-state.d.ts +10 -0
  14. package/dist/core/collector.d.ts +27 -0
  15. package/dist/core/events.d.ts +5 -0
  16. package/dist/core/index.d.ts +111 -0
  17. package/dist/core/index.js +3188 -0
  18. package/dist/core/index.js.map +29 -0
  19. package/dist/core/permissions.d.ts +293 -0
  20. package/dist/formatters/index.d.ts +10 -0
  21. package/dist/formatters/index.js +43 -0
  22. package/dist/formatters/index.js.map +10 -0
  23. package/dist/handlers/index.d.ts +16 -0
  24. package/dist/handlers/index.js +37 -0
  25. package/dist/handlers/index.js.map +10 -0
  26. package/{src/index.ts → dist/index.d.ts} +2 -29
  27. package/dist/index.js +4182 -0
  28. package/dist/index.js.map +41 -0
  29. package/dist/managers/application.d.ts +28 -0
  30. package/dist/managers/base.d.ts +28 -0
  31. package/dist/managers/index.d.ts +96 -0
  32. package/dist/managers/index.js +947 -0
  33. package/dist/managers/index.js.map +22 -0
  34. package/dist/managers/member.d.ts +35 -0
  35. package/dist/managers/message.d.ts +25 -0
  36. package/dist/managers/role.d.ts +34 -0
  37. package/dist/managers/thread.d.ts +14 -0
  38. package/dist/rest/index.d.ts +49 -0
  39. package/dist/rest/index.js +344 -0
  40. package/dist/rest/index.js.map +12 -0
  41. package/dist/rest/routes.d.ts +44 -0
  42. package/dist/rest/types.d.ts +26 -0
  43. package/dist/rest/webhook.d.ts +40 -0
  44. package/dist/sharding/bus.d.ts +22 -0
  45. package/dist/sharding/index.d.ts +34 -0
  46. package/dist/sharding/index.js +732 -0
  47. package/dist/sharding/index.js.map +13 -0
  48. package/dist/structures/base.d.ts +75 -0
  49. package/dist/structures/index.d.ts +39 -0
  50. package/dist/structures/index.js +571 -0
  51. package/dist/structures/index.js.map +14 -0
  52. package/dist/structures/interactions.d.ts +136 -0
  53. package/dist/structures/permissions.d.ts +73 -0
  54. package/dist/structures/resources.d.ts +64 -0
  55. package/dist/types/index.d.ts +535 -0
  56. package/dist/types/index.js +132 -0
  57. package/dist/types/index.js.map +10 -0
  58. package/dist/utils/index.d.ts +6 -0
  59. package/dist/utils/index.js +18 -0
  60. package/dist/utils/index.js.map +10 -0
  61. package/dist/voice/index.d.ts +97 -0
  62. package/dist/voice/index.js +161 -0
  63. package/dist/voice/index.js.map +10 -0
  64. package/dist/ws/index.d.ts +76 -0
  65. package/dist/ws/index.js +582 -0
  66. package/dist/ws/index.js.map +11 -0
  67. package/package.json +113 -28
@@ -0,0 +1,28 @@
1
+ import { REST } from "@lunibee/rest";
2
+ import type { APIApplicationCommand, ApplicationCommandData } from "@lunibee/types";
3
+ /** Manages global and guild-scoped application commands for a Discord application. */
4
+ export declare class ApplicationCommandManager {
5
+ #private;
6
+ /** Creates an application command manager. @param rest REST transport. @param applicationId Application identifier. */
7
+ constructor(rest: REST, applicationId: string);
8
+ /** Fetches all global application commands. @returns Array of registered commands. */
9
+ fetch(): Promise<APIApplicationCommand[]>;
10
+ /** Creates a single global application command. @param data Command data. @returns Created command. */
11
+ create(data: ApplicationCommandData): Promise<APIApplicationCommand>;
12
+ /** Overwrites all global application commands atomically. @param commands Array of command data. @returns New full command list. */
13
+ set(commands: ApplicationCommandData[]): Promise<APIApplicationCommand[]>;
14
+ /** 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>;
16
+ /** Deletes a global application command. @param commandId Command identifier. @returns Nothing. */
17
+ delete(commandId: string): Promise<void>;
18
+ /** Fetches all guild-scoped application commands. @param guildId Guild identifier. @returns Array of registered guild commands. */
19
+ fetchGuild(guildId: string): Promise<APIApplicationCommand[]>;
20
+ /** 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>;
22
+ /** 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[]>;
24
+ /** 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>;
26
+ /** Deletes a guild-scoped application command. @param guildId Guild identifier. @param commandId Command identifier. @returns Nothing. */
27
+ deleteGuild(guildId: string, commandId: string): Promise<void>;
28
+ }
@@ -0,0 +1,28 @@
1
+ import { Collection } from "@lunibee/collection";
2
+ /** Generic cache manager. @typeParam K Cache key type. @typeParam V Cached value type. */
3
+ export declare class Manager<K, V> {
4
+ /** Cached resources. */ readonly cache: Collection<K, V>;
5
+ /** Gets a cached value. @param id Cache key. @returns Cached value. */ get(id: K): V | undefined;
6
+ /** Checks whether a value is cached. @param id Cache key. @returns True when cached. */ has(id: K): boolean;
7
+ /** Stores a value. @param id Cache key. @param value Value. @returns This manager. */ set(id: K, value: V): this;
8
+ /** Deletes a cached value. @param id Cache key. @returns True when deleted. */ delete(id: K): boolean;
9
+ /** Clears the cache. @returns Nothing. */ clear(): void;
10
+ /** Gets cache size. @returns Number of cached values. */ get size(): number;
11
+ /** Gets the first cached value. @returns First value. */ first(): V | undefined;
12
+ /** Returns cached values. @returns Array of values. */ values(): V[];
13
+ /** Finds a cached value. @param predicate Predicate. @returns Matching value. */ find(predicate: (value: V, key: K) => boolean): V | undefined;
14
+ /** Iterates cached entries. @returns Cache iterator. */ [Symbol.iterator](): IterableIterator<[
15
+ K,
16
+ V
17
+ ]>;
18
+ }
19
+ /** Generic REST-backed resource manager. @typeParam K Resource key type. @typeParam V Resource type. */
20
+ export declare class ResourceManager<K, V> extends Manager<K, V> {
21
+ #private;
22
+ constructor(fetcher: (id: K) => Promise<V>, key: (value: V) => K);
23
+ resolve(id: K): Promise<V>;
24
+ fetch(id: K): Promise<V>;
25
+ fetchMany(ids: Iterable<K>): Promise<V[]>;
26
+ upsert(resource: V): V;
27
+ update(resource: V): V;
28
+ }
@@ -0,0 +1,96 @@
1
+ import { Manager, ResourceManager } from "./base.js";
2
+ export { Manager, ResourceManager } from "./base.js";
3
+ import { REST } from "@lunibee/rest";
4
+ import { Channel, Message, User, Guild } from "@lunibee/structures";
5
+ import { MessageManager } from "./message.js";
6
+ import { ThreadManager } from "./thread.js";
7
+ /** Manages users. */
8
+ export declare class UserManager extends ResourceManager<string, User> {
9
+ /** Creates a user manager. @param rest REST transport. */ constructor(rest: REST);
10
+ }
11
+ /** Manages guilds. */
12
+ export declare class GuildManager extends ResourceManager<string, Guild> {
13
+ /** Creates a guild manager. @param rest REST transport. */ constructor(rest: REST);
14
+ }
15
+ /** Message creation options. */
16
+ export interface MessageCreateOptions {
17
+ /** Message content. */ content?: string;
18
+ }
19
+ /** Message edit options. */
20
+ export interface MessageEditOptions {
21
+ /** New message content. */ content?: string;
22
+ }
23
+ /** Message fetch options. */
24
+ export interface MessageFetchOptions {
25
+ /** Whether to use cache. */ cache?: boolean;
26
+ }
27
+ /** Message list query options. */
28
+ export interface MessageQueryOptions {
29
+ /** Message before this ID. */ before?: string;
30
+ /** Message after this ID. */ after?: string;
31
+ /** Message around this ID. */ around?: string;
32
+ /** Maximum number of messages. */ limit?: number;
33
+ }
34
+ /** Message thread creation options. */
35
+ export interface MessageThreadOptions {
36
+ /** Thread name. */ name: string;
37
+ /** Auto archive duration. */ autoArchiveDuration?: 60 | 1440 | 4320 | 10080;
38
+ /** Slowmode duration. */ rateLimitPerUser?: number;
39
+ }
40
+ /** Reaction list options. */
41
+ export interface ReactionFetchOptions {
42
+ /** Maximum reactions. */ limit?: number;
43
+ /** Reaction pagination cursor. */ after?: string;
44
+ }
45
+ /** Runtime compatibility placeholders for legacy value imports. */
46
+ export declare const MessageCreateOptions: undefined;
47
+ /** Runtime compatibility placeholder. */
48
+ export declare const MessageEditOptions: undefined;
49
+ /** Runtime compatibility placeholder. */
50
+ export declare const MessageFetchOptions: undefined;
51
+ /** Runtime compatibility placeholder. */
52
+ export declare const MessageThreadOptions: undefined;
53
+ /** Runtime compatibility placeholder. */
54
+ export declare const ReactionFetchOptions: undefined;
55
+ /** Manages Discord channels and their message APIs. */
56
+ export declare class ChannelManager extends Manager<string, Channel> {
57
+ #private;
58
+ /** Creates a channel manager. @param rest REST transport. */
59
+ constructor(rest: REST);
60
+ /** Gets the canonical message manager for a channel. @param channelId Channel ID. @returns Message manager. */ messages(channelId: string): MessageManager;
61
+ /** Creates a thread manager. @param channelId Channel ID. @returns Thread manager. */ threads(channelId: string): ThreadManager;
62
+ /** Fetches a channel. @param channelId Channel ID. @returns Channel. */ fetch(channelId: string): Promise<Channel>;
63
+ /** Resolves a channel. @param channelId Channel ID. @returns Canonical channel. */ resolve(channelId: string): Promise<Channel>;
64
+ /** Inserts or updates a channel. @param data Channel payload. @returns Canonical channel. */ upsert(data: ConstructorParameters<typeof Channel>[0]): Channel;
65
+ /** Updates a channel. @param channel Channel. @returns This manager. */ update(channel: Channel): this;
66
+ /** Sends a message. @param channelId Channel ID. @param options Message options. @returns Created message. */ send(channelId: string, options: MessageCreateOptions): Promise<Message>;
67
+ /** Alias for send. @param channelId Channel ID. @param options Message options. @returns Created message. */ sendMessage(channelId: string, options: MessageCreateOptions): Promise<Message>;
68
+ /** Fetches one message. @param channelId Channel ID. @param messageId Message ID. @param options Fetch options. @returns Message. */ fetchMessage(channelId: string, messageId: string, options?: MessageFetchOptions): Promise<Message>;
69
+ /** Fetches messages by query or by iterable IDs. @param channelId Channel ID. @param query Query options or message IDs. @returns Messages. */ fetchMessages(channelId: string, query: MessageQueryOptions | Iterable<string>): Promise<Message[]>;
70
+ /** Inserts a message through the canonical cache path. @param data Message payload. @returns Canonical message. */ upsertMessage(data: ConstructorParameters<typeof Message>[0]): Message;
71
+ /** Edits a message. @param channelId Channel ID. @param messageId Message ID. @param options Edit options. @returns Updated message. */ editMessage(channelId: string, messageId: string, options: MessageEditOptions): Promise<Message>;
72
+ /** Deletes a message. @param channelId Channel ID. @param messageId Message ID. @returns Nothing. */ deleteMessage(channelId: string, messageId: string): Promise<void>;
73
+ /** Deletes a cached message. @param channelId Channel ID. @param messageId Message ID. @returns Whether removed. */ deleteCachedMessage(channelId: string, messageId: string): boolean;
74
+ /** Crossposts a message. @param channelId Channel ID. @param messageId Message ID. @returns Crossposted message. */ crosspostMessage(channelId: string, messageId: string): Promise<Message>;
75
+ /** Bulk deletes messages. @param channelId Channel ID. @param messageIds Message IDs. @returns Nothing. */ bulkDeleteMessages(channelId: string, messageIds: Iterable<string>): Promise<void>;
76
+ /** Adds a reaction. @param channelId Channel ID. @param messageId Message ID. @param emoji Emoji identifier. @returns Nothing. */ addReaction(channelId: string, messageId: string, emoji: string): Promise<void>;
77
+ /** Fetches users who reacted. @param channelId Channel ID. @param messageId Message ID. @param emoji Emoji identifier. @param options Query options. @returns Users. */ fetchReactions(channelId: string, messageId: string, emoji: string, options?: ReactionFetchOptions): Promise<User[]>;
78
+ /** Removes the current bot user's reaction. @param channelId Channel ID. @param messageId Message ID. @param emoji Emoji identifier. @returns Nothing. */ removeOwnReaction(channelId: string, messageId: string, emoji: string): Promise<void>;
79
+ /** Removes a user's reaction. @param channelId Channel ID. @param messageId Message ID. @param emoji Emoji identifier. @param userId User ID. @returns Nothing. */ removeReaction(channelId: string, messageId: string, emoji: string, userId: string): Promise<void>;
80
+ /** Removes all reactions. @param channelId Channel ID. @param messageId Message ID. @returns Nothing. */ removeAllReactions(channelId: string, messageId: string): Promise<void>;
81
+ /** Fetches pinned messages. @param channelId Channel ID. @returns Pinned messages. */ fetchPinnedMessages(channelId: string): Promise<Message[]>;
82
+ /** Pins a message. @param channelId Channel ID. @param messageId Message ID. @returns Nothing. */ pinMessage(channelId: string, messageId: string): Promise<void>;
83
+ /** Unpins a message. @param channelId Channel ID. @param messageId Message ID. @returns Nothing. */ unpinMessage(channelId: string, messageId: string): Promise<void>;
84
+ /** Creates a thread from a message. @param channelId Channel ID. @param messageId Message ID. @param options Thread options. @returns Created thread channel. */ createThreadFromMessage(channelId: string, messageId: string, options: MessageThreadOptions): Promise<Channel>;
85
+ /** Deletes a channel and its message manager. @param channelId Channel ID. @returns Whether removed. */ delete(channelId: string): boolean;
86
+ /** Clears all channels and message managers. @returns Nothing. */ clear(): void;
87
+ }
88
+ /** Backward-compatible message option alias. */
89
+ export type CreateMessageOptions = MessageCreateOptions;
90
+ /** Exposes the message manager class. */
91
+ export { MessageManager } from "./message.js";
92
+ /** Exposes the thread manager class. */
93
+ export { ThreadManager } from "./thread.js";
94
+ export { RoleManager, type RoleCreateOptions, type RoleEditOptions, } from "./role.js";
95
+ export { GuildMemberManager, type MemberEditOptions, type BanOptions, } from "./member.js";
96
+ export { ApplicationCommandManager } from "./application.js";