seyfert 2.1.1-dev-11310514874.0 → 2.1.1-dev-11316886063.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.
@@ -1,12 +1,11 @@
1
- import type { PermissionStrings, SeyfertNumberOption, SeyfertStringOption } from '../..';
1
+ import type { PermissionStrings, SeyfertBaseChoiceableOption, SeyfertBasicOption, SeyfertChoice, SeyfertNumberOption, SeyfertStringOption } from '../..';
2
2
  import type { Attachment } from '../../builders';
3
3
  import type { GuildRoleStructure, InteractionGuildMemberStructure, UserStructure } from '../../client/transformers';
4
- import { type Awaitable, type FlatObjectKeys } from '../../common';
5
4
  import type { AllChannels, AutocompleteInteraction } from '../../structures';
6
5
  import { type APIApplicationCommandBasicOption, type APIApplicationCommandOption, ApplicationCommandOptionType, ApplicationCommandType, type ApplicationIntegrationType, type InteractionContextType, type LocaleString } from '../../types';
7
6
  import type { Groups, RegisteredMiddlewares } from '../decorators';
8
7
  import type { CommandContext } from './chatcontext';
9
- import type { DefaultLocale, ExtraProps, IgnoreCommand, OKFunction, OnOptionsReturnObject, StopFunction, UsingClient } from './shared';
8
+ import type { ExtraProps, IgnoreCommand, OnOptionsReturnObject, UsingClient } from './shared';
10
9
  export interface ReturnOptionsTypes {
11
10
  1: never;
12
11
  2: never;
@@ -20,49 +19,30 @@ export interface ReturnOptionsTypes {
20
19
  10: number;
21
20
  11: Attachment;
22
21
  }
23
- type Wrap<N extends ApplicationCommandOptionType> = N extends ApplicationCommandOptionType.Subcommand | ApplicationCommandOptionType.SubcommandGroup ? never : {
24
- required?: boolean;
25
- value?(data: {
26
- context: CommandContext;
27
- value: ReturnOptionsTypes[N];
28
- }, ok: OKFunction<any>, fail: StopFunction): Awaitable<void>;
29
- } & {
30
- description: string;
31
- description_localizations?: APIApplicationCommandBasicOption['description_localizations'];
32
- name_localizations?: APIApplicationCommandBasicOption['name_localizations'];
33
- locales?: {
34
- name?: FlatObjectKeys<DefaultLocale>;
35
- description?: FlatObjectKeys<DefaultLocale>;
36
- };
37
- };
38
- export type __TypeWrapper<T extends ApplicationCommandOptionType> = Wrap<T>;
39
- export type __TypesWrapper = {
40
- [P in keyof typeof ApplicationCommandOptionType]: `${(typeof ApplicationCommandOptionType)[P]}` extends `${infer D extends number}` ? Wrap<D> : never;
41
- };
42
22
  export type AutocompleteCallback = (interaction: AutocompleteInteraction) => any;
43
23
  export type OnAutocompleteErrorCallback = (interaction: AutocompleteInteraction, error: unknown) => any;
44
- export type CommandBaseOption = __TypesWrapper[keyof __TypesWrapper];
45
- export type CommandBaseAutocompleteOption = __TypesWrapper[keyof __TypesWrapper] & {
24
+ export type CommandBaseOption = SeyfertBaseChoiceableOption<ApplicationCommandOptionType> | SeyfertBasicOption<ApplicationCommandOptionType>;
25
+ export type CommandBaseAutocompleteOption = (SeyfertBasicOption<ApplicationCommandOptionType> | SeyfertBaseChoiceableOption<ApplicationCommandOptionType>) & {
46
26
  autocomplete: AutocompleteCallback;
47
27
  onAutocompleteError?: OnAutocompleteErrorCallback;
48
28
  };
49
29
  export type CommandAutocompleteOption = CommandBaseAutocompleteOption & {
50
30
  name: string;
51
31
  };
52
- export type __CommandOption = CommandBaseOption;
53
- export type CommandOption = __CommandOption & {
32
+ export type CommandOptionWithoutName = CommandBaseOption;
33
+ export type CommandOption = CommandOptionWithoutName & {
54
34
  name: string;
55
35
  };
56
- export type OptionsRecord = Record<string, __CommandOption & {
36
+ export type OptionsRecord = Record<string, CommandOptionWithoutName & {
57
37
  type: ApplicationCommandOptionType;
58
38
  }>;
59
39
  type KeysWithoutRequired<T extends OptionsRecord> = {
60
40
  [K in keyof T]-?: T[K]['required'] extends true ? never : K;
61
41
  }[keyof T];
62
42
  type ContextOptionsAux<T extends OptionsRecord> = {
63
- [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 ? T[K]['choices'] extends NonNullable<SeyfertStringOption['choices'] | SeyfertNumberOption['choices']> ? T[K]['choices'][number]['value'] : ReturnOptionsTypes[T[K]['type']] : ReturnOptionsTypes[T[K]['type']];
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']];
64
44
  } & {
65
- [K in KeysWithoutRequired<T>]?: T[K]['value'] extends (...args: any) => any ? Parameters<Parameters<T[K]['value']>[1]>[0] : T[K] extends SeyfertStringOption | SeyfertNumberOption ? T[K]['choices'] extends NonNullable<SeyfertStringOption['choices'] | SeyfertNumberOption['choices']> ? T[K]['choices'][number]['value'] : ReturnOptionsTypes[T[K]['type']] : ReturnOptionsTypes[T[K]['type']];
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']];
66
46
  };
67
47
  export type ContextOptions<T extends OptionsRecord> = ContextOptionsAux<T>;
68
48
  export declare class BaseCommand {
@@ -1,48 +1,127 @@
1
- import type { AutocompleteCallback, EntryPointContext, MenuCommandContext, OnAutocompleteErrorCallback, ReturnOptionsTypes, __TypesWrapper } from '..';
1
+ import type { AutocompleteCallback, EntryPointContext, MenuCommandContext, OnAutocompleteErrorCallback, ReturnOptionsTypes } from '..';
2
+ import type { Awaitable, FlatObjectKeys } from '../../common';
2
3
  import type { ModalContext } from '../../components';
3
4
  import type { ComponentContext } from '../../components/componentcontext';
4
5
  import type { MessageCommandInteraction, UserCommandInteraction } from '../../structures';
5
- import { type APIApplicationCommandOptionChoice, ApplicationCommandOptionType, type ChannelType } from '../../types';
6
+ import { type APIApplicationCommandBasicOption, type APIApplicationCommandOptionChoice, ApplicationCommandOptionType, type ChannelType } from '../../types';
6
7
  import type { CommandContext } from './chatcontext';
7
- import type { MiddlewareContext } from './shared';
8
- export type SeyfertBasicOption<T extends keyof __TypesWrapper, D = object> = __TypesWrapper[T] & D;
9
- export type SeyfertStringOption = SeyfertBasicOption<'String'> & {
8
+ import type { DefaultLocale, MiddlewareContext, OKFunction, StopFunction } from './shared';
9
+ export interface SeyfertBasicOption<T extends keyof ReturnOptionsTypes> {
10
+ required?: boolean;
11
+ value?(data: {
12
+ context: CommandContext;
13
+ value: ReturnOptionsTypes[T];
14
+ }, ok: OKFunction<any>, fail: StopFunction): Awaitable<void>;
15
+ description: string;
16
+ description_localizations?: APIApplicationCommandBasicOption['description_localizations'];
17
+ name_localizations?: APIApplicationCommandBasicOption['name_localizations'];
18
+ locales?: {
19
+ name?: FlatObjectKeys<DefaultLocale>;
20
+ description?: FlatObjectKeys<DefaultLocale>;
21
+ };
22
+ }
23
+ export interface SeyfertBaseChoiceableOption<T extends keyof ReturnOptionsTypes, C = T extends ChoiceableTypes ? SeyfertChoice<ChoiceableValues[T]>[] : never> {
24
+ required?: boolean;
25
+ choices?: C;
26
+ value?: ValueCallback<T, C>;
27
+ description: string;
28
+ description_localizations?: APIApplicationCommandBasicOption['description_localizations'];
29
+ name_localizations?: APIApplicationCommandBasicOption['name_localizations'];
30
+ locales?: {
31
+ name?: FlatObjectKeys<DefaultLocale>;
32
+ description?: FlatObjectKeys<DefaultLocale>;
33
+ };
34
+ }
35
+ export type SeyfertChoice<T extends string | number> = {
36
+ readonly name: string;
37
+ readonly value: T;
38
+ } | APIApplicationCommandOptionChoice<T>;
39
+ export type ChoiceableTypes = ApplicationCommandOptionType.String | ApplicationCommandOptionType.Integer | ApplicationCommandOptionType.Number;
40
+ export interface ChoiceableValues {
41
+ [ApplicationCommandOptionType.String]: string;
42
+ [ApplicationCommandOptionType.Number]: number;
43
+ [ApplicationCommandOptionType.Integer]: number;
44
+ }
45
+ export type ValueCallback<T extends keyof ReturnOptionsTypes, C = T extends ChoiceableTypes ? SeyfertChoice<ChoiceableValues[T]>[] : never> = (data: {
46
+ context: CommandContext;
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> & {
10
50
  autocomplete?: AutocompleteCallback;
11
51
  onAutocompleteError?: OnAutocompleteErrorCallback;
12
- choices?: readonly {
13
- readonly name: string;
14
- readonly value: string;
15
- }[] | APIApplicationCommandOptionChoice<ReturnOptionsTypes[ApplicationCommandOptionType.String]>[];
16
52
  min_length?: number;
17
53
  max_length?: number;
18
54
  };
19
- export type SeyfertIntegerOption = SeyfertBasicOption<'Integer'> & {
55
+ export type SeyfertIntegerOption<T = SeyfertChoice<number>[]> = SeyfertBaseChoiceableOption<ApplicationCommandOptionType.Integer, T> & {
20
56
  autocomplete?: AutocompleteCallback;
21
57
  onAutocompleteError?: OnAutocompleteErrorCallback;
22
- choices?: APIApplicationCommandOptionChoice<ReturnOptionsTypes[ApplicationCommandOptionType.Integer]>[];
23
58
  min_value?: number;
24
59
  max_value?: number;
25
60
  };
26
- export type SeyfertBooleanOption = SeyfertBasicOption<'Boolean'>;
27
- export type SeyfertUserOption = SeyfertBasicOption<'User'>;
28
- export type SeyfertChannelOption = SeyfertBasicOption<'Channel'> & {
29
- channel_types?: ChannelType[];
30
- };
31
- export type SeyfertRoleOption = SeyfertBasicOption<'Role'>;
32
- export type SeyfertMentionableOption = SeyfertBasicOption<'Mentionable'>;
33
- export type SeyfertNumberOption = SeyfertBasicOption<'Number'> & {
61
+ export type SeyfertNumberOption<T = SeyfertChoice<number>[]> = SeyfertBaseChoiceableOption<ApplicationCommandOptionType.Number, T> & {
34
62
  autocomplete?: AutocompleteCallback;
35
63
  onAutocompleteError?: OnAutocompleteErrorCallback;
36
- choices?: APIApplicationCommandOptionChoice<ReturnOptionsTypes[ApplicationCommandOptionType.Number]>[];
37
64
  min_value?: number;
38
65
  max_value?: number;
39
66
  };
40
- export type SeyfertAttachmentOption = SeyfertBasicOption<'Attachment'>;
41
- export declare function createStringOption<T extends SeyfertStringOption = SeyfertStringOption>(data: T): T & {
67
+ export type SeyfertBooleanOption = SeyfertBasicOption<ApplicationCommandOptionType.Boolean>;
68
+ export type SeyfertUserOption = SeyfertBasicOption<ApplicationCommandOptionType.User>;
69
+ export type SeyfertChannelOption = SeyfertBasicOption<ApplicationCommandOptionType.Channel> & {
70
+ channel_types?: ChannelType[];
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>): {
42
76
  readonly type: ApplicationCommandOptionType.String;
77
+ readonly required?: boolean;
78
+ readonly choices?: C | undefined;
79
+ readonly value?: ValueCallback<ApplicationCommandOptionType.String, C> | undefined;
80
+ readonly description: string;
81
+ readonly description_localizations?: APIApplicationCommandBasicOption["description_localizations"];
82
+ readonly name_localizations?: APIApplicationCommandBasicOption["name_localizations"];
83
+ readonly locales?: {
84
+ name?: FlatObjectKeys<DefaultLocale>;
85
+ description?: FlatObjectKeys<DefaultLocale>;
86
+ };
87
+ readonly autocomplete?: AutocompleteCallback;
88
+ readonly onAutocompleteError?: OnAutocompleteErrorCallback;
89
+ readonly min_length?: number;
90
+ readonly max_length?: number;
43
91
  };
44
- export declare function createIntegerOption<T extends SeyfertIntegerOption = SeyfertIntegerOption>(data: T): T & {
92
+ export declare function createIntegerOption<C extends SeyfertChoice<number>[] = SeyfertChoice<number>[]>(data: SeyfertIntegerOption<C>): {
45
93
  readonly type: ApplicationCommandOptionType.Integer;
94
+ readonly required?: boolean;
95
+ readonly choices?: C | undefined;
96
+ readonly value?: ValueCallback<ApplicationCommandOptionType.Integer, C> | undefined;
97
+ readonly description: string;
98
+ readonly description_localizations?: APIApplicationCommandBasicOption["description_localizations"];
99
+ readonly name_localizations?: APIApplicationCommandBasicOption["name_localizations"];
100
+ readonly locales?: {
101
+ name?: FlatObjectKeys<DefaultLocale>;
102
+ description?: FlatObjectKeys<DefaultLocale>;
103
+ };
104
+ readonly autocomplete?: AutocompleteCallback;
105
+ readonly onAutocompleteError?: OnAutocompleteErrorCallback;
106
+ readonly min_value?: number;
107
+ readonly max_value?: number;
108
+ };
109
+ export declare function createNumberOption<C extends SeyfertChoice<number>[] = SeyfertChoice<number>[]>(data: SeyfertNumberOption<C>): {
110
+ readonly type: ApplicationCommandOptionType.Number;
111
+ readonly required?: boolean;
112
+ readonly choices?: C | undefined;
113
+ readonly value?: ValueCallback<ApplicationCommandOptionType.Number, C> | undefined;
114
+ readonly description: string;
115
+ readonly description_localizations?: APIApplicationCommandBasicOption["description_localizations"];
116
+ readonly name_localizations?: APIApplicationCommandBasicOption["name_localizations"];
117
+ readonly locales?: {
118
+ name?: FlatObjectKeys<DefaultLocale>;
119
+ description?: FlatObjectKeys<DefaultLocale>;
120
+ };
121
+ readonly autocomplete?: AutocompleteCallback;
122
+ readonly onAutocompleteError?: OnAutocompleteErrorCallback;
123
+ readonly min_value?: number;
124
+ readonly max_value?: number;
46
125
  };
47
126
  export declare function createBooleanOption<T extends SeyfertBooleanOption = SeyfertBooleanOption>(data: T): T & {
48
127
  readonly type: ApplicationCommandOptionType.Boolean;
@@ -59,9 +138,6 @@ export declare function createRoleOption<T extends SeyfertRoleOption = SeyfertRo
59
138
  export declare function createMentionableOption<T extends SeyfertMentionableOption = SeyfertMentionableOption>(data: T): T & {
60
139
  readonly type: ApplicationCommandOptionType.Mentionable;
61
140
  };
62
- export declare function createNumberOption<T extends SeyfertNumberOption = SeyfertNumberOption>(data: T): T & {
63
- readonly type: ApplicationCommandOptionType.Number;
64
- };
65
141
  export declare function createAttachmentOption<T extends SeyfertAttachmentOption = SeyfertAttachmentOption>(data: T): T & {
66
142
  readonly type: ApplicationCommandOptionType.Attachment;
67
143
  };
@@ -2,12 +2,12 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createStringOption = createStringOption;
4
4
  exports.createIntegerOption = createIntegerOption;
5
+ exports.createNumberOption = createNumberOption;
5
6
  exports.createBooleanOption = createBooleanOption;
6
7
  exports.createUserOption = createUserOption;
7
8
  exports.createChannelOption = createChannelOption;
8
9
  exports.createRoleOption = createRoleOption;
9
10
  exports.createMentionableOption = createMentionableOption;
10
- exports.createNumberOption = createNumberOption;
11
11
  exports.createAttachmentOption = createAttachmentOption;
12
12
  exports.createMiddleware = createMiddleware;
13
13
  const types_1 = require("../../types");
@@ -17,6 +17,9 @@ function createStringOption(data) {
17
17
  function createIntegerOption(data) {
18
18
  return { ...data, type: types_1.ApplicationCommandOptionType.Integer };
19
19
  }
20
+ function createNumberOption(data) {
21
+ return { ...data, type: types_1.ApplicationCommandOptionType.Number };
22
+ }
20
23
  function createBooleanOption(data) {
21
24
  return { ...data, type: types_1.ApplicationCommandOptionType.Boolean };
22
25
  }
@@ -32,9 +35,6 @@ function createRoleOption(data) {
32
35
  function createMentionableOption(data) {
33
36
  return { ...data, type: types_1.ApplicationCommandOptionType.Mentionable };
34
37
  }
35
- function createNumberOption(data) {
36
- return { ...data, type: types_1.ApplicationCommandOptionType.Number };
37
- }
38
38
  function createAttachmentOption(data) {
39
39
  return { ...data, type: types_1.ApplicationCommandOptionType.Attachment };
40
40
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "seyfert",
3
- "version": "2.1.1-dev-11310514874.0",
3
+ "version": "2.1.1-dev-11316886063.0",
4
4
  "description": "The most advanced framework for discord bots",
5
5
  "main": "./lib/index.js",
6
6
  "module": "./lib/index.js",