dfx 0.9.5 → 0.9.8
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 +8 -7
- package/README.md +0 -41
- package/dist/DiscordConfig/index.d.ts +0 -40
- package/dist/DiscordConfig/index.d.ts.map +0 -1
- package/dist/DiscordConfig/index.js +0 -29
- package/dist/DiscordConfig/index.js.map +0 -1
- package/dist/DiscordGateway/DiscordWS/index.d.ts +0 -24
- package/dist/DiscordGateway/DiscordWS/index.d.ts.map +0 -1
- package/dist/DiscordGateway/DiscordWS/index.js +0 -26
- package/dist/DiscordGateway/DiscordWS/index.js.map +0 -1
- package/dist/DiscordGateway/Shard/heartbeats.d.ts +0 -4
- package/dist/DiscordGateway/Shard/heartbeats.d.ts.map +0 -1
- package/dist/DiscordGateway/Shard/heartbeats.js +0 -24
- package/dist/DiscordGateway/Shard/heartbeats.js.map +0 -1
- package/dist/DiscordGateway/Shard/identify.d.ts +0 -13
- package/dist/DiscordGateway/Shard/identify.d.ts.map +0 -1
- package/dist/DiscordGateway/Shard/identify.js +0 -30
- package/dist/DiscordGateway/Shard/identify.js.map +0 -1
- package/dist/DiscordGateway/Shard/index.d.ts +0 -10
- package/dist/DiscordGateway/Shard/index.d.ts.map +0 -1
- package/dist/DiscordGateway/Shard/index.js +0 -52
- package/dist/DiscordGateway/Shard/index.js.map +0 -1
- package/dist/DiscordGateway/Shard/invalidSession.d.ts +0 -4
- package/dist/DiscordGateway/Shard/invalidSession.d.ts.map +0 -1
- package/dist/DiscordGateway/Shard/invalidSession.js +0 -10
- package/dist/DiscordGateway/Shard/invalidSession.js.map +0 -1
- package/dist/DiscordGateway/Shard/sendEvents.d.ts +0 -8
- package/dist/DiscordGateway/Shard/sendEvents.d.ts.map +0 -1
- package/dist/DiscordGateway/Shard/sendEvents.js +0 -26
- package/dist/DiscordGateway/Shard/sendEvents.js.map +0 -1
- package/dist/DiscordGateway/Shard/utils.d.ts +0 -4
- package/dist/DiscordGateway/Shard/utils.d.ts.map +0 -1
- package/dist/DiscordGateway/Shard/utils.js +0 -9
- package/dist/DiscordGateway/Shard/utils.js.map +0 -1
- package/dist/DiscordGateway/ShardStore/index.d.ts +0 -13
- package/dist/DiscordGateway/ShardStore/index.d.ts.map +0 -1
- package/dist/DiscordGateway/ShardStore/index.js +0 -22
- package/dist/DiscordGateway/ShardStore/index.js.map +0 -1
- package/dist/DiscordGateway/Sharder/index.d.ts +0 -10
- package/dist/DiscordGateway/Sharder/index.d.ts.map +0 -1
- package/dist/DiscordGateway/Sharder/index.js +0 -61
- package/dist/DiscordGateway/Sharder/index.js.map +0 -1
- package/dist/DiscordGateway/WS/index.d.ts +0 -28
- package/dist/DiscordGateway/WS/index.d.ts.map +0 -1
- package/dist/DiscordGateway/WS/index.js +0 -82
- package/dist/DiscordGateway/WS/index.js.map +0 -1
- package/dist/DiscordGateway/index.d.ts +0 -21
- package/dist/DiscordGateway/index.d.ts.map +0 -1
- package/dist/DiscordGateway/index.js +0 -27
- package/dist/DiscordGateway/index.js.map +0 -1
- package/dist/DiscordREST/index.d.ts +0 -13
- package/dist/DiscordREST/index.d.ts.map +0 -1
- package/dist/DiscordREST/index.js +0 -85
- package/dist/DiscordREST/index.js.map +0 -1
- package/dist/DiscordREST/types.d.ts +0 -10
- package/dist/DiscordREST/types.d.ts.map +0 -1
- package/dist/DiscordREST/types.js +0 -2
- package/dist/DiscordREST/types.js.map +0 -1
- package/dist/DiscordREST/utils.d.ts +0 -11
- package/dist/DiscordREST/utils.d.ts.map +0 -1
- package/dist/DiscordREST/utils.js +0 -22
- package/dist/DiscordREST/utils.js.map +0 -1
- package/dist/Helpers/flags.d.ts +0 -28
- package/dist/Helpers/flags.d.ts.map +0 -1
- package/dist/Helpers/flags.js +0 -36
- package/dist/Helpers/flags.js.map +0 -1
- package/dist/Helpers/intents.d.ts +0 -25
- package/dist/Helpers/intents.d.ts.map +0 -1
- package/dist/Helpers/intents.js +0 -28
- package/dist/Helpers/intents.js.map +0 -1
- package/dist/Helpers/interactions.d.ts +0 -74
- package/dist/Helpers/interactions.d.ts.map +0 -1
- package/dist/Helpers/interactions.js +0 -93
- package/dist/Helpers/interactions.js.map +0 -1
- package/dist/Helpers/members.d.ts +0 -10
- package/dist/Helpers/members.d.ts.map +0 -1
- package/dist/Helpers/members.js +0 -10
- package/dist/Helpers/members.js.map +0 -1
- package/dist/Helpers/permissions.d.ts +0 -35
- package/dist/Helpers/permissions.d.ts.map +0 -1
- package/dist/Helpers/permissions.js +0 -69
- package/dist/Helpers/permissions.js.map +0 -1
- package/dist/Helpers/ui.d.ts +0 -48
- package/dist/Helpers/ui.d.ts.map +0 -1
- package/dist/Helpers/ui.js +0 -67
- package/dist/Helpers/ui.js.map +0 -1
- package/dist/Http/index.d.ts +0 -31
- package/dist/Http/index.d.ts.map +0 -1
- package/dist/Http/index.js +0 -53
- package/dist/Http/index.js.map +0 -1
- package/dist/Interactions/context.d.ts +0 -37
- package/dist/Interactions/context.d.ts.map +0 -1
- package/dist/Interactions/context.js +0 -34
- package/dist/Interactions/context.js.map +0 -1
- package/dist/Interactions/definitions.d.ts +0 -61
- package/dist/Interactions/definitions.d.ts.map +0 -1
- package/dist/Interactions/definitions.js +0 -52
- package/dist/Interactions/definitions.js.map +0 -1
- package/dist/Interactions/gateway.d.ts +0 -7
- package/dist/Interactions/gateway.d.ts.map +0 -1
- package/dist/Interactions/gateway.js +0 -21
- package/dist/Interactions/gateway.js.map +0 -1
- package/dist/Interactions/handlers.d.ts +0 -9
- package/dist/Interactions/handlers.d.ts.map +0 -1
- package/dist/Interactions/handlers.js +0 -49
- package/dist/Interactions/handlers.js.map +0 -1
- package/dist/Interactions/index.d.ts +0 -18
- package/dist/Interactions/index.d.ts.map +0 -1
- package/dist/Interactions/index.js +0 -39
- package/dist/Interactions/index.js.map +0 -1
- package/dist/Interactions/utils.d.ts +0 -11
- package/dist/Interactions/utils.d.ts.map +0 -1
- package/dist/Interactions/utils.js +0 -61
- package/dist/Interactions/utils.js.map +0 -1
- package/dist/Interactions/webhook.d.ts +0 -33
- package/dist/Interactions/webhook.d.ts.map +0 -1
- package/dist/Interactions/webhook.js +0 -42
- package/dist/Interactions/webhook.js.map +0 -1
- package/dist/Log/index.d.ts +0 -13
- package/dist/Log/index.d.ts.map +0 -1
- package/dist/Log/index.js +0 -19
- package/dist/Log/index.js.map +0 -1
- package/dist/RateLimitStore/index.d.ts +0 -25
- package/dist/RateLimitStore/index.d.ts.map +0 -1
- package/dist/RateLimitStore/index.js +0 -24
- package/dist/RateLimitStore/index.js.map +0 -1
- package/dist/RateLimitStore/memory.d.ts +0 -3
- package/dist/RateLimitStore/memory.d.ts.map +0 -1
- package/dist/RateLimitStore/memory.js +0 -31
- package/dist/RateLimitStore/memory.js.map +0 -1
- package/dist/RateLimitStore/utils.d.ts +0 -3
- package/dist/RateLimitStore/utils.d.ts.map +0 -1
- package/dist/RateLimitStore/utils.js +0 -18
- package/dist/RateLimitStore/utils.js.map +0 -1
- package/dist/common-gateway.d.ts +0 -6
- package/dist/common-gateway.d.ts.map +0 -1
- package/dist/common-gateway.js +0 -6
- package/dist/common-gateway.js.map +0 -1
- package/dist/common.d.ts +0 -29
- package/dist/common.d.ts.map +0 -1
- package/dist/common.js +0 -16
- package/dist/common.js.map +0 -1
- package/dist/global.d.ts +0 -18
- package/dist/global.d.ts.map +0 -1
- package/dist/global.js +0 -2
- package/dist/global.js.map +0 -1
- package/dist/index.d.ts +0 -22
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -29
- package/dist/index.js.map +0 -1
- package/dist/types.d.ts +0 -4229
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js +0 -1796
- package/dist/types.js.map +0 -1
- package/dist/utils/effect.d.ts +0 -3
- package/dist/utils/effect.d.ts.map +0 -1
- package/dist/utils/effect.js +0 -2
- package/dist/utils/effect.js.map +0 -1
- package/dist/utils/tsplus.d.ts +0 -14
- package/dist/utils/tsplus.d.ts.map +0 -1
- package/dist/utils/tsplus.js +0 -2
- package/dist/utils/tsplus.js.map +0 -1
- package/dist/webhooks.d.ts +0 -16
- package/dist/webhooks.d.ts.map +0 -1
- package/dist/webhooks.js +0 -23
- package/dist/webhooks.js.map +0 -1
- package/src/DiscordConfig/index.ts +0 -52
- package/src/DiscordGateway/DiscordWS/index.ts +0 -50
- package/src/DiscordGateway/Shard/heartbeats.ts +0 -39
- package/src/DiscordGateway/Shard/identify.ts +0 -61
- package/src/DiscordGateway/Shard/index.ts +0 -90
- package/src/DiscordGateway/Shard/invalidSession.ts +0 -11
- package/src/DiscordGateway/Shard/sendEvents.ts +0 -35
- package/src/DiscordGateway/Shard/utils.ts +0 -14
- package/src/DiscordGateway/ShardStore/index.ts +0 -33
- package/src/DiscordGateway/Sharder/index.ts +0 -95
- package/src/DiscordGateway/WS/index.ts +0 -99
- package/src/DiscordGateway/index.ts +0 -55
- package/src/DiscordREST/index.ts +0 -132
- package/src/DiscordREST/types.ts +0 -14
- package/src/DiscordREST/utils.ts +0 -35
- package/src/Helpers/flags.ts +0 -68
- package/src/Helpers/intents.ts +0 -32
- package/src/Helpers/interactions.ts +0 -180
- package/src/Helpers/members.ts +0 -14
- package/src/Helpers/permissions.ts +0 -102
- package/src/Helpers/ui.ts +0 -103
- package/src/Http/index.ts +0 -65
- package/src/Interactions/context.ts +0 -100
- package/src/Interactions/definitions.ts +0 -144
- package/src/Interactions/gateway.ts +0 -55
- package/src/Interactions/handlers.ts +0 -139
- package/src/Interactions/index.ts +0 -83
- package/src/Interactions/utils.ts +0 -81
- package/src/Interactions/webhook.ts +0 -96
- package/src/Log/index.ts +0 -23
- package/src/RateLimitStore/index.ts +0 -65
- package/src/RateLimitStore/memory.ts +0 -48
- package/src/RateLimitStore/utils.ts +0 -27
- package/src/common-gateway.ts +0 -5
- package/src/common.ts +0 -30
- package/src/global.ts +0 -50
- package/src/index.ts +0 -36
- package/src/json.d.ts +0 -1
- package/src/types.ts +0 -6095
- package/src/utils/effect.ts +0 -7
- package/src/utils/tsplus.ts +0 -11
- package/src/webhooks.ts +0 -30
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import { Discord, Maybe } from "dfx/common";
|
|
2
|
-
/**
|
|
3
|
-
* Maybe find a sub-command within the interaction options.
|
|
4
|
-
*/
|
|
5
|
-
export declare const allSubCommands: (interaction: Discord.ApplicationCommandDatum) => readonly import("../types.js").ApplicationCommandInteractionDataOption[];
|
|
6
|
-
/**
|
|
7
|
-
* Maybe find a sub-command within the interaction options.
|
|
8
|
-
*/
|
|
9
|
-
export declare const findSubCommand: (name: string) => (interaction: Discord.ApplicationCommandDatum) => import("../common.js").Maybe<import("../types.js").ApplicationCommandInteractionDataOption>;
|
|
10
|
-
/**
|
|
11
|
-
* If the sub-command exists return `true`, else `false`.
|
|
12
|
-
*/
|
|
13
|
-
export declare const isSubCommand: (name: string) => (interaction: import("../types.js").ApplicationCommandDatum) => boolean;
|
|
14
|
-
/**
|
|
15
|
-
* Maybe get the options for a sub-command
|
|
16
|
-
*/
|
|
17
|
-
export declare const subCommandOptions: (name: string) => (interaction: import("../types.js").ApplicationCommandDatum) => import("../common.js").Maybe<import("../types.js").ApplicationCommandInteractionDataOption[]>;
|
|
18
|
-
/**
|
|
19
|
-
* A lens for accessing nested options in a interaction.
|
|
20
|
-
*/
|
|
21
|
-
export declare const optionsWithNested: (data: Pick<Discord.ApplicationCommandDatum, "options">) => Discord.ApplicationCommandInteractionDataOption[];
|
|
22
|
-
/**
|
|
23
|
-
* Return the interaction options as a name / value map.
|
|
24
|
-
*/
|
|
25
|
-
export declare const transformOptions: (options: Discord.ApplicationCommandInteractionDataOption[]) => Record<string, string | undefined>;
|
|
26
|
-
/**
|
|
27
|
-
* Return the interaction options as a name / value map.
|
|
28
|
-
*/
|
|
29
|
-
export declare const optionsMap: (data: Pick<import("../types.js").ApplicationCommandDatum, "options">) => Record<string, string | undefined>;
|
|
30
|
-
/**
|
|
31
|
-
* Try find a matching option from the interaction.
|
|
32
|
-
*/
|
|
33
|
-
export declare const getOption: (name: string) => (data: Pick<import("../types.js").ApplicationCommandDatum, "options">) => import("../common.js").Maybe<import("../types.js").ApplicationCommandInteractionDataOption>;
|
|
34
|
-
/**
|
|
35
|
-
* Try find a matching option from the interaction.
|
|
36
|
-
*/
|
|
37
|
-
export declare const focusedOption: (data: Pick<import("../types.js").ApplicationCommandDatum, "options">) => import("../common.js").Maybe<import("../types.js").ApplicationCommandInteractionDataOption>;
|
|
38
|
-
/**
|
|
39
|
-
* Try find a matching option value from the interaction.
|
|
40
|
-
*/
|
|
41
|
-
export declare const optionValue: (name: string) => (data: Pick<import("../types.js").ApplicationCommandDatum, "options">) => import("../common.js").Maybe<string>;
|
|
42
|
-
/**
|
|
43
|
-
* Try extract resolved data
|
|
44
|
-
*/
|
|
45
|
-
export declare const resolved: (data: Discord.ApplicationCommandDatum) => import("../common.js").Maybe<import("../types.js").ResolvedDatum>;
|
|
46
|
-
/**
|
|
47
|
-
* Try find a matching option value from the interaction.
|
|
48
|
-
*/
|
|
49
|
-
export declare const resolveOptionValue: <T>(name: string, f: (id: Discord.Snowflake, data: Discord.ResolvedDatum) => T | undefined) => (a: Discord.ApplicationCommandDatum) => import("../common.js").Maybe<T>;
|
|
50
|
-
/**
|
|
51
|
-
* A lens for accessing the components in a interaction.
|
|
52
|
-
*/
|
|
53
|
-
export declare const components: (a: Discord.ModalSubmitDatum) => Discord.Component[];
|
|
54
|
-
/**
|
|
55
|
-
* A lens for accessing the components in a interaction.
|
|
56
|
-
*/
|
|
57
|
-
export declare const componentsWithValue: (a: import("../types.js").ModalSubmitDatum) => readonly import("../types.js").Component[];
|
|
58
|
-
/**
|
|
59
|
-
* Return the interaction components as an id / value map.
|
|
60
|
-
*/
|
|
61
|
-
export declare const transformComponents: (options: Discord.Component[]) => Record<string, string | undefined>;
|
|
62
|
-
/**
|
|
63
|
-
* Return the interaction components as an id / value map.
|
|
64
|
-
*/
|
|
65
|
-
export declare const componentsMap: (a: import("../types.js").ModalSubmitDatum) => Record<string, string | undefined>;
|
|
66
|
-
/**
|
|
67
|
-
* Try find a matching component from the interaction.
|
|
68
|
-
*/
|
|
69
|
-
export declare const getComponent: (id: string) => (a: import("../types.js").ModalSubmitDatum) => import("../common.js").Maybe<import("../types.js").Component>;
|
|
70
|
-
/**
|
|
71
|
-
* Try find a matching component value from the interaction.
|
|
72
|
-
*/
|
|
73
|
-
export declare const componentValue: (id: string) => (a: import("../types.js").ModalSubmitDatum) => import("../common.js").Maybe<string>;
|
|
74
|
-
//# sourceMappingURL=interactions.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"interactions.d.ts","sourceRoot":"","sources":["../../src/Helpers/interactions.ts"],"names":[],"mappings":";AAEA;;GAEG;AACH,eAAO,MAAM,cAAc,gBAAiB,QAAQ,uBAAuB,6EAMxE,CAAA;AAEH;;GAEG;AACH,eAAO,MAAM,cAAc,SAClB,MAAM,mBAAmB,QAAQ,uBAAuB,gGAQ5D,CAAA;AAEL;;GAEG;AACH,eAAO,MAAM,YAAY,SAAU,MAAM,4EACI,CAAA;AAE7C;;GAEG;AACH,eAAO,MAAM,iBAAiB,SAAU,MAAM,kKAC0B,CAAA;AAExE;;GAEG;AACH,eAAO,MAAM,iBAAiB,SACtB,KAAK,QAAQ,uBAAuB,EAAE,SAAS,CAAC,KACrD,QAAQ,uCAAuC,EAWjD,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,gBAAgB,YAClB,QAAQ,uCAAuC,EAAE,uCAQzD,CAAA;AAEH;;GAEG;AACH,eAAO,MAAM,UAAU,8GAA4C,CAAA;AAEnE;;GAEG;AACH,eAAO,MAAM,SAAS,SAAU,MAAM,0KAInC,CAAA;AAEH;;GAEG;AACH,eAAO,MAAM,aAAa,uKAGzB,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,WAAW,SAAU,MAAM,mHACyB,CAAA;AAEjE;;GAEG;AACH,eAAO,MAAM,QAAQ,SAAU,QAAQ,uBAAuB,sEAC3B,CAAA;AAEnC;;GAEG;AACH,eAAO,MAAM,kBAAkB,YAErB,MAAM,UACJ,QAAQ,SAAS,QAAQ,QAAQ,aAAa,2BAEpD,QAAQ,uBAAuB,oCAS/B,CAAA;AAUN;;GAEG;AACH,eAAO,MAAM,UAAU,MAClB,QAAQ,gBAAgB,KAC1B,QAAQ,SAAS,EAGnB,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,mBAAmB,2FAG/B,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,mBAAmB,YAAa,QAAQ,SAAS,EAAE,uCAI7D,CAAA;AAEH;;GAEG;AACH,eAAO,MAAM,aAAa,mFAAwC,CAAA;AAElE;;GAEG;AACH,eAAO,MAAM,YAAY,OAAQ,MAAM,iHAIpC,CAAA;AAEH;;GAEG;AACH,eAAO,MAAM,cAAc,OAAQ,MAAM,wFAGtC,CAAA"}
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
import * as tsplus_module_1 from "dfx/common";
|
|
2
|
-
import * as tsplus_module_2 from "@fp-ts/data/Function";
|
|
3
|
-
import * as tsplus_module_3 from "@fp-ts/data/Option";
|
|
4
|
-
import * as Arr from "@fp-ts/data/ReadonlyArray";
|
|
5
|
-
/**
|
|
6
|
-
* Maybe find a sub-command within the interaction options.
|
|
7
|
-
*/
|
|
8
|
-
export const allSubCommands = (interaction) => tsplus_module_2.pipe(optionsWithNested(interaction), Arr.filter((o) => o.type === tsplus_module_1.Discord.ApplicationCommandOptionType.SUB_COMMAND));
|
|
9
|
-
/**
|
|
10
|
-
* Maybe find a sub-command within the interaction options.
|
|
11
|
-
*/
|
|
12
|
-
export const findSubCommand = (name) => (interaction) => tsplus_module_2.pipe(optionsWithNested(interaction), Arr.findFirst((o) => o.type === tsplus_module_1.Discord.ApplicationCommandOptionType.SUB_COMMAND &&
|
|
13
|
-
o.name === name));
|
|
14
|
-
/**
|
|
15
|
-
* If the sub-command exists return `true`, else `false`.
|
|
16
|
-
*/
|
|
17
|
-
export const isSubCommand = (name) => tsplus_module_2.flow(findSubCommand(name), (o) => tsplus_module_3.isSome(o));
|
|
18
|
-
/**
|
|
19
|
-
* Maybe get the options for a sub-command
|
|
20
|
-
*/
|
|
21
|
-
export const subCommandOptions = (name) => tsplus_module_2.flow(findSubCommand(name), (o) => tsplus_module_3.flatMapNullable((o) => o.options)(o));
|
|
22
|
-
/**
|
|
23
|
-
* A lens for accessing nested options in a interaction.
|
|
24
|
-
*/
|
|
25
|
-
export const optionsWithNested = (data) => {
|
|
26
|
-
const optsFromOption = (opt) => tsplus_module_3.match(() => [], tsplus_module_2.identity)(tsplus_module_3.map((opts) => [...opts, ...opts.flatMap(optsFromOption)])(tsplus_module_3.fromNullable(opt.options)));
|
|
27
|
-
return tsplus_module_3.getOrElse(() => [])(tsplus_module_3.map((opts) => [...opts, ...opts.flatMap(optsFromOption)])(tsplus_module_3.fromNullable(data.options)));
|
|
28
|
-
};
|
|
29
|
-
/**
|
|
30
|
-
* Return the interaction options as a name / value map.
|
|
31
|
-
*/
|
|
32
|
-
export const transformOptions = (options) => options.reduce((map, option) => ({
|
|
33
|
-
...map,
|
|
34
|
-
[option.name]: option.value,
|
|
35
|
-
}), {});
|
|
36
|
-
/**
|
|
37
|
-
* Return the interaction options as a name / value map.
|
|
38
|
-
*/
|
|
39
|
-
export const optionsMap = tsplus_module_2.flow(optionsWithNested, transformOptions);
|
|
40
|
-
/**
|
|
41
|
-
* Try find a matching option from the interaction.
|
|
42
|
-
*/
|
|
43
|
-
export const getOption = (name) => tsplus_module_2.flow(optionsWithNested, Arr.findFirst((o) => o.name === name));
|
|
44
|
-
/**
|
|
45
|
-
* Try find a matching option from the interaction.
|
|
46
|
-
*/
|
|
47
|
-
export const focusedOption = tsplus_module_2.flow(optionsWithNested, Arr.findFirst((o) => o.focused === true));
|
|
48
|
-
/**
|
|
49
|
-
* Try find a matching option value from the interaction.
|
|
50
|
-
*/
|
|
51
|
-
export const optionValue = (name) => tsplus_module_2.flow(getOption(name), (o) => tsplus_module_3.flatMapNullable((o) => o.value)(o));
|
|
52
|
-
/**
|
|
53
|
-
* Try extract resolved data
|
|
54
|
-
*/
|
|
55
|
-
export const resolved = (data) => tsplus_module_3.fromNullable(data.resolved);
|
|
56
|
-
/**
|
|
57
|
-
* Try find a matching option value from the interaction.
|
|
58
|
-
*/
|
|
59
|
-
export const resolveOptionValue = (name, f) => (a) => tsplus_module_3.flatMap(id => tsplus_module_3.flatMap(data => tsplus_module_3.fromNullable(f(id, data)))(resolved(a)))(tsplus_module_3.flatMapNullable(({ value }) => value)(getOption(name)(a)));
|
|
60
|
-
const extractComponents = (c) => {
|
|
61
|
-
if ("components" in c) {
|
|
62
|
-
return [...c.components, ...c.components.flatMap(extractComponents)];
|
|
63
|
-
}
|
|
64
|
-
return [];
|
|
65
|
-
};
|
|
66
|
-
/**
|
|
67
|
-
* A lens for accessing the components in a interaction.
|
|
68
|
-
*/
|
|
69
|
-
export const components = (a) => [
|
|
70
|
-
...a.components,
|
|
71
|
-
...a.components.flatMap(extractComponents),
|
|
72
|
-
];
|
|
73
|
-
/**
|
|
74
|
-
* A lens for accessing the components in a interaction.
|
|
75
|
-
*/
|
|
76
|
-
export const componentsWithValue = tsplus_module_2.flow(components, Arr.filter((c) => "value" in c && c.value !== undefined));
|
|
77
|
-
/**
|
|
78
|
-
* Return the interaction components as an id / value map.
|
|
79
|
-
*/
|
|
80
|
-
export const transformComponents = (options) => options.reduce((map, c) => (c.custom_id ? { ...map, [c.custom_id]: c.value } : map), {});
|
|
81
|
-
/**
|
|
82
|
-
* Return the interaction components as an id / value map.
|
|
83
|
-
*/
|
|
84
|
-
export const componentsMap = tsplus_module_2.flow(components, transformComponents);
|
|
85
|
-
/**
|
|
86
|
-
* Try find a matching component from the interaction.
|
|
87
|
-
*/
|
|
88
|
-
export const getComponent = (id) => tsplus_module_2.flow(components, Arr.findFirst((o) => o.custom_id === id));
|
|
89
|
-
/**
|
|
90
|
-
* Try find a matching component value from the interaction.
|
|
91
|
-
*/
|
|
92
|
-
export const componentValue = (id) => tsplus_module_2.flow(getComponent(id), (o) => tsplus_module_3.flatMapNullable((o) => o.value)(o));
|
|
93
|
-
//# sourceMappingURL=interactions.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"interactions.js","sourceRoot":"","sources":["../../src/Helpers/interactions.ts"],"names":[],"mappings":";;;AAAA,OAAO,KAAK,GAAG,MAAM,2BAA2B,CAAA;AAEhD;;GAEG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,WAA4C,EAAE,EAAE,CAC7E,gBAAA,IAAI,CACF,iBAAiB,CAAC,WAAW,CAAC,EAC9B,GAAG,CAAC,MAAM,CACR,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,gBAAA,OAAO,CAAC,4BAA4B,CAAC,WAAW,CACnE,CACF,CAAA;AAEH;;GAEG;AACH,MAAM,CAAC,MAAM,cAAc,GACzB,CAAC,IAAY,EAAE,EAAE,CAAC,CAAC,WAA4C,EAAE,EAAE,CACjE,gBAAA,IAAI,CACF,iBAAiB,CAAC,WAAW,CAAC,EAC9B,GAAG,CAAC,SAAS,CACX,CAAC,CAAC,EAAE,EAAE,CACJ,CAAC,CAAC,IAAI,KAAK,gBAAA,OAAO,CAAC,4BAA4B,CAAC,WAAW;IAC3D,CAAC,CAAC,IAAI,KAAK,IAAI,CAClB,CACF,CAAA;AAEL;;GAEG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,IAAY,EAAE,EAAE,CAC3C,gBAAA,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,wBAAC,CAAC,CAAO,CAAC,CAAA;AAE7C;;GAEG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,IAAY,EAAE,EAAE,CAChD,gBAAA,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,gCAAkB,CAAC,CAAC,EAAE,EAAE,CAA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
|
|
1
|
-
import { Discord } from "dfx/common";
|
|
2
|
-
/**
|
|
3
|
-
* From a list of roles, filter out the ones the guild member has.
|
|
4
|
-
*/
|
|
5
|
-
export declare const roles: (roles: Discord.Role[]) => (member: Discord.GuildMember) => import("../types.js").Role[];
|
|
6
|
-
/**
|
|
7
|
-
* Type-guard function for checking if the object is a guild member
|
|
8
|
-
*/
|
|
9
|
-
export declare const is: (thing: unknown) => thing is import("../types.js").GuildMember;
|
|
10
|
-
//# sourceMappingURL=members.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"members.d.ts","sourceRoot":"","sources":["../../src/Helpers/members.ts"],"names":[],"mappings":";AAAA;;GAEG;AACH,eAAO,MAAM,KAAK,UAAW,QAAQ,IAAI,EAAE,cAAc,QAAQ,WAAW,iCAGzE,CAAA;AAEH;;GAEG;AACH,eAAO,MAAM,EAAE,UAAW,OAAO,+CAEyB,CAAA"}
|
package/dist/Helpers/members.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* From a list of roles, filter out the ones the guild member has.
|
|
3
|
-
*/
|
|
4
|
-
export const roles = (roles) => (member) => roles.filter((role) => member.roles.includes(role.id) || role.name === "@everyone");
|
|
5
|
-
/**
|
|
6
|
-
* Type-guard function for checking if the object is a guild member
|
|
7
|
-
*/
|
|
8
|
-
export const is = (thing) => Object.prototype.hasOwnProperty.call(thing, "roles") &&
|
|
9
|
-
Object.prototype.hasOwnProperty.call(thing, "joined_at");
|
|
10
|
-
//# sourceMappingURL=members.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"members.js","sourceRoot":"","sources":["../../src/Helpers/members.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,KAAqB,EAAE,EAAE,CAAC,CAAC,MAA2B,EAAE,EAAE,CAC9E,KAAK,CAAC,MAAM,CACV,CAAC,IAAI,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,IAAI,CAAC,IAAI,KAAK,WAAW,CACtE,CAAA;AAEH;;GAEG;AACH,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAAc,EAAgC,EAAE,CACjE,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,KAAK,EAAE,OAAO,CAAC;IACpD,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,KAAK,EAAE,WAAW,CAAC,CAAA"}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { Discord } from "dfx/common";
|
|
2
|
-
/**
|
|
3
|
-
* A constant of all the permissions
|
|
4
|
-
*/
|
|
5
|
-
export declare const ALL: bigint;
|
|
6
|
-
/**
|
|
7
|
-
* Check if a flag exists in the permissions.
|
|
8
|
-
*/
|
|
9
|
-
export declare const has: (flag: string | bigint) => (bits: string | bigint) => boolean;
|
|
10
|
-
/**
|
|
11
|
-
* Convert a permissions bitfield to a list of flag names.
|
|
12
|
-
*/
|
|
13
|
-
export declare const toList: (bitfield: bigint) => ("CREATE_INSTANT_INVITE" | "KICK_MEMBERS" | "BAN_MEMBERS" | "ADMINISTRATOR" | "MANAGE_CHANNELS" | "MANAGE_GUILD" | "ADD_REACTIONS" | "VIEW_AUDIT_LOG" | "PRIORITY_SPEAKER" | "STREAM" | "VIEW_CHANNEL" | "SEND_MESSAGES" | "SEND_TTS_MESSAGES" | "MANAGE_MESSAGES" | "EMBED_LINKS" | "ATTACH_FILES" | "READ_MESSAGE_HISTORY" | "MENTION_EVERYONE" | "USE_EXTERNAL_EMOJIS" | "VIEW_GUILD_INSIGHTS" | "CONNECT" | "SPEAK" | "MUTE_MEMBERS" | "DEAFEN_MEMBERS" | "MOVE_MEMBERS" | "USE_VAD" | "CHANGE_NICKNAME" | "MANAGE_NICKNAMES" | "MANAGE_ROLES" | "MANAGE_WEBHOOKS" | "MANAGE_EMOJIS_AND_STICKERS" | "USE_APPLICATION_COMMANDS" | "REQUEST_TO_SPEAK" | "MANAGE_EVENTS" | "MANAGE_THREADS" | "CREATE_PUBLIC_THREADS" | "CREATE_PRIVATE_THREADS" | "USE_EXTERNAL_STICKERS" | "SEND_MESSAGES_IN_THREADS" | "USE_EMBEDDED_ACTIVITIES" | "MODERATE_MEMBERS")[];
|
|
14
|
-
/**
|
|
15
|
-
* Convert a list of flag names to a bitfield.
|
|
16
|
-
*/
|
|
17
|
-
export declare const fromList: (list: ("CREATE_INSTANT_INVITE" | "KICK_MEMBERS" | "BAN_MEMBERS" | "ADMINISTRATOR" | "MANAGE_CHANNELS" | "MANAGE_GUILD" | "ADD_REACTIONS" | "VIEW_AUDIT_LOG" | "PRIORITY_SPEAKER" | "STREAM" | "VIEW_CHANNEL" | "SEND_MESSAGES" | "SEND_TTS_MESSAGES" | "MANAGE_MESSAGES" | "EMBED_LINKS" | "ATTACH_FILES" | "READ_MESSAGE_HISTORY" | "MENTION_EVERYONE" | "USE_EXTERNAL_EMOJIS" | "VIEW_GUILD_INSIGHTS" | "CONNECT" | "SPEAK" | "MUTE_MEMBERS" | "DEAFEN_MEMBERS" | "MOVE_MEMBERS" | "USE_VAD" | "CHANGE_NICKNAME" | "MANAGE_NICKNAMES" | "MANAGE_ROLES" | "MANAGE_WEBHOOKS" | "MANAGE_EMOJIS_AND_STICKERS" | "USE_APPLICATION_COMMANDS" | "REQUEST_TO_SPEAK" | "MANAGE_EVENTS" | "MANAGE_THREADS" | "CREATE_PUBLIC_THREADS" | "CREATE_PRIVATE_THREADS" | "USE_EXTERNAL_STICKERS" | "SEND_MESSAGES_IN_THREADS" | "USE_EMBEDDED_ACTIVITIES" | "MODERATE_MEMBERS")[]) => bigint;
|
|
18
|
-
/**
|
|
19
|
-
* Reduce a list of roles to a bitfield of all the permissions added together.
|
|
20
|
-
*/
|
|
21
|
-
export declare const forRoles: (roles: Discord.Role[]) => bigint;
|
|
22
|
-
/**
|
|
23
|
-
* From a list of roles, calculate the permissions bitfield for the member.
|
|
24
|
-
*/
|
|
25
|
-
export declare const forMember: (roles: Discord.Role[]) => (member: Discord.GuildMember) => bigint;
|
|
26
|
-
/**
|
|
27
|
-
* From a list of roles and a channel, calculate the permission bitfield for
|
|
28
|
-
* the guild member or role for that channel.
|
|
29
|
-
*/
|
|
30
|
-
export declare const forChannel: (roles: Discord.Role[]) => ({ guild_id, permission_overwrites: overwrites }: Discord.Channel) => (memberOrRole: Discord.GuildMember | Discord.Role) => bigint;
|
|
31
|
-
/**
|
|
32
|
-
* Apply permission overwrites to a bitfield.
|
|
33
|
-
*/
|
|
34
|
-
export declare const applyOverwrites: (permissions: bigint) => (overwrites: Discord.Overwrite[]) => bigint;
|
|
35
|
-
//# sourceMappingURL=permissions.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"permissions.d.ts","sourceRoot":"","sources":["../../src/Helpers/permissions.ts"],"names":[],"mappings":";AAAA;;GAEG;AACH,eAAO,MAAM,GAAG,QAAoC,CAAA;AAEpD;;GAEG;AACH,eAAO,MAAM,GAAG,+DAAkB,CAAA;AAElC;;GAEG;AACH,eAAO,MAAM,MAAM,o1BAAuC,CAAA;AAE1D;;GAEG;AACH,eAAO,MAAM,QAAQ,g1BAA+C,CAAA;AAEpE;;GAEG;AACH,eAAO,MAAM,QAAQ,UAAW,QAAQ,IAAI,EAAE,WAI3C,CAAA;AAEH;;GAEG;AACH,eAAO,MAAM,SAAS,UACZ,QAAQ,IAAI,EAAE,cAAc,QAAQ,WAAW,WACT,CAAA;AAuBhD;;;GAGG;AACH,eAAO,MAAM,UAAU,UACb,QAAQ,IAAI,EAAE,uDACiC,QAAQ,OAAO,oBACvD,QAAQ,WAAW,GAAG,QAAQ,IAAI,WA0BhD,CAAA;AAEH;;GAEG;AACH,eAAO,MAAM,eAAe,gBACZ,MAAM,kBAAkB,QAAQ,SAAS,EAAE,WAKtD,CAAA"}
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import * as tsplus_module_1 from "dfx/common";
|
|
2
|
-
import * as tsplus_module_2 from "@fp-ts/data/Function";
|
|
3
|
-
/**
|
|
4
|
-
* A constant of all the permissions
|
|
5
|
-
*/
|
|
6
|
-
export const ALL = tsplus_module_1.Flags.all(tsplus_module_1.Discord.PermissionFlag);
|
|
7
|
-
/**
|
|
8
|
-
* Check if a flag exists in the permissions.
|
|
9
|
-
*/
|
|
10
|
-
export const has = tsplus_module_1.Flags.hasBigInt;
|
|
11
|
-
/**
|
|
12
|
-
* Convert a permissions bitfield to a list of flag names.
|
|
13
|
-
*/
|
|
14
|
-
export const toList = tsplus_module_1.Flags.toList(tsplus_module_1.Discord.PermissionFlag);
|
|
15
|
-
/**
|
|
16
|
-
* Convert a list of flag names to a bitfield.
|
|
17
|
-
*/
|
|
18
|
-
export const fromList = tsplus_module_1.Flags.fromListBigint(tsplus_module_1.Discord.PermissionFlag);
|
|
19
|
-
/**
|
|
20
|
-
* Reduce a list of roles to a bitfield of all the permissions added together.
|
|
21
|
-
*/
|
|
22
|
-
export const forRoles = (roles) => roles.reduce((permissions, role) => permissions | BigInt(role.permissions), BigInt(0));
|
|
23
|
-
/**
|
|
24
|
-
* From a list of roles, calculate the permissions bitfield for the member.
|
|
25
|
-
*/
|
|
26
|
-
export const forMember = (roles) => (member) => tsplus_module_2.pipe(tsplus_module_1.Members.roles(roles)(member), forRoles);
|
|
27
|
-
const overwriteIsForMember = (guildId) => (member) => (overwrite) => {
|
|
28
|
-
if (overwrite.type === 0) {
|
|
29
|
-
return overwrite.id === guildId || member.roles.includes(overwrite.id);
|
|
30
|
-
}
|
|
31
|
-
return overwrite.id === member.user?.id;
|
|
32
|
-
};
|
|
33
|
-
const overwriteIsForRole = (guildId) => (role) => (overwrite) => {
|
|
34
|
-
if (overwrite.type === 0) {
|
|
35
|
-
return overwrite.id === guildId || overwrite.id === role.id;
|
|
36
|
-
}
|
|
37
|
-
return false;
|
|
38
|
-
};
|
|
39
|
-
/**
|
|
40
|
-
* From a list of roles and a channel, calculate the permission bitfield for
|
|
41
|
-
* the guild member or role for that channel.
|
|
42
|
-
*/
|
|
43
|
-
export const forChannel = (roles) => ({ guild_id, permission_overwrites: overwrites = [] }) => (memberOrRole) => {
|
|
44
|
-
const hasAdmin = has(tsplus_module_1.Discord.PermissionFlag.ADMINISTRATOR);
|
|
45
|
-
let basePermissions;
|
|
46
|
-
let filteredOverwrites;
|
|
47
|
-
if (tsplus_module_1.Members.is(memberOrRole)) {
|
|
48
|
-
if (memberOrRole.permissions)
|
|
49
|
-
return BigInt(memberOrRole.permissions);
|
|
50
|
-
const memberRoles = tsplus_module_1.Members.roles(roles)(memberOrRole);
|
|
51
|
-
basePermissions = forRoles(memberRoles);
|
|
52
|
-
filteredOverwrites = overwrites.filter(overwriteIsForMember(guild_id)(memberOrRole));
|
|
53
|
-
}
|
|
54
|
-
else {
|
|
55
|
-
const everyone = roles.find((role) => role.name === "@everyone");
|
|
56
|
-
basePermissions =
|
|
57
|
-
BigInt(everyone?.permissions || "0") | BigInt(memberOrRole.permissions);
|
|
58
|
-
filteredOverwrites = overwrites.filter(overwriteIsForRole(guild_id)(memberOrRole));
|
|
59
|
-
}
|
|
60
|
-
if (hasAdmin(basePermissions)) {
|
|
61
|
-
return ALL;
|
|
62
|
-
}
|
|
63
|
-
return applyOverwrites(basePermissions)(filteredOverwrites);
|
|
64
|
-
};
|
|
65
|
-
/**
|
|
66
|
-
* Apply permission overwrites to a bitfield.
|
|
67
|
-
*/
|
|
68
|
-
export const applyOverwrites = (permissions) => (overwrites) => overwrites.reduce((permissions, overwrite) => (permissions & ~BigInt(overwrite.deny)) | BigInt(overwrite.allow), permissions);
|
|
69
|
-
//# sourceMappingURL=permissions.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"permissions.js","sourceRoot":"","sources":["../../src/Helpers/permissions.ts"],"names":[],"mappings":";;AAAA;;GAEG;AACH,MAAM,CAAC,MAAM,GAAG,GAAG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AY,CAAC,WAAW,CAAC,CAAA;QACzE,kBAAkB,GAAG,UAAU,CAAC,MAAM,CACpC,kBAAkB,CAAC,QAAQ,CAAC,CAAC,YAAY,CAAC,CAC3C,CAAA;KACF;IAED,IAAI,QAAQ,CAAC,eAAe,CAAC,EAAE;QAC7B,OAAO,GAAG,CAAA;KACX;IACD,OAAO,eAAe,CAAC,eAAe,CAAC,CAAC,kBAAkB,CAAC,CAAA;AAC7D,CAAC,CAAA;AAEH;;GAEG;AACH,MAAM,CAAC,MAAM,eAAe,GAC1B,CAAC,WAAmB,EAAE,EAAE,CAAC,CAAC,UAA+B,EAAE,EAAE,CAC3D,UAAU,CAAC,MAAM,CACf,CAAC,WAAW,EAAE,SAAS,EAAE,EAAE,CACzB,CAAC,WAAW,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,GAAG,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,EACnE,WAAW,CACZ,CAAA"}
|
package/dist/Helpers/ui.d.ts
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { ActionRow, Button, Component, SelectMenu, SelectOption, TextInput, TextInputStyle } from "../types.js";
|
|
2
|
-
export type UIComponent = Exclude<Component, ActionRow>;
|
|
3
|
-
/**
|
|
4
|
-
* Helper to create an Action Row grid.
|
|
5
|
-
*/
|
|
6
|
-
export declare const grid: (items: UIComponent[][]) => ActionRow[];
|
|
7
|
-
/**
|
|
8
|
-
* Helper to create a single column of components
|
|
9
|
-
*/
|
|
10
|
-
export declare const singleColumn: (items: UIComponent[]) => ActionRow[];
|
|
11
|
-
/**
|
|
12
|
-
* Helper to create a button component.
|
|
13
|
-
*/
|
|
14
|
-
export declare const button: (button: Partial<Button>) => Button;
|
|
15
|
-
type BasicSelect = Omit<SelectMenu, "type" | "channel_types" | "options">;
|
|
16
|
-
type StringSelect = BasicSelect & {
|
|
17
|
-
options: SelectOption[];
|
|
18
|
-
};
|
|
19
|
-
type ChannelSelect = Omit<SelectMenu, "type" | "options">;
|
|
20
|
-
/**
|
|
21
|
-
* Helper to create a select component.
|
|
22
|
-
*/
|
|
23
|
-
export declare const select: (select: StringSelect) => SelectMenu;
|
|
24
|
-
/**
|
|
25
|
-
* Helper to create a select component.
|
|
26
|
-
*/
|
|
27
|
-
export declare const userSelect: (select: BasicSelect) => SelectMenu;
|
|
28
|
-
/**
|
|
29
|
-
* Helper to create a select component.
|
|
30
|
-
*/
|
|
31
|
-
export declare const roleSelect: (select: BasicSelect) => SelectMenu;
|
|
32
|
-
/**
|
|
33
|
-
* Helper to create a select component.
|
|
34
|
-
*/
|
|
35
|
-
export declare const mentionableSelect: (select: BasicSelect) => SelectMenu;
|
|
36
|
-
/**
|
|
37
|
-
* Helper to create a select component.
|
|
38
|
-
*/
|
|
39
|
-
export declare const channelSelect: (select: ChannelSelect) => SelectMenu;
|
|
40
|
-
type TextInputOpts = Omit<TextInput, "type" | "style"> & {
|
|
41
|
-
style?: TextInputStyle;
|
|
42
|
-
};
|
|
43
|
-
/**
|
|
44
|
-
* Helper to create a text input
|
|
45
|
-
*/
|
|
46
|
-
export declare const textInput: (input: TextInputOpts) => TextInput;
|
|
47
|
-
export {};
|
|
48
|
-
//# sourceMappingURL=ui.d.ts.map
|
package/dist/Helpers/ui.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ui.d.ts","sourceRoot":"","sources":["../../src/Helpers/ui.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,MAAM,EAEN,SAAS,EAET,UAAU,EACV,YAAY,EACZ,SAAS,EACT,cAAc,EACf,MAAM,aAAa,CAAA;AAEpB,MAAM,MAAM,WAAW,GAAG,OAAO,CAAC,SAAS,EAAE,SAAS,CAAC,CAAA;AAEvD;;GAEG;AACH,eAAO,MAAM,IAAI,UAAW,WAAW,EAAE,EAAE,KAAG,SAAS,EAMpD,CAAA;AAEH;;GAEG;AACH,eAAO,MAAM,YAAY,UAAW,WAAW,EAAE,KAAG,SAAS,EAIxD,CAAA;AAEL;;GAEG;AACH,eAAO,MAAM,MAAM,WAAY,QAAQ,MAAM,CAAC,KAAG,MAI/C,CAAA;AAEF,KAAK,WAAW,GAAG,IAAI,CAAC,UAAU,EAAE,MAAM,GAAG,eAAe,GAAG,SAAS,CAAC,CAAA;AAEzE,KAAK,YAAY,GAAG,WAAW,GAAG;IAChC,OAAO,EAAE,YAAY,EAAE,CAAA;CACxB,CAAA;AAED,KAAK,aAAa,GAAG,IAAI,CAAC,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC,CAAA;AAEzD;;GAEG;AACH,eAAO,MAAM,MAAM,WAAY,YAAY,KAAG,UAG5C,CAAA;AAEF;;GAEG;AACH,eAAO,MAAM,UAAU,WAAY,WAAW,KAAG,UAG/C,CAAA;AAEF;;GAEG;AACH,eAAO,MAAM,UAAU,WAAY,WAAW,KAAG,UAG/C,CAAA;AAEF;;GAEG;AACH,eAAO,MAAM,iBAAiB,WAAY,WAAW,KAAG,UAGtD,CAAA;AAEF;;GAEG;AACH,eAAO,MAAM,aAAa,WAAY,aAAa,KAAG,UAGpD,CAAA;AAEF,KAAK,aAAa,GAAG,IAAI,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG;IACvD,KAAK,CAAC,EAAE,cAAc,CAAA;CACvB,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,SAAS,UAAW,aAAa,KAAG,SAI/C,CAAA"}
|
package/dist/Helpers/ui.js
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import { ButtonStyle, ComponentType, TextInputStyle, } from "../types.js";
|
|
2
|
-
/**
|
|
3
|
-
* Helper to create an Action Row grid.
|
|
4
|
-
*/
|
|
5
|
-
export const grid = (items) => items.map((components) => ({
|
|
6
|
-
type: ComponentType.ACTION_ROW,
|
|
7
|
-
components,
|
|
8
|
-
}));
|
|
9
|
-
/**
|
|
10
|
-
* Helper to create a single column of components
|
|
11
|
-
*/
|
|
12
|
-
export const singleColumn = (items) => items.map((c) => ({
|
|
13
|
-
type: ComponentType.ACTION_ROW,
|
|
14
|
-
components: [c],
|
|
15
|
-
}));
|
|
16
|
-
/**
|
|
17
|
-
* Helper to create a button component.
|
|
18
|
-
*/
|
|
19
|
-
export const button = (button) => ({
|
|
20
|
-
type: ComponentType.BUTTON,
|
|
21
|
-
style: ButtonStyle.PRIMARY,
|
|
22
|
-
...button,
|
|
23
|
-
});
|
|
24
|
-
/**
|
|
25
|
-
* Helper to create a select component.
|
|
26
|
-
*/
|
|
27
|
-
export const select = (select) => ({
|
|
28
|
-
type: ComponentType.STRING_SELECT,
|
|
29
|
-
...select,
|
|
30
|
-
});
|
|
31
|
-
/**
|
|
32
|
-
* Helper to create a select component.
|
|
33
|
-
*/
|
|
34
|
-
export const userSelect = (select) => ({
|
|
35
|
-
type: ComponentType.USER_SELECT,
|
|
36
|
-
...select,
|
|
37
|
-
});
|
|
38
|
-
/**
|
|
39
|
-
* Helper to create a select component.
|
|
40
|
-
*/
|
|
41
|
-
export const roleSelect = (select) => ({
|
|
42
|
-
type: ComponentType.ROLE_SELECT,
|
|
43
|
-
...select,
|
|
44
|
-
});
|
|
45
|
-
/**
|
|
46
|
-
* Helper to create a select component.
|
|
47
|
-
*/
|
|
48
|
-
export const mentionableSelect = (select) => ({
|
|
49
|
-
type: ComponentType.MENTIONABLE_SELECT,
|
|
50
|
-
...select,
|
|
51
|
-
});
|
|
52
|
-
/**
|
|
53
|
-
* Helper to create a select component.
|
|
54
|
-
*/
|
|
55
|
-
export const channelSelect = (select) => ({
|
|
56
|
-
type: ComponentType.CHANNEL_SELECT,
|
|
57
|
-
...select,
|
|
58
|
-
});
|
|
59
|
-
/**
|
|
60
|
-
* Helper to create a text input
|
|
61
|
-
*/
|
|
62
|
-
export const textInput = (input) => ({
|
|
63
|
-
type: ComponentType.TEXT_INPUT,
|
|
64
|
-
style: TextInputStyle.SHORT,
|
|
65
|
-
...input,
|
|
66
|
-
});
|
|
67
|
-
//# sourceMapping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mB,EAAc,EAAE,CAAC,CAAC;IAC9D,IAAI,EAAE,aAAa,CAAC,WAAW;IAC/B,GAAG,MAAM;CACV,CAAC,CAAA;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,MAAmB,EAAc,EAAE,CAAC,CAAC;IACrE,IAAI,EAAE,aAAa,CAAC,kBAAkB;IACtC,GAAG,MAAM;CACV,CAAC,CAAA;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,MAAqB,EAAc,EAAE,CAAC,CAAC;IACnE,IAAI,EAAE,aAAa,CAAC,cAAc;IAClC,GAAG,MAAM;CACV,CAAC,CAAA;AAMF;;GAEG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,KAAoB,EAAa,EAAE,CAAC,CAAC;IAC7D,IAAI,EAAE,aAAa,CAAC,UAAU;IAC9B,KAAK,EAAE,cAAc,CAAC,KAAK;IAC3B,GAAG,KAAK;CACT,CAAC,CAAA"}
|
package/dist/Http/index.d.ts
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
export declare class FetchError {
|
|
2
|
-
readonly reason: unknown;
|
|
3
|
-
readonly _tag = "FetchError";
|
|
4
|
-
constructor(reason: unknown);
|
|
5
|
-
}
|
|
6
|
-
export declare class StatusCodeError {
|
|
7
|
-
readonly response: Response;
|
|
8
|
-
readonly _tag = "StatusCodeError";
|
|
9
|
-
readonly code: number;
|
|
10
|
-
constructor(response: Response);
|
|
11
|
-
}
|
|
12
|
-
export declare const request: (url: URL | string, init?: RequestInit) => import("../common.js").Effect<never, FetchError | StatusCodeError, Response>;
|
|
13
|
-
export declare class JsonParseError {
|
|
14
|
-
readonly reason: unknown;
|
|
15
|
-
readonly _tag = "JsonParseError";
|
|
16
|
-
constructor(reason: unknown);
|
|
17
|
-
}
|
|
18
|
-
export declare const json: <A = unknown>(r: Response) => import("../common.js").Effect<never, JsonParseError, A>;
|
|
19
|
-
export declare class BlobError {
|
|
20
|
-
readonly reason: unknown;
|
|
21
|
-
readonly _tag = "BlobError";
|
|
22
|
-
constructor(reason: unknown);
|
|
23
|
-
}
|
|
24
|
-
export declare const blob: (r: Response) => import("../common.js").Effect<never, BlobError, Blob>;
|
|
25
|
-
export declare const requestWithJson: <A = unknown>(url: URL | string, init?: RequestInit) => import("../common.js").Effect<never, FetchError | StatusCodeError, {
|
|
26
|
-
response: Response;
|
|
27
|
-
json: import("../common.js").Effect<never, JsonParseError, A>;
|
|
28
|
-
blob: import("../common.js").Effect<never, BlobError, Blob>;
|
|
29
|
-
text: import("../common.js").Effect<never, never, string>;
|
|
30
|
-
}>;
|
|
31
|
-
//# sourceMappingURL=index.d.ts.map
|
package/dist/Http/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/Http/index.ts"],"names":[],"mappings":"AAAA,qBAAa,UAAU;IAET,QAAQ,CAAC,MAAM,EAAE,OAAO;IADpC,QAAQ,CAAC,IAAI,gBAAe;gBACP,MAAM,EAAE,OAAO;CACrC;AAED,qBAAa,eAAe;IAGd,QAAQ,CAAC,QAAQ,EAAE,QAAQ;IAFvC,QAAQ,CAAC,IAAI,qBAAoB;IACjC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;gBACA,QAAQ,EAAE,QAAQ;CAGxC;AAED,eAAO,MAAM,OAAO,QAAS,GAAG,GAAG,MAAM,SAAQ,WAAW,iFAkBzD,CAAA;AAEH,qBAAa,cAAc;IAEb,QAAQ,CAAC,MAAM,EAAE,OAAO;IADpC,QAAQ,CAAC,IAAI,oBAAmB;gBACX,MAAM,EAAE,OAAO;CACrC;AAED,eAAO,MAAM,IAAI,mBAAoB,QAAQ,4DAI1C,CAAA;AAEH,qBAAa,SAAS;IAER,QAAQ,CAAC,MAAM,EAAE,OAAO;IADpC,QAAQ,CAAC,IAAI,eAAc;gBACN,MAAM,EAAE,OAAO;CACrC;AAED,eAAO,MAAM,IAAI,MAAO,QAAQ,0DAI7B,CAAA;AAEH,eAAO,MAAM,eAAe,qBACrB,GAAG,GAAG,MAAM,SACX,WAAW;;;;;EAOd,CAAA"}
|
package/dist/Http/index.js
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import * as tsplus_module_1 from "@effect/io/Effect";
|
|
2
|
-
import * as tsplus_module_2 from "@fp-ts/data/Either";
|
|
3
|
-
export class FetchError {
|
|
4
|
-
reason;
|
|
5
|
-
_tag = "FetchError";
|
|
6
|
-
constructor(reason) {
|
|
7
|
-
this.reason = reason;
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
export class StatusCodeError {
|
|
11
|
-
response;
|
|
12
|
-
_tag = "StatusCodeError";
|
|
13
|
-
code;
|
|
14
|
-
constructor(response) {
|
|
15
|
-
this.response = response;
|
|
16
|
-
this.code = response.status;
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
export const request = (url, init = {}) => tsplus_module_1.filterOrElseWith((r) => r.status < 300, (r) => tsplus_module_1.fail(new StatusCodeError(r)))(tsplus_module_1.asyncInterrupt((resume) => {
|
|
20
|
-
const controller = new AbortController();
|
|
21
|
-
fetch(url, {
|
|
22
|
-
...init,
|
|
23
|
-
signal: controller.signal,
|
|
24
|
-
})
|
|
25
|
-
.then((a) => resume(tsplus_module_1.succeed(a)))
|
|
26
|
-
.catch((e) => resume(tsplus_module_1.fail(new FetchError(e))));
|
|
27
|
-
return tsplus_module_2.left(tsplus_module_1.sync(() => {
|
|
28
|
-
controller.abort();
|
|
29
|
-
}));
|
|
30
|
-
}));
|
|
31
|
-
export class JsonParseError {
|
|
32
|
-
reason;
|
|
33
|
-
_tag = "JsonParseError";
|
|
34
|
-
constructor(reason) {
|
|
35
|
-
this.reason = reason;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
export const json = (r) => tsplus_module_1.tryCatchPromise(() => r.json(), (reason) => new JsonParseError(reason));
|
|
39
|
-
export class BlobError {
|
|
40
|
-
reason;
|
|
41
|
-
_tag = "BlobError";
|
|
42
|
-
constructor(reason) {
|
|
43
|
-
this.reason = reason;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
export const blob = (r) => tsplus_module_1.tryCatchPromise(() => r.blob(), (reason) => new BlobError(reason));
|
|
47
|
-
export const requestWithJson = (url, init = {}) => tsplus_module_1.map((response) => ({
|
|
48
|
-
response,
|
|
49
|
-
json: json(response),
|
|
50
|
-
blob: blob(response),
|
|
51
|
-
text: tsplus_module_1.promise(() => response.text()),
|
|
52
|
-
}))(request(url, init));
|
|
53
|
-
//# sourceMappingURL=index.js.map
|
package/dist/Http/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/Http/index.ts"],"names":[],"mappings":";;AAAA,MAAM,OAAO,UAAU;IAEA;IADZ,IAAI,GAAG,YAAY,CAAA;IAC5B,YAAqB,MAAe;QAAf,WAAM,GAAN,MAAM,CAAS;IAAG,CAAC;CACzC;AAED,MAAM,OAAO,eAAe;IAGL;IAFZ,IAAI,GAAG,iBAAiB,CAAA;IACxB,IAAI,CAAQ;IACrB,YAAqB,QAAkB;QAAlB,aAAQ,GAAR,QAAQ,CAAU;QACrC,IAAI,CAAC,IAAI,GAAG,QAAQ,CAAC,MAAM,CAAA;IAC7B,CAAC;CACF;AAED,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,GAAiB,EAAE,OAAoB,EAAE,EAAE,EAAE,CACnE,iCAeE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,GAAG,GAAG,EACrB,CAAC,CAAC,EAAE,EAAE,CAAC,qBAAY,IAAI,eAAe,CAAC,CAAC,CAAC,CAAC,EAhB5C,+BAAmD,CAAC,MAAM,EAAE,EAAE;IAC5D,MAAM,UAAU,GAAG,IAAI,eAAe,EAAE,CAAA;IACxC,KAAK,CAAC,GAAG,EAAE;QACT,GAAG,IAAI;QACP,MAAM,EAAE,UAAU,C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Q,CAAC;IACpB,IAAI,EAAE,wBAAe,GAAG,EAAE,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC;CAC5C,CAAC,EALF,OAAO,CAAC,GAAG,EAAE,IAAI,CAAC,CAKf,CAAA"}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { Discord, Effect } from "dfx/common";
|
|
2
|
-
import { InteractionResponse } from "./definitions.js";
|
|
3
|
-
export declare const InteractionContext: import("../common.js").Tag<import("../types.js").Interaction>;
|
|
4
|
-
export declare const ApplicationCommandContext: import("../common.js").Tag<import("../types.js").ApplicationCommandDatum>;
|
|
5
|
-
export declare const MessageComponentContext: import("../common.js").Tag<import("../types.js").MessageComponentDatum>;
|
|
6
|
-
export declare const ModalSubmitContext: import("../common.js").Tag<import("../types.js").ModalSubmitDatum>;
|
|
7
|
-
export interface FocusedOptionContext {
|
|
8
|
-
readonly focusedOption: Discord.ApplicationCommandInteractionDataOption;
|
|
9
|
-
}
|
|
10
|
-
export declare const FocusedOptionContext: import("../common.js").Tag<FocusedOptionContext>;
|
|
11
|
-
export interface SubCommandContext {
|
|
12
|
-
readonly command: Discord.ApplicationCommandInteractionDataOption;
|
|
13
|
-
}
|
|
14
|
-
export declare const SubCommandContext: import("../common.js").Tag<SubCommandContext>;
|
|
15
|
-
export declare const getCommand: import("../common.js").Effect<import("../types.js").ApplicationCommandDatum, never, import("../types.js").ApplicationCommandDatum>;
|
|
16
|
-
export declare class ResolvedDataNotFound {
|
|
17
|
-
readonly data: Discord.ApplicationCommandDatum;
|
|
18
|
-
readonly name: string;
|
|
19
|
-
readonly _tag = "ResolvedDataNotFound";
|
|
20
|
-
constructor(data: Discord.ApplicationCommandDatum, name: string);
|
|
21
|
-
}
|
|
22
|
-
export declare const getResolved: <A>(name: string, f: (id: Discord.Snowflake, data: Discord.ResolvedDatum) => A | undefined) => import("../common.js").Effect<import("../types.js").ApplicationCommandDatum, ResolvedDataNotFound, A>;
|
|
23
|
-
export declare const focusedOptionValue: import("../common.js").Effect<FocusedOptionContext, never, string>;
|
|
24
|
-
export declare const commandOptionsMap: import("../common.js").Effect<import("../types.js").ApplicationCommandDatum, never, Record<string, string | undefined>>;
|
|
25
|
-
export declare const handleSubCommands: <NER extends Record<string, import("../common.js").Effect<any, any, InteractionResponse>>>(commands: NER) => import("../common.js").Effect<import("../types.js").Interaction | import("../types.js").ApplicationCommandDatum | Exclude<[NER[keyof NER]] extends [{
|
|
26
|
-
[EffectTypeId]: {
|
|
27
|
-
_R: (_: never) => infer R;
|
|
28
|
-
};
|
|
29
|
-
}] ? R : never, SubCommandContext>, [NER[keyof NER]] extends [{
|
|
30
|
-
[EffectTypeId]: {
|
|
31
|
-
_E: (_: never) => infer E;
|
|
32
|
-
};
|
|
33
|
-
}] ? E : never, InteractionResponse>;
|
|
34
|
-
export declare const getSubCommand: import("../common.js").Effect<SubCommandContext, never, import("../types.js").ApplicationCommandInteractionDataOption>;
|
|
35
|
-
export declare const subCommandOptionsMap: import("../common.js").Effect<SubCommandContext, never, Record<string, string | undefined>>;
|
|
36
|
-
export declare const modalValues: import("../common.js").Effect<import("../types.js").ModalSubmitDatum, never, Record<string, string | undefined>>;
|
|
37
|
-
//# sourceMappingURL=context.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/Interactions/context.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAA;AAKtD,eAAO,MAAM,kBAAkB,+DAA6B,CAAA;AAC5D,eAAO,MAAM,yBAAyB,2EAAyC,CAAA;AAC/E,eAAO,MAAM,uBAAuB,yEAAuC,CAAA;AAC3E,eAAO,MAAM,kBAAkB,oEAAkC,CAAA;AAEjE,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,aAAa,EAAE,OAAO,CAAC,uCAAuC,CAAA;CACxE;AACD,eAAO,MAAM,oBAAoB,kDAA8B,CAAA;AAE/D,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC,uCAAuC,CAAA;CAClE;AACD,eAAO,MAAM,iBAAiB,+CAA2B,CAAA;AAEzD,eAAO,MAAM,UAAU,oIAA4C,CAAA;AAEnE,qBAAa,oBAAoB;IAG7B,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC,uBAAuB;IAC9C,QAAQ,CAAC,IAAI,EAAE,MAAM;IAHvB,QAAQ,CAAC,IAAI,0BAAyB;gBAE3B,IAAI,EAAE,OAAO,CAAC,uBAAuB,EACrC,IAAI,EAAE,MAAM;CAExB;AAED,eAAO,MAAM,WAAW,YAChB,MAAM,UACJ,QAAQ,SAAS,QAAQ,QAAQ,aAAa,4HAUrD,CAAA;AAEH,eAAO,MAAM,kBAAkB,oEAE9B,CAAA;AAED,eAAO,MAAM,iBAAiB,yHAE7B,CAAA;AAED,eAAO,MAAM,iBAAiB;;gBAOM,KAAK;;;;gBAQe,KAAK;;oCAsB1D,CAAA;AAEH,eAAO,MAAM,aAAa,wHAEzB,CAAA;AAED,eAAO,MAAM,oBAAoB,6FAA0C,CAAA;AAE3E,eAAO,MAAM,WAAW,kHAEvB,CAAA"}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import * as tsplus_module_1 from "dfx/common";
|
|
2
|
-
import * as tsplus_module_2 from "@effect/io/Effect";
|
|
3
|
-
import * as tsplus_module_3 from "@fp-ts/data/Option";
|
|
4
|
-
import * as tsplus_module_4 from "@fp-ts/data/Function";
|
|
5
|
-
import { InteractionNotFound } from "./handlers.js";
|
|
6
|
-
import * as Arr from "@fp-ts/data/ReadonlyArray";
|
|
7
|
-
import { optionsMap } from "dfx/Helpers/interactions";
|
|
8
|
-
export const InteractionContext = tsplus_module_1.Tag();
|
|
9
|
-
export const ApplicationCommandContext = tsplus_module_1.Tag();
|
|
10
|
-
export const MessageComponentContext = tsplus_module_1.Tag();
|
|
11
|
-
export const ModalSubmitContext = tsplus_module_1.Tag();
|
|
12
|
-
export const FocusedOptionContext = tsplus_module_1.Tag();
|
|
13
|
-
export const SubCommandContext = tsplus_module_1.Tag();
|
|
14
|
-
export const getCommand = tsplus_module_2.service(ApplicationCommandContext);
|
|
15
|
-
export class ResolvedDataNotFound {
|
|
16
|
-
data;
|
|
17
|
-
name;
|
|
18
|
-
_tag = "ResolvedDataNotFound";
|
|
19
|
-
constructor(data, name) {
|
|
20
|
-
this.data = data;
|
|
21
|
-
this.name = name;
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
export const getResolved = (name, f) => tsplus_module_2.serviceWithEffect(ApplicationCommandContext)((a) => tsplus_module_3.match(() => tsplus_module_2.fail(new ResolvedDataNotFound(a, name)), tsplus_module_2.succeed)(tsplus_module_1.IxHelpers.resolveOptionValue(name, f)(a)));
|
|
25
|
-
export const focusedOptionValue = tsplus_module_2.serviceWith(FocusedOptionContext)((a) => a.focusedOption.value ?? "");
|
|
26
|
-
export const commandOptionsMap = tsplus_module_2.serviceWith(ApplicationCommandContext)(optionsMap);
|
|
27
|
-
export const handleSubCommands = (commands) => tsplus_module_2.flatMap(({ interaction, data }) => tsplus_module_4.pipe(tsplus_module_1.IxHelpers.allSubCommands(data), Arr.findFirst((a) => !!commands[a.name]), (o) => tsplus_module_3.toEither(() => new InteractionNotFound(interaction))(o), tsplus_module_2.fromEither, (a) => tsplus_module_2.flatMap((command) => tsplus_module_4.pipe(commands[command.name], tsplus_module_2.provideService(SubCommandContext)({ command })))(a)))(tsplus_module_2.struct({
|
|
28
|
-
interaction: tsplus_module_2.service(InteractionContext),
|
|
29
|
-
data: tsplus_module_2.service(ApplicationCommandContext),
|
|
30
|
-
}));
|
|
31
|
-
export const getSubCommand = tsplus_module_2.serviceWith(SubCommandContext)((a) => a.command);
|
|
32
|
-
export const subCommandOptionsMap = tsplus_module_2.map(tsplus_module_1.IxHelpers.optionsMap)(getSubCommand);
|
|
33
|
-
export const modalValues = tsplus_module_2.serviceWith(ModalSubmitContext)(tsplus_module_1.IxHelpers.componentsMap);
|
|
34
|
-
//# sourceMappingURL=context.js.map
|