seyfert 2.1.1-dev-11316886063.0 → 2.1.1-dev-11317878487.0

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.
@@ -37,12 +37,15 @@ export type OptionsRecord = Record<string, CommandOptionWithoutName & {
37
37
  type: ApplicationCommandOptionType;
38
38
  }>;
39
39
  type KeysWithoutRequired<T extends OptionsRecord> = {
40
- [K in keyof T]-?: T[K]['required'] extends true ? never : K;
40
+ [K in keyof T]-?: NonNullable<T[K]['required']> extends true ? never : K;
41
41
  }[keyof T];
42
+ type ContextOptionsAuxInternal<T extends CommandBaseOption & {
43
+ type: ApplicationCommandOptionType;
44
+ }> = T['value'] extends (...args: any) => any ? Parameters<Parameters<T['value']>[1]>[0] : NonNullable<T['value']> extends (...args: any) => any ? Parameters<Parameters<NonNullable<T['value']>>[1]>[0] extends never ? T extends SeyfertStringOption | SeyfertNumberOption ? NonNullable<T['choices']> extends SeyfertChoice<string | number>[] ? NonNullable<T['choices']>[number]['value'] : ReturnOptionsTypes[T['type']] : ReturnOptionsTypes[T['type']] : Parameters<Parameters<NonNullable<T['value']>>[1]>[0] : T extends SeyfertStringOption | SeyfertNumberOption ? NonNullable<T['choices']> extends SeyfertChoice<string | number>[] ? NonNullable<T['choices']>[number]['value'] : ReturnOptionsTypes[T['type']] : ReturnOptionsTypes[T['type']];
42
45
  type ContextOptionsAux<T extends OptionsRecord> = {
43
- [K in Exclude<keyof T, KeysWithoutRequired<T>>]: T[K]['value'] extends (...args: any) => any ? Parameters<Parameters<T[K]['value']>[1]>[0] : T[K] extends SeyfertStringOption | SeyfertNumberOption ? NonNullable<T[K]['choices']> extends SeyfertChoice<string | number>[] ? NonNullable<T[K]['choices']>[number]['value'] : ReturnOptionsTypes[T[K]['type']] : ReturnOptionsTypes[T[K]['type']];
46
+ [K in Exclude<keyof T, KeysWithoutRequired<T>>]: ContextOptionsAuxInternal<T[K]>;
44
47
  } & {
45
- [K in KeysWithoutRequired<T>]?: T[K]['value'] extends (...args: any) => any ? Parameters<Parameters<T[K]['value']>[1]>[0] : T[K] extends SeyfertStringOption | SeyfertNumberOption ? NonNullable<T[K]['choices']> extends SeyfertChoice<string | number>[] ? NonNullable<T[K]['choices']>[number]['value'] : ReturnOptionsTypes[T[K]['type']] : ReturnOptionsTypes[T[K]['type']];
48
+ [K in KeysWithoutRequired<T>]?: ContextOptionsAuxInternal<T[K]>;
46
49
  };
47
50
  export type ContextOptions<T extends OptionsRecord> = ContextOptionsAux<T>;
48
51
  export declare class BaseCommand {
@@ -6,8 +6,8 @@ import type { MessageCommandInteraction, UserCommandInteraction } from '../../st
6
6
  import { type APIApplicationCommandBasicOption, type APIApplicationCommandOptionChoice, ApplicationCommandOptionType, type ChannelType } from '../../types';
7
7
  import type { CommandContext } from './chatcontext';
8
8
  import type { DefaultLocale, MiddlewareContext, OKFunction, StopFunction } from './shared';
9
- export interface SeyfertBasicOption<T extends keyof ReturnOptionsTypes> {
10
- required?: boolean;
9
+ export interface SeyfertBasicOption<T extends keyof ReturnOptionsTypes, R = true | false> {
10
+ required?: R;
11
11
  value?(data: {
12
12
  context: CommandContext;
13
13
  value: ReturnOptionsTypes[T];
@@ -20,10 +20,10 @@ export interface SeyfertBasicOption<T extends keyof ReturnOptionsTypes> {
20
20
  description?: FlatObjectKeys<DefaultLocale>;
21
21
  };
22
22
  }
23
- export interface SeyfertBaseChoiceableOption<T extends keyof ReturnOptionsTypes, C = T extends ChoiceableTypes ? SeyfertChoice<ChoiceableValues[T]>[] : never> {
24
- required?: boolean;
23
+ export interface SeyfertBaseChoiceableOption<T extends keyof ReturnOptionsTypes, C = T extends ChoiceableTypes ? SeyfertChoice<ChoiceableValues[T]>[] : never, R = true | false, VC = never> {
24
+ required?: R;
25
25
  choices?: C;
26
- value?: ValueCallback<T, C>;
26
+ value?: ValueCallback<T, C, VC>;
27
27
  description: string;
28
28
  description_localizations?: APIApplicationCommandBasicOption['description_localizations'];
29
29
  name_localizations?: APIApplicationCommandBasicOption['name_localizations'];
@@ -42,41 +42,41 @@ export interface ChoiceableValues {
42
42
  [ApplicationCommandOptionType.Number]: number;
43
43
  [ApplicationCommandOptionType.Integer]: number;
44
44
  }
45
- export type ValueCallback<T extends keyof ReturnOptionsTypes, C = T extends ChoiceableTypes ? SeyfertChoice<ChoiceableValues[T]>[] : never> = (data: {
45
+ export type ValueCallback<T extends keyof ReturnOptionsTypes, C = T extends ChoiceableTypes ? SeyfertChoice<ChoiceableValues[T]>[] : never, I = any> = (data: {
46
46
  context: CommandContext;
47
47
  value: T extends ChoiceableTypes ? C extends SeyfertChoice<ChoiceableValues[T]>[] ? C[number]['value'] extends ReturnOptionsTypes[T] ? C[number]['value'] : ReturnOptionsTypes[T] : ReturnOptionsTypes[T] : ReturnOptionsTypes[T];
48
- }, ok: OKFunction<any>, fail: StopFunction) => Awaitable<void>;
49
- export type SeyfertStringOption<T = SeyfertChoice<string>[]> = SeyfertBaseChoiceableOption<ApplicationCommandOptionType.String, T> & {
48
+ }, ok: OKFunction<I>, fail: StopFunction) => Awaitable<void>;
49
+ export type SeyfertStringOption<T = SeyfertChoice<string>[], R = boolean, VC = never> = SeyfertBaseChoiceableOption<ApplicationCommandOptionType.String, T, R, VC> & {
50
50
  autocomplete?: AutocompleteCallback;
51
51
  onAutocompleteError?: OnAutocompleteErrorCallback;
52
52
  min_length?: number;
53
53
  max_length?: number;
54
54
  };
55
- export type SeyfertIntegerOption<T = SeyfertChoice<number>[]> = SeyfertBaseChoiceableOption<ApplicationCommandOptionType.Integer, T> & {
55
+ export type SeyfertIntegerOption<T = SeyfertChoice<number>[], R = boolean, VC = never> = SeyfertBaseChoiceableOption<ApplicationCommandOptionType.Integer, T, R, VC> & {
56
56
  autocomplete?: AutocompleteCallback;
57
57
  onAutocompleteError?: OnAutocompleteErrorCallback;
58
58
  min_value?: number;
59
59
  max_value?: number;
60
60
  };
61
- export type SeyfertNumberOption<T = SeyfertChoice<number>[]> = SeyfertBaseChoiceableOption<ApplicationCommandOptionType.Number, T> & {
61
+ export type SeyfertNumberOption<T = SeyfertChoice<number>[], R = boolean, VC = never> = SeyfertBaseChoiceableOption<ApplicationCommandOptionType.Number, T, R, VC> & {
62
62
  autocomplete?: AutocompleteCallback;
63
63
  onAutocompleteError?: OnAutocompleteErrorCallback;
64
64
  min_value?: number;
65
65
  max_value?: number;
66
66
  };
67
- export type SeyfertBooleanOption = SeyfertBasicOption<ApplicationCommandOptionType.Boolean>;
68
- export type SeyfertUserOption = SeyfertBasicOption<ApplicationCommandOptionType.User>;
69
- export type SeyfertChannelOption = SeyfertBasicOption<ApplicationCommandOptionType.Channel> & {
67
+ export type SeyfertBooleanOption<R = boolean> = SeyfertBasicOption<ApplicationCommandOptionType.Boolean, R>;
68
+ export type SeyfertUserOption<R = boolean> = SeyfertBasicOption<ApplicationCommandOptionType.User, R>;
69
+ export type SeyfertChannelOption<R = boolean> = SeyfertBasicOption<ApplicationCommandOptionType.Channel, R> & {
70
70
  channel_types?: ChannelType[];
71
71
  };
72
- export type SeyfertRoleOption = SeyfertBasicOption<ApplicationCommandOptionType.Role>;
73
- export type SeyfertMentionableOption = SeyfertBasicOption<ApplicationCommandOptionType.Mentionable>;
74
- export type SeyfertAttachmentOption = SeyfertBasicOption<ApplicationCommandOptionType.Attachment>;
75
- export declare function createStringOption<C extends SeyfertChoice<string>[] = SeyfertChoice<string>[]>(data: SeyfertStringOption<C>): {
72
+ export type SeyfertRoleOption<R = boolean> = SeyfertBasicOption<ApplicationCommandOptionType.Role, R>;
73
+ export type SeyfertMentionableOption<R = boolean> = SeyfertBasicOption<ApplicationCommandOptionType.Mentionable, R>;
74
+ export type SeyfertAttachmentOption<R = boolean> = SeyfertBasicOption<ApplicationCommandOptionType.Attachment, R>;
75
+ export declare function createStringOption<R extends boolean, C extends SeyfertChoice<string>[] = SeyfertChoice<string>[], VC = never>(data: SeyfertStringOption<C, R, VC>): {
76
76
  readonly type: ApplicationCommandOptionType.String;
77
- readonly required?: boolean;
77
+ readonly required?: R | undefined;
78
78
  readonly choices?: C | undefined;
79
- readonly value?: ValueCallback<ApplicationCommandOptionType.String, C> | undefined;
79
+ readonly value?: ValueCallback<ApplicationCommandOptionType.String, C, VC> | undefined;
80
80
  readonly description: string;
81
81
  readonly description_localizations?: APIApplicationCommandBasicOption["description_localizations"];
82
82
  readonly name_localizations?: APIApplicationCommandBasicOption["name_localizations"];
@@ -89,11 +89,11 @@ export declare function createStringOption<C extends SeyfertChoice<string>[] = S
89
89
  readonly min_length?: number;
90
90
  readonly max_length?: number;
91
91
  };
92
- export declare function createIntegerOption<C extends SeyfertChoice<number>[] = SeyfertChoice<number>[]>(data: SeyfertIntegerOption<C>): {
92
+ export declare function createIntegerOption<R extends boolean, C extends SeyfertChoice<number>[] = SeyfertChoice<number>[], VC = never>(data: SeyfertIntegerOption<C, R, VC>): {
93
93
  readonly type: ApplicationCommandOptionType.Integer;
94
- readonly required?: boolean;
94
+ readonly required?: R | undefined;
95
95
  readonly choices?: C | undefined;
96
- readonly value?: ValueCallback<ApplicationCommandOptionType.Integer, C> | undefined;
96
+ readonly value?: ValueCallback<ApplicationCommandOptionType.Integer, C, VC> | undefined;
97
97
  readonly description: string;
98
98
  readonly description_localizations?: APIApplicationCommandBasicOption["description_localizations"];
99
99
  readonly name_localizations?: APIApplicationCommandBasicOption["name_localizations"];
@@ -106,11 +106,11 @@ export declare function createIntegerOption<C extends SeyfertChoice<number>[] =
106
106
  readonly min_value?: number;
107
107
  readonly max_value?: number;
108
108
  };
109
- export declare function createNumberOption<C extends SeyfertChoice<number>[] = SeyfertChoice<number>[]>(data: SeyfertNumberOption<C>): {
109
+ export declare function createNumberOption<R extends boolean, C extends SeyfertChoice<number>[] = SeyfertChoice<number>[], VC = never>(data: SeyfertNumberOption<C, R, VC>): {
110
110
  readonly type: ApplicationCommandOptionType.Number;
111
- readonly required?: boolean;
111
+ readonly required?: R | undefined;
112
112
  readonly choices?: C | undefined;
113
- readonly value?: ValueCallback<ApplicationCommandOptionType.Number, C> | undefined;
113
+ readonly value?: ValueCallback<ApplicationCommandOptionType.Number, C, VC> | undefined;
114
114
  readonly description: string;
115
115
  readonly description_localizations?: APIApplicationCommandBasicOption["description_localizations"];
116
116
  readonly name_localizations?: APIApplicationCommandBasicOption["name_localizations"];
@@ -123,22 +123,22 @@ export declare function createNumberOption<C extends SeyfertChoice<number>[] = S
123
123
  readonly min_value?: number;
124
124
  readonly max_value?: number;
125
125
  };
126
- export declare function createBooleanOption<T extends SeyfertBooleanOption = SeyfertBooleanOption>(data: T): T & {
126
+ export declare function createBooleanOption<R extends boolean, T extends SeyfertBooleanOption<R> = SeyfertBooleanOption<R>>(data: T): T & {
127
127
  readonly type: ApplicationCommandOptionType.Boolean;
128
128
  };
129
- export declare function createUserOption<T extends SeyfertUserOption = SeyfertUserOption>(data: T): T & {
129
+ export declare function createUserOption<R extends boolean, T extends SeyfertUserOption<R> = SeyfertUserOption<R>>(data: T): T & {
130
130
  readonly type: ApplicationCommandOptionType.User;
131
131
  };
132
- export declare function createChannelOption<T extends SeyfertChannelOption = SeyfertChannelOption>(data: T): T & {
132
+ export declare function createChannelOption<R extends boolean, T extends SeyfertChannelOption<R> = SeyfertChannelOption<R>>(data: T): T & {
133
133
  readonly type: ApplicationCommandOptionType.Channel;
134
134
  };
135
- export declare function createRoleOption<T extends SeyfertRoleOption = SeyfertRoleOption>(data: T): T & {
135
+ export declare function createRoleOption<R extends boolean, T extends SeyfertRoleOption<R> = SeyfertRoleOption<R>>(data: T): T & {
136
136
  readonly type: ApplicationCommandOptionType.Role;
137
137
  };
138
- export declare function createMentionableOption<T extends SeyfertMentionableOption = SeyfertMentionableOption>(data: T): T & {
138
+ export declare function createMentionableOption<R extends boolean, T extends SeyfertMentionableOption<R> = SeyfertMentionableOption<R>>(data: T): T & {
139
139
  readonly type: ApplicationCommandOptionType.Mentionable;
140
140
  };
141
- export declare function createAttachmentOption<T extends SeyfertAttachmentOption = SeyfertAttachmentOption>(data: T): T & {
141
+ export declare function createAttachmentOption<R extends boolean, T extends SeyfertAttachmentOption<R> = SeyfertAttachmentOption<R>>(data: T): T & {
142
142
  readonly type: ApplicationCommandOptionType.Attachment;
143
143
  };
144
144
  export type AnyContext = CommandContext | MenuCommandContext<MessageCommandInteraction<boolean> | UserCommandInteraction<boolean>> | ComponentContext | ModalContext | EntryPointContext;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "seyfert",
3
- "version": "2.1.1-dev-11316886063.0",
3
+ "version": "2.1.1-dev-11317878487.0",
4
4
  "description": "The most advanced framework for discord bots",
5
5
  "main": "./lib/index.js",
6
6
  "module": "./lib/index.js",