@kyvrixon/utils 1.4.2 → 1.4.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.
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.2",
4
+ "version": "1.4.4",
5
5
  "type": "module",
6
6
  "private": false,
7
7
  "license": "MIT",
@@ -21,13 +21,15 @@
21
21
  },
22
22
  "types": "./src/index.ts",
23
23
  "devDependencies": {
24
- "@biomejs/biome": "2.4.10",
25
- "@types/bun": "1.3.11",
26
- "typescript": "6.0.2"
24
+ "@biomejs/biome": "^2.4.10",
25
+ "@types/bun": "^1.3.11",
26
+ "typescript": "^6.0.2"
27
27
  },
28
28
  "dependencies": {
29
- "chalk": "5.6.2",
30
- "discord.js": "14.26.2"
29
+ "chalk": "^5.6.2"
30
+ },
31
+ "peerDependencies": {
32
+ "discord.js": "^14.26.2"
31
33
  },
32
34
  "exports": {
33
35
  ".": {
@@ -7,6 +7,11 @@ import type {
7
7
  SlashCommandSubcommandsOnlyBuilder,
8
8
  } from "discord.js";
9
9
 
10
+ export type CommandData =
11
+ | SlashCommandBuilder
12
+ | SlashCommandOptionsOnlyBuilder
13
+ | SlashCommandSubcommandsOnlyBuilder;
14
+
10
15
  export interface DiscordCommandMetadata extends Record<string, unknown> {}
11
16
 
12
17
  /**
@@ -21,11 +26,8 @@ export interface DiscordCommandMetadata extends Record<string, unknown> {}
21
26
  * }
22
27
  * }
23
28
  */
24
- export class DiscordCommand<C extends Client> {
25
- public readonly data:
26
- | SlashCommandBuilder
27
- | SlashCommandOptionsOnlyBuilder
28
- | SlashCommandSubcommandsOnlyBuilder;
29
+ export class DiscordCommand<C extends Client = Client> {
30
+ public readonly data: CommandData;
29
31
  public readonly execute: (
30
32
  client: C,
31
33
  interaction: ChatInputCommandInteraction,
@@ -37,10 +39,16 @@ export class DiscordCommand<C extends Client> {
37
39
  public metadata: DiscordCommandMetadata;
38
40
 
39
41
  constructor(ops: {
40
- data: DiscordCommand<C>["data"];
41
- metadata: DiscordCommand<C>["metadata"];
42
- execute: DiscordCommand<C>["execute"];
43
- autocomplete?: DiscordCommand<C>["autocomplete"];
42
+ data: CommandData;
43
+ metadata: DiscordCommandMetadata;
44
+ execute: (
45
+ client: C,
46
+ interaction: ChatInputCommandInteraction,
47
+ ) => Promise<void>;
48
+ autocomplete?: (
49
+ client: C,
50
+ interaction: AutocompleteInteraction,
51
+ ) => Promise<void>;
44
52
  }) {
45
53
  this.data = ops.data;
46
54
  this.metadata = ops.metadata;
@@ -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,50 +11,49 @@ 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 {
15
- }
14
+ export interface DiscordEventCustomType {}
16
15
 
17
16
  /** Maps an event type discriminant to its corresponding event map. */
18
17
  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;
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;
26
25
 
27
26
  /** Resolves the argument tuple for a given event type + key pair. */
28
27
  export type EventArgs<
29
- T extends "client" | "rest" | "custom",
30
- K extends keyof EventMap<T>,
28
+ T extends "client" | "rest" | "custom",
29
+ K extends keyof EventMap<T>,
31
30
  > = Extract<EventMap<T>[K], any[]>;
32
31
 
33
32
  /**
34
33
  * Wraps a discord.js event handler. Supports `"client"`, `"rest"`, and `"custom"` event types.
35
34
  */
36
35
  export class DiscordEvent<
37
- C extends Client,
38
- T extends "client" | "rest" | "custom",
39
- K extends keyof EventMap<T> = keyof EventMap<T>,
36
+ T extends "client" | "rest" | "custom",
37
+ K extends keyof EventMap<T> = keyof EventMap<T>,
38
+ C extends Client = Client,
40
39
  > {
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>;
40
+ public readonly type: T;
41
+ public readonly name: K;
42
+ public readonly once: boolean;
43
+ public readonly method: (
44
+ client: C,
45
+ ...args: EventArgs<T, K>
46
+ ) => void | Promise<void>;
48
47
 
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
- }
48
+ constructor(opts: {
49
+ type: T;
50
+ name: K;
51
+ once: boolean;
52
+ method: (client: C, ...args: EventArgs<T, K>) => void | Promise<void>;
53
+ }) {
54
+ this.type = opts.type;
55
+ this.name = opts.name;
56
+ this.once = opts.once;
57
+ this.method = opts.method;
58
+ }
60
59
  }