@kyvrixon/utils 1.4.0 → 1.4.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.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@kyvrixon/utils",
3
3
  "main": "./src/index.ts",
4
- "version": "1.4.0",
4
+ "version": "1.4.2",
5
5
  "type": "module",
6
6
  "private": false,
7
7
  "license": "MIT",
@@ -21,13 +21,13 @@
21
21
  },
22
22
  "types": "./src/index.ts",
23
23
  "devDependencies": {
24
- "@biomejs/biome": "2.4.9",
24
+ "@biomejs/biome": "2.4.10",
25
25
  "@types/bun": "1.3.11",
26
26
  "typescript": "6.0.2"
27
27
  },
28
28
  "dependencies": {
29
29
  "chalk": "5.6.2",
30
- "discord.js": "14.25.1"
30
+ "discord.js": "14.26.2"
31
31
  },
32
32
  "exports": {
33
33
  ".": {
@@ -1,5 +1,5 @@
1
1
  /** biome-ignore-all lint/suspicious/noExplicitAny: Its fine */
2
- import type { Client, ClientEvents, RestEvents } from "discord.js";
2
+ import type {Client, ClientEvents, RestEvents} from "discord.js";
3
3
 
4
4
  /**
5
5
  * Augment this interface via module declaration to register custom event types.
@@ -10,52 +10,51 @@ import type { Client, ClientEvents, RestEvents } from "discord.js";
10
10
  * }
11
11
  * }
12
12
  */
13
- // biome-ignore lint/suspicious/noEmptyInterface: Its fine
14
- export interface DiscordEventCustomType {}
13
+ // biome-ignore lint/suspicious/noEmptyInterface: It's fine
14
+ export interface DiscordEventCustomType {
15
+ }
15
16
 
16
17
  /** Maps an event type discriminant to its corresponding event map. */
17
- type EventMap<T extends "client" | "rest" | "custom"> = T extends "client"
18
- ? ClientEvents
19
- : T extends "rest"
20
- ? RestEvents
21
- : keyof DiscordEventCustomType extends never
22
- ? { "sooo.. there's no custom events..": [] }
23
- : DiscordEventCustomType;
18
+ export type EventMap<T extends "client" | "rest" | "custom"> =
19
+ T extends "client"
20
+ ? ClientEvents
21
+ : T extends "rest"
22
+ ? RestEvents
23
+ : keyof DiscordEventCustomType extends never
24
+ ? { "sooo.. there's no custom events..": [] }
25
+ : DiscordEventCustomType;
24
26
 
25
27
  /** Resolves the argument tuple for a given event type + key pair. */
26
- type EventArgs<
27
- T extends "client" | "rest" | "custom",
28
- K extends keyof EventMap<T>,
28
+ export type EventArgs<
29
+ T extends "client" | "rest" | "custom",
30
+ K extends keyof EventMap<T>,
29
31
  > = Extract<EventMap<T>[K], any[]>;
30
32
 
31
33
  /**
32
34
  * Wraps a discord.js event handler. Supports `"client"`, `"rest"`, and `"custom"` event types.
33
- * @typeParam V - The bot's `Client` type.
34
- * @typeParam T - The event source discriminant.
35
- * @typeParam K - The event name within the chosen source.
36
35
  */
37
36
  export class DiscordEvent<
38
- V extends Client,
39
- T extends "client" | "rest" | "custom",
40
- K extends keyof EventMap<T> = keyof EventMap<T>,
37
+ C extends Client,
38
+ T extends "client" | "rest" | "custom",
39
+ K extends keyof EventMap<T> = keyof EventMap<T>,
41
40
  > {
42
- public readonly type: T;
43
- public readonly name: K;
44
- public readonly once: boolean;
45
- public readonly method: (
46
- client: V,
47
- ...args: EventArgs<T, K>
48
- ) => void | Promise<void>;
41
+ public readonly type: T;
42
+ public readonly name: K;
43
+ public readonly once: boolean;
44
+ public readonly method: (
45
+ client: C,
46
+ ...args: EventArgs<T, K>
47
+ ) => void | Promise<void>;
49
48
 
50
- constructor(opts: {
51
- type: T;
52
- name: K;
53
- once: boolean;
54
- method: DiscordEvent<V, T, K>["method"];
55
- }) {
56
- this.type = opts.type;
57
- this.name = opts.name;
58
- this.once = opts.once;
59
- this.method = opts.method;
60
- }
49
+ constructor(opts: {
50
+ type: T;
51
+ name: K;
52
+ once: boolean;
53
+ method: (client: C, ...args: EventArgs<T, K>) => void | Promise<void>;
54
+ }) {
55
+ this.type = opts.type;
56
+ this.name = opts.name;
57
+ this.once = opts.once;
58
+ this.method = opts.method;
59
+ }
61
60
  }