@kyvrixon/utils 1.4.1 → 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.1",
4
+ "version": "1.4.2",
5
5
  "type": "module",
6
6
  "private": false,
7
7
  "license": "MIT",
@@ -27,7 +27,7 @@
27
27
  },
28
28
  "dependencies": {
29
29
  "chalk": "5.6.2",
30
- "discord.js": "14.26.0"
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.
@@ -11,48 +11,50 @@ import type { Client, ClientEvents, RestEvents } from "discord.js";
11
11
  * }
12
12
  */
13
13
  // biome-ignore lint/suspicious/noEmptyInterface: It's fine
14
- export interface DiscordEventCustomType {}
14
+ export interface DiscordEventCustomType {
15
+ }
15
16
 
16
17
  /** Maps an event type discriminant to its corresponding event map. */
17
18
  export type EventMap<T extends "client" | "rest" | "custom"> =
18
- T extends "client"
19
- ? ClientEvents
20
- : T extends "rest"
21
- ? RestEvents
22
- : keyof DiscordEventCustomType extends never
23
- ? { "sooo.. there's no custom events..": [] }
24
- : DiscordEventCustomType;
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;
25
26
 
26
27
  /** Resolves the argument tuple for a given event type + key pair. */
27
28
  export type EventArgs<
28
- T extends "client" | "rest" | "custom",
29
- K extends keyof EventMap<T>,
29
+ T extends "client" | "rest" | "custom",
30
+ K extends keyof EventMap<T>,
30
31
  > = Extract<EventMap<T>[K], any[]>;
31
32
 
32
33
  /**
33
34
  * Wraps a discord.js event handler. Supports `"client"`, `"rest"`, and `"custom"` event types.
34
35
  */
35
36
  export class DiscordEvent<
36
- T extends "client" | "rest" | "custom",
37
- 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>,
38
40
  > {
39
- public readonly type: T;
40
- public readonly name: K;
41
- public readonly once: boolean;
42
- public readonly method: (
43
- client: Client<true>,
44
- ...args: EventArgs<T, K>
45
- ) => 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>;
46
48
 
47
- constructor(opts: {
48
- type: T;
49
- name: K;
50
- once: boolean;
51
- method: DiscordEvent<T, K>["method"];
52
- }) {
53
- this.type = opts.type;
54
- this.name = opts.name;
55
- this.once = opts.once;
56
- this.method = opts.method;
57
- }
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
+ }
58
60
  }