dfx 0.43.1 → 0.45.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.
@@ -0,0 +1,48 @@
1
+ import { Chunk, Cause } from "dfx/_common";
2
+ import * as Http from "@effect-http/client";
3
+ import { DiscordREST } from "dfx";
4
+ import { Discord, Effect } from "dfx/_common";
5
+ import * as D from "./definitions.js";
6
+ type ExtractTag<A> = A extends {
7
+ _tag: infer Tag;
8
+ } ? Tag extends string ? Tag : never : never;
9
+ /**
10
+ * @tsplus type dfx/InteractionBuilder
11
+ */
12
+ export declare class InteractionBuilder<R, E, TE> {
13
+ readonly definitions: Chunk<readonly [
14
+ handler: D.InteractionDefinition<R, E>,
15
+ transform: (self: Effect<any, any, any>) => Effect<R, TE, void>
16
+ ]>;
17
+ readonly transform: (self: Effect<any, any, any>) => Effect<R, TE, void>;
18
+ constructor(definitions: Chunk<readonly [
19
+ handler: D.InteractionDefinition<R, E>,
20
+ transform: (self: Effect<any, any, any>) => Effect<R, TE, void>
21
+ ]>, transform: (self: Effect<any, any, any>) => Effect<R, TE, void>);
22
+ add<R1, E1>(definition: D.InteractionDefinition<R1, E1>): InteractionBuilder<R | R1, E | E1, TE | E1>;
23
+ concat<R1, E1, TE1>(builder: InteractionBuilder<R1, E1, TE1>): InteractionBuilder<R | R1, E | E1, TE | TE1>;
24
+ private transformTransform;
25
+ private transformHandlers;
26
+ catchAllCause<R1, E1>(f: (cause: Cause<TE>) => Effect<R1, E1, void>): InteractionBuilder<R | R1, E, E1>;
27
+ catchAllCauseRespond<R1, E1>(f: (cause: Cause<E>) => Effect<R1, E1, Discord.InteractionResponse>): InteractionBuilder<R | R1, E1, Exclude<TE, Exclude<E, E1>> | Exclude<E1, E>>;
28
+ catchAll<R1, E1>(f: (error: TE) => Effect<R1, E1, void>): InteractionBuilder<R | R1, E, E1>;
29
+ catchAllRespond<R1, E1>(f: (error: E) => Effect<R1, E1, Discord.InteractionResponse>): InteractionBuilder<R | R1, E1, Exclude<TE, Exclude<E, E1>> | Exclude<E1, E>>;
30
+ catchTag<T extends ExtractTag<E>, R1, E1>(tag: T, f: (error: Extract<TE, {
31
+ _tag: T;
32
+ }>) => Effect<R1, E1, void>): InteractionBuilder<R | R1, E, E1 | Exclude<TE, {
33
+ _tag: T;
34
+ }>>;
35
+ catchTagRespond<T extends ExtractTag<E>, R1, E1>(tag: T, f: (error: Extract<E, {
36
+ _tag: T;
37
+ }>) => Effect<R1, E1, Discord.InteractionResponse>): InteractionBuilder<R | R1, E1 | Exclude<E, {
38
+ _tag: T;
39
+ }>, Exclude<TE, Exclude<E, E1 | Exclude<E, {
40
+ _tag: T;
41
+ }>>> | Exclude<E1, E> | Exclude<Exclude<E, {
42
+ _tag: T;
43
+ }>, E>>;
44
+ get syncGlobal(): Effect<DiscordREST, import("../DiscordREST.js").DiscordRESTError | Http.ResponseDecodeError, import("../DiscordREST/types.js").ResponseWithData<Discord.ApplicationCommand[]>>;
45
+ syncGuild(appId: Discord.Snowflake, guildId: Discord.Snowflake): Effect<DiscordREST, import("../DiscordREST.js").DiscordRESTError, import("../DiscordREST/types.js").ResponseWithData<Discord.ApplicationCommand[]>>;
46
+ }
47
+ export declare const builder: InteractionBuilder<never, never, never>;
48
+ export {};
@@ -0,0 +1,68 @@
1
+ import * as tsplus_module_1 from "@effect/data/Chunk";
2
+ import * as tsplus_module_2 from "@effect/io/Effect";
3
+ import * as tsplus_module_3 from "@effect/data/Function";
4
+ import * as Http from "@effect-http/client";
5
+ import { catchTag } from "@effect/io/Effect";
6
+ import { DiscordREST } from "dfx";
7
+ /**
8
+ * @tsplus type dfx/InteractionBuilder
9
+ */
10
+ export class InteractionBuilder {
11
+ definitions;
12
+ transform;
13
+ constructor(definitions, transform) {
14
+ this.definitions = definitions;
15
+ this.transform = transform;
16
+ }
17
+ add(definition) {
18
+ return new InteractionBuilder(tsplus_module_1.append(this.definitions, [definition, this.transform]), this.transform);
19
+ }
20
+ concat(builder) {
21
+ return new InteractionBuilder(tsplus_module_1.concat(this.definitions, builder.definitions), this.transform);
22
+ }
23
+ transformTransform(f) {
24
+ return new InteractionBuilder(tsplus_module_1.map(this.definitions, ([d, t]) => [d, _ => f(t(_))]), _ => f(this.transform(_)));
25
+ }
26
+ transformHandlers(f) {
27
+ return new InteractionBuilder(tsplus_module_1.map(this.definitions, ([d, t]) => [
28
+ {
29
+ ...d,
30
+ handle: tsplus_module_2.isEffect(d.handle)
31
+ ? f(d.handle)
32
+ : (_) => f(d.handle(_)),
33
+ },
34
+ t,
35
+ ]), this.transform);
36
+ }
37
+ catchAllCause(f) {
38
+ return this.transformTransform(_ => tsplus_module_2.catchAllCause(_, f));
39
+ }
40
+ catchAllCauseRespond(f) {
41
+ return this.transformHandlers(_ => tsplus_module_2.catchAllCause(_, f));
42
+ }
43
+ catchAll(f) {
44
+ return this.transformTransform(_ => tsplus_module_2.catchAll(_, f));
45
+ }
46
+ catchAllRespond(f) {
47
+ return this.transformHandlers(_ => tsplus_module_2.catchAll(_, f));
48
+ }
49
+ catchTag(tag, f) {
50
+ return this.transformTransform(_ => catchTag(_, tag, f));
51
+ }
52
+ catchTagRespond(tag, f) {
53
+ return this.transformHandlers(_ => catchTag(_, tag, f));
54
+ }
55
+ get syncGlobal() {
56
+ const commands = tsplus_module_1.map(tsplus_module_1.filter(tsplus_module_1.map(this.definitions, ([d, _]) => d), (c) => c._tag === "GlobalApplicationCommand"), c => c.command);
57
+ return tsplus_module_2.flatMap(DiscordREST, rest => tsplus_module_2.flatMap(tsplus_module_2.flatMap(rest
58
+ .getCurrentBotApplicationInformation(), r => r.json), app => rest.bulkOverwriteGlobalApplicationCommands(app.id, {
59
+ body: Http.body.json(commands),
60
+ })));
61
+ }
62
+ syncGuild(appId, guildId) {
63
+ const commands = tsplus_module_1.map(tsplus_module_1.filter(tsplus_module_1.map(this.definitions, ([d, _]) => d), (c) => c._tag === "GuildApplicationCommand"), c => c.command);
64
+ return tsplus_module_2.flatMap(DiscordREST, rest => rest.bulkOverwriteGuildApplicationCommands(appId, guildId, commands));
65
+ }
66
+ }
67
+ export const builder = new InteractionBuilder(tsplus_module_1.empty(), tsplus_module_3.identity);
68
+ //# sourceMappingURL=builder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"builder.js","sourceRoot":"","sources":["../src/Interactions/builder.ts"],"names":[],"mappings":";;;AAAA,OAAO,KAAK,IAAI,MAAM,qBAAqB,CAAA;AAC3C,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,KAAK,CAAA;AAUjC;;GAEG;AACH,MAAM,OAAO,kBAAkB;IAElB;IAMA;IAPX,YACW,WAKR,EACQ,SAA+D;QAN/D,gBAAW,GAAX,WAAW,CAKnB;QACQ,cAAS,GAAT,SAAS,CAAsD;IACvE,CAAC;IAEJ,GAAG,CAAS,UAA2C;QACrD,OAAO,IAAI,kBAAkB,CAC3B,uBAAA,IAAI,CAAC,WAAW,EAAQ,CAAC,UAAU,EAAE,IAAI,CAAC,SAAS,CAAU,CAAC,EAC9D,IAAI,CAAC,SAAS,CACf,CAAA;IACH,CAAC;IAED,MAAM,CAAc,OAAwC;QAC1D,OAAO,IAAI,kBAAkB,CAC3B,uBAAA,IAAI,CAAC,WAAW,EAAQ,OAAO,CAAC,WAAW,CAAC,EAC5C,IAAI,CAAC,SAAS,CACf,CAAA;IACH,CAAC;IAEO,kBAAkB,CACxB,CAAsD;QAEtD,OAAO,IAAI,kBAAkB,CAC3B,oBAAA,IAAI,CAAC,WAAW,EAAK,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAQ,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAQ,CAAC,CAAC,EACjE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAQ,CACjC,CAAA;IACH,CA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ACH,CAAC;CACF;AAED,MAAM,CAAC,MAAM,OAAO,GAAG,IAAI,kBAAkB,CAC3C,uBAAa,EACb,gBAAA,QAAe,CAChB,CAAA"}
@@ -48,7 +48,7 @@ interface DeepReadonlyArray<T> extends ReadonlyArray<DeepReadonly<T>> {
48
48
  type DeepReadonlyObject<T> = {
49
49
  readonly [P in keyof T]: DeepReadonly<T[P]>;
50
50
  };
51
- type CommandHandler<R, E, A = any> = Effect<R, E, Discord.InteractionResponse> | CommandHandlerFn<R, E, A>;
51
+ export type CommandHandler<R, E, A = any> = Effect<R, E, Discord.InteractionResponse> | CommandHandlerFn<R, E, A>;
52
52
  export interface CommandHelper<A> {
53
53
  resolve: <T>(name: AllResolvables<A>["name"], f: (id: Discord.Snowflake, data: Discord.ResolvedDatum) => T | undefined) => Effect<Discord.Interaction, ResolvedDataNotFound, T>;
54
54
  option: (name: AllCommandOptions<A>["name"]) => Effect<Discord.ApplicationCommandDatum, never, Maybe<Discord.ApplicationCommandInteractionDataOption>>;
@@ -70,7 +70,7 @@ export interface CommandHelper<A> {
70
70
  };
71
71
  }] ? E : never, Discord.InteractionResponse>;
72
72
  }
73
- type CommandHandlerFn<R, E, A> = (i: CommandHelper<A>) => Effect<R, E, Discord.InteractionResponse>;
73
+ export type CommandHandlerFn<R, E, A> = (i: CommandHelper<A>) => Effect<R, E, Discord.InteractionResponse>;
74
74
  interface CommandOption {
75
75
  readonly type: any;
76
76
  readonly name: string;
@@ -1,4 +1,4 @@
1
- import { Effect, Discord } from "dfx/_common";
1
+ import { Effect, Discord, Cause } from "dfx/_common";
2
2
  import * as Http from "@effect-http/client";
3
3
  import { DiscordGateway } from "dfx/DiscordGateway";
4
4
  import { DiscordREST, DiscordRESTError } from "dfx/DiscordREST";
@@ -11,4 +11,10 @@ export interface RunOpts {
11
11
  * @tsplus pipeable dfx/InteractionBuilder runGateway
12
12
  * @tsplus location "dfx/Interactions/gateway"
13
13
  */
14
- export declare const run: <R, R2, E, E2>(postHandler: (effect: import("@effect/io/Effect").Effect<R | DiscordREST | import("../types.js").Interaction, E | DiscordRESTError | DefinitionNotFound, void>) => import("@effect/io/Effect").Effect<R2, E2, void>, { sync }?: RunOpts) => (ix: InteractionBuilder<R, E>) => import("@effect/io/Effect").Effect<DiscordREST | DiscordGateway | Exclude<R2, import("../types.js").Interaction>, E2 | DiscordRESTError | Http.ResponseDecodeError, never>;
14
+ export declare const run: <R, R2, E, TE, E2>(postHandler: (effect: import("@effect/io/Effect").Effect<R | DiscordREST | import("../types.js").Interaction, TE | DiscordRESTError | DefinitionNotFound, void>) => import("@effect/io/Effect").Effect<R2, E2, void>, { sync }?: RunOpts) => (ix: InteractionBuilder<R, E, TE>) => import("@effect/io/Effect").Effect<DiscordREST | DiscordGateway | Exclude<R2, import("../types.js").Interaction>, E2 | DiscordRESTError | Http.ResponseDecodeError, never>;
15
+ export interface InteractionsRegistry {
16
+ readonly register: <E>(ix: InteractionBuilder<never, E, never>) => Effect<never, never, void>;
17
+ readonly run: <R, E>(onError: (_: Cause<DiscordRESTError | DefinitionNotFound>) => Effect<R, E, void>, opts?: RunOpts) => Effect<DiscordREST | DiscordGateway | Exclude<R, Discord.Interaction>, DiscordRESTError | Http.ResponseDecodeError | E, never>;
18
+ }
19
+ export declare const InteractionsRegistry: import("@effect/data/Context").Tag<InteractionsRegistry, InteractionsRegistry>;
20
+ export declare const InteractionsRegistryLive: import("@effect-http/client/_common").Layer<never, never, InteractionsRegistry>;
@@ -1,24 +1,36 @@
1
1
  import * as tsplus_module_1 from "@effect/io/Effect";
2
- import * as tsplus_module_2 from "@effect/data/Function";
2
+ import * as tsplus_module_2 from "@effect/data/Chunk";
3
+ import * as tsplus_module_3 from "@effect/io/Ref";
4
+ import * as tsplus_module_4 from "dfx/_common";
3
5
  import * as Http from "@effect-http/client";
4
6
  import { DiscordGateway } from "dfx/DiscordGateway";
5
7
  import { DiscordREST } from "dfx/DiscordREST";
6
8
  import { handlers } from "./handlers.js";
7
- import { Interaction } from "./index.js";
8
- import { splitDefinitions } from "./utils.js";
9
+ import { Interaction, builder } from "./index.js";
9
10
  /**
10
11
  * @tsplus pipeable dfx/InteractionBuilder runGateway
11
12
  */
12
- export const run = (postHandler, { sync = true } = {}) => (ix) => (() => {
13
- const { GlobalApplicationCommand, GuildApplicationCommand } = splitDefinitions(ix.definitions);
13
+ const run_1 = (postHandler, { sync = true } = {}) => (ix) => (() => {
14
+ const GlobalApplicationCommand = tsplus_module_2.toReadonlyArray(tsplus_module_2.filter(tsplus_module_2.map(ix.definitions, _ => _[0]), (_) => _._tag === "GlobalApplicationCommand"));
15
+ const GuildApplicationCommand = tsplus_module_2.toReadonlyArray(tsplus_module_2.filter(tsplus_module_2.map(ix.definitions, _ => _[0]), (_) => _._tag === "GuildApplicationCommand"));
14
16
  return tsplus_module_1.flatMap(DiscordGateway, gateway => tsplus_module_1.flatMap(DiscordREST, rest => tsplus_module_1.flatMap(tsplus_module_1.flatMap(rest.getCurrentBotApplicationInformation(), a => a.json), application => {
15
- const globalSync = rest.bulkOverwriteGlobalApplicationCommands(application.id, { body: Http.body.json(GlobalApplicationCommand.map(a => a.command)) });
17
+ const globalSync = rest.bulkOverwriteGlobalApplicationCommands(application.id, {
18
+ body: Http.body.json(GlobalApplicationCommand.map(_ => _.command)),
19
+ });
16
20
  const guildSync = GuildApplicationCommand.length
17
- ? gateway.handleDispatch("GUILD_CREATE", a => rest.bulkOverwriteGuildApplicationCommands(application.id, a.id, GuildApplicationCommand.map(a => a.command)))
21
+ ? gateway.handleDispatch("GUILD_CREATE", a => rest.bulkOverwriteGuildApplicationCommands(application.id, a.id, GuildApplicationCommand.map(_ => _.command)))
18
22
  : tsplus_module_1.never();
19
- const handle = handlers(ix.definitions);
20
- const run = gateway.handleDispatch("INTERACTION_CREATE", i => tsplus_module_1.provideService(tsplus_module_2.pipe(tsplus_module_1.tap(handle[i.type](i), r => rest.createInteractionResponse(i.id, i.token, r)), postHandler), Interaction, i));
23
+ const handle = handlers(ix.definitions, (i, r) => rest.createInteractionResponse(i.id, i.token, r));
24
+ const run = gateway.handleDispatch("INTERACTION_CREATE", i => tsplus_module_1.provideService(postHandler(handle[i.type](i)), Interaction, i));
21
25
  return sync ? tsplus_module_1.zipParRight(tsplus_module_1.zipParRight(run, globalSync), guildSync) : run;
22
26
  })));
23
27
  })();
28
+ export const run = run_1;
29
+ const makeRegistry = tsplus_module_1.map(tsplus_module_3.make(builder), ref => {
30
+ const register = (ix) => tsplus_module_3.update(ref, _ => _.concat(ix));
31
+ const run = (onError, opts) => tsplus_module_1.flatMap(tsplus_module_3.get(ref), _ => run_1(_ => tsplus_module_1.catchAllCause(_, onError), opts)(_));
32
+ return { register, run };
33
+ });
34
+ export const InteractionsRegistry = tsplus_module_4.Tag();
35
+ export const InteractionsRegistryLive = tsplus_module_1.toLayer(makeRegistry, InteractionsRegistry);
24
36
  //# sourceMappingURL=gateway.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"gateway.js","sourceRoot":"","sources":["../src/Interactions/gateway.ts"],"names":[],"mappings":";;AAAA,OAAO,KAAK,IAAI,MAAM,qBAAqB,CAAA;AAC3C,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AACnD,OAAO,EAAE,WAAW,EAAoB,MAAM,iBAAiB,CAAA;AAC/D,OAAO,EAAsB,QAAQ,EAAE,MAAM,eAAe,CAAA;AAC5D,OAAO,EAAE,WAAW,EAAsB,MAAM,YAAY,CAAA;AAC5D,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA;AAM7C;;GAEG;AACH,MAAM,CAAC,MAAM,GAAG,GACd,CACE,WAMyB,EACzB,EAAE,IAAI,GAAG,IAAI,KAAc,EAAE,EAC7B,EAAE,CACJ,CACE,EAA4B,EAK5B,EAAE;IAEA,MAAM,EAAE,wBAAwB,EAAE,uBAAuB,EAAE,GACzD,gBAAgB,CAAC,EAAE,CAAC,WAAW,CAAC,CAAA;mCAEhB,cAAc,EAA1B,OAAO,4BACE,WAAW,EAApB,I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,CAAC,EAAe,OAAO,CAAC,EAAE,IAAI,EAAhD,CAAC,CAAgD,CAAC,CAAA;IAE5E,OAAO,EAAE,QAAQ,EAAE,GAAG,EAAW,CAAA;EACjC,CAAA;AAmBF,MAAM,CAAC,MAAM,oBAAoB,GAAG,gBAAA,GAAG,EAAwB,CAAA;AAC/D,MAAM,CAAC,MAAM,wBAAwB,GACnC,wBAAA,YAAY,EAAS,oBAAoB,CAAC,CAAA"}
@@ -1,10 +1,10 @@
1
- import { Discord, Effect } from "dfx/_common";
1
+ import { Discord, Effect, Chunk } from "dfx/_common";
2
2
  import * as D from "./definitions.js";
3
3
  export declare class DefinitionNotFound {
4
4
  readonly interaction: Discord.Interaction;
5
5
  readonly _tag = "DefinitionNotFound";
6
6
  constructor(interaction: Discord.Interaction);
7
7
  }
8
- type Handler<R, E> = Effect<R | Discord.Interaction, E | DefinitionNotFound, Discord.InteractionResponse>;
9
- export declare const handlers: <R, E>(definitions: D.InteractionDefinition<R, E>[]) => Record<import("../types.js").InteractionType, (i: Discord.Interaction) => Handler<R, E>>;
8
+ type Handler<R, E, A> = Effect<R | Discord.Interaction, E | DefinitionNotFound, A>;
9
+ export declare const handlers: <R, E, TE, A, B>(definitions: import("../_common.js").Chunk<readonly [handler: D.InteractionDefinition<R, E>, transform: (self: import("@effect/io/Effect").Effect<R, E, A>) => import("@effect/io/Effect").Effect<R, TE, B>]>, handleResponse: (ix: Discord.Interaction, _: Discord.InteractionResponse) => import("@effect/io/Effect").Effect<R, E, A>) => Record<import("../types.js").InteractionType, (i: Discord.Interaction) => Handler<R, E, B>>;
10
10
  export {};
@@ -1,11 +1,9 @@
1
1
  import * as tsplus_module_1 from "dfx/_common";
2
2
  import * as tsplus_module_2 from "@effect/io/Effect";
3
3
  import * as tsplus_module_3 from "@effect/data/Option";
4
- import * as tsplus_module_4 from "@effect/data/Function";
5
- import * as Arr from "@effect/data/ReadonlyArray";
6
4
  import * as IxHelpers from "dfx/Helpers/interactions";
7
5
  import * as Ctx from "./context.js";
8
- import { splitDefinitions } from "./utils.js";
6
+ import { flattenDefinitions, splitDefinitions } from "./utils.js";
9
7
  export class DefinitionNotFound {
10
8
  interaction;
11
9
  _tag = "DefinitionNotFound";
@@ -13,45 +11,34 @@ export class DefinitionNotFound {
13
11
  this.interaction = interaction;
14
12
  }
15
13
  }
16
- const context = {
17
- resolve: Ctx.resolved,
18
- option: Ctx.option,
19
- optionValue: Ctx.optionValue,
20
- optionValueOptional: Ctx.optionValueOptional,
21
- subCommands: Ctx.handleSubCommands,
22
- };
23
- export const handlers = (definitions) => {
24
- const { Commands, Autocomplete, MessageComponent, ModalSubmit } = splitDefinitions(definitions);
14
+ export const handlers = (definitions, handleResponse) => {
15
+ const flattened = flattenDefinitions(definitions, handleResponse);
16
+ const { Commands, Autocomplete, MessageComponent, ModalSubmit } = splitDefinitions(flattened);
25
17
  return {
26
18
  [1 /* Discord.InteractionType.PING */]: () => tsplus_module_2.succeed({
27
19
  type: 1 /* Discord.InteractionCallbackType.PONG */,
28
20
  }),
29
21
  [2 /* Discord.InteractionType.APPLICATION_COMMAND */]: i => {
30
22
  const data = i.data;
31
- return tsplus_module_2.provideService(tsplus_module_3.match(tsplus_module_3.fromNullable(Commands[data.name]), () => tsplus_module_2.fail(new DefinitionNotFound(i)), command => tsplus_module_2.isEffect(command.handle)
32
- ? command.handle
33
- : command.handle(context)), Ctx.ApplicationCommand, data);
23
+ return tsplus_module_3.match(tsplus_module_3.fromNullable(Commands[data.name]), () => tsplus_module_2.fail(new DefinitionNotFound(i)), command => tsplus_module_2.provideService(command
24
+ .handle(i), Ctx.ApplicationCommand, data));
34
25
  },
35
- [5 /* Discord.InteractionType.MODAL_SUBMIT */]: (i) => {
26
+ [5 /* Discord.InteractionType.MODAL_SUBMIT */]: i => {
36
27
  const data = i.data;
37
- return tsplus_module_4.pipe(ModalSubmit, Arr.map(a => tsplus_module_2.all({
38
- command: tsplus_module_2.succeed(a),
39
- match: a.predicate(data.custom_id),
40
- })), _ => tsplus_module_2.provideService(tsplus_module_2.flatMap(tsplus_module_2.allPar(_), _ => tsplus_module_3.match(Arr.findFirst(_, _ => _.match), () => tsplus_module_2.fail(new DefinitionNotFound(i)), a => a.command.handle)), Ctx.ModalSubmitData, data));
28
+ return tsplus_module_2.flatMap(tsplus_module_2.find(ModalSubmit, _ => _.predicate(data.custom_id)), _ => tsplus_module_3.match(_, () => tsplus_module_2.fail(new DefinitionNotFound(i)), match => tsplus_module_2.provideService(match
29
+ .handle(i), Ctx.ModalSubmitData, data)));
41
30
  },
42
31
  [3 /* Discord.InteractionType.MESSAGE_COMPONENT */]: i => {
43
32
  const data = i.data;
44
- return tsplus_module_4.pipe(MessageComponent, Arr.map(a => tsplus_module_2.all({
45
- command: tsplus_module_2.succeed(a),
46
- match: a.predicate(data.custom_id),
47
- })), _ => tsplus_module_2.provideService(tsplus_module_2.flatMap(tsplus_module_2.allPar(_), commands => tsplus_module_3.match(Arr.findFirst(commands, _ => _.match), () => tsplus_module_2.fail(new DefinitionNotFound(i)), _ => _.command.handle)), Ctx.MessageComponentData, data));
33
+ return tsplus_module_2.flatMap(tsplus_module_2.find(MessageComponent, _ => _.predicate(data.custom_id)), _ => tsplus_module_3.match(_, () => tsplus_module_2.fail(new DefinitionNotFound(i)), match => tsplus_module_2.provideService(match
34
+ .handle(i), Ctx.MessageComponentData, data)));
48
35
  },
49
36
  [4 /* Discord.InteractionType.APPLICATION_COMMAND_AUTOCOMPLETE */]: i => {
50
37
  const data = i.data;
51
- return tsplus_module_3.getOrElse(tsplus_module_3.map(IxHelpers.focusedOption(data), focusedOption => tsplus_module_4.pipe(Autocomplete, Arr.map(_ => tsplus_module_2.all({
52
- command: tsplus_module_2.succeed(_),
53
- match: _.predicate(data, focusedOption),
54
- })), _ => tsplus_module_2.provideService(tsplus_module_2.provideService(tsplus_module_2.flatMap(tsplus_module_2.allPar(_), _ => tsplus_module_3.match(Arr.findFirst(_, _ => _.match), () => tsplus_module_2.fail(new DefinitionNotFound(i)), _ => _.command.handle)), Ctx.ApplicationCommand, data), Ctx.FocusedOptionContext, { focusedOption }))), () => tsplus_module_2.fail(new DefinitionNotFound(i)));
38
+ return tsplus_module_3.match(IxHelpers.focusedOption(data), () => tsplus_module_2.fail(new DefinitionNotFound(i)), focusedOption => tsplus_module_2.flatMap(tsplus_module_2.find(Autocomplete, _ => _.predicate(data, focusedOption)), _ => tsplus_module_3.match(_, () => tsplus_module_2.fail(new DefinitionNotFound(i)), match => tsplus_module_2.provideService(tsplus_module_2.provideService(match
39
+ .handle(i), Ctx.ApplicationCommand, data), Ctx.FocusedOptionContext, {
40
+ focusedOption,
41
+ }))));
55
42
  },
56
43
  };
57
44
  };
@@ -1 +1 @@
1
- {"version":3,"file":"handlers.js","sourceRoot":"","sources":["../src/Interactions/handlers.ts"],"names":[],"mappings":";;;;AAAA,OAAO,KAAK,GAAG,MAAM,4BAA4B,CAAA;AACjD,OAAO,KAAK,SAAS,MAAM,0BAA0B,CAAA;AACrD,OAAO,KAAK,GAAG,MAAM,cAAc,CAAA;AAEnC,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA;AAE7C,MAAM,OAAO,kBAAkB;IAER;IADZ,IAAI,GAAG,oBAAoB,CAAA;IACpC,YAAqB,WAAgC;QAAhC,gBAAW,GAAX,WAAW,CAAqB;IAAG,CAAC;CAC1D;AAQD,MAAM,OAAO,GAAyB;IACpC,OAAO,EAAE,GAAG,CAAC,QAAQ;IACrB,MAAM,EAAE,GAAG,CAAC,MAAM;IAClB,WAAW,EAAE,GAAG,CAAC,WAAW;IAC5B,mBAAmB,EAAE,GAAG,CAAC,mBAAmB;IAC5C,WAAW,EAAE,GAAG,CAAC,iBAAiB;CAC5B,CAAA;AAER,MAAM,CAAC,MAAM,QAAQ,GAAG,CACtB,WAA4C,EAI5C,EAAE;IACF,MAAM,EAAE,QAAQ,EAAE,YAAY,EAAE,gBAAgB,EAAE,WAAW,EAAE,GAC7D,gBAAgB,CAAC,WAAW,CAAC,CAAA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,kEAA0D,EAAE,CAAC,CAAC,EAAE;YAC9D,MAAM,IAAI,GAAG,CAAC,CAAC,IAAuC,CAAA;YAEtD,OAAO,sBAAA,SAAS,CAAC,aAAa,CAAC,IAAI,CAAC,EAClC,GAAG,EAAE,CAAC,qBAAY,IAAI,kBAAkB,CAAC,CAAC,CAAC,CAAC,EAC5C,aAAa,CAAC,EAAE,CACd,wBAAA,qBAAA,YAAY,EAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,IAAI,EAAE,aAAa,CAAC,CAAC,EAAS,CAAC,CAAC,EAAE,CACnE,sBAAA,CAAC,EACC,GAAG,EAAE,CAAC,qBAAY,IAAI,kBAAkB,CAAC,CAAC,CAAC,CAAC,EAC5C,KAAK,CAAC,EAAE,CACN,+BAAA,+BAAA,KAAK;iBACF,MAAM,CAAC,CAAC,CAAC,EACM,GAAG,CAAC,kBAAkB,EAAE,IAAI,CAAC,EAC7B,GAAG,CAAC,oBAAoB,EAAE;gBACxC,aAAa;aACd,CAAqB,CAC3B,CACF,CACJ,CAAA;QACH,CAAC;KACF,CAAA;AACH,CAAC,CAAA"}
@@ -1,23 +1,8 @@
1
- import { DiscordREST } from "dfx";
2
1
  import { Discord, Effect } from "dfx/_common";
3
- import * as D from "./definitions.js";
4
- import * as Http from "@effect-http/client";
5
2
  export { response } from "../Helpers/interactions.js";
6
- export * as helpers from "../Helpers/interactions.js";
3
+ export * from "./builder.js";
7
4
  export * from "./context.js";
8
- export { autocomplete, global, guild, InteractionDefinition, messageComponent, modalSubmit, } from "./definitions.js";
9
- /**
10
- * @tsplus type dfx/InteractionBuilder
11
- */
12
- export declare class InteractionBuilder<R, E> {
13
- readonly definitions: D.InteractionDefinition<R, E>[];
14
- constructor(definitions: D.InteractionDefinition<R, E>[]);
15
- add<R1, E1>(definition: D.InteractionDefinition<R1, E1>): InteractionBuilder<R | R1, E | E1>;
16
- concat<R1, E1>(builder: InteractionBuilder<R1, E1>): InteractionBuilder<R | R1, E | E1>;
17
- get syncGlobal(): Effect<DiscordREST, import("../DiscordREST.js").DiscordRESTError | Http.ResponseDecodeError, import("../DiscordREST/types.js").ResponseWithData<Discord.ApplicationCommand[]>>;
18
- syncGuild(appId: Discord.Snowflake, guildId: Discord.Snowflake): Effect<DiscordREST, import("../DiscordREST.js").DiscordRESTError, import("../DiscordREST/types.js").ResponseWithData<Discord.ApplicationCommand[]>>;
19
- }
20
- export declare const builder: InteractionBuilder<never, never>;
5
+ export { InteractionDefinition, autocomplete, global, guild, messageComponent, modalSubmit, } from "./definitions.js";
21
6
  export declare const id: (query: string) => (customId: string) => Effect<never, never, boolean>;
22
7
  export declare const idStartsWith: (query: string) => (customId: string) => Effect<never, never, boolean>;
23
8
  export declare const idRegex: (query: RegExp) => (customId: string) => Effect<never, never, boolean>;
@@ -1,47 +1,8 @@
1
1
  import * as tsplus_module_1 from "@effect/io/Effect";
2
- import { DiscordREST } from "dfx";
3
- import * as Http from "@effect-http/client";
4
2
  export { response } from "../Helpers/interactions.js";
5
- export * as helpers from "../Helpers/interactions.js";
3
+ export * from "./builder.js";
6
4
  export * from "./context.js";
7
5
  export { autocomplete, global, guild, messageComponent, modalSubmit, } from "./definitions.js";
8
- /**
9
- * @tsplus type dfx/InteractionBuilder
10
- */
11
- export class InteractionBuilder {
12
- definitions;
13
- constructor(definitions) {
14
- this.definitions = definitions;
15
- }
16
- add(definition) {
17
- return new InteractionBuilder([
18
- ...this.definitions,
19
- definition,
20
- ]);
21
- }
22
- concat(builder) {
23
- return new InteractionBuilder([
24
- ...this.definitions,
25
- ...builder.definitions,
26
- ]);
27
- }
28
- get syncGlobal() {
29
- const commands = this.definitions
30
- .filter((c) => c._tag === "GlobalApplicationCommand")
31
- .map(c => c.command);
32
- return tsplus_module_1.flatMap(DiscordREST, rest => tsplus_module_1.flatMap(tsplus_module_1.flatMap(rest
33
- .getCurrentBotApplicationInformation(), r => r.json), app => rest.bulkOverwriteGlobalApplicationCommands(app.id, {
34
- body: Http.body.json(commands),
35
- })));
36
- }
37
- syncGuild(appId, guildId) {
38
- const commands = this.definitions
39
- .filter((c) => c._tag === "GuildApplicationCommand")
40
- .map(c => c.command);
41
- return tsplus_module_1.flatMap(DiscordREST, rest => rest.bulkOverwriteGuildApplicationCommands(appId, guildId, commands));
42
- }
43
- }
44
- export const builder = new InteractionBuilder([]);
45
6
  // Filters
46
7
  export const id = (query) => (customId) => tsplus_module_1.succeed(query === customId);
47
8
  export const idStartsWith = (query) => (customId) => tsplus_module_1.succeed(customId.startsWith(query));
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/Interactions/index.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,KAAK,CAAA;AAGjC,OAAO,KAAK,IAAI,MAAM,qBAAqB,CAAA;AAE3C,OAAO,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAA;AACrD,OAAO,KAAK,OAAO,MAAM,4BAA4B,CAAA;AACrD,cAAc,cAAc,CAAA;AAC5B,OAAO,EACL,YAAY,EACZ,MAAM,EACN,KAAK,EAEL,gBAAgB,EAChB,WAAW,GACZ,MAAM,kBAAkB,CAAA;AAEzB;;GAEG;AACH,MAAM,OAAO,kBAAkB;IACR;IAArB,YAAqB,WAA4C;QAA5C,gBAAW,GAAX,WAAW,CAAiC;IAAG,CAAC;IAErE,GAAG,CAAS,UAA2C;QACrD,OAAO,IAAI,kBAAkB,CAAiB;YAC5C,GAAG,IAAI,CAAC,WAAW;YACnB,UAAU;SACX,CAAC,CAAA;IACJ,CAAC;IAED,MAAM,CAAS,OAAmC;QAChD,OAAO,IAAI,kBAAkB,CAAiB;YAC5C,GAAG,IAAI,CAAC,WAAW;YACnB,GAAG,OAAO,CAAC,WAAW;SACvB,CAAC,CAAA;IACJ,CAAC;IAED,IAAI,UAAU;QACZ,MAAM,QAAQ,GAAG,IAAI,CAAC,WAAW;aAC9B,MAAM,CACL,CAAC,CAAC,EAAyC,EAAE,CAC3C,CAAC,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,CAAC,MAAM,MAAM,GACjB,CAAC,OAAe,EAAE,UAAkB,EAAE,EAAE,CACxC,CACE,IAAmD,EACnD,aAGC,EACD,EAAE,CACF,wBAAe,IAAI,CAAC,IAAI,KAAK,OAAO,IAAI,aAAa,CAAC,IAAI,KAAK,UAAU,CAAC,CAAA;AAE9E,MAAM,CAAC,MAAM,UAAU,GACrB,CAAC,UAAkB,EAAE,EAAE,CACvB,CACE,CAAU,EACV,aAGC,EACD,EAAE,CACF,wBAAe,aAAa,CAAC,IAAI,KAAK,UAAU,CAAC,CAAA"}
@@ -1,10 +1,78 @@
1
+ import { Discord, Effect, Chunk } from "dfx/_common";
1
2
  import * as D from "./definitions.js";
2
- export declare const splitDefinitions: <R, E>(definitions: D.InteractionDefinition<R, E>[]) => {
3
- Commands: Record<string, D.GlobalApplicationCommand<R, E> | D.GuildApplicationCommand<R, E>>;
4
- GlobalApplicationCommand: D.GlobalApplicationCommand<R, E>[];
5
- GuildApplicationCommand: D.GuildApplicationCommand<R, E>[];
6
- MessageComponent: D.MessageComponent<R, E>[];
7
- ModalSubmit: D.ModalSubmit<R, E>[];
8
- Autocomplete: D.Autocomplete<R, E>[];
3
+ export type DefinitionFlattened<R, E, TE, A> = D.InteractionDefinition<R, E> extends infer D ? {
4
+ [K in keyof D]: K extends "handle" ? (_: Discord.Interaction) => Effect<R, TE, A> : D[K];
5
+ } : never;
6
+ export type DefinitionFlattenedCommand<R, E, TE, A> = Extract<DefinitionFlattened<R, E, TE, A>, {
7
+ _tag: "GlobalApplicationCommand" | "GuildApplicationCommand";
8
+ }>;
9
+ export declare const flattenDefinitions: <R, E, TE, A, B>(definitions: import("../_common.js").Chunk<readonly [handler: D.InteractionDefinition<R, E>, transform: (self: import("@effect/io/Effect").Effect<R, E, A>) => import("@effect/io/Effect").Effect<R, TE, B>]>, handleResponse: (ix: Discord.Interaction, _: Discord.InteractionResponse) => import("@effect/io/Effect").Effect<R, E, A>) => import("../_common.js").Chunk<{
10
+ handle: (i: Discord.Interaction) => import("@effect/io/Effect").Effect<R, TE, B>;
11
+ _tag: "GlobalApplicationCommand";
12
+ command: import("../types.js").CreateGlobalApplicationCommandParams;
13
+ } | {
14
+ handle: (i: Discord.Interaction) => import("@effect/io/Effect").Effect<R, TE, B>;
15
+ _tag: "GuildApplicationCommand";
16
+ command: import("../types.js").CreateGuildApplicationCommandParams;
17
+ } | {
18
+ handle: (i: Discord.Interaction) => import("@effect/io/Effect").Effect<R, TE, B>;
19
+ _tag: "MessageComponent";
20
+ predicate: (customId: string) => import("@effect/io/Effect").Effect<R, E, boolean>;
21
+ } | {
22
+ handle: (i: Discord.Interaction) => import("@effect/io/Effect").Effect<R, TE, B>;
23
+ _tag: "ModalSubmit";
24
+ predicate: (customId: string) => import("@effect/io/Effect").Effect<R, E, boolean>;
25
+ } | {
26
+ handle: (i: Discord.Interaction) => import("@effect/io/Effect").Effect<R, TE, B>;
27
+ _tag: "Autocomplete";
28
+ predicate: (data: import("../types.js").ApplicationCommandDatum, focusedOption: import("../types.js").ApplicationCommandInteractionDataOption) => import("@effect/io/Effect").Effect<R, E, boolean>;
29
+ }>;
30
+ export declare const splitDefinitions: <R, E, TE, A>(definitions: import("../_common.js").Chunk<{
31
+ readonly _tag: "GlobalApplicationCommand";
32
+ readonly command: import("../types.js").CreateGlobalApplicationCommandParams;
33
+ readonly handle: (_: Discord.Interaction) => import("@effect/io/Effect").Effect<R, TE, A>;
34
+ } | {
35
+ readonly _tag: "GuildApplicationCommand";
36
+ readonly command: import("../types.js").CreateGuildApplicationCommandParams;
37
+ readonly handle: (_: Discord.Interaction) => import("@effect/io/Effect").Effect<R, TE, A>;
38
+ } | {
39
+ readonly _tag: "MessageComponent";
40
+ readonly predicate: (customId: string) => import("@effect/io/Effect").Effect<R, E, boolean>;
41
+ readonly handle: (_: Discord.Interaction) => import("@effect/io/Effect").Effect<R, TE, A>;
42
+ } | {
43
+ readonly _tag: "ModalSubmit";
44
+ readonly predicate: (customId: string) => import("@effect/io/Effect").Effect<R, E, boolean>;
45
+ readonly handle: (_: Discord.Interaction) => import("@effect/io/Effect").Effect<R, TE, A>;
46
+ } | {
47
+ readonly _tag: "Autocomplete";
48
+ readonly predicate: (data: import("../types.js").ApplicationCommandDatum, focusedOption: import("../types.js").ApplicationCommandInteractionDataOption) => import("@effect/io/Effect").Effect<R, E, boolean>;
49
+ readonly handle: (_: Discord.Interaction) => import("@effect/io/Effect").Effect<R, TE, A>;
50
+ }>) => {
51
+ Commands: Record<string, DefinitionFlattenedCommand<R, E, TE, A>>;
52
+ GlobalApplicationCommand: import("../_common.js").Chunk<{
53
+ readonly _tag: "GlobalApplicationCommand";
54
+ readonly command: import("../types.js").CreateGlobalApplicationCommandParams;
55
+ readonly handle: (_: Discord.Interaction) => import("@effect/io/Effect").Effect<R, TE, A>;
56
+ }>;
57
+ GuildApplicationCommand: import("../_common.js").Chunk<{
58
+ readonly _tag: "GuildApplicationCommand";
59
+ readonly command: import("../types.js").CreateGuildApplicationCommandParams;
60
+ readonly handle: (_: Discord.Interaction) => import("@effect/io/Effect").Effect<R, TE, A>;
61
+ }>;
62
+ MessageComponent: import("../_common.js").Chunk<{
63
+ readonly _tag: "MessageComponent";
64
+ readonly predicate: (customId: string) => import("@effect/io/Effect").Effect<R, E, boolean>;
65
+ readonly handle: (_: Discord.Interaction) => import("@effect/io/Effect").Effect<R, TE, A>;
66
+ }>;
67
+ ModalSubmit: import("../_common.js").Chunk<{
68
+ readonly _tag: "ModalSubmit";
69
+ readonly predicate: (customId: string) => import("@effect/io/Effect").Effect<R, E, boolean>;
70
+ readonly handle: (_: Discord.Interaction) => import("@effect/io/Effect").Effect<R, TE, A>;
71
+ }>;
72
+ Autocomplete: import("../_common.js").Chunk<{
73
+ readonly _tag: "Autocomplete";
74
+ readonly predicate: (data: import("../types.js").ApplicationCommandDatum, focusedOption: import("../types.js").ApplicationCommandInteractionDataOption) => import("@effect/io/Effect").Effect<R, E, boolean>;
75
+ readonly handle: (_: Discord.Interaction) => import("@effect/io/Effect").Effect<R, TE, A>;
76
+ }>;
9
77
  };
10
78
  export declare function fromHex(hexString: string): Uint8Array;
@@ -1,21 +1,34 @@
1
+ import * as tsplus_module_1 from "@effect/io/Effect";
2
+ import * as tsplus_module_2 from "@effect/data/Chunk";
3
+ import * as Ctx from "./context.js";
4
+ const context = {
5
+ resolve: Ctx.resolved,
6
+ option: Ctx.option,
7
+ optionValue: Ctx.optionValue,
8
+ optionValueOptional: Ctx.optionValueOptional,
9
+ subCommands: Ctx.handleSubCommands,
10
+ };
11
+ export const flattenDefinitions = (definitions, handleResponse) => tsplus_module_2.map(definitions, ([definition, transform]) => ({
12
+ ...definition,
13
+ handle: (i) => tsplus_module_1.isEffect(definition.handle)
14
+ ? transform(tsplus_module_1.flatMap(definition.handle, _ => handleResponse(i, _)))
15
+ : transform(tsplus_module_1.flatMap(definition.handle(context), _ => handleResponse(i, _))),
16
+ }));
1
17
  export const splitDefinitions = (definitions) => {
2
- const grouped = definitions.reduce((acc, a) => ({
18
+ const grouped = tsplus_module_2.reduce(definitions, {
19
+ Autocomplete: tsplus_module_2.empty(),
20
+ GlobalApplicationCommand: tsplus_module_2.empty(),
21
+ GuildApplicationCommand: tsplus_module_2.empty(),
22
+ MessageComponent: tsplus_module_2.empty(),
23
+ ModalSubmit: tsplus_module_2.empty(),
24
+ }, (acc, d) => ({
3
25
  ...acc,
4
- [a._tag]: [...(acc[a._tag] ?? []), a],
5
- }), {
6
- Autocomplete: [],
7
- GlobalApplicationCommand: [],
8
- GuildApplicationCommand: [],
9
- MessageComponent: [],
10
- ModalSubmit: [],
11
- });
12
- const Commands = [
13
- ...grouped.GlobalApplicationCommand,
14
- ...grouped.GuildApplicationCommand,
15
- ].reduce((acc, a) => ({
26
+ [d._tag]: tsplus_module_2.append(acc[d._tag], d),
27
+ }));
28
+ const Commands = tsplus_module_2.reduce(tsplus_module_2.concat(grouped.GlobalApplicationCommand, grouped.GuildApplicationCommand), {}, (acc, d) => ({
16
29
  ...acc,
17
- [a.command.name]: a,
18
- }), {});
30
+ [d.command.name]: d,
31
+ }));
19
32
  return {
20
33
  ...grouped,
21
34
  Commands,
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/Interactions/utils.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAC9B,WAA4C,EAC5C,EAAE;IACF,MAAM,OAAO,GAAG,WAAW,CAAC,MAAM,CAMhC,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;QACX,GAAG,GAAG;QACN,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC,CAAC;KACtC,CAAC,EACF;QACE,YAAY,EAAE,EAAE;QAChB,wBAAwB,EAAE,EAAE;QAC5B,uBAAuB,EAAE,EAAE;QAC3B,gBAAgB,EAAE,EAAE;QACpB,WAAW,EAAE,EAAE;KAChB,CACF,CAAA;IAED,MAAM,QAAQ,GAAG;QACf,GAAG,OAAO,CAAC,wBAAwB;QACnC,GAAG,OAAO,CAAC,uBAAuB;KACnC,CAAC,MAAM,CACN,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;QACX,GAAG,GAAG;QACN,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;KACpB,CAAC,EACF,EAGC,CACF,CAAA;IAED,OAAO;QACL,GAAG,OAAO;QACV,QAAQ;KACT,CAAA;AACH,CAAC,CAAA;AACD,MAAM,OAAO,GAA2B;IACtC,CAAC,EAAE,CAAC;IACJ,CAAC,EAAE,CAAC;IACJ,CAAC,EAAE,CAAC;IACJ,CAAC,EAAE,CAAC;IACJ,CAAC,EAAE,CAAC;IACJ,CAAC,EAAE,CAAC;IACJ,CAAC,EAAE,CAAC;IACJ,CAAC,EAAE,CAAC;IACJ,CAAC,EAAE,CAAC;IACJ,CAAC,EAAE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CAAC,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAA;QACvC,IAAI,CAAC,KAAK,SAAS,IAAI,CAAC,KAAK,SAAS,EAAE;YACtC,MAAK;SACN;QACD,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAA;KACxB;IACD,OAAO,CAAC,KAAK,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;AACvD,CAAC"}
@@ -1,4 +1,4 @@
1
- import { ConfigSecret, Config, Discord, Effect, Cause } from "dfx/_common";
1
+ import { ConfigSecret, Config, Discord, Chunk, Effect, Cause } from "dfx/_common";
2
2
  import { DefinitionNotFound } from "./handlers.js";
3
3
  import { InteractionBuilder } from "./index.js";
4
4
  export declare class BadWebhookSignature {
@@ -33,13 +33,13 @@ export interface HandleWebhookOpts<E> {
33
33
  * @tsplus getter dfx/InteractionBuilder webhookHandler
34
34
  * @tsplus location "dfx/Interactions/webhook"
35
35
  */
36
- export declare const makeHandler: <R, E>(ix: InteractionBuilder<R, E>) => ({ headers, body, success, error, }: HandleWebhookOpts<DefinitionNotFound | BadWebhookSignature | WebhookParseError | E>) => import("@effect/io/Effect").Effect<WebhookConfig | Exclude<R, import("../types.js").Interaction>, never, void>;
36
+ export declare const makeHandler: <R, E, TE>(ix: InteractionBuilder<R, E, TE>) => ({ headers, body, success, error, }: HandleWebhookOpts<DefinitionNotFound | BadWebhookSignature | WebhookParseError | E>) => import("@effect/io/Effect").Effect<WebhookConfig, never, void>;
37
37
  /**
38
38
  * @tsplus getter dfx/InteractionBuilder simpleWebhookHandler
39
39
  * @tsplus location "dfx/Interactions/webhook"
40
40
  */
41
- export declare const makeSimpleHandler: <R, E>(ix: InteractionBuilder<R, E>) => ({ headers, body }: {
41
+ export declare const makeSimpleHandler: <R, E, TE>(ix: InteractionBuilder<R, E, TE>) => ({ headers, body }: {
42
42
  headers: Headers;
43
43
  body: string;
44
- }) => import("@effect/io/Effect").Effect<WebhookConfig | Exclude<R, import("../types.js").Interaction>, DefinitionNotFound | BadWebhookSignature | WebhookParseError | E, import("../types.js").InteractionResponse>;
44
+ }) => import("@effect/io/Effect").Effect<WebhookConfig, DefinitionNotFound | BadWebhookSignature | WebhookParseError, import("../types.js").InteractionResponse>;
45
45
  export {};