lunibee 0.2.2 → 0.2.4

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 (70) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +225 -225
  3. package/dist/builders/attachment.d.ts +10 -2
  4. package/dist/builders/commands.d.ts +161 -101
  5. package/dist/builders/components.d.ts +54 -75
  6. package/dist/builders/embed.d.ts +68 -35
  7. package/dist/builders/index.d.ts +1 -1
  8. package/dist/builders/index.js +108 -133
  9. package/dist/builders/index.js.map +8 -8
  10. package/dist/collection/cache.d.ts +13 -6
  11. package/dist/collection/index.d.ts +90 -17
  12. package/dist/collection/index.js +442 -266
  13. package/dist/collection/index.js.map +4 -4
  14. package/dist/core/index.d.ts +9 -0
  15. package/dist/core/index.js +791 -436
  16. package/dist/core/index.js.map +47 -47
  17. package/dist/core/permissions.d.ts +9 -5
  18. package/dist/formatters/index.js +9 -5
  19. package/dist/formatters/index.js.map +3 -3
  20. package/dist/handlers/index.js +5 -10
  21. package/dist/handlers/index.js.map +3 -3
  22. package/dist/index.js +1010 -679
  23. package/dist/index.js.map +66 -65
  24. package/dist/managers/base.d.ts +26 -14
  25. package/dist/managers/emoji.d.ts +7 -1
  26. package/dist/managers/guild-resources.d.ts +11 -3
  27. package/dist/managers/guild.d.ts +13 -5
  28. package/dist/managers/index.d.ts +28 -14
  29. package/dist/managers/index.js +580 -340
  30. package/dist/managers/index.js.map +26 -26
  31. package/dist/managers/member.d.ts +5 -3
  32. package/dist/managers/message.d.ts +7 -3
  33. package/dist/managers/role.d.ts +13 -1
  34. package/dist/rest/error-codes.d.ts +48 -0
  35. package/dist/rest/errors.d.ts +14 -6
  36. package/dist/rest/index.d.ts +25 -12
  37. package/dist/rest/index.js +105 -18
  38. package/dist/rest/index.js.map +15 -14
  39. package/dist/rest/redis.d.ts +1 -1
  40. package/dist/rest/route.d.ts +8 -4
  41. package/dist/rest/routes.d.ts +102 -46
  42. package/dist/rest/transport.d.ts +10 -5
  43. package/dist/rest/webhook.d.ts +9 -5
  44. package/dist/sharding/bus.d.ts +34 -17
  45. package/dist/sharding/index.d.ts +34 -17
  46. package/dist/sharding/index.js +68 -36
  47. package/dist/sharding/index.js.map +17 -17
  48. package/dist/structures/base.d.ts +28 -10
  49. package/dist/structures/channels.d.ts +28 -14
  50. package/dist/structures/index.d.ts +6 -6
  51. package/dist/structures/index.js +81 -99
  52. package/dist/structures/index.js.map +19 -18
  53. package/dist/structures/interactions.d.ts +98 -50
  54. package/dist/structures/resources.d.ts +90 -46
  55. package/dist/types/gateway.d.ts +1 -1
  56. package/dist/types/index.d.ts +43 -18
  57. package/dist/types/index.js +20 -22
  58. package/dist/types/index.js.map +4 -4
  59. package/dist/utils/index.js.map +2 -2
  60. package/dist/voice/index.d.ts +12 -4
  61. package/dist/voice/index.js +17 -20
  62. package/dist/voice/index.js.map +3 -3
  63. package/dist/ws/decoder.d.ts +6 -2
  64. package/dist/ws/index.d.ts +25 -13
  65. package/dist/ws/index.js +63 -31
  66. package/dist/ws/index.js.map +14 -14
  67. package/dist/ws/protocol.d.ts +10 -2
  68. package/dist/ws/session.d.ts +14 -4
  69. package/dist/ws/state.d.ts +22 -11
  70. package/package.json +16 -15
@@ -91,7 +91,7 @@ export interface IdentifyProperties {
91
91
  os?: string;
92
92
  browser?: string;
93
93
  device?: string;
94
- [key: string]: unknown;
94
+ [key: string]: string | undefined;
95
95
  }
96
96
  /** Everything IDENTIFY needs. */
97
97
  export interface IdentifyOptions {
@@ -102,8 +102,16 @@ export interface IdentifyOptions {
102
102
  properties?: IdentifyProperties;
103
103
  presence?: GatewayPresence;
104
104
  }
105
+ /** The `d` field of an IDENTIFY payload. */
106
+ export interface IdentifyData {
107
+ token: string;
108
+ intents: number;
109
+ properties: IdentifyProperties;
110
+ presence: Required<GatewayPresence>;
111
+ shard: [shardId: number, shardCount: number];
112
+ }
105
113
  /** Builds an IDENTIFY payload. */
106
- export declare function identifyPayload(options: IdentifyOptions): GatewayPayload;
114
+ export declare function identifyPayload(options: IdentifyOptions): GatewayPayload<IdentifyData>;
107
115
  /** Builds a RESUME payload from the session's resume material. */
108
116
  export declare function resumePayload(token: string, resume: ResumeInfo): GatewayPayload;
109
117
  /** Builds a heartbeat payload carrying the last sequence seen. */
@@ -9,9 +9,12 @@
9
9
  */
10
10
  /** Everything needed to send a RESUME, or nothing when one is impossible. */
11
11
  export interface ResumeInfo {
12
- /** Discord's session identifier from READY. */ sessionId: string;
13
- /** Last sequence number observed on this session. */ sequence: number;
14
- /** Host READY nominated for resuming this session. */ resumeURL: string;
12
+ /** Discord's session identifier from READY. */
13
+ sessionId: string;
14
+ /** Last sequence number observed on this session. */
15
+ sequence: number;
16
+ /** Host READY nominated for resuming this session. */
17
+ resumeURL: string;
15
18
  }
16
19
  /**
17
20
  * What the next connection must do.
@@ -95,6 +98,13 @@ export declare class GatewaySession {
95
98
  resumeInfo(): ResumeInfo | undefined;
96
99
  /** What the next connection must send: RESUME with material, or IDENTIFY. */
97
100
  handshake(): HandshakeIntent;
98
- /** Host the next connection should dial: the resume host, else `fallback`. */
101
+ /**
102
+ * Host the next connection should dial: the resume host, else `fallback`.
103
+ * The resume host comes from READY, so it is used only when it is a `wss:`
104
+ * URL on discord.gg (or a subdomain), or on the fallback's own host; any
105
+ * other host would receive the bot token in the RESUME frame.
106
+ */
99
107
  connectURL(fallback: string): string;
100
108
  }
109
+ /** Whether `url` is a `wss:` URL on discord.gg (or a subdomain) or on `fallback`'s host. */
110
+ export declare function isTrustedGatewayURL(url: string, fallback: string): boolean;
@@ -1,14 +1,23 @@
1
1
  /** Gateway connection lifecycle states. */
2
2
  export declare enum GatewayState {
3
- /** Initial connection state. */ Connect = "CONNECT",
4
- /** Gateway HELLO received state. */ Hello = "HELLO",
5
- /** IDENTIFY operation in progress. */ Identify = "IDENTIFY",
6
- /** RESUME operation in progress. */ Resume = "RESUME",
7
- /** Gateway READY state. */ Ready = "READY",
8
- /** Gateway dispatch processing state. */ Dispatch = "DISPATCH",
9
- /** Heartbeat processing state. */ Heartbeat = "HEARTBEAT",
10
- /** Reconnect in progress. */ Reconnect = "RECONNECT",
11
- /** Gateway is permanently closed. */ Closed = "CLOSED"
3
+ /** Initial connection state. */
4
+ Connect = "CONNECT",
5
+ /** Gateway HELLO received state. */
6
+ Hello = "HELLO",
7
+ /** IDENTIFY operation in progress. */
8
+ Identify = "IDENTIFY",
9
+ /** RESUME operation in progress. */
10
+ Resume = "RESUME",
11
+ /** Gateway READY state. */
12
+ Ready = "READY",
13
+ /** Gateway dispatch processing state. */
14
+ Dispatch = "DISPATCH",
15
+ /** Heartbeat processing state. */
16
+ Heartbeat = "HEARTBEAT",
17
+ /** Reconnect in progress. */
18
+ Reconnect = "RECONNECT",
19
+ /** Gateway is permanently closed. */
20
+ Closed = "CLOSED"
12
21
  }
13
22
  /**
14
23
  * Discord.js-familiar alias for {@link GatewayState}.
@@ -22,6 +31,8 @@ export declare enum GatewayState {
22
31
  export { GatewayState as Status };
23
32
  /** Gateway protocol error. */
24
33
  export declare class GatewayError extends Error {
25
- /** Gateway close/error code. */ readonly code?: number;
26
- /** Creates a Gateway error. @param message Error message. @param code Optional Gateway code. @param options Optional error metadata. */ constructor(message: string, code?: number, options?: ErrorOptions);
34
+ /** Gateway close/error code. */
35
+ readonly code?: number;
36
+ /** Creates a Gateway error. @param message Error message. @param code Optional Gateway code. @param options Optional error metadata. */
37
+ constructor(message: string, code?: number, options?: ErrorOptions);
27
38
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lunibee",
3
- "version": "0.2.2",
3
+ "version": "0.2.4",
4
4
  "description": "A lightweight, Bun-first Discord API library.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -92,7 +92,7 @@
92
92
  "format:check": "prettier --check \"packages/*/src/**/*.ts\" \"tests/**/*.ts\"",
93
93
  "check:deps": "bun scripts/check-dependency-graph.ts",
94
94
  "audit:api": "bun scripts/api-audit.ts",
95
- "typecheck": "bunx tsc --noEmit --project tsconfig.json",
95
+ "typecheck": "bunx tsc --noEmit --project tsconfig.json && bunx tsc --noEmit --project tsconfig.strict.json",
96
96
  "ci:install": "bun install --frozen-lockfile",
97
97
  "ci:deps": "bun run check:deps",
98
98
  "ci:typecheck": "bun run typecheck",
@@ -103,21 +103,22 @@
103
103
  "publish:all": "bun run scripts/publish.ts"
104
104
  },
105
105
  "dependencies": {
106
- "@lunibee/builders": "^0.2.2",
107
- "@lunibee/collection": "^0.2.2",
108
- "@lunibee/core": "^0.2.2",
109
- "@lunibee/formatters": "^0.2.2",
110
- "@lunibee/handlers": "^0.2.2",
111
- "@lunibee/managers": "^0.2.2",
112
- "@lunibee/rest": "^0.2.2",
113
- "@lunibee/sharding": "^0.2.2",
114
- "@lunibee/structures": "^0.2.2",
115
- "@lunibee/types": "^0.2.2",
116
- "@lunibee/utils": "^0.2.2",
117
- "@lunibee/voice": "^0.2.2",
118
- "@lunibee/ws": "^0.2.2"
106
+ "@lunibee/builders": "^0.2.4",
107
+ "@lunibee/collection": "^0.2.4",
108
+ "@lunibee/core": "^0.2.4",
109
+ "@lunibee/formatters": "^0.2.4",
110
+ "@lunibee/handlers": "^0.2.4",
111
+ "@lunibee/managers": "^0.2.4",
112
+ "@lunibee/rest": "^0.2.4",
113
+ "@lunibee/sharding": "^0.2.4",
114
+ "@lunibee/structures": "^0.2.4",
115
+ "@lunibee/types": "^0.2.4",
116
+ "@lunibee/utils": "^0.2.4",
117
+ "@lunibee/voice": "^0.2.4",
118
+ "@lunibee/ws": "^0.2.4"
119
119
  },
120
120
  "devDependencies": {
121
+ "@discordjs/collection": "^2.1.1",
121
122
  "@types/bun": "^1.4.1",
122
123
  "prettier": "^3.9.9",
123
124
  "typescript": "^7.0.2"