lunibee 0.1.6 → 0.1.7
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/README.md +3 -3
- package/dist/builders/commands.d.ts +37 -0
- package/dist/builders/components.d.ts +19 -12
- package/dist/builders/embed.d.ts +3 -1
- package/dist/builders/index.d.ts +1 -1
- package/dist/builders/index.js +146 -19
- package/dist/builders/index.js.map +8 -7
- package/dist/collection/index.d.ts +30 -0
- package/dist/collection/index.js +78 -5
- package/dist/collection/index.js.map +4 -4
- package/dist/core/events.d.ts +2 -0
- package/dist/core/index.d.ts +38 -0
- package/dist/core/index.js +754 -175
- package/dist/core/index.js.map +24 -22
- package/dist/core/permissions.d.ts +112 -53
- package/dist/formatters/index.d.ts +43 -3
- package/dist/formatters/index.js +64 -1
- package/dist/formatters/index.js.map +3 -3
- package/dist/handlers/index.js.map +2 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1762 -291
- package/dist/index.js.map +43 -38
- package/dist/managers/emoji.d.ts +38 -0
- package/dist/managers/guild.d.ts +112 -1
- package/dist/managers/index.d.ts +31 -1
- package/dist/managers/index.js +803 -77
- package/dist/managers/index.js.map +21 -20
- package/dist/rest/index.d.ts +101 -11
- package/dist/rest/index.js +301 -45
- package/dist/rest/index.js.map +8 -6
- package/dist/rest/redis.d.ts +37 -0
- package/dist/rest/routes.d.ts +22 -0
- package/dist/rest/store.d.ts +38 -0
- package/dist/rest/webhook.d.ts +2 -2
- package/dist/sharding/cluster.d.ts +61 -0
- package/dist/sharding/index.d.ts +8 -0
- package/dist/sharding/index.js +286 -18
- package/dist/sharding/index.js.map +8 -7
- package/dist/structures/audit-log.d.ts +26 -0
- package/dist/structures/base.d.ts +32 -0
- package/dist/structures/index.d.ts +29 -1
- package/dist/structures/index.js +1022 -86
- package/dist/structures/index.js.map +14 -10
- package/dist/structures/resources.d.ts +192 -4
- package/dist/types/index.d.ts +76 -0
- package/dist/types/index.js.map +2 -2
- package/dist/utils/index.js.map +2 -2
- package/dist/voice/index.d.ts +88 -0
- package/dist/voice/index.js +204 -5
- package/dist/voice/index.js.map +3 -3
- package/dist/ws/index.d.ts +40 -1
- package/dist/ws/index.js +102 -18
- package/dist/ws/index.js.map +4 -4
- package/package.json +16 -16
- package/dist/structures/permissions.d.ts +0 -73
package/dist/collection/index.js
CHANGED
|
@@ -49,10 +49,14 @@ class Cache {
|
|
|
49
49
|
const expiresAt = this.#ttl > 0 ? Date.now() + this.#ttl : 0;
|
|
50
50
|
this.#entries.delete(key);
|
|
51
51
|
this.#entries.set(key, { value, expiresAt });
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
52
|
+
if (this.#maxSize !== Infinity) {
|
|
53
|
+
while (this.#entries.size > this.#maxSize) {
|
|
54
|
+
const oldest = this.#entries.firstKey();
|
|
55
|
+
if (oldest !== undefined)
|
|
56
|
+
this.#entries.delete(oldest);
|
|
57
|
+
else
|
|
58
|
+
break;
|
|
59
|
+
}
|
|
56
60
|
}
|
|
57
61
|
return this;
|
|
58
62
|
}
|
|
@@ -236,10 +240,79 @@ class Collection extends Map {
|
|
|
236
240
|
}
|
|
237
241
|
return result;
|
|
238
242
|
}
|
|
243
|
+
partition(predicate) {
|
|
244
|
+
const pass = new Collection;
|
|
245
|
+
const fail = new Collection;
|
|
246
|
+
for (const [key, value] of this) {
|
|
247
|
+
if (predicate(value, key, this))
|
|
248
|
+
pass.set(key, value);
|
|
249
|
+
else
|
|
250
|
+
fail.set(key, value);
|
|
251
|
+
}
|
|
252
|
+
return [pass, fail];
|
|
253
|
+
}
|
|
254
|
+
tap(fn) {
|
|
255
|
+
fn(this);
|
|
256
|
+
return this;
|
|
257
|
+
}
|
|
258
|
+
flatMap(transform) {
|
|
259
|
+
const result = [];
|
|
260
|
+
for (const [key, value] of this) {
|
|
261
|
+
for (const item of transform(value, key, this))
|
|
262
|
+
result.push(item);
|
|
263
|
+
}
|
|
264
|
+
return result;
|
|
265
|
+
}
|
|
266
|
+
reduce(fn, initialValue) {
|
|
267
|
+
let acc = initialValue;
|
|
268
|
+
for (const [key, value] of this)
|
|
269
|
+
acc = fn(acc, value, key, this);
|
|
270
|
+
return acc;
|
|
271
|
+
}
|
|
272
|
+
sorted(comparator) {
|
|
273
|
+
const decorated = [...this.entries()].map((entry, index) => ({
|
|
274
|
+
entry,
|
|
275
|
+
index
|
|
276
|
+
}));
|
|
277
|
+
if (comparator)
|
|
278
|
+
decorated.sort((x, y) => {
|
|
279
|
+
const comparison = comparator(x.entry[1], y.entry[1], x.entry[0], y.entry[0]);
|
|
280
|
+
return comparison !== 0 ? comparison : x.index - y.index;
|
|
281
|
+
});
|
|
282
|
+
const result = new Collection;
|
|
283
|
+
for (const { entry } of decorated)
|
|
284
|
+
result.set(entry[0], entry[1]);
|
|
285
|
+
return result;
|
|
286
|
+
}
|
|
287
|
+
random() {
|
|
288
|
+
const arr = [...this.values()];
|
|
289
|
+
if (!arr.length)
|
|
290
|
+
return;
|
|
291
|
+
return arr[Math.floor(Math.random() * arr.length)];
|
|
292
|
+
}
|
|
293
|
+
randomKey() {
|
|
294
|
+
const arr = [...this.keys()];
|
|
295
|
+
if (!arr.length)
|
|
296
|
+
return;
|
|
297
|
+
return arr[Math.floor(Math.random() * arr.length)];
|
|
298
|
+
}
|
|
299
|
+
at(index) {
|
|
300
|
+
const arr = [...this.values()];
|
|
301
|
+
const i = index < 0 ? arr.length + index : index;
|
|
302
|
+
return arr[i];
|
|
303
|
+
}
|
|
304
|
+
keyAt(index) {
|
|
305
|
+
const arr = [...this.keys()];
|
|
306
|
+
const i = index < 0 ? arr.length + index : index;
|
|
307
|
+
return arr[i];
|
|
308
|
+
}
|
|
309
|
+
toJSON() {
|
|
310
|
+
return [...this.entries()];
|
|
311
|
+
}
|
|
239
312
|
}
|
|
240
313
|
export {
|
|
241
314
|
Cache,
|
|
242
315
|
Collection
|
|
243
316
|
};
|
|
244
317
|
|
|
245
|
-
//# debugId=
|
|
318
|
+
//# debugId=F7AF9637261DF97664756E2164756E21
|
|
@@ -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\";\r\n\r\n/** Cache policy for bounded resource storage. */\r\nexport interface CacheOptions {\r\n
|
|
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(callback: (value: V, key: K, collection: this) => unknown): 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}\r\n\r\nexport { Cache } from \"./cache.js\";\r\nexport type { CacheOptions } from \"./cache.js\";\r\n"
|
|
5
|
+
"import { Collection } from \"./index.js\";\r\n\r\n/** Cache policy for bounded resource storage. */\r\nexport interface CacheOptions {\r\n /** Maximum number of entries retained. */\r\n maxSize?: number;\r\n /** Time-to-live in milliseconds. Omit to disable expiration. */\r\n ttl?: number;\r\n /** Sweep interval in milliseconds. */\r\n sweepInterval?: number;\r\n}\r\n\r\ntype Entry<V> = { value: V; expiresAt: number };\r\n\r\n/** Bounded cache with TTL expiration and explicit invalidation support. */\r\nexport class Cache<K, V> {\r\n readonly #entries = new Collection<K, Entry<V>>();\r\n readonly #maxSize: number;\r\n readonly #ttl: number;\r\n #timer?: ReturnType<typeof setInterval>;\r\n\r\n /** Creates a cache using the supplied retention policy. */\r\n public constructor(options: CacheOptions = {}) {\r\n this.#maxSize = options.maxSize ?? Infinity;\r\n this.#ttl = options.ttl ?? 0;\r\n if (\r\n (!Number.isInteger(this.#maxSize) && this.#maxSize !== Infinity) ||\r\n this.#maxSize < 1\r\n )\r\n throw new RangeError(\"Cache maxSize must be a positive integer.\");\r\n if (!Number.isFinite(this.#ttl) || this.#ttl < 0)\r\n throw new RangeError(\r\n \"Cache ttl must be a non-negative finite number.\",\r\n );\r\n if (this.#ttl > 0) {\r\n const interval =\r\n options.sweepInterval ?? Math.min(this.#ttl, 60_000);\r\n if (!Number.isFinite(interval) || interval < 1)\r\n throw new RangeError(\"Cache sweepInterval must be positive.\");\r\n this.#timer = setInterval(() => this.sweep(), interval);\r\n }\r\n }\r\n\r\n /** Number of currently live entries. */\r\n public get size(): number {\r\n this.#sweepExpired();\r\n return this.#entries.size;\r\n }\r\n /** Reads a live entry. */\r\n public get(key: K): V | undefined {\r\n const entry = this.#entries.get(key);\r\n if (!entry) return undefined;\r\n if (entry.expiresAt > 0 && entry.expiresAt <= Date.now()) {\r\n this.#entries.delete(key);\r\n return undefined;\r\n }\r\n // LRU Promotion: move to end of insertion order\r\n this.#entries.delete(key);\r\n this.#entries.set(key, entry);\r\n return entry.value;\r\n }\r\n /** Returns whether a live entry exists. */\r\n public has(key: K): boolean {\r\n const entry = this.#entries.get(key);\r\n if (!entry) return false;\r\n if (entry.expiresAt > 0 && entry.expiresAt <= Date.now()) {\r\n this.#entries.delete(key);\r\n return false;\r\n }\r\n return true;\r\n }\r\n /** Stores an entry and evicts the oldest entries when the bound is exceeded. */\r\n public set(key: K, value: V): this {\r\n const expiresAt = this.#ttl > 0 ? Date.now() + this.#ttl : 0;\r\n this.#entries.delete(key);\r\n this.#entries.set(key, { value, expiresAt });\r\n // Skip eviction entirely for unbounded caches (maxSize === Infinity).\r\n if (this.#maxSize !== Infinity) {\r\n while (this.#entries.size > this.#maxSize) {\r\n const oldest = this.#entries.firstKey();\r\n if (oldest !== undefined) this.#entries.delete(oldest);\r\n else break;\r\n }\r\n }\r\n return this;\r\n }\r\n /** Invalidates one key. */\r\n public delete(key: K): boolean {\r\n return this.#entries.delete(key);\r\n }\r\n /** Invalidates every cached resource. */\r\n public clear(): void {\r\n this.#entries.clear();\r\n }\r\n /** Invalidates every entry matching a predicate. */\r\n public invalidate(predicate: (value: V, key: K) => boolean): number {\r\n return this.#entries.sweep((entry, key) => predicate(entry.value, key));\r\n }\r\n /** Removes expired entries and returns the number removed. */\r\n public sweep(): number {\r\n return this.#entries.sweep((entry) => this.#expired(entry));\r\n }\r\n /** Stops the background sweeper and releases its timer. */\r\n public dispose(): void {\r\n if (this.#timer) clearInterval(this.#timer);\r\n this.#timer = undefined;\r\n }\r\n /** Returns live cached values. */\r\n public values(): V[] {\r\n this.#sweepExpired();\r\n return this.#entries.map((entry) => entry.value);\r\n }\r\n /** Returns live cached entries. */\r\n public entries(): [K, V][] {\r\n this.#sweepExpired();\r\n return this.#entries.map((entry, key) => [key, entry.value]);\r\n }\r\n #expired(entry: Entry<V>): boolean {\r\n return entry.expiresAt > 0 && entry.expiresAt <= Date.now();\r\n }\r\n #sweepExpired(): void {\r\n if (this.#ttl > 0) this.sweep();\r\n }\r\n}\r\n",
|
|
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"
|
|
7
7
|
],
|
|
8
|
-
"mappings": ";;AAeO,MAAM,MAAY;AAAA,
|
|
9
|
-
"debugId": "
|
|
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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,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": "F7AF9637261DF97664756E2164756E21",
|
|
10
10
|
"names": []
|
|
11
11
|
}
|
package/dist/core/events.d.ts
CHANGED
package/dist/core/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { Permission, Permissions, PermissionFlagsBits, PermissionSet, PermissionsBitField, PermissionOverwriteType, type PermissionName, } from "./permissions.js";
|
|
2
2
|
export { ClientEvent, type ClientEventName, type ClientListener, } from "./events.js";
|
|
3
|
+
export { Collector, type CollectorOptions } from "./collector.js";
|
|
3
4
|
export { GatewayIntentBits, IntentBits, Intents, resolveGatewayIntents, type GatewayIntentResolvable, } from "@lunibee/types";
|
|
4
5
|
import { ApplicationCommandManager, ChannelManager, GuildManager, UserManager } from "@lunibee/managers";
|
|
5
6
|
import { REST } from "@lunibee/rest";
|
|
@@ -17,6 +18,8 @@ declare class EventEmitter<Events extends {
|
|
|
17
18
|
on<K extends keyof Events>(event: K, listener: Listener<Events[K]>): this;
|
|
18
19
|
once<K extends keyof Events>(event: K, listener: Listener<Events[K]>): this;
|
|
19
20
|
off<K extends keyof Events>(event: K, listener: Listener<Events[K]>): this;
|
|
21
|
+
/** Alias of {@link off}, provided for Node.js/Discord.js familiarity. */
|
|
22
|
+
removeListener<K extends keyof Events>(event: K, listener: Listener<Events[K]>): this;
|
|
20
23
|
removeAllListeners<K extends keyof Events>(event?: K): this;
|
|
21
24
|
protected emit<K extends keyof Events>(event: K, ...args: Events[K]): boolean;
|
|
22
25
|
}
|
|
@@ -36,11 +39,21 @@ export declare class Client extends EventEmitter<ClientEvents> implements Intera
|
|
|
36
39
|
user?: ClientUser;
|
|
37
40
|
readyAt?: Date;
|
|
38
41
|
state: ClientState;
|
|
42
|
+
/**
|
|
43
|
+
* The bot token this client is authenticated with, or `null` once the
|
|
44
|
+
* client has been destroyed. Mirrors `Client#token` in Discord.js.
|
|
45
|
+
*/
|
|
46
|
+
get token(): string | null;
|
|
39
47
|
get uptime(): number | null;
|
|
48
|
+
get ping(): number;
|
|
40
49
|
/** Whether the client is ready and connected. */
|
|
41
50
|
isReady(): boolean;
|
|
42
51
|
/** Sets the bot's presence / status. @param data Presence payload. @returns Whether the payload was sent. */
|
|
43
52
|
setPresence(data: import("@lunibee/types").GatewayPresence): boolean;
|
|
53
|
+
/** Sends a voice state update. @param data Voice state payload. @returns Whether it was sent. */
|
|
54
|
+
setVoiceState(data: Record<string, unknown>): boolean;
|
|
55
|
+
/** Requests guild members. @param data Guild member request payload. @returns Whether it was sent. */
|
|
56
|
+
requestGuildMembers(data: Record<string, unknown>): boolean;
|
|
44
57
|
constructor(options: ClientOptions);
|
|
45
58
|
/**
|
|
46
59
|
* Convenience method to connect the bot to Discord.
|
|
@@ -58,9 +71,34 @@ export declare class Client extends EventEmitter<ClientEvents> implements Intera
|
|
|
58
71
|
editInteractionReply(token: string, data: Record<string, unknown>): Promise<unknown>;
|
|
59
72
|
deleteInteractionReply(token: string): Promise<void>;
|
|
60
73
|
followUpInteraction(token: string, data: Record<string, unknown>): Promise<unknown>;
|
|
74
|
+
/** Fetches a webhook from Discord. */
|
|
75
|
+
fetchWebhook(id: string, token?: string): Promise<Record<string, unknown>>;
|
|
76
|
+
/** Fetches a guild preview from Discord. */
|
|
77
|
+
fetchGuildPreview(guildId: string): Promise<Record<string, unknown>>;
|
|
78
|
+
/** Fetches the voice regions from Discord. */
|
|
79
|
+
fetchVoiceRegions(): Promise<Record<string, unknown>[]>;
|
|
80
|
+
/** Fetches an invite from Discord. */
|
|
81
|
+
fetchInvite(code: string, options?: {
|
|
82
|
+
withCounts?: boolean;
|
|
83
|
+
withExpiration?: boolean;
|
|
84
|
+
guildScheduledEventId?: string;
|
|
85
|
+
}): Promise<Record<string, unknown>>;
|
|
86
|
+
/** Fetches a sticker from Discord. */
|
|
87
|
+
fetchSticker(id: string): Promise<Record<string, unknown>>;
|
|
88
|
+
/** Fetches premium sticker packs from Discord. */
|
|
89
|
+
fetchPremiumStickerPacks(): Promise<Record<string, unknown>>;
|
|
90
|
+
/** Fetches a guild template from Discord. */
|
|
91
|
+
fetchGuildTemplate(code: string): Promise<Record<string, unknown>>;
|
|
92
|
+
/** Generates an invite link for this client. */
|
|
93
|
+
generateInvite(options?: {
|
|
94
|
+
scopes?: string[];
|
|
95
|
+
permissions?: string | bigint;
|
|
96
|
+
}): string;
|
|
61
97
|
}
|
|
62
98
|
export type ClientEvents = {
|
|
63
99
|
ready: [user: ClientUser];
|
|
100
|
+
resumed: [];
|
|
101
|
+
invalidSession: [isRecoverable: boolean];
|
|
64
102
|
raw: [data: {
|
|
65
103
|
event: string;
|
|
66
104
|
data: unknown;
|