dfx 0.43.1 → 0.44.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.
- package/Interactions/gateway.d.ts +6 -0
- package/Interactions/gateway.js +14 -3
- package/Interactions/gateway.js.map +1 -1
- package/Interactions/index.d.ts +23 -4
- package/Interactions/index.js +29 -12
- package/Interactions/index.js.map +1 -1
- package/Interactions/webhook.d.ts +1 -1
- package/Interactions/webhook.js +2 -1
- package/Interactions/webhook.js.map +1 -1
- package/gateway.d.ts +1 -1
- package/gateway.js +1 -1
- package/gateway.js.map +1 -1
- package/package.json +2 -2
- package/src/Interactions/gateway.ts +34 -4
- package/src/Interactions/index.ts +91 -13
- package/src/Interactions/webhook.ts +4 -1
- package/src/gateway.ts +5 -1
- package/src/package.json +0 -52
|
@@ -12,3 +12,9 @@ export interface RunOpts {
|
|
|
12
12
|
* @tsplus location "dfx/Interactions/gateway"
|
|
13
13
|
*/
|
|
14
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>;
|
|
15
|
+
export interface InteractionsRegistry {
|
|
16
|
+
readonly register: (ix: InteractionBuilder<never, never>) => Effect<never, never, void>;
|
|
17
|
+
readonly run: Effect<DiscordREST | DiscordGateway, DiscordRESTError | Http.ResponseDecodeError, 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>;
|
package/Interactions/gateway.js
CHANGED
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
import * as tsplus_module_1 from "@effect/io/Effect";
|
|
2
2
|
import * as tsplus_module_2 from "@effect/data/Function";
|
|
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";
|
|
9
|
+
import { Interaction, builder } from "./index.js";
|
|
8
10
|
import { splitDefinitions } from "./utils.js";
|
|
9
11
|
/**
|
|
10
12
|
* @tsplus pipeable dfx/InteractionBuilder runGateway
|
|
11
13
|
*/
|
|
12
|
-
|
|
14
|
+
const run_1 = (postHandler, { sync = true } = {}) => (ix) => (() => {
|
|
13
15
|
const { GlobalApplicationCommand, GuildApplicationCommand } = splitDefinitions(ix.definitions);
|
|
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
17
|
const globalSync = rest.bulkOverwriteGlobalApplicationCommands(application.id, { body: Http.body.json(GlobalApplicationCommand.map(a => a.command)) });
|
|
@@ -17,8 +19,17 @@ export const run = (postHandler, { sync = true } = {}) => (ix) => (() => {
|
|
|
17
19
|
? gateway.handleDispatch("GUILD_CREATE", a => rest.bulkOverwriteGuildApplicationCommands(application.id, a.id, GuildApplicationCommand.map(a => a.command)))
|
|
18
20
|
: tsplus_module_1.never();
|
|
19
21
|
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(
|
|
22
|
+
const run = gateway.handleDispatch("INTERACTION_CREATE", i => tsplus_module_1.provideService(tsplus_module_2.pipe(tsplus_module_1.tap(ix
|
|
23
|
+
.transformRespond(handle[i.type](i)), r => rest.createInteractionResponse(i.id, i.token, r)), ix.transform, postHandler), Interaction, i));
|
|
21
24
|
return sync ? tsplus_module_1.zipParRight(tsplus_module_1.zipParRight(run, globalSync), guildSync) : run;
|
|
22
25
|
})));
|
|
23
26
|
})();
|
|
27
|
+
export const run = run_1;
|
|
28
|
+
const makeRegistry = tsplus_module_1.map(tsplus_module_3.make(builder), ref => {
|
|
29
|
+
const register = (ix) => tsplus_module_3.update(ref, _ => _.concat(ix));
|
|
30
|
+
const run = tsplus_module_1.flatMap(tsplus_module_3.get(ref), _ => run_1(_ => tsplus_module_1.catchAllCause(_, _ => tsplus_module_1.logErrorCause(_)))(_));
|
|
31
|
+
return { register, run };
|
|
32
|
+
});
|
|
33
|
+
export const InteractionsRegistry = tsplus_module_4.Tag();
|
|
34
|
+
export const InteractionsRegistryLive = tsplus_module_1.toLayer(makeRegistry, InteractionsRegistry);
|
|
24
35
|
//# sourceMappingURL=gateway.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gateway.js","sourceRoot":"","sources":["../src/Interactions/gateway.ts"],"names":[],"mappings":"
|
|
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,OAAO,EAAE,MAAM,YAAY,CAAA;AACrE,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA;AAM7C;;GAEG;AACI,MAAM,QACX,CACE,WAMyB,EACzB,EAAE,IAAI,GAAG,IAAI,KAAc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AAC,CAAC,CAAC,EAC7D,EAAE,CAAC,SAAS,EACZ,WAAW,CACZ,EAAgB,WAAW,EAAE,CAAC,CAAC,CACjC,CAAA;eAEQ,IAAI,CAAC,CAAC,CAAC,4BAAA,4BAAA,GAAG,EAAa,UAAU,CAAC,EAAa,SAAS,CAAC,CAAC,CAAC,CAAC,GAAG;;IACxE,CAAA;aAzDO,GAAG;AA2DhB,MAAM,YAAY,uBACF,qBAAS,OAAO,CAAC,EAAzB,GAAG;IAET,MAAM,QAAQ,GAAG,CAAC,EAAoC,EAAE,EAAE,CACxD,uBAAA,GAAG,EAAQ,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAA;IAE/B,MAAM,GAAG,GAAG,4CAAA,GAAG,GAAa,CAAC,CAAC,EAAE,CAC9B,MAAa,CAAC,CAAC,EAAE,CAAC,8BAAA,CAAC,EAAe,CAAC,CAAC,EAAE,+BAAC,CAAC,CAAc,CAAC,EAAvD,CAAC,CAAuD,CACzD,CAAA;IAED,OAAO,EAAE,QAAQ,EAAE,GAAG,EAAW,CAAA;EACjC,CAAA;AAcF,MAAM,CAAC,MAAM,oBAAoB,GAAG,gBAAA,GAAG,EAAwB,CAAA;AAC/D,MAAM,CAAC,MAAM,wBAAwB,GACnC,wBAAA,YAAY,EAAS,oBAAoB,CAAC,CAAA"}
|
package/Interactions/index.d.ts
CHANGED
|
@@ -1,19 +1,38 @@
|
|
|
1
|
+
import { Cause } from "dfx/_common";
|
|
2
|
+
import * as Http from "@effect-http/client";
|
|
1
3
|
import { DiscordREST } from "dfx";
|
|
2
4
|
import { Discord, Effect } from "dfx/_common";
|
|
3
5
|
import * as D from "./definitions.js";
|
|
4
|
-
import * as Http from "@effect-http/client";
|
|
5
6
|
export { response } from "../Helpers/interactions.js";
|
|
6
|
-
export * as helpers from "../Helpers/interactions.js";
|
|
7
7
|
export * from "./context.js";
|
|
8
|
-
export { autocomplete, global, guild,
|
|
8
|
+
export { InteractionDefinition, autocomplete, global, guild, messageComponent, modalSubmit, } from "./definitions.js";
|
|
9
|
+
type ExtractTag<A> = A extends {
|
|
10
|
+
_tag: infer Tag;
|
|
11
|
+
} ? Tag extends string ? Tag : never : never;
|
|
9
12
|
/**
|
|
10
13
|
* @tsplus type dfx/InteractionBuilder
|
|
11
14
|
*/
|
|
12
15
|
export declare class InteractionBuilder<R, E> {
|
|
13
16
|
readonly definitions: D.InteractionDefinition<R, E>[];
|
|
14
|
-
|
|
17
|
+
readonly transform: (self: Effect<any, any, any>) => Effect<R, E, void>;
|
|
18
|
+
readonly transformRespond: (self: Effect<any, any, Discord.InteractionResponse>) => Effect<R, E, Discord.InteractionResponse>;
|
|
19
|
+
constructor(definitions: D.InteractionDefinition<R, E>[], transform: (self: Effect<any, any, any>) => Effect<R, E, void>, transformRespond: (self: Effect<any, any, Discord.InteractionResponse>) => Effect<R, E, Discord.InteractionResponse>);
|
|
15
20
|
add<R1, E1>(definition: D.InteractionDefinition<R1, E1>): InteractionBuilder<R | R1, E | E1>;
|
|
16
21
|
concat<R1, E1>(builder: InteractionBuilder<R1, E1>): InteractionBuilder<R | R1, E | E1>;
|
|
22
|
+
catchAllCause<R1, E1>(f: (cause: Cause<E>) => Effect<R1, E1, void>): InteractionBuilder<R | R1, E1>;
|
|
23
|
+
catchAllCauseRespond<R1, E1>(f: (cause: Cause<E>) => Effect<R1, E1, Discord.InteractionResponse>): InteractionBuilder<R | R1, E1>;
|
|
24
|
+
catchAll<R1, E1>(f: (error: E) => Effect<R1, E1, void>): InteractionBuilder<R | R1, E1>;
|
|
25
|
+
catchAllRespond<R1, E1>(f: (error: E) => Effect<R1, E1, Discord.InteractionResponse>): InteractionBuilder<R | R1, E1>;
|
|
26
|
+
catchTag<T extends ExtractTag<E>, R1, E1>(tag: T, f: (error: Extract<E, {
|
|
27
|
+
_tag: T;
|
|
28
|
+
}>) => Effect<R1, E1, void>): InteractionBuilder<R | R1, E1 | Exclude<E, {
|
|
29
|
+
_tag: T;
|
|
30
|
+
}>>;
|
|
31
|
+
catchTagRespond<T extends ExtractTag<E>, R1, E1>(tag: T, f: (error: Extract<E, {
|
|
32
|
+
_tag: T;
|
|
33
|
+
}>) => Effect<R1, E1, Discord.InteractionResponse>): InteractionBuilder<R | R1, E1 | Exclude<E, {
|
|
34
|
+
_tag: T;
|
|
35
|
+
}>>;
|
|
17
36
|
get syncGlobal(): Effect<DiscordREST, import("../DiscordREST.js").DiscordRESTError | Http.ResponseDecodeError, import("../DiscordREST/types.js").ResponseWithData<Discord.ApplicationCommand[]>>;
|
|
18
37
|
syncGuild(appId: Discord.Snowflake, guildId: Discord.Snowflake): Effect<DiscordREST, import("../DiscordREST.js").DiscordRESTError, import("../DiscordREST/types.js").ResponseWithData<Discord.ApplicationCommand[]>>;
|
|
19
38
|
}
|
package/Interactions/index.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import * as tsplus_module_1 from "@effect/io/Effect";
|
|
2
|
-
import
|
|
2
|
+
import * as tsplus_module_2 from "@effect/data/Function";
|
|
3
3
|
import * as Http from "@effect-http/client";
|
|
4
|
+
import { catchTag } from "@effect/io/Effect";
|
|
5
|
+
import { DiscordREST } from "dfx";
|
|
4
6
|
export { response } from "../Helpers/interactions.js";
|
|
5
|
-
export * as helpers from "../Helpers/interactions.js";
|
|
6
7
|
export * from "./context.js";
|
|
7
8
|
export { autocomplete, global, guild, messageComponent, modalSubmit, } from "./definitions.js";
|
|
8
9
|
/**
|
|
@@ -10,20 +11,36 @@ export { autocomplete, global, guild, messageComponent, modalSubmit, } from "./d
|
|
|
10
11
|
*/
|
|
11
12
|
export class InteractionBuilder {
|
|
12
13
|
definitions;
|
|
13
|
-
|
|
14
|
+
transform;
|
|
15
|
+
transformRespond;
|
|
16
|
+
constructor(definitions, transform, transformRespond) {
|
|
14
17
|
this.definitions = definitions;
|
|
18
|
+
this.transform = transform;
|
|
19
|
+
this.transformRespond = transformRespond;
|
|
15
20
|
}
|
|
16
21
|
add(definition) {
|
|
17
|
-
return new InteractionBuilder([
|
|
18
|
-
...this.definitions,
|
|
19
|
-
definition,
|
|
20
|
-
]);
|
|
22
|
+
return new InteractionBuilder([...this.definitions, definition], this.transform, this.transformRespond);
|
|
21
23
|
}
|
|
22
24
|
concat(builder) {
|
|
23
|
-
return new InteractionBuilder([
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
return new InteractionBuilder([...this.definitions, ...builder.definitions], this.transform, this.transformRespond);
|
|
26
|
+
}
|
|
27
|
+
catchAllCause(f) {
|
|
28
|
+
return new InteractionBuilder(this.definitions, _ => tsplus_module_1.catchAllCause(this.transform(_), f), this.transformRespond);
|
|
29
|
+
}
|
|
30
|
+
catchAllCauseRespond(f) {
|
|
31
|
+
return new InteractionBuilder(this.definitions, this.transform, _ => tsplus_module_1.catchAllCause(this.transformRespond(_), f));
|
|
32
|
+
}
|
|
33
|
+
catchAll(f) {
|
|
34
|
+
return new InteractionBuilder(this.definitions, _ => tsplus_module_1.catchAll(this.transform(_), f), this.transformRespond);
|
|
35
|
+
}
|
|
36
|
+
catchAllRespond(f) {
|
|
37
|
+
return new InteractionBuilder(this.definitions, this.transform, _ => tsplus_module_1.catchAll(this.transformRespond(_), f));
|
|
38
|
+
}
|
|
39
|
+
catchTag(tag, f) {
|
|
40
|
+
return new InteractionBuilder(this.definitions, _ => catchTag(this.transform(_), tag, f), this.transformRespond);
|
|
41
|
+
}
|
|
42
|
+
catchTagRespond(tag, f) {
|
|
43
|
+
return new InteractionBuilder(this.definitions, this.transform, _ => catchTag(this.transformRespond(_), tag, f));
|
|
27
44
|
}
|
|
28
45
|
get syncGlobal() {
|
|
29
46
|
const commands = this.definitions
|
|
@@ -41,7 +58,7 @@ export class InteractionBuilder {
|
|
|
41
58
|
return tsplus_module_1.flatMap(DiscordREST, rest => rest.bulkOverwriteGuildApplicationCommands(appId, guildId, commands));
|
|
42
59
|
}
|
|
43
60
|
}
|
|
44
|
-
export const builder = new InteractionBuilder([]);
|
|
61
|
+
export const builder = new InteractionBuilder([], tsplus_module_2.identity, tsplus_module_2.identity);
|
|
45
62
|
// Filters
|
|
46
63
|
export const id = (query) => (customId) => tsplus_module_1.succeed(query === customId);
|
|
47
64
|
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":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/Interactions/index.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;AAIjC,OAAO,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAA;AACrD,cAAc,cAAc,CAAA;AAC5B,OAAO,EAEL,YAAY,EACZ,MAAM,EACN,KAAK,EACL,gBAAgB,EAChB,WAAW,GACZ,MAAM,kBAAkB,CAAA;AAQzB;;GAEG;AACH,MAAM,OAAO,kBAAkB;IAElB;IACA;IACA;IAHX,YACW,WAA4C,EAC5C,SAA8D,EAC9D,gBAEqC;QAJrC,gBAAW,GAAX,WAAW,CAAiC;QAC5C,cAAS,GAAT,SAAS,CAAqD;QAC9D,qBAAgB,GAAhB,gBAAgB,CAEqB;IAC7C,CAAC;IAEJ,GAAG,CAAS,UAA2C;QACrD,OAAO,IAAI,kBAAkB,CAC3B,CAAC,GAAG,IAAI,CAAC,WAAW,EAAE,UAAU,CAAC,EACjC,IAAI,CAAC,SAAS,EACd,IAAI,CAAC,gBAAgB,CACtB,CAAA;IACH,CAAC;IAED,MAAM,CAAS,OAAmC;QAChD,OAAO,IAAI,kBAAkB,CAC3B,CAAC,GAAG,IAAI,CAAC,WAAW,EAAE,GAAG,OAAO,CAAC,WAAW,CAAC,EAC7C,IAAI,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AA,QAAe,EACf,gBAAA,QAAe,CAChB,CAAA;AAED,UAAU;AACV,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAAa,EAAE,EAAE,CAAC,CAAC,QAAgB,EAAE,EAAE,CACxD,wBAAe,KAAK,KAAK,QAAQ,CAAC,CAAA;AAEpC,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,KAAa,EAAE,EAAE,CAAC,CAAC,QAAgB,EAAE,EAAE,CAClE,wBAAe,QAAQ,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAA;AAE5C,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,KAAa,EAAE,EAAE,CAAC,CAAC,QAAgB,EAAE,EAAE,CAC7D,wBAAe,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAA;AAEtC,MAAM,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"}
|
|
@@ -33,7 +33,7 @@ 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<
|
|
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<R, never, void>;
|
|
37
37
|
/**
|
|
38
38
|
* @tsplus getter dfx/InteractionBuilder simpleWebhookHandler
|
|
39
39
|
* @tsplus location "dfx/Interactions/webhook"
|
package/Interactions/webhook.js
CHANGED
|
@@ -43,7 +43,8 @@ const run = (definitions) => {
|
|
|
43
43
|
*/
|
|
44
44
|
export const makeHandler = (ix) => {
|
|
45
45
|
const handle = run(ix.definitions);
|
|
46
|
-
return ({ headers, body, success, error, }) => tsplus_module_7.catchAllCause(
|
|
46
|
+
return ({ headers, body, success, error, }) => tsplus_module_7.catchAllCause(ix
|
|
47
|
+
.transform(tsplus_module_7.flatMap(ix.transformRespond(handle(headers, body)), success)), error);
|
|
47
48
|
};
|
|
48
49
|
/**
|
|
49
50
|
* @tsplus getter dfx/InteractionBuilder simpleWebhookHandler
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webhook.js","sourceRoot":"","sources":["../src/Interactions/webhook.ts"],"names":[],"mappings":";;;;;;;AAAA,OAAO,IAAI,MAAM,WAAW,CAAA;AAE5B,OAAO,EAAsB,QAAQ,EAAE,MAAM,eAAe,CAAA;AAC5D,OAAO,EAAsB,WAAW,EAAE,MAAM,YAAY,CAAA;AAC5D,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;AAEpC,MAAM,OAAO,mBAAmB;IACrB,IAAI,GAAG,qBAAqB,CAAA;CACtC;AAID,MAAM,cAAc,GAAG,CACrB,SAAqB,EACrB,OAAgB,EAChB,IAAY,EACZ,EAAE,wBACF,yBAYY,GAAG,EAAE,CAAC,IAAI,mBAAmB,EAAE,EAZ3C,uBAIU,CAAC,CAAC,EAAE;IACV,MAAM,GAAG,GAAG,IAAI,WAAW,EAAE,CAAA;IAC7B,OAAO,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAC9B,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,GA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,WAAW,CAAC,CAAA;IACrC,OAAO,CAAC,OAAgB,EAAE,IAAY,EAAE,EAAE,yBAEhB,kBAAkB,CAAC,OAAO,EAAE,IAAI,CAAC,EAAjD,WAAW,IAEf,+BAAA,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,WAAW,CAAC,EACpC,WAAW,EACX,WAAW,CACZ,CAEH,CAAA;AACN,CAAC,CAAA;AASD;;GAEG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,CAAO,EAA4B,EAAE,EAAE;IAChE,MAAM,MAAM,GAAG,GAAG,CAAC,EAAE,CAAC,WAAW,CAAC,CAAA;IAElC,OAAO,CAAC,EACN,OAAO,EACP,IAAI,EACJ,OAAO,EACP,KAAK,GAGN,EAAE,EAAE,CACH,8BAAA,EAAE;SACC,SAAS,CAAC,wBAAA,EAAE,CAAC,gBAAgB,CAAC,MAAM,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,EAAS,OAAO,CAAC,CAAC,EACxD,KAAK,CAAC,CAAA;AAC3B,CAAC,CAAA;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAO,EAA4B,EAAE,EAAE;IACtE,MAAM,MAAM,GAAG,GAAG,CAAC,EAAE,CAAC,WAAW,CAAC,CAAA;IAElC,OAAO,CAAC,EAAE,OAAO,EAAE,IAAI,EAAsC,EAAE,EAAE,CAC/D,MAAM,CAAC,OAAO,EAAE,IAAI,CAAC,CAAA;AACzB,CAAC,CAAA"}
|
package/gateway.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ export * as DiscordWS from "./DiscordGateway/DiscordWS.js";
|
|
|
6
6
|
export * as Shard from "./DiscordGateway/Shard.js";
|
|
7
7
|
export * as ShardStore from "./DiscordGateway/ShardStore.js";
|
|
8
8
|
export * as WS from "./DiscordGateway/WS.js";
|
|
9
|
-
export { run as runIx } from "./Interactions/gateway.js";
|
|
9
|
+
export { InteractionsRegistry, InteractionsRegistryLive, run as runIx, } from "./Interactions/gateway.js";
|
|
10
10
|
export declare const MemoryRateLimit: import("@effect-http/client/_common").Layer<Log.Log, never, import("dfx").RateLimiter>;
|
|
11
11
|
export declare const MemoryBot: import("@effect-http/client/_common").Layer<DiscordConfig.DiscordConfig | Log.Log | import("@effect-http/client").HttpRequestExecutor, never, import("dfx").DiscordREST | import("dfx").RateLimiter | import("./DiscordGateway.js").DiscordGateway>;
|
|
12
12
|
export declare const makeLiveWithoutFetch: (config: Config.Wrap<DiscordConfig.MakeOpts>) => import("@effect-http/client/_common").Layer<import("@effect-http/client").HttpRequestExecutor, import("./_common.js").ConfigError, import("dfx").DiscordREST | DiscordConfig.DiscordConfig | Log.Log | import("dfx").RateLimiter | import("./DiscordGateway.js").DiscordGateway>;
|
package/gateway.js
CHANGED
|
@@ -13,7 +13,7 @@ export * as DiscordWS from "./DiscordGateway/DiscordWS.js";
|
|
|
13
13
|
export * as Shard from "./DiscordGateway/Shard.js";
|
|
14
14
|
export * as ShardStore from "./DiscordGateway/ShardStore.js";
|
|
15
15
|
export * as WS from "./DiscordGateway/WS.js";
|
|
16
|
-
export { run as runIx } from "./Interactions/gateway.js";
|
|
16
|
+
export { InteractionsRegistry, InteractionsRegistryLive, run as runIx, } from "./Interactions/gateway.js";
|
|
17
17
|
export const MemoryRateLimit = tsplus_module_1.provide(LiveRateLimiter)(LiveMemoryRateLimitStore);
|
|
18
18
|
export const MemoryBot = tsplus_module_1.provide((tsplus_module_1.merge(MemoryRateLimit)((tsplus_module_1.provideMerge(LiveDiscordGateway)(LiveDiscordREST)))))((tsplus_module_1.merge(LiveJsonDiscordWSCodec)(tsplus_module_1.merge(LiveMemoryRateLimitStore)(LiveMemoryShardStore))));
|
|
19
19
|
export const makeLiveWithoutFetch = (config) => tsplus_module_1.unwrapEffect(tsplus_module_3.map(tsplus_module_3.map(tsplus_module_3.config(tsplus_module_2.unwrap(config)), DiscordConfig.make), config => {
|
package/gateway.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gateway.js","sourceRoot":"","sources":["src/gateway.ts"],"names":[],"mappings":";;;AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAA;AAC9D,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,GAAG,EAAE,MAAM,KAAK,CAAA;AACzD,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAA;AACxD,OAAO,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAA;AACtE,OAAO,EAAE,oBAAoB,EAAE,MAAM,gCAAgC,CAAA;AACrE,OAAO,EAAE,wBAAwB,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAE1E,OAAO,KAAK,YAAY,MAAM,oBAAoB,CAAA;AAClD,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAA;AACxE,OAAO,KAAK,SAAS,MAAM,+BAA+B,CAAA;AAC1D,OAAO,KAAK,KAAK,MAAM,2BAA2B,CAAA;AAClD,OAAO,KAAK,UAAU,MAAM,gCAAgC,CAAA;AAC5D,OAAO,KAAK,EAAE,MAAM,wBAAwB,CAAA;AAC5C,OAAO,
|
|
1
|
+
{"version":3,"file":"gateway.js","sourceRoot":"","sources":["src/gateway.ts"],"names":[],"mappings":";;;AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAA;AAC9D,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,GAAG,EAAE,MAAM,KAAK,CAAA;AACzD,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAA;AACxD,OAAO,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAA;AACtE,OAAO,EAAE,oBAAoB,EAAE,MAAM,gCAAgC,CAAA;AACrE,OAAO,EAAE,wBAAwB,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAE1E,OAAO,KAAK,YAAY,MAAM,oBAAoB,CAAA;AAClD,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,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",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public",
|
|
@@ -48,5 +48,5 @@
|
|
|
48
48
|
"ws": "^8.13.0"
|
|
49
49
|
},
|
|
50
50
|
"sideEffects": false,
|
|
51
|
-
"gitHead": "
|
|
51
|
+
"gitHead": "e8c64ec253a70ff461247eafcccce4d181a1d67d"
|
|
52
52
|
}
|
|
@@ -2,7 +2,7 @@ import * as Http from "@effect-http/client"
|
|
|
2
2
|
import { DiscordGateway } from "dfx/DiscordGateway"
|
|
3
3
|
import { DiscordREST, DiscordRESTError } from "dfx/DiscordREST"
|
|
4
4
|
import { DefinitionNotFound, handlers } from "./handlers.js"
|
|
5
|
-
import { Interaction, InteractionBuilder } from "./index.js"
|
|
5
|
+
import { Interaction, InteractionBuilder, builder } from "./index.js"
|
|
6
6
|
import { splitDefinitions } from "./utils.js"
|
|
7
7
|
|
|
8
8
|
export interface RunOpts {
|
|
@@ -60,12 +60,42 @@ export const run =
|
|
|
60
60
|
|
|
61
61
|
const run = gateway.handleDispatch("INTERACTION_CREATE", i =>
|
|
62
62
|
pipe(
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
63
|
+
ix
|
|
64
|
+
.transformRespond(handle[i.type](i))
|
|
65
|
+
.tap(r => rest.createInteractionResponse(i.id, i.token, r)),
|
|
66
|
+
ix.transform,
|
|
66
67
|
postHandler,
|
|
67
68
|
).provideService(Interaction, i),
|
|
68
69
|
)
|
|
69
70
|
|
|
70
71
|
return $(sync ? run.zipParRight(globalSync).zipParRight(guildSync) : run)
|
|
71
72
|
})
|
|
73
|
+
|
|
74
|
+
const makeRegistry = Do($ => {
|
|
75
|
+
const ref = $(Ref.make(builder))
|
|
76
|
+
|
|
77
|
+
const register = (ix: InteractionBuilder<never, never>) =>
|
|
78
|
+
ref.update(_ => _.concat(ix))
|
|
79
|
+
|
|
80
|
+
const run = ref.get.flatMap(_ =>
|
|
81
|
+
_.runGateway(_ => _.catchAllCause(_ => _.logErrorCause)),
|
|
82
|
+
)
|
|
83
|
+
|
|
84
|
+
return { register, run } as const
|
|
85
|
+
})
|
|
86
|
+
|
|
87
|
+
export interface InteractionsRegistry {
|
|
88
|
+
readonly register: (
|
|
89
|
+
ix: InteractionBuilder<never, never>,
|
|
90
|
+
) => Effect<never, never, void>
|
|
91
|
+
|
|
92
|
+
readonly run: Effect<
|
|
93
|
+
DiscordREST | DiscordGateway,
|
|
94
|
+
DiscordRESTError | Http.ResponseDecodeError,
|
|
95
|
+
never
|
|
96
|
+
>
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export const InteractionsRegistry = Tag<InteractionsRegistry>()
|
|
100
|
+
export const InteractionsRegistryLive =
|
|
101
|
+
makeRegistry.toLayer(InteractionsRegistry)
|
|
@@ -1,38 +1,112 @@
|
|
|
1
|
+
import * as Http from "@effect-http/client"
|
|
2
|
+
import { catchTag } from "@effect/io/Effect"
|
|
1
3
|
import { DiscordREST } from "dfx"
|
|
2
4
|
import { Discord, Effect } from "dfx/_common"
|
|
3
5
|
import * as D from "./definitions.js"
|
|
4
|
-
import * as Http from "@effect-http/client"
|
|
5
6
|
|
|
6
7
|
export { response } from "../Helpers/interactions.js"
|
|
7
|
-
export * as helpers from "../Helpers/interactions.js"
|
|
8
8
|
export * from "./context.js"
|
|
9
9
|
export {
|
|
10
|
+
InteractionDefinition,
|
|
10
11
|
autocomplete,
|
|
11
12
|
global,
|
|
12
13
|
guild,
|
|
13
|
-
InteractionDefinition,
|
|
14
14
|
messageComponent,
|
|
15
15
|
modalSubmit,
|
|
16
16
|
} from "./definitions.js"
|
|
17
17
|
|
|
18
|
+
type ExtractTag<A> = A extends { _tag: infer Tag }
|
|
19
|
+
? Tag extends string
|
|
20
|
+
? Tag
|
|
21
|
+
: never
|
|
22
|
+
: never
|
|
23
|
+
|
|
18
24
|
/**
|
|
19
25
|
* @tsplus type dfx/InteractionBuilder
|
|
20
26
|
*/
|
|
21
27
|
export class InteractionBuilder<R, E> {
|
|
22
|
-
constructor(
|
|
28
|
+
constructor(
|
|
29
|
+
readonly definitions: D.InteractionDefinition<R, E>[],
|
|
30
|
+
readonly transform: (self: Effect<any, any, any>) => Effect<R, E, void>,
|
|
31
|
+
readonly transformRespond: (
|
|
32
|
+
self: Effect<any, any, Discord.InteractionResponse>,
|
|
33
|
+
) => Effect<R, E, Discord.InteractionResponse>,
|
|
34
|
+
) {}
|
|
23
35
|
|
|
24
36
|
add<R1, E1>(definition: D.InteractionDefinition<R1, E1>) {
|
|
25
|
-
return new InteractionBuilder<R | R1, E | E1>(
|
|
26
|
-
...this.definitions,
|
|
27
|
-
|
|
28
|
-
|
|
37
|
+
return new InteractionBuilder<R | R1, E | E1>(
|
|
38
|
+
[...this.definitions, definition],
|
|
39
|
+
this.transform,
|
|
40
|
+
this.transformRespond,
|
|
41
|
+
)
|
|
29
42
|
}
|
|
30
43
|
|
|
31
44
|
concat<R1, E1>(builder: InteractionBuilder<R1, E1>) {
|
|
32
|
-
return new InteractionBuilder<R | R1, E | E1>(
|
|
33
|
-
...this.definitions,
|
|
34
|
-
|
|
35
|
-
|
|
45
|
+
return new InteractionBuilder<R | R1, E | E1>(
|
|
46
|
+
[...this.definitions, ...builder.definitions],
|
|
47
|
+
this.transform,
|
|
48
|
+
this.transformRespond,
|
|
49
|
+
)
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
catchAllCause<R1, E1>(f: (cause: Cause<E>) => Effect<R1, E1, void>) {
|
|
53
|
+
return new InteractionBuilder<R | R1, E1>(
|
|
54
|
+
this.definitions as any,
|
|
55
|
+
_ => this.transform(_).catchAllCause(f),
|
|
56
|
+
this.transformRespond as any,
|
|
57
|
+
)
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
catchAllCauseRespond<R1, E1>(
|
|
61
|
+
f: (cause: Cause<E>) => Effect<R1, E1, Discord.InteractionResponse>,
|
|
62
|
+
) {
|
|
63
|
+
return new InteractionBuilder<R | R1, E1>(
|
|
64
|
+
this.definitions as any,
|
|
65
|
+
this.transform as any,
|
|
66
|
+
_ => this.transformRespond(_).catchAllCause(f),
|
|
67
|
+
)
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
catchAll<R1, E1>(f: (error: E) => Effect<R1, E1, void>) {
|
|
71
|
+
return new InteractionBuilder<R | R1, E1>(
|
|
72
|
+
this.definitions as any,
|
|
73
|
+
_ => this.transform(_).catchAll(f),
|
|
74
|
+
this.transformRespond as any,
|
|
75
|
+
)
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
catchAllRespond<R1, E1>(
|
|
79
|
+
f: (error: E) => Effect<R1, E1, Discord.InteractionResponse>,
|
|
80
|
+
) {
|
|
81
|
+
return new InteractionBuilder<R | R1, E1>(
|
|
82
|
+
this.definitions as any,
|
|
83
|
+
this.transform as any,
|
|
84
|
+
_ => this.transformRespond(_).catchAll(f),
|
|
85
|
+
)
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
catchTag<T extends ExtractTag<E>, R1, E1>(
|
|
89
|
+
tag: T,
|
|
90
|
+
f: (error: Extract<E, { _tag: T }>) => Effect<R1, E1, void>,
|
|
91
|
+
) {
|
|
92
|
+
return new InteractionBuilder<R | R1, Exclude<E, { _tag: T }> | E1>(
|
|
93
|
+
this.definitions as any,
|
|
94
|
+
_ => catchTag(this.transform(_) as any, tag, f as any) as any,
|
|
95
|
+
this.transformRespond as any,
|
|
96
|
+
)
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
catchTagRespond<T extends ExtractTag<E>, R1, E1>(
|
|
100
|
+
tag: T,
|
|
101
|
+
f: (
|
|
102
|
+
error: Extract<E, { _tag: T }>,
|
|
103
|
+
) => Effect<R1, E1, Discord.InteractionResponse>,
|
|
104
|
+
) {
|
|
105
|
+
return new InteractionBuilder<R | R1, Exclude<E, { _tag: T }> | E1>(
|
|
106
|
+
this.definitions as any,
|
|
107
|
+
this.transform as any,
|
|
108
|
+
_ => catchTag(this.transformRespond(_) as any, tag, f as any) as any,
|
|
109
|
+
)
|
|
36
110
|
}
|
|
37
111
|
|
|
38
112
|
get syncGlobal() {
|
|
@@ -73,7 +147,11 @@ export class InteractionBuilder<R, E> {
|
|
|
73
147
|
}
|
|
74
148
|
}
|
|
75
149
|
|
|
76
|
-
export const builder = new InteractionBuilder<never, never>(
|
|
150
|
+
export const builder = new InteractionBuilder<never, never>(
|
|
151
|
+
[],
|
|
152
|
+
identity as any,
|
|
153
|
+
identity as any,
|
|
154
|
+
)
|
|
77
155
|
|
|
78
156
|
// Filters
|
|
79
157
|
export const id = (query: string) => (customId: string) =>
|
|
@@ -96,7 +96,10 @@ export const makeHandler = <R, E>(ix: InteractionBuilder<R, E>) => {
|
|
|
96
96
|
error,
|
|
97
97
|
}: HandleWebhookOpts<
|
|
98
98
|
E | WebhookParseError | BadWebhookSignature | DefinitionNotFound
|
|
99
|
-
>) =>
|
|
99
|
+
>) =>
|
|
100
|
+
ix
|
|
101
|
+
.transform(ix.transformRespond(handle(headers, body)).flatMap(success))
|
|
102
|
+
.catchAllCause(error)
|
|
100
103
|
}
|
|
101
104
|
|
|
102
105
|
/**
|
package/src/gateway.ts
CHANGED
|
@@ -11,7 +11,11 @@ export * as DiscordWS from "./DiscordGateway/DiscordWS.js"
|
|
|
11
11
|
export * as Shard from "./DiscordGateway/Shard.js"
|
|
12
12
|
export * as ShardStore from "./DiscordGateway/ShardStore.js"
|
|
13
13
|
export * as WS from "./DiscordGateway/WS.js"
|
|
14
|
-
export {
|
|
14
|
+
export {
|
|
15
|
+
InteractionsRegistry,
|
|
16
|
+
InteractionsRegistryLive,
|
|
17
|
+
run as runIx,
|
|
18
|
+
} from "./Interactions/gateway.js"
|
|
15
19
|
|
|
16
20
|
export const MemoryRateLimit = LiveMemoryRateLimitStore >> LiveRateLimiter
|
|
17
21
|
|
package/src/package.json
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "dfx",
|
|
3
|
-
"version": "0.43.1",
|
|
4
|
-
"type": "module",
|
|
5
|
-
"publishConfig": {
|
|
6
|
-
"access": "public",
|
|
7
|
-
"directory": "dist"
|
|
8
|
-
},
|
|
9
|
-
"description": "Effect-TS discord library",
|
|
10
|
-
"author": "Tim Smart <hello@timsmart.co>",
|
|
11
|
-
"repository": {
|
|
12
|
-
"type": "git",
|
|
13
|
-
"url": "https://github.com/tim-smart/dfx.git"
|
|
14
|
-
},
|
|
15
|
-
"license": "MIT",
|
|
16
|
-
"scripts": {
|
|
17
|
-
"prepublishOnly": "make build",
|
|
18
|
-
"types": "discord-api-codegen ./discord-api-docs -l typescript -o 'imports=RestResponse|dfx/DiscordREST/types' 'endpointReturnType=RestResponse' > src/types.ts && prettier -w src/types.ts"
|
|
19
|
-
},
|
|
20
|
-
"exports": {
|
|
21
|
-
".": "./index.js",
|
|
22
|
-
"./gateway": "./gateway.js",
|
|
23
|
-
"./webhooks": "./webhooks.js",
|
|
24
|
-
"./*": "./*.js"
|
|
25
|
-
},
|
|
26
|
-
"devDependencies": {
|
|
27
|
-
"@tim-smart/discord-api-docs-parser": "^0.5.2",
|
|
28
|
-
"@tsplus-types/effect__data": "0.12.2-3b576ba",
|
|
29
|
-
"@tsplus-types/effect__io": "0.25.8-11739c0",
|
|
30
|
-
"@tsplus-types/effect__stream": "0.21.1-3b576ba",
|
|
31
|
-
"@types/ws": "^8.5.4",
|
|
32
|
-
"dotenv": "^16.0.3",
|
|
33
|
-
"lerna": "^6.6.1",
|
|
34
|
-
"madge": "^6.0.0",
|
|
35
|
-
"typescript": "https://cdn.jsdelivr.net/npm/@tsplus/installer@0.0.171/compiler/typescript.tgz"
|
|
36
|
-
},
|
|
37
|
-
"dependencies": {
|
|
38
|
-
"@effect-http/client": "^0.24.2",
|
|
39
|
-
"@effect/data": "^0.12.2",
|
|
40
|
-
"@effect/io": "~0.25.8",
|
|
41
|
-
"@effect/stream": "~0.21.1",
|
|
42
|
-
"tweetnacl": "^1.0.3"
|
|
43
|
-
},
|
|
44
|
-
"optionalDependencies": {
|
|
45
|
-
"bufferutil": "^4.0.7",
|
|
46
|
-
"isomorphic-ws": "^5.0.0",
|
|
47
|
-
"utf-8-validate": "^6.0.3",
|
|
48
|
-
"ws": "^8.13.0"
|
|
49
|
-
},
|
|
50
|
-
"sideEffects": false,
|
|
51
|
-
"gitHead": "2f76a8860ec37c8a44b227557fa472b30c832819"
|
|
52
|
-
}
|