dfx 0.17.4 → 0.17.5
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/Interactions/definitions.d.ts +35 -16
- package/package.json +2 -2
|
@@ -47,9 +47,9 @@ type CommandHandler<R, E, A = any> = Effect<R, E, Discord.InteractionResponse> |
|
|
|
47
47
|
export interface CommandHelper<A> {
|
|
48
48
|
resolve: <T>(name: Resolvables<A>["name"], f: (id: Discord.Snowflake, data: Discord.ResolvedDatum) => T | undefined) => Effect<Discord.Interaction, ResolvedDataNotFound, T>;
|
|
49
49
|
option: (name: CommandOptions<A>["name"]) => Effect<Discord.ApplicationCommandDatum, never, Maybe<Discord.ApplicationCommandInteractionDataOption>>;
|
|
50
|
-
optionValue: (name:
|
|
50
|
+
optionValue: (name: AllRequiredCommandOptions<A>["name"]) => Effect<Discord.ApplicationCommandDatum, never, string>;
|
|
51
51
|
optionValueOptional: (name: CommandOptions<A>["name"]) => Effect<Discord.ApplicationCommandDatum, never, Maybe<string>>;
|
|
52
|
-
subCommands: <NER extends
|
|
52
|
+
subCommands: <NER extends SubCommandNames<A> extends never ? never : Record<SubCommandNames<A>, Effect<any, any, Discord.InteractionResponse>>>(commands: NER) => Effect<Exclude<[
|
|
53
53
|
NER[keyof NER]
|
|
54
54
|
] extends [
|
|
55
55
|
{
|
|
@@ -66,24 +66,43 @@ export interface CommandHelper<A> {
|
|
|
66
66
|
}] ? E : never, Discord.InteractionResponse>;
|
|
67
67
|
}
|
|
68
68
|
type CommandHandlerFn<R, E, A> = (i: CommandHelper<A>) => Effect<R, E, Discord.InteractionResponse>;
|
|
69
|
-
type
|
|
70
|
-
|
|
69
|
+
type StringLiteral<T> = T extends string ? string extends T ? never : T : never;
|
|
70
|
+
type Option<A> = A extends {
|
|
71
|
+
name: infer N;
|
|
72
|
+
} ? N extends StringLiteral<N> ? A : never : never;
|
|
73
|
+
type Options<A, T> = A extends T ? T : A extends {
|
|
74
|
+
options: Discord.ApplicationCommandOption[];
|
|
75
|
+
} ? Options<A["options"][number], T> : never;
|
|
76
|
+
type OptionsWithLiteral<A, T> = A extends {
|
|
77
|
+
options: Discord.ApplicationCommandOption[];
|
|
78
|
+
} ? Extract<A["options"][number], Option<A["options"][number]> & T> : never;
|
|
79
|
+
type CommandOptionType = Exclude<Discord.ApplicationCommandOptionType, Discord.ApplicationCommandOptionType.SUB_COMMAND | Discord.ApplicationCommandOptionType.SUB_COMMAND_GROUP>;
|
|
80
|
+
type CommandOptions<A> = OptionsWithLiteral<A, {
|
|
81
|
+
name: string;
|
|
82
|
+
type: CommandOptionType;
|
|
83
|
+
}>;
|
|
84
|
+
type RequiredCommandOptions<A> = OptionsWithLiteral<A, {
|
|
85
|
+
type: CommandOptionType;
|
|
86
|
+
name: string;
|
|
87
|
+
required: true;
|
|
88
|
+
}>;
|
|
89
|
+
type SubCommands<A> = A extends {
|
|
71
90
|
name: string;
|
|
91
|
+
type: Discord.ApplicationCommandOptionType.SUB_COMMAND;
|
|
72
92
|
options?: Discord.ApplicationCommandOption[];
|
|
73
93
|
} ? A : A extends {
|
|
74
94
|
options: Discord.ApplicationCommandOption[];
|
|
75
|
-
} ?
|
|
76
|
-
type
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
}> : never;
|
|
82
|
-
type CommandOptions<A> = ExtractOptions<A, Exclude<Discord.ApplicationCommandOptionType, Discord.ApplicationCommandOptionType.SUB_COMMAND | Discord.ApplicationCommandOptionType.SUB_COMMAND_GROUP>>;
|
|
83
|
-
type SubCommands<A> = ExtractOptions<A, Discord.ApplicationCommandOptionType.SUB_COMMAND>;
|
|
84
|
-
type RequiredSubCommandOptions<A> = Extract<Exclude<SubCommands<A>["options"], undefined>[number], {
|
|
95
|
+
} ? SubCommands<A["options"][number]> : never;
|
|
96
|
+
type SubCommandNames<A> = Option<SubCommands<A>>["name"];
|
|
97
|
+
type SubCommandOptions<A> = Extract<Option<SubCommands<A>["options"]>, {
|
|
98
|
+
type: CommandOptionType;
|
|
99
|
+
}>;
|
|
100
|
+
type RequiredSubCommandOptions<A> = Extract<SubCommandOptions<A>, {
|
|
85
101
|
required: true;
|
|
86
102
|
}>;
|
|
87
|
-
type
|
|
88
|
-
type Resolvables<A> =
|
|
103
|
+
type AllRequiredCommandOptions<A> = RequiredCommandOptions<A> | RequiredSubCommandOptions<A>;
|
|
104
|
+
type Resolvables<A> = Options<A, {
|
|
105
|
+
name: string;
|
|
106
|
+
type: Discord.ApplicationCommandOptionType.ROLE | Discord.ApplicationCommandOptionType.USER | Discord.ApplicationCommandOptionType.MENTIONABLE | Discord.ApplicationCommandOptionType.CHANNEL;
|
|
107
|
+
}>;
|
|
89
108
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dfx",
|
|
3
|
-
"version": "0.17.
|
|
3
|
+
"version": "0.17.5",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public",
|
|
@@ -49,5 +49,5 @@
|
|
|
49
49
|
"@fp-ts/data": "^0.0.20"
|
|
50
50
|
}
|
|
51
51
|
},
|
|
52
|
-
"gitHead": "
|
|
52
|
+
"gitHead": "a0f69c0023c9b346eaf490f314c18479b6618457"
|
|
53
53
|
}
|