lunibee 0.1.7 → 0.1.8
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/LICENSE +21 -21
- package/README.md +223 -223
- package/dist/builders/commands.d.ts +6 -4
- package/dist/builders/components.d.ts +18 -0
- package/dist/builders/index.d.ts +2 -2
- package/dist/builders/index.js +49 -13
- package/dist/builders/index.js.map +9 -8
- package/dist/collection/index.js +2 -1
- package/dist/collection/index.js.map +4 -4
- package/dist/core/events.d.ts +86 -2
- package/dist/core/index.d.ts +10 -87
- package/dist/core/index.js +1752 -725
- package/dist/core/index.js.map +44 -24
- package/dist/formatters/index.js.map +1 -1
- package/dist/handlers/index.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2103 -800
- package/dist/index.js.map +63 -43
- package/dist/managers/guild-resources.d.ts +109 -0
- package/dist/managers/guild.d.ts +5 -0
- package/dist/managers/index.d.ts +7 -1
- package/dist/managers/index.js +330 -12
- package/dist/managers/index.js.map +25 -21
- package/dist/rest/decoder.d.ts +23 -0
- package/dist/rest/errors.d.ts +20 -0
- package/dist/rest/index.d.ts +21 -17
- package/dist/rest/index.js +479 -263
- package/dist/rest/index.js.map +14 -8
- package/dist/rest/limiter.d.ts +42 -0
- package/dist/rest/redis.d.ts +18 -1
- package/dist/rest/route.d.ts +31 -0
- package/dist/rest/routes.d.ts +2 -0
- package/dist/rest/scheduler.d.ts +42 -0
- package/dist/rest/store.d.ts +29 -0
- package/dist/rest/transport.d.ts +40 -0
- package/dist/sharding/bus.d.ts +31 -0
- package/dist/sharding/cluster.d.ts +10 -0
- package/dist/sharding/index.d.ts +10 -2
- package/dist/sharding/index.js +1011 -394
- package/dist/sharding/index.js.map +18 -8
- package/dist/structures/base.d.ts +8 -0
- package/dist/structures/channels.d.ts +56 -0
- package/dist/structures/index.d.ts +1 -0
- package/dist/structures/index.js +211 -271
- package/dist/structures/index.js.map +17 -14
- package/dist/structures/interactions.d.ts +12 -52
- package/dist/structures/options.d.ts +55 -0
- package/dist/structures/resources.d.ts +3 -3
- package/dist/types/gateway-events.d.ts +132 -0
- package/dist/types/gateway.d.ts +181 -0
- package/dist/types/index.d.ts +2 -263
- package/dist/types/index.js +44 -2
- package/dist/types/index.js.map +5 -4
- package/dist/utils/index.js.map +1 -1
- package/dist/voice/index.d.ts +29 -1
- package/dist/voice/index.js +59 -7
- package/dist/voice/index.js.map +3 -3
- package/dist/ws/close-codes.d.ts +23 -0
- package/dist/ws/decoder.d.ts +58 -0
- package/dist/ws/heartbeat.d.ts +87 -0
- package/dist/ws/index.d.ts +18 -65
- package/dist/ws/index.js +903 -385
- package/dist/ws/index.js.map +15 -5
- package/dist/ws/opcodes.d.ts +14 -0
- package/dist/ws/protocol.d.ts +110 -0
- package/dist/ws/reconnect.d.ts +108 -0
- package/dist/ws/send-budget.d.ts +17 -0
- package/dist/ws/session.d.ts +100 -0
- package/dist/ws/state.d.ts +27 -0
- package/dist/ws/transport.d.ts +80 -0
- package/package.json +21 -20
package/dist/collection/index.js
CHANGED
|
@@ -17,6 +17,7 @@ class Cache {
|
|
|
17
17
|
if (!Number.isFinite(interval) || interval < 1)
|
|
18
18
|
throw new RangeError("Cache sweepInterval must be positive.");
|
|
19
19
|
this.#timer = setInterval(() => this.sweep(), interval);
|
|
20
|
+
this.#timer.unref?.();
|
|
20
21
|
}
|
|
21
22
|
}
|
|
22
23
|
get size() {
|
|
@@ -315,4 +316,4 @@ export {
|
|
|
315
316
|
Collection
|
|
316
317
|
};
|
|
317
318
|
|
|
318
|
-
//# debugId=
|
|
319
|
+
//# debugId=7983082ABFA81D2164756E2164756E21
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../packages/collection/src/cache.ts", "../../packages/collection/src/index.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
5
|
-
"import { Collection } from \"./index.js\";\
|
|
6
|
-
"/** A lightweight keyed collection for Lunibee resource and application state. */\r\nexport class Collection<K, V> extends Map<K, V> {\r\n /** Returns the first stored value. */\r\n public first(): V | undefined {\r\n for (const value of this.values()) return value;\r\n return undefined;\r\n }\r\n /** Returns the first stored key. */\r\n public firstKey(): K | undefined {\r\n for (const key of this.keys()) return key;\r\n return undefined;\r\n }\r\n /** Returns the last stored value. */\r\n public last(): V | undefined {\r\n let value: V | undefined;\r\n for (const item of this.values()) value = item;\r\n return value;\r\n }\r\n /** Returns the last stored key. */\r\n public lastKey(): K | undefined {\r\n let key: K | undefined;\r\n for (const item of this.keys()) key = item;\r\n return key;\r\n }\r\n /** Finds the first value matching a predicate. */\r\n public find(\r\n predicate: (value: V, key: K, collection: this) => boolean,\r\n ): V | undefined {\r\n for (const [key, value] of this) {\r\n if (predicate(value, key, this)) return value;\r\n }\r\n return undefined;\r\n }\r\n /** Returns all values matching a predicate. */\r\n public filter(\r\n predicate: (value: V, key: K, collection: this) => boolean,\r\n ): Collection<K, V> {\r\n const result = new Collection<K, V>();\r\n for (const [key, value] of this) {\r\n if (predicate(value, key, this)) result.set(key, value);\r\n }\r\n return result;\r\n }\r\n /** Transforms every stored value into an array. */\r\n public map<T>(transform: (value: V, key: K, collection: this) => T): T[] {\r\n const result: T[] = [];\r\n for (const [key, value] of this) {\r\n result.push(transform(value, key, this));\r\n }\r\n return result;\r\n }\r\n /** Returns whether at least one stored value satisfies a predicate. */\r\n public some(\r\n predicate: (value: V, key: K, collection: this) => boolean,\r\n ): boolean {\r\n for (const [key, value] of this) {\r\n if (predicate(value, key, this)) return true;\r\n }\r\n return false;\r\n }\r\n /** Returns whether every stored value satisfies a predicate. */\r\n public every(\r\n predicate: (value: V, key: K, collection: this) => boolean,\r\n ): boolean {\r\n for (const [key, value] of this) {\r\n if (!predicate(value, key, this)) return false;\r\n }\r\n return true;\r\n }\r\n /** Runs a callback for each stored value. */\r\n public each(\r\n callback: (value: V, key: K, collection: this) => unknown,\r\n ): this {\r\n for (const [key, value] of this) {\r\n callback(value, key, this);\r\n }\r\n return this;\r\n }\r\n /** Returns an array containing all stored values. */\r\n public array(): V[] {\r\n return [...this.values()];\r\n }\r\n /** Returns an array containing all stored keys. */\r\n public keyArray(): K[] {\r\n return [...this.keys()];\r\n }\r\n /** Returns a plain array of entries. */\r\n public entriesArray(): [K, V][] {\r\n return [...this.entries()];\r\n }\r\n /** Returns a new collection with the same entries. */\r\n public clone(): Collection<K, V> {\r\n const copy = new Collection<K, V>();\r\n for (const [key, value] of this) copy.set(key, value);\r\n return copy;\r\n }\r\n /** Returns whether all supplied keys are present. */\r\n public hasAll(...keys: K[]): boolean {\r\n for (let i = 0; i < keys.length; i++) {\r\n if (!this.has(keys[i]!)) return false;\r\n }\r\n return true;\r\n }\r\n /** Returns whether at least one supplied key is present. */\r\n public hasAny(...keys: K[]): boolean {\r\n for (let i = 0; i < keys.length; i++) {\r\n if (this.has(keys[i]!)) return true;\r\n }\r\n return false;\r\n }\r\n /** Returns the first key whose value matches a predicate. */\r\n public findKey(\r\n predicate: (value: V, key: K, collection: this) => boolean,\r\n ): K | undefined {\r\n for (const [key, value] of this) {\r\n if (predicate(value, key, this)) return key;\r\n }\r\n return undefined;\r\n }\r\n /** Returns whether a predicate matches at least one entry. */\r\n public someEntry(\r\n predicate: (value: V, key: K, collection: this) => boolean,\r\n ): boolean {\r\n return this.some(predicate);\r\n }\r\n /** Removes every entry matching a predicate and returns the number removed. */\r\n public sweep(\r\n predicate: (value: V, key: K, collection: this) => boolean,\r\n ): number {\r\n let removed = 0;\r\n for (const [key, value] of this) {\r\n if (predicate(value, key, this) && this.delete(key)) removed++;\r\n }\r\n return removed;\r\n }\r\n /** Returns the collection's first matching entry as a tuple. */\r\n public firstEntry(): [K, V] | undefined {\r\n for (const [key, value] of this) return [key, value];\r\n return undefined;\r\n }\r\n /** Returns the collection's last matching entry as a tuple. */\r\n public lastEntry(): [K, V] | undefined {\r\n let entry: [K, V] | undefined;\r\n for (const item of this) entry = [item[0], item[1]];\r\n return entry;\r\n }\r\n /** Returns a new Collection containing elements from both collections. */\r\n public union(other: Collection<K, V>): Collection<K, V> {\r\n const result = this.clone();\r\n for (const [key, value] of other) result.set(key, value);\r\n return result;\r\n }\r\n /** Returns a new Collection containing only elements present in both collections. */\r\n public intersection(other: Collection<K, V>): Collection<K, V> {\r\n const result = new Collection<K, V>();\r\n for (const [key, value] of this) {\r\n if (other.has(key)) result.set(key, value);\r\n }\r\n return result;\r\n }\r\n /** Returns a new Collection containing elements present in this collection but not the other. */\r\n public difference(other: Collection<K, V>): Collection<K, V> {\r\n const result = new Collection<K, V>();\r\n for (const [key, value] of this) {\r\n if (!other.has(key)) result.set(key, value);\r\n }\r\n return result;\r\n }\r\n /** Splits the collection into two collections based on a predicate.\r\n * @returns `[passing, failing]` — entries satisfying the predicate, then those that don't.\r\n */\r\n public partition(\r\n predicate: (value: V, key: K, collection: this) => boolean,\r\n ): [Collection<K, V>, Collection<K, V>] {\r\n const pass = new Collection<K, V>();\r\n const fail = new Collection<K, V>();\r\n for (const [key, value] of this) {\r\n if (predicate(value, key, this)) pass.set(key, value);\r\n else fail.set(key, value);\r\n }\r\n return [pass, fail];\r\n }\r\n /** Calls `fn` with this collection and returns the collection unchanged.\r\n * Useful for inserting debug side-effects in a chain without breaking the flow.\r\n */\r\n public tap(fn: (collection: this) => unknown): this {\r\n fn(this);\r\n return this;\r\n }\r\n /** Maps every entry to an array of items and flattens the results. */\r\n public flatMap<T>(\r\n transform: (value: V, key: K, collection: this) => T[],\r\n ): T[] {\r\n const result: T[] = [];\r\n for (const [key, value] of this) {\r\n for (const item of transform(value, key, this)) result.push(item);\r\n }\r\n return result;\r\n }\r\n /** Reduces the collection to a single value. */\r\n public reduce<T>(\r\n fn: (accumulator: T, value: V, key: K, collection: this) => T,\r\n initialValue: T,\r\n ): T {\r\n let acc = initialValue;\r\n for (const [key, value] of this) acc = fn(acc, value, key, this);\r\n return acc;\r\n }\r\n /** Returns a new Collection with entries sorted by comparator (non-mutating).\r\n * Defaults to insertion order if no comparator is provided.\r\n */\r\n public sorted(\r\n comparator?: (a: V, b: V, aKey: K, bKey: K) => number,\r\n ): Collection<K, V> {\r\n // Decorate with the original insertion index and use it as a tiebreaker so\r\n // equal elements keep their insertion order (a stable sort independent of\r\n // the engine's Array.prototype.sort stability guarantees).\r\n const decorated = [...this.entries()].map((entry, index) => ({\r\n entry,\r\n index,\r\n }));\r\n if (comparator)\r\n decorated.sort((x, y) => {\r\n const comparison = comparator(\r\n x.entry[1],\r\n y.entry[1],\r\n x.entry[0],\r\n y.entry[0],\r\n );\r\n return comparison !== 0 ? comparison : x.index - y.index;\r\n });\r\n const result = new Collection<K, V>();\r\n for (const { entry } of decorated) result.set(entry[0], entry[1]);\r\n return result;\r\n }\r\n /** Returns a random value from the collection, or `undefined` if empty.\r\n * Uses `Math.random()` (fast, non-cryptographic) — do not use for security-sensitive\r\n * selection such as tokens or secrets. */\r\n public random(): V | undefined {\r\n const arr = [...this.values()];\r\n if (!arr.length) return undefined;\r\n return arr[Math.floor(Math.random() * arr.length)];\r\n }\r\n /** Returns a random key from the collection, or `undefined` if empty.\r\n * Uses `Math.random()` (fast, non-cryptographic) — do not use for security-sensitive\r\n * selection such as tokens or secrets. */\r\n public randomKey(): K | undefined {\r\n const arr = [...this.keys()];\r\n if (!arr.length) return undefined;\r\n return arr[Math.floor(Math.random() * arr.length)];\r\n }\r\n /** Returns the value at a given insertion-order index (supports negative indices). */\r\n public at(index: number): V | undefined {\r\n const arr = [...this.values()];\r\n const i = index < 0 ? arr.length + index : index;\r\n return arr[i];\r\n }\r\n /** Returns the key at a given insertion-order index (supports negative indices). */\r\n public keyAt(index: number): K | undefined {\r\n const arr = [...this.keys()];\r\n const i = index < 0 ? arr.length + index : index;\r\n return arr[i];\r\n }\r\n /** Serializes the collection to a plain `[key, value]` array. */\r\n public toJSON(): [K, V][] {\r\n return [...this.entries()];\r\n }\r\n}\r\n\r\nexport { Cache } from \"./cache.js\";\r\nexport type { CacheOptions } from \"./cache.js\";\r\n"
|
|
5
|
+
"import { Collection } from \"./index.js\";\n\n/** Cache policy for bounded resource storage. */\nexport interface CacheOptions {\n /** Maximum number of entries retained. */\n maxSize?: number;\n /** Time-to-live in milliseconds. Omit to disable expiration. */\n ttl?: number;\n /** Sweep interval in milliseconds. */\n sweepInterval?: number;\n}\n\ntype Entry<V> = { value: V; expiresAt: number };\n\n/** Bounded cache with TTL expiration and explicit invalidation support. */\nexport class Cache<K, V> {\n readonly #entries = new Collection<K, Entry<V>>();\n readonly #maxSize: number;\n readonly #ttl: number;\n #timer?: ReturnType<typeof setInterval>;\n\n /** Creates a cache using the supplied retention policy. */\n public constructor(options: CacheOptions = {}) {\n this.#maxSize = options.maxSize ?? Infinity;\n this.#ttl = options.ttl ?? 0;\n if (\n (!Number.isInteger(this.#maxSize) && this.#maxSize !== Infinity) ||\n this.#maxSize < 1\n )\n throw new RangeError(\"Cache maxSize must be a positive integer.\");\n if (!Number.isFinite(this.#ttl) || this.#ttl < 0)\n throw new RangeError(\n \"Cache ttl must be a non-negative finite number.\",\n );\n if (this.#ttl > 0) {\n const interval =\n options.sweepInterval ?? Math.min(this.#ttl, 60_000);\n if (!Number.isFinite(interval) || interval < 1)\n throw new RangeError(\"Cache sweepInterval must be positive.\");\n this.#timer = setInterval(() => this.sweep(), interval);\n // A sweeper is housekeeping, not work: keeping it referenced makes\n // a TTL cache hold the process open until dispose() is called.\n (this.#timer as { unref?: () => void }).unref?.();\n }\n }\n\n /** Number of currently live entries. */\n public get size(): number {\n this.#sweepExpired();\n return this.#entries.size;\n }\n /** Reads a live entry. */\n public get(key: K): V | undefined {\n const entry = this.#entries.get(key);\n if (!entry) return undefined;\n if (entry.expiresAt > 0 && entry.expiresAt <= Date.now()) {\n this.#entries.delete(key);\n return undefined;\n }\n // LRU Promotion: move to end of insertion order\n this.#entries.delete(key);\n this.#entries.set(key, entry);\n return entry.value;\n }\n /** Returns whether a live entry exists. */\n public has(key: K): boolean {\n const entry = this.#entries.get(key);\n if (!entry) return false;\n if (entry.expiresAt > 0 && entry.expiresAt <= Date.now()) {\n this.#entries.delete(key);\n return false;\n }\n return true;\n }\n /** Stores an entry and evicts the oldest entries when the bound is exceeded. */\n public set(key: K, value: V): this {\n const expiresAt = this.#ttl > 0 ? Date.now() + this.#ttl : 0;\n this.#entries.delete(key);\n this.#entries.set(key, { value, expiresAt });\n // Skip eviction entirely for unbounded caches (maxSize === Infinity).\n if (this.#maxSize !== Infinity) {\n while (this.#entries.size > this.#maxSize) {\n const oldest = this.#entries.firstKey();\n if (oldest !== undefined) this.#entries.delete(oldest);\n else break;\n }\n }\n return this;\n }\n /** Invalidates one key. */\n public delete(key: K): boolean {\n return this.#entries.delete(key);\n }\n /** Invalidates every cached resource. */\n public clear(): void {\n this.#entries.clear();\n }\n /** Invalidates every entry matching a predicate. */\n public invalidate(predicate: (value: V, key: K) => boolean): number {\n return this.#entries.sweep((entry, key) => predicate(entry.value, key));\n }\n /** Removes expired entries and returns the number removed. */\n public sweep(): number {\n return this.#entries.sweep((entry) => this.#expired(entry));\n }\n /** Stops the background sweeper and releases its timer. */\n public dispose(): void {\n if (this.#timer) clearInterval(this.#timer);\n this.#timer = undefined;\n }\n /** Returns live cached values. */\n public values(): V[] {\n this.#sweepExpired();\n return this.#entries.map((entry) => entry.value);\n }\n /** Returns live cached entries. */\n public entries(): [K, V][] {\n this.#sweepExpired();\n return this.#entries.map((entry, key) => [key, entry.value]);\n }\n #expired(entry: Entry<V>): boolean {\n return entry.expiresAt > 0 && entry.expiresAt <= Date.now();\n }\n #sweepExpired(): void {\n if (this.#ttl > 0) this.sweep();\n }\n}\n",
|
|
6
|
+
"/** A lightweight keyed collection for Lunibee resource and application state. */\nexport class Collection<K, V> extends Map<K, V> {\n /** Returns the first stored value. */\n public first(): V | undefined {\n for (const value of this.values()) return value;\n return undefined;\n }\n /** Returns the first stored key. */\n public firstKey(): K | undefined {\n for (const key of this.keys()) return key;\n return undefined;\n }\n /** Returns the last stored value. */\n public last(): V | undefined {\n let value: V | undefined;\n for (const item of this.values()) value = item;\n return value;\n }\n /** Returns the last stored key. */\n public lastKey(): K | undefined {\n let key: K | undefined;\n for (const item of this.keys()) key = item;\n return key;\n }\n /** Finds the first value matching a predicate. */\n public find(\n predicate: (value: V, key: K, collection: this) => boolean,\n ): V | undefined {\n for (const [key, value] of this) {\n if (predicate(value, key, this)) return value;\n }\n return undefined;\n }\n /** Returns all values matching a predicate. */\n public filter(\n predicate: (value: V, key: K, collection: this) => boolean,\n ): Collection<K, V> {\n const result = new Collection<K, V>();\n for (const [key, value] of this) {\n if (predicate(value, key, this)) result.set(key, value);\n }\n return result;\n }\n /** Transforms every stored value into an array. */\n public map<T>(transform: (value: V, key: K, collection: this) => T): T[] {\n const result: T[] = [];\n for (const [key, value] of this) {\n result.push(transform(value, key, this));\n }\n return result;\n }\n /** Returns whether at least one stored value satisfies a predicate. */\n public some(\n predicate: (value: V, key: K, collection: this) => boolean,\n ): boolean {\n for (const [key, value] of this) {\n if (predicate(value, key, this)) return true;\n }\n return false;\n }\n /** Returns whether every stored value satisfies a predicate. */\n public every(\n predicate: (value: V, key: K, collection: this) => boolean,\n ): boolean {\n for (const [key, value] of this) {\n if (!predicate(value, key, this)) return false;\n }\n return true;\n }\n /** Runs a callback for each stored value. */\n public each(\n callback: (value: V, key: K, collection: this) => unknown,\n ): this {\n for (const [key, value] of this) {\n callback(value, key, this);\n }\n return this;\n }\n /** Returns an array containing all stored values. */\n public array(): V[] {\n return [...this.values()];\n }\n /** Returns an array containing all stored keys. */\n public keyArray(): K[] {\n return [...this.keys()];\n }\n /** Returns a plain array of entries. */\n public entriesArray(): [K, V][] {\n return [...this.entries()];\n }\n /** Returns a new collection with the same entries. */\n public clone(): Collection<K, V> {\n const copy = new Collection<K, V>();\n for (const [key, value] of this) copy.set(key, value);\n return copy;\n }\n /** Returns whether all supplied keys are present. */\n public hasAll(...keys: K[]): boolean {\n for (let i = 0; i < keys.length; i++) {\n if (!this.has(keys[i]!)) return false;\n }\n return true;\n }\n /** Returns whether at least one supplied key is present. */\n public hasAny(...keys: K[]): boolean {\n for (let i = 0; i < keys.length; i++) {\n if (this.has(keys[i]!)) return true;\n }\n return false;\n }\n /** Returns the first key whose value matches a predicate. */\n public findKey(\n predicate: (value: V, key: K, collection: this) => boolean,\n ): K | undefined {\n for (const [key, value] of this) {\n if (predicate(value, key, this)) return key;\n }\n return undefined;\n }\n /** Returns whether a predicate matches at least one entry. */\n public someEntry(\n predicate: (value: V, key: K, collection: this) => boolean,\n ): boolean {\n return this.some(predicate);\n }\n /** Removes every entry matching a predicate and returns the number removed. */\n public sweep(\n predicate: (value: V, key: K, collection: this) => boolean,\n ): number {\n let removed = 0;\n for (const [key, value] of this) {\n if (predicate(value, key, this) && this.delete(key)) removed++;\n }\n return removed;\n }\n /** Returns the collection's first matching entry as a tuple. */\n public firstEntry(): [K, V] | undefined {\n for (const [key, value] of this) return [key, value];\n return undefined;\n }\n /** Returns the collection's last matching entry as a tuple. */\n public lastEntry(): [K, V] | undefined {\n let entry: [K, V] | undefined;\n for (const item of this) entry = [item[0], item[1]];\n return entry;\n }\n /** Returns a new Collection containing elements from both collections. */\n public union(other: Collection<K, V>): Collection<K, V> {\n const result = this.clone();\n for (const [key, value] of other) result.set(key, value);\n return result;\n }\n /** Returns a new Collection containing only elements present in both collections. */\n public intersection(other: Collection<K, V>): Collection<K, V> {\n const result = new Collection<K, V>();\n for (const [key, value] of this) {\n if (other.has(key)) result.set(key, value);\n }\n return result;\n }\n /** Returns a new Collection containing elements present in this collection but not the other. */\n public difference(other: Collection<K, V>): Collection<K, V> {\n const result = new Collection<K, V>();\n for (const [key, value] of this) {\n if (!other.has(key)) result.set(key, value);\n }\n return result;\n }\n /** Splits the collection into two collections based on a predicate.\n * @returns `[passing, failing]` — entries satisfying the predicate, then those that don't.\n */\n public partition(\n predicate: (value: V, key: K, collection: this) => boolean,\n ): [Collection<K, V>, Collection<K, V>] {\n const pass = new Collection<K, V>();\n const fail = new Collection<K, V>();\n for (const [key, value] of this) {\n if (predicate(value, key, this)) pass.set(key, value);\n else fail.set(key, value);\n }\n return [pass, fail];\n }\n /** Calls `fn` with this collection and returns the collection unchanged.\n * Useful for inserting debug side-effects in a chain without breaking the flow.\n */\n public tap(fn: (collection: this) => unknown): this {\n fn(this);\n return this;\n }\n /** Maps every entry to an array of items and flattens the results. */\n public flatMap<T>(\n transform: (value: V, key: K, collection: this) => T[],\n ): T[] {\n const result: T[] = [];\n for (const [key, value] of this) {\n for (const item of transform(value, key, this)) result.push(item);\n }\n return result;\n }\n /** Reduces the collection to a single value. */\n public reduce<T>(\n fn: (accumulator: T, value: V, key: K, collection: this) => T,\n initialValue: T,\n ): T {\n let acc = initialValue;\n for (const [key, value] of this) acc = fn(acc, value, key, this);\n return acc;\n }\n /** Returns a new Collection with entries sorted by comparator (non-mutating).\n * Defaults to insertion order if no comparator is provided.\n */\n public sorted(\n comparator?: (a: V, b: V, aKey: K, bKey: K) => number,\n ): Collection<K, V> {\n // Decorate with the original insertion index and use it as a tiebreaker so\n // equal elements keep their insertion order (a stable sort independent of\n // the engine's Array.prototype.sort stability guarantees).\n const decorated = [...this.entries()].map((entry, index) => ({\n entry,\n index,\n }));\n if (comparator)\n decorated.sort((x, y) => {\n const comparison = comparator(\n x.entry[1],\n y.entry[1],\n x.entry[0],\n y.entry[0],\n );\n return comparison !== 0 ? comparison : x.index - y.index;\n });\n const result = new Collection<K, V>();\n for (const { entry } of decorated) result.set(entry[0], entry[1]);\n return result;\n }\n /** Returns a random value from the collection, or `undefined` if empty.\n * Uses `Math.random()` (fast, non-cryptographic) — do not use for security-sensitive\n * selection such as tokens or secrets. */\n public random(): V | undefined {\n const arr = [...this.values()];\n if (!arr.length) return undefined;\n return arr[Math.floor(Math.random() * arr.length)];\n }\n /** Returns a random key from the collection, or `undefined` if empty.\n * Uses `Math.random()` (fast, non-cryptographic) — do not use for security-sensitive\n * selection such as tokens or secrets. */\n public randomKey(): K | undefined {\n const arr = [...this.keys()];\n if (!arr.length) return undefined;\n return arr[Math.floor(Math.random() * arr.length)];\n }\n /** Returns the value at a given insertion-order index (supports negative indices). */\n public at(index: number): V | undefined {\n const arr = [...this.values()];\n const i = index < 0 ? arr.length + index : index;\n return arr[i];\n }\n /** Returns the key at a given insertion-order index (supports negative indices). */\n public keyAt(index: number): K | undefined {\n const arr = [...this.keys()];\n const i = index < 0 ? arr.length + index : index;\n return arr[i];\n }\n /** Serializes the collection to a plain `[key, value]` array. */\n public toJSON(): [K, V][] {\n return [...this.entries()];\n }\n}\n\nexport { Cache } from \"./cache.js\";\nexport type { CacheOptions } from \"./cache.js\";\n"
|
|
7
7
|
],
|
|
8
|
-
"mappings": ";;AAeO,MAAM,MAAY;AAAA,EACZ,WAAW,IAAI;AAAA,EACf;AAAA,EACA;AAAA,EACT;AAAA,EAGO,WAAW,CAAC,UAAwB,CAAC,GAAG;AAAA,IAC3C,KAAK,WAAW,QAAQ,WAAW;AAAA,IACnC,KAAK,OAAO,QAAQ,OAAO;AAAA,IAC3B,IACK,CAAC,OAAO,UAAU,KAAK,QAAQ,KAAK,KAAK,aAAa,YACvD,KAAK,WAAW;AAAA,MAEhB,MAAM,IAAI,WAAW,2CAA2C;AAAA,IACpE,IAAI,CAAC,OAAO,SAAS,KAAK,IAAI,KAAK,KAAK,OAAO;AAAA,MAC3C,MAAM,IAAI,WACN,iDACJ;AAAA,IACJ,IAAI,KAAK,OAAO,GAAG;AAAA,MACf,MAAM,WACF,QAAQ,iBAAiB,KAAK,IAAI,KAAK,MAAM,KAAM;AAAA,MACvD,IAAI,CAAC,OAAO,SAAS,QAAQ,KAAK,WAAW;AAAA,QACzC,MAAM,IAAI,WAAW,uCAAuC;AAAA,MAChE,KAAK,SAAS,YAAY,MAAM,KAAK,MAAM,GAAG,QAAQ;AAAA,
|
|
9
|
-
"debugId": "
|
|
8
|
+
"mappings": ";;AAeO,MAAM,MAAY;AAAA,EACZ,WAAW,IAAI;AAAA,EACf;AAAA,EACA;AAAA,EACT;AAAA,EAGO,WAAW,CAAC,UAAwB,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OACtD;AAAA,IACL,MAAM,SAAS,IAAI;AAAA,IACnB,aAAa,WAAW;AAAA,MAAW,OAAO,IAAI,MAAM,IAAI,MAAM,EAAE;AAAA,IAChE,OAAO;AAAA;AAAA,EAKJ,MAAM,GAAkB;AAAA,IAC3B,MAAM,MAAM,CAAC,GAAG,KAAK,OAAO,CAAC;AAAA,IAC7B,IAAI,CAAC,IAAI;AAAA,MAAQ;AAAA,IACjB,OAAO,IAAI,KAAK,MAAM,KAAK,OAAO,IAAI,IAAI,MAAM;AAAA;AAAA,EAK7C,SAAS,GAAkB;AAAA,IAC9B,MAAM,MAAM,CAAC,GAAG,KAAK,KAAK,CAAC;AAAA,IAC3B,IAAI,CAAC,IAAI;AAAA,MAAQ;AAAA,IACjB,OAAO,IAAI,KAAK,MAAM,KAAK,OAAO,IAAI,IAAI,MAAM;AAAA;AAAA,EAG7C,EAAE,CAAC,OAA8B;AAAA,IACpC,MAAM,MAAM,CAAC,GAAG,KAAK,OAAO,CAAC;AAAA,IAC7B,MAAM,IAAI,QAAQ,IAAI,IAAI,SAAS,QAAQ;AAAA,IAC3C,OAAO,IAAI;AAAA;AAAA,EAGR,KAAK,CAAC,OAA8B;AAAA,IACvC,MAAM,MAAM,CAAC,GAAG,KAAK,KAAK,CAAC;AAAA,IAC3B,MAAM,IAAI,QAAQ,IAAI,IAAI,SAAS,QAAQ;AAAA,IAC3C,OAAO,IAAI;AAAA;AAAA,EAGR,MAAM,GAAa;AAAA,IACtB,OAAO,CAAC,GAAG,KAAK,QAAQ,CAAC;AAAA;AAEjC;",
|
|
9
|
+
"debugId": "7983082ABFA81D2164756E2164756E21",
|
|
10
10
|
"names": []
|
|
11
11
|
}
|
package/dist/core/events.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { APIAutoModerationActionExecution, APIAutoModerationRule, APIChannel, APIChannelPinsUpdate, APIGuild, APIGuildBanEvent, APIGuildEmojisUpdateEvent, APIGuildMember, APIGuildMembersChunk, APIGuildRoleDeleteEvent, APIGuildRoleEvent, APIGuildScheduledEvent, APIGuildScheduledEventUserEvent, APIGuildStickersUpdateEvent, APIInviteCreate, APIInviteDelete, APIMessageDeleteBulkEvent, APIMessageDeleteEvent, APIMessagePollVoteEvent, APIMessageReactionEvent, APIMessageReactionRemoveEmojiEvent, APIPresenceUpdate, APIStageInstance, APIThreadEvent, APIThreadListSync, APIThreadMember, APIThreadMembersUpdate, APITypingStart, APIVoiceServerUpdate, APIVoiceState, APIWebhooksUpdate, ClientUser } from "@lunibee/types";
|
|
2
|
+
import type { Channel, Interaction, Message } from "@lunibee/structures";
|
|
1
3
|
/** Names of events emitted by a Lunibee client. */
|
|
2
4
|
export declare enum ClientEvent {
|
|
3
5
|
Ready = "ready",
|
|
@@ -66,6 +68,88 @@ export declare enum ClientEvent {
|
|
|
66
68
|
InteractionCreate = "interactionCreate"
|
|
67
69
|
}
|
|
68
70
|
/** Names of events emitted by a Lunibee client. */
|
|
69
|
-
export type ClientEventName = keyof
|
|
71
|
+
export type ClientEventName = keyof ClientEvents;
|
|
70
72
|
/** Listener signature for a Lunibee client event. */
|
|
71
|
-
export type ClientListener<K extends ClientEventName> = (...args:
|
|
73
|
+
export type ClientListener<K extends ClientEventName> = (...args: ClientEvents[K]) => unknown;
|
|
74
|
+
export type ClientEvents = {
|
|
75
|
+
ready: [user: ClientUser];
|
|
76
|
+
resumed: [];
|
|
77
|
+
invalidSession: [isRecoverable: boolean];
|
|
78
|
+
raw: [data: {
|
|
79
|
+
event: string;
|
|
80
|
+
data: unknown;
|
|
81
|
+
}];
|
|
82
|
+
error: [error: Error];
|
|
83
|
+
open: [];
|
|
84
|
+
close: [data: {
|
|
85
|
+
code: number;
|
|
86
|
+
action: string;
|
|
87
|
+
}];
|
|
88
|
+
messageCreate: [message: Message];
|
|
89
|
+
messageUpdate: [message: Message];
|
|
90
|
+
messageDelete: [data: APIMessageDeleteEvent];
|
|
91
|
+
messageDeleteBulk: [data: APIMessageDeleteBulkEvent];
|
|
92
|
+
messageReactionAdd: [data: APIMessageReactionEvent];
|
|
93
|
+
messageReactionRemove: [data: APIMessageReactionEvent];
|
|
94
|
+
messageReactionRemoveAll: [data: APIMessageDeleteEvent];
|
|
95
|
+
messageReactionRemoveEmoji: [data: APIMessageReactionRemoveEmojiEvent];
|
|
96
|
+
messagePollVoteAdd: [data: APIMessagePollVoteEvent];
|
|
97
|
+
messagePollVoteRemove: [data: APIMessagePollVoteEvent];
|
|
98
|
+
guildCreate: [data: APIGuild];
|
|
99
|
+
guildUpdate: [data: APIGuild];
|
|
100
|
+
guildDelete: [data: {
|
|
101
|
+
id: string;
|
|
102
|
+
unavailable?: boolean;
|
|
103
|
+
}];
|
|
104
|
+
guildAvailable: [data: APIGuild & {
|
|
105
|
+
unavailable?: boolean;
|
|
106
|
+
}];
|
|
107
|
+
guildUnavailable: [data: {
|
|
108
|
+
id: string;
|
|
109
|
+
unavailable?: boolean;
|
|
110
|
+
}];
|
|
111
|
+
guildMemberAdd: [member: APIGuildMember];
|
|
112
|
+
guildMemberUpdate: [member: APIGuildMember];
|
|
113
|
+
guildMemberRemove: [member: APIGuildMember];
|
|
114
|
+
guildMembersChunk: [data: APIGuildMembersChunk];
|
|
115
|
+
guildBanAdd: [data: APIGuildBanEvent];
|
|
116
|
+
guildBanRemove: [data: APIGuildBanEvent];
|
|
117
|
+
guildRoleCreate: [data: APIGuildRoleEvent];
|
|
118
|
+
guildRoleUpdate: [data: APIGuildRoleEvent];
|
|
119
|
+
guildRoleDelete: [data: APIGuildRoleDeleteEvent];
|
|
120
|
+
guildEmojisUpdate: [data: APIGuildEmojisUpdateEvent];
|
|
121
|
+
guildStickersUpdate: [data: APIGuildStickersUpdateEvent];
|
|
122
|
+
guildIntegrationsUpdate: [data: {
|
|
123
|
+
guild_id: string;
|
|
124
|
+
}];
|
|
125
|
+
guildScheduledEventCreate: [data: APIGuildScheduledEvent];
|
|
126
|
+
guildScheduledEventUpdate: [data: APIGuildScheduledEvent];
|
|
127
|
+
guildScheduledEventDelete: [data: APIGuildScheduledEvent];
|
|
128
|
+
guildScheduledEventUserAdd: [data: APIGuildScheduledEventUserEvent];
|
|
129
|
+
guildScheduledEventUserRemove: [data: APIGuildScheduledEventUserEvent];
|
|
130
|
+
autoModerationRuleCreate: [data: APIAutoModerationRule];
|
|
131
|
+
autoModerationRuleUpdate: [data: APIAutoModerationRule];
|
|
132
|
+
autoModerationRuleDelete: [data: APIAutoModerationRule];
|
|
133
|
+
autoModerationActionExecution: [data: APIAutoModerationActionExecution];
|
|
134
|
+
channelCreate: [channel: Channel];
|
|
135
|
+
channelUpdate: [channel: Channel];
|
|
136
|
+
channelDelete: [data: APIChannel];
|
|
137
|
+
channelPinsUpdate: [data: APIChannelPinsUpdate];
|
|
138
|
+
threadCreate: [channel: Channel];
|
|
139
|
+
threadUpdate: [channel: Channel];
|
|
140
|
+
threadDelete: [data: APIThreadEvent];
|
|
141
|
+
threadListSync: [data: APIThreadListSync];
|
|
142
|
+
threadMembersUpdate: [data: APIThreadMembersUpdate];
|
|
143
|
+
threadMemberUpdate: [data: APIThreadMember];
|
|
144
|
+
stageInstanceCreate: [data: APIStageInstance];
|
|
145
|
+
stageInstanceUpdate: [data: APIStageInstance];
|
|
146
|
+
stageInstanceDelete: [data: APIStageInstance];
|
|
147
|
+
inviteCreate: [data: APIInviteCreate];
|
|
148
|
+
inviteDelete: [data: APIInviteDelete];
|
|
149
|
+
webhooksUpdate: [data: APIWebhooksUpdate];
|
|
150
|
+
voiceStateUpdate: [data: APIVoiceState];
|
|
151
|
+
voiceServerUpdate: [data: APIVoiceServerUpdate];
|
|
152
|
+
presenceUpdate: [data: APIPresenceUpdate];
|
|
153
|
+
typingStart: [data: APITypingStart];
|
|
154
|
+
interactionCreate: [interaction: Interaction];
|
|
155
|
+
};
|
package/dist/core/index.d.ts
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
export { Permission, Permissions, PermissionFlagsBits, PermissionSet, PermissionsBitField, PermissionOverwriteType, type PermissionName, } from "./permissions.js";
|
|
2
|
-
export { ClientEvent,
|
|
2
|
+
export { ClientEvent,
|
|
3
|
+
/** Discord.js-familiar alias for {@link ClientEvent}. */
|
|
4
|
+
ClientEvent as Events, type ClientEventName, type ClientEvents, type ClientListener, } from "./events.js";
|
|
3
5
|
export { Collector, type CollectorOptions } from "./collector.js";
|
|
4
|
-
export { GatewayIntentBits, IntentBits, Intents, resolveGatewayIntents, type GatewayIntentResolvable, } from "@lunibee/types";
|
|
5
|
-
import { ApplicationCommandManager, ChannelManager, GuildManager, UserManager } from "@lunibee/managers";
|
|
6
|
+
export { GatewayIntentBits, IntentBits, Intents, IntentsBitField, resolveGatewayIntents, type GatewayIntentResolvable, } from "@lunibee/types";
|
|
7
|
+
import { ApplicationCommandManager, ChannelManager, GuildManager, StageInstanceManager, UserManager } from "@lunibee/managers";
|
|
6
8
|
import { REST } from "@lunibee/rest";
|
|
7
|
-
import {
|
|
9
|
+
import { type InteractionClient } from "@lunibee/structures";
|
|
8
10
|
import { Gateway } from "@lunibee/ws";
|
|
9
|
-
import type {
|
|
11
|
+
import type { ClientOptions, ClientUser } from "@lunibee/types";
|
|
12
|
+
import { type ClientEvents } from "./events.js";
|
|
10
13
|
/** Lifecycle state of a client. */
|
|
11
14
|
export type ClientState = "idle" | "connecting" | "ready" | "destroyed";
|
|
12
15
|
type Listener<T extends unknown[]> = (...args: T) => unknown;
|
|
@@ -31,6 +34,8 @@ export declare class Client extends EventEmitter<ClientEvents> implements Intera
|
|
|
31
34
|
readonly users: UserManager;
|
|
32
35
|
readonly guilds: GuildManager;
|
|
33
36
|
readonly channels: ChannelManager;
|
|
37
|
+
/** Stage instances, cached by stage channel ID. */
|
|
38
|
+
readonly stageInstances: StageInstanceManager;
|
|
34
39
|
readonly application: {
|
|
35
40
|
commands: ApplicationCommandManager;
|
|
36
41
|
};
|
|
@@ -95,85 +100,3 @@ export declare class Client extends EventEmitter<ClientEvents> implements Intera
|
|
|
95
100
|
permissions?: string | bigint;
|
|
96
101
|
}): string;
|
|
97
102
|
}
|
|
98
|
-
export type ClientEvents = {
|
|
99
|
-
ready: [user: ClientUser];
|
|
100
|
-
resumed: [];
|
|
101
|
-
invalidSession: [isRecoverable: boolean];
|
|
102
|
-
raw: [data: {
|
|
103
|
-
event: string;
|
|
104
|
-
data: unknown;
|
|
105
|
-
}];
|
|
106
|
-
error: [error: Error];
|
|
107
|
-
open: [];
|
|
108
|
-
close: [data: {
|
|
109
|
-
code: number;
|
|
110
|
-
action: string;
|
|
111
|
-
}];
|
|
112
|
-
messageCreate: [message: Message];
|
|
113
|
-
messageUpdate: [message: Message];
|
|
114
|
-
messageDelete: [data: APIMessageDeleteEvent];
|
|
115
|
-
messageDeleteBulk: [data: APIMessageDeleteBulkEvent];
|
|
116
|
-
messageReactionAdd: [data: APIMessageReactionEvent];
|
|
117
|
-
messageReactionRemove: [data: APIMessageReactionEvent];
|
|
118
|
-
messageReactionRemoveAll: [data: APIMessageDeleteEvent];
|
|
119
|
-
messageReactionRemoveEmoji: [data: APIMessageReactionRemoveEmojiEvent];
|
|
120
|
-
messagePollVoteAdd: [data: APIMessagePollVoteEvent];
|
|
121
|
-
messagePollVoteRemove: [data: APIMessagePollVoteEvent];
|
|
122
|
-
guildCreate: [data: APIGuild];
|
|
123
|
-
guildUpdate: [data: APIGuild];
|
|
124
|
-
guildDelete: [data: {
|
|
125
|
-
id: string;
|
|
126
|
-
unavailable?: boolean;
|
|
127
|
-
}];
|
|
128
|
-
guildAvailable: [data: APIGuild & {
|
|
129
|
-
unavailable?: boolean;
|
|
130
|
-
}];
|
|
131
|
-
guildUnavailable: [data: {
|
|
132
|
-
id: string;
|
|
133
|
-
unavailable?: boolean;
|
|
134
|
-
}];
|
|
135
|
-
guildMemberAdd: [member: APIGuildMember];
|
|
136
|
-
guildMemberUpdate: [member: APIGuildMember];
|
|
137
|
-
guildMemberRemove: [member: APIGuildMember];
|
|
138
|
-
guildMembersChunk: [data: APIGuildMembersChunk];
|
|
139
|
-
guildBanAdd: [data: APIGuildBanEvent];
|
|
140
|
-
guildBanRemove: [data: APIGuildBanEvent];
|
|
141
|
-
guildRoleCreate: [data: APIGuildRoleEvent];
|
|
142
|
-
guildRoleUpdate: [data: APIGuildRoleEvent];
|
|
143
|
-
guildRoleDelete: [data: APIGuildRoleDeleteEvent];
|
|
144
|
-
guildEmojisUpdate: [data: APIGuildEmojisUpdateEvent];
|
|
145
|
-
guildStickersUpdate: [data: APIGuildStickersUpdateEvent];
|
|
146
|
-
guildIntegrationsUpdate: [data: {
|
|
147
|
-
guild_id: string;
|
|
148
|
-
}];
|
|
149
|
-
guildScheduledEventCreate: [data: APIGuildScheduledEvent];
|
|
150
|
-
guildScheduledEventUpdate: [data: APIGuildScheduledEvent];
|
|
151
|
-
guildScheduledEventDelete: [data: APIGuildScheduledEvent];
|
|
152
|
-
guildScheduledEventUserAdd: [data: APIGuildScheduledEventUserEvent];
|
|
153
|
-
guildScheduledEventUserRemove: [data: APIGuildScheduledEventUserEvent];
|
|
154
|
-
autoModerationRuleCreate: [data: APIAutoModerationRule];
|
|
155
|
-
autoModerationRuleUpdate: [data: APIAutoModerationRule];
|
|
156
|
-
autoModerationRuleDelete: [data: APIAutoModerationRule];
|
|
157
|
-
autoModerationActionExecution: [data: APIAutoModerationActionExecution];
|
|
158
|
-
channelCreate: [channel: Channel];
|
|
159
|
-
channelUpdate: [channel: Channel];
|
|
160
|
-
channelDelete: [data: APIChannel];
|
|
161
|
-
channelPinsUpdate: [data: APIChannelPinsUpdate];
|
|
162
|
-
threadCreate: [channel: Channel];
|
|
163
|
-
threadUpdate: [channel: Channel];
|
|
164
|
-
threadDelete: [data: APIThreadEvent];
|
|
165
|
-
threadListSync: [data: APIThreadListSync];
|
|
166
|
-
threadMembersUpdate: [data: APIThreadMembersUpdate];
|
|
167
|
-
threadMemberUpdate: [data: APIThreadMember];
|
|
168
|
-
stageInstanceCreate: [data: APIStageInstance];
|
|
169
|
-
stageInstanceUpdate: [data: APIStageInstance];
|
|
170
|
-
stageInstanceDelete: [data: APIStageInstance];
|
|
171
|
-
inviteCreate: [data: APIInviteCreate];
|
|
172
|
-
inviteDelete: [data: APIInviteDelete];
|
|
173
|
-
webhooksUpdate: [data: APIWebhooksUpdate];
|
|
174
|
-
voiceStateUpdate: [data: APIVoiceState];
|
|
175
|
-
voiceServerUpdate: [data: APIVoiceServerUpdate];
|
|
176
|
-
presenceUpdate: [data: APIPresenceUpdate];
|
|
177
|
-
typingStart: [data: APITypingStart];
|
|
178
|
-
interactionCreate: [interaction: Interaction];
|
|
179
|
-
};
|