seyfert 2.1.1-dev-11310514874.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.
|
@@ -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 {
|
|
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,33 @@ 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 =
|
|
45
|
-
export type CommandBaseAutocompleteOption =
|
|
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
|
|
53
|
-
export type CommandOption =
|
|
32
|
+
export type CommandOptionWithoutName = CommandBaseOption;
|
|
33
|
+
export type CommandOption = CommandOptionWithoutName & {
|
|
54
34
|
name: string;
|
|
55
35
|
};
|
|
56
|
-
export type OptionsRecord = Record<string,
|
|
36
|
+
export type OptionsRecord = Record<string, CommandOptionWithoutName & {
|
|
57
37
|
type: ApplicationCommandOptionType;
|
|
58
38
|
}>;
|
|
59
39
|
type KeysWithoutRequired<T extends OptionsRecord> = {
|
|
60
|
-
[K in keyof T]-?: T[K]['required'] extends true ? never : K;
|
|
40
|
+
[K in keyof T]-?: NonNullable<T[K]['required']> extends true ? never : K;
|
|
61
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']];
|
|
62
45
|
type ContextOptionsAux<T extends OptionsRecord> = {
|
|
63
|
-
[K in Exclude<keyof T, KeysWithoutRequired<T>>]:
|
|
46
|
+
[K in Exclude<keyof T, KeysWithoutRequired<T>>]: ContextOptionsAuxInternal<T[K]>;
|
|
64
47
|
} & {
|
|
65
|
-
[K in KeysWithoutRequired<T>]?:
|
|
48
|
+
[K in KeysWithoutRequired<T>]?: ContextOptionsAuxInternal<T[K]>;
|
|
66
49
|
};
|
|
67
50
|
export type ContextOptions<T extends OptionsRecord> = ContextOptionsAux<T>;
|
|
68
51
|
export declare class BaseCommand {
|
|
@@ -1,68 +1,144 @@
|
|
|
1
|
-
import type { AutocompleteCallback, EntryPointContext, MenuCommandContext, OnAutocompleteErrorCallback, ReturnOptionsTypes
|
|
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
|
|
9
|
-
|
|
8
|
+
import type { DefaultLocale, MiddlewareContext, OKFunction, StopFunction } from './shared';
|
|
9
|
+
export interface SeyfertBasicOption<T extends keyof ReturnOptionsTypes, R = true | false> {
|
|
10
|
+
required?: R;
|
|
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, R = true | false, VC = never> {
|
|
24
|
+
required?: R;
|
|
25
|
+
choices?: C;
|
|
26
|
+
value?: ValueCallback<T, C, VC>;
|
|
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, I = any> = (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<I>, fail: StopFunction) => Awaitable<void>;
|
|
49
|
+
export type SeyfertStringOption<T = SeyfertChoice<string>[], R = boolean, VC = never> = SeyfertBaseChoiceableOption<ApplicationCommandOptionType.String, T, R, VC> & {
|
|
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 =
|
|
55
|
+
export type SeyfertIntegerOption<T = SeyfertChoice<number>[], R = boolean, VC = never> = SeyfertBaseChoiceableOption<ApplicationCommandOptionType.Integer, T, R, VC> & {
|
|
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
|
|
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>[], R = boolean, VC = never> = SeyfertBaseChoiceableOption<ApplicationCommandOptionType.Number, T, R, VC> & {
|
|
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
|
|
41
|
-
export
|
|
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
|
+
channel_types?: ChannelType[];
|
|
71
|
+
};
|
|
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>): {
|
|
42
76
|
readonly type: ApplicationCommandOptionType.String;
|
|
77
|
+
readonly required?: R | undefined;
|
|
78
|
+
readonly choices?: C | undefined;
|
|
79
|
+
readonly value?: ValueCallback<ApplicationCommandOptionType.String, C, VC> | 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<
|
|
92
|
+
export declare function createIntegerOption<R extends boolean, C extends SeyfertChoice<number>[] = SeyfertChoice<number>[], VC = never>(data: SeyfertIntegerOption<C, R, VC>): {
|
|
45
93
|
readonly type: ApplicationCommandOptionType.Integer;
|
|
94
|
+
readonly required?: R | undefined;
|
|
95
|
+
readonly choices?: C | undefined;
|
|
96
|
+
readonly value?: ValueCallback<ApplicationCommandOptionType.Integer, C, VC> | 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;
|
|
46
108
|
};
|
|
47
|
-
export declare function
|
|
109
|
+
export declare function createNumberOption<R extends boolean, C extends SeyfertChoice<number>[] = SeyfertChoice<number>[], VC = never>(data: SeyfertNumberOption<C, R, VC>): {
|
|
110
|
+
readonly type: ApplicationCommandOptionType.Number;
|
|
111
|
+
readonly required?: R | undefined;
|
|
112
|
+
readonly choices?: C | undefined;
|
|
113
|
+
readonly value?: ValueCallback<ApplicationCommandOptionType.Number, C, VC> | 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;
|
|
125
|
+
};
|
|
126
|
+
export declare function createBooleanOption<R extends boolean, T extends SeyfertBooleanOption<R> = SeyfertBooleanOption<R>>(data: T): T & {
|
|
48
127
|
readonly type: ApplicationCommandOptionType.Boolean;
|
|
49
128
|
};
|
|
50
|
-
export declare function createUserOption<T extends SeyfertUserOption = SeyfertUserOption
|
|
129
|
+
export declare function createUserOption<R extends boolean, T extends SeyfertUserOption<R> = SeyfertUserOption<R>>(data: T): T & {
|
|
51
130
|
readonly type: ApplicationCommandOptionType.User;
|
|
52
131
|
};
|
|
53
|
-
export declare function createChannelOption<T extends SeyfertChannelOption = SeyfertChannelOption
|
|
132
|
+
export declare function createChannelOption<R extends boolean, T extends SeyfertChannelOption<R> = SeyfertChannelOption<R>>(data: T): T & {
|
|
54
133
|
readonly type: ApplicationCommandOptionType.Channel;
|
|
55
134
|
};
|
|
56
|
-
export declare function createRoleOption<T extends SeyfertRoleOption = SeyfertRoleOption
|
|
135
|
+
export declare function createRoleOption<R extends boolean, T extends SeyfertRoleOption<R> = SeyfertRoleOption<R>>(data: T): T & {
|
|
57
136
|
readonly type: ApplicationCommandOptionType.Role;
|
|
58
137
|
};
|
|
59
|
-
export declare function createMentionableOption<T extends SeyfertMentionableOption = SeyfertMentionableOption
|
|
138
|
+
export declare function createMentionableOption<R extends boolean, T extends SeyfertMentionableOption<R> = SeyfertMentionableOption<R>>(data: T): T & {
|
|
60
139
|
readonly type: ApplicationCommandOptionType.Mentionable;
|
|
61
140
|
};
|
|
62
|
-
export declare function
|
|
63
|
-
readonly type: ApplicationCommandOptionType.Number;
|
|
64
|
-
};
|
|
65
|
-
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 & {
|
|
66
142
|
readonly type: ApplicationCommandOptionType.Attachment;
|
|
67
143
|
};
|
|
68
144
|
export type AnyContext = CommandContext | MenuCommandContext<MessageCommandInteraction<boolean> | UserCommandInteraction<boolean>> | ComponentContext | ModalContext | EntryPointContext;
|
|
@@ -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
|
}
|