dfx 0.91.3 → 0.92.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/context.d.ts +1 -4
- package/Interactions/context.d.ts.map +1 -1
- package/Interactions/context.js +1 -1
- package/Interactions/context.js.map +1 -1
- package/Interactions/definitions.d.ts +11 -15
- package/Interactions/definitions.d.ts.map +1 -1
- package/Interactions/definitions.js.map +1 -1
- package/Interactions/handlers.d.ts.map +1 -1
- package/Interactions/handlers.js +25 -23
- package/Interactions/handlers.js.map +1 -1
- package/Interactions/index.d.ts +5 -6
- package/Interactions/index.d.ts.map +1 -1
- package/Interactions/index.js +5 -8
- package/Interactions/index.js.map +1 -1
- package/Interactions/utils.d.ts +21 -20
- package/Interactions/utils.d.ts.map +1 -1
- package/Interactions/utils.js +18 -20
- package/Interactions/utils.js.map +1 -1
- package/mjs/Interactions/context.mjs +1 -1
- package/mjs/Interactions/context.mjs.map +1 -1
- package/mjs/Interactions/definitions.mjs.map +1 -1
- package/mjs/Interactions/handlers.mjs +25 -23
- package/mjs/Interactions/handlers.mjs.map +1 -1
- package/mjs/Interactions/index.mjs +5 -6
- package/mjs/Interactions/index.mjs.map +1 -1
- package/mjs/Interactions/utils.mjs +18 -20
- package/mjs/Interactions/utils.mjs.map +1 -1
- package/mjs/version.mjs +1 -1
- package/package.json +2 -2
- package/src/Interactions/context.ts +2 -5
- package/src/Interactions/definitions.ts +23 -37
- package/src/Interactions/handlers.ts +40 -66
- package/src/Interactions/index.ts +5 -7
- package/src/Interactions/utils.ts +49 -42
- package/src/version.ts +1 -1
- package/version.d.ts +1 -1
- package/version.js +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.mjs","names":["TypeIdError","IxHelpers","InteractionsErrorTypeId","GenericTag","Effect","Option","Arr","Interaction","ApplicationCommand","MessageComponentData","ModalSubmitData","FocusedOptionContext","SubCommandContext","resolvedValues","f","flatMap","ix","resolveValues","resolved","name","resolveOptionValue","focusedOptionValue","map","_","
|
|
1
|
+
{"version":3,"file":"context.mjs","names":["TypeIdError","IxHelpers","InteractionsErrorTypeId","GenericTag","Effect","Option","Arr","Interaction","ApplicationCommand","MessageComponentData","ModalSubmitData","FocusedOptionContext","SubCommandContext","resolvedValues","f","flatMap","ix","resolveValues","resolved","name","resolveOptionValue","focusedOptionValue","map","_","value","SubCommandNotFound","handleSubCommands","commands","pipe","data","mapError","findFirst","allSubCommands","command","provideService","currentSubCommand","optionsMap","RequiredOptionNotFound","_tag","constructor","option","getOption","optionValue","match","flatMapNullable","a","onNone","fail","onSome","succeed","optionValueOptional","o","modalValues","componentsMap","modalValueOption","componentValue","modalValue"],"sources":["../../src/Interactions/context.ts"],"sourcesContent":[null],"mappings":"AAAA,SAASA,WAAW,QAAQ,wBAAwB;AACpD,OAAO,KAAKC,SAAS,MAAM,0BAA0B;AACrD,SAASC,uBAAuB,QAAQ,wBAAwB;AAGhE,SAASC,UAAU,QAAQ,gBAAgB;AAC3C,OAAO,KAAKC,MAAM,MAAM,eAAe;AAEvC,OAAO,KAAKC,MAAM,MAAM,eAAe;AACvC,OAAO,KAAKC,GAAG,MAAM,sBAAsB;AAK3C,OAAO,MAAMC,WAAW,gBAAGJ,UAAU,CACnC,8BAA8B,CAC/B;AAKD,OAAO,MAAMK,kBAAkB,gBAAGL,UAAU,CAG1C,qCAAqC,CAAC;AAKxC,OAAO,MAAMM,oBAAoB,gBAAGN,UAAU,CAG5C,uCAAuC,CAAC;AAK1C,OAAO,MAAMO,eAAe,gBAAGP,UAAU,CAGvC,kCAAkC,CAAC;AAKrC,OAAO,MAAMQ,oBAAoB,gBAAGR,UAAU,CAG5C,uCAAuC,CAAC;AAQ1C,OAAO,MAAMS,iBAAiB,gBAAGT,UAAU,CAGzC,oCAAoC,CAAC;AAEvC,OAAO,MAAMU,cAAc,GACzBC,CAAwE,IAKrEV,MAAM,CAACW,OAAO,CAACR,WAAW,EAAES,EAAE,IAAIf,SAAS,CA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AAO,CAACL,eAAe,EAAEmB,IAAI,IAAI5B,SAAS,CAACsD,cAAc,CAACpC,IAAI,CAAC,CAACU,IAAI,CAAC,CAAC","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"definitions.mjs","names":["GlobalApplicationCommand","command","handle","_tag","constructor","global","GuildApplicationCommand","guild","MessageComponent","predicate","messageComponent","pred","ModalSubmit","modalSubmit","Autocomplete","autocomplete"],"sources":["../../src/Interactions/definitions.ts"],"sourcesContent":[null],"mappings":"AAqBA,OAAM,MAAOA,wBAAwB;EAGxBC,OAAA;EACAC,MAAA;EAHFC,IAAI,GAAG,0BAA0B;EAC1CC,YACWH,OAAqD,EACrDC,MAA4B;IAD5B,KAAAD,OAAO,GAAPA,OAAO;IACP,KAAAC,MAAM,GAANA,MAAM;EACd;;AAGL,OAAO,MAAMG,MAAM,GAAGA,
|
|
1
|
+
{"version":3,"file":"definitions.mjs","names":["GlobalApplicationCommand","command","handle","_tag","constructor","global","GuildApplicationCommand","guild","MessageComponent","predicate","messageComponent","pred","ModalSubmit","modalSubmit","Autocomplete","autocomplete"],"sources":["../../src/Interactions/definitions.ts"],"sourcesContent":[null],"mappings":"AAqBA,OAAM,MAAOA,wBAAwB;EAGxBC,OAAA;EACAC,MAAA;EAHFC,IAAI,GAAG,0BAA0B;EAC1CC,YACWH,OAAqD,EACrDC,MAA4B;IAD5B,KAAAD,OAAO,GAAPA,OAAO;IACP,KAAAC,MAAM,GAANA,MAAM;EACd;;AAGL,OAAO,MAAMG,MAAM,GAAGA,CAKpBJ,OAAU,EACVC,MAA+B,KAE/B,IAAIF,wBAAwB,CAG1BC,OAAc,EAAEC,MAAa,CAAC;AAElC,OAAM,MAAOI,uBAAuB;EAGvBL,OAAA;EACAC,MAAA;EAHFC,IAAI,GAAG,yBAAyB;EACzCC,YACWH,OAAoD,EACpDC,MAA4B;IAD5B,KAAAD,OAAO,GAAPA,OAAO;IACP,KAAAC,MAAM,GAANA,MAAM;EACd;;AAGL,OAAO,MAAMK,KAAK,GAAGA,CAKnBN,OAAU,EACVC,MAA+B,KAE/B,IAAII,uBAAuB,CAGzBL,OAAc,EAAEC,MAAa,CAAC;AAElC,OAAM,MAAOM,gBAAgB;EAGhBC,SAAA;EACAP,MAAA;EAHFC,IAAI,GAAG,kBAAkB;EAClCC,YACWK,SAAwC,EACxCP,MAAwD;IADxD,KAAAO,SAAS,GAATA,SAAS;IACT,KAAAP,MAAM,GAANA,MAAM;EACd;;AAGL,OAAO,MAAMQ,gBAAgB,GAAGA,CAC9BC,IAAmC,EACnCT,MAAyD,KAEzD,IAAIM,gBAAgB,CAGlBG,IAAI,EAAET,MAAa,CAAC;AAExB,OAAM,MAAOU,WAAW;EAGXH,SAAA;EACAP,MAAA;EAHFC,IAAI,GAAG,aAAa;EAC7BC,YACWK,SAAwC,EACxCP,MAAwD;IADxD,KAAAO,SAAS,GAATA,SAAS;IACT,KAAAP,MAAM,GAANA,MAAM;EACd;;AAGL,OAAO,MAAMW,WAAW,GAAGA,CACzBF,IAAmC,EACnCT,MAAwD,KAExD,IAAIU,WAAW,CAGbD,IAAI,EAAET,MAAa,CAAC;AAExB,OAAM,MAAOY,YAAY;EAGZL,SAAA;EAIAP,MAAA;EANFC,IAAI,GAAG,cAAc;EAC9BC,YACWK,SAGG,EACHP,MAAwD;IAJxD,KAAAO,SAAS,GAATA,SAAS;IAIT,KAAAP,MAAM,GAANA,MAAM;EACd;;AAGL,OAAO,MAAMa,YAAY,GAAGA,CAC1BJ,IAGY,EACZT,MAAwD,KAExD,IAAIY,YAAY,CASdH,IAAI,EAAET,MAAa,CAAC","ignoreList":[]}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import * as Option from "effect/Option";
|
|
2
1
|
import * as Effect from "effect/Effect";
|
|
3
2
|
import * as IxHelpers from "dfx/Helpers/interactions";
|
|
4
3
|
import * as Ctx from "dfx/Interactions/context";
|
|
@@ -20,41 +19,44 @@ export const handlers = (definitions, handleResponse) => {
|
|
|
20
19
|
ModalSubmit
|
|
21
20
|
} = splitDefinitions(flattened);
|
|
22
21
|
return {
|
|
23
|
-
[Discord.InteractionType.PING]:
|
|
22
|
+
[Discord.InteractionType.PING]: _ => Effect.succeed({
|
|
24
23
|
type: Discord.InteractionCallbackType.PONG
|
|
25
24
|
}),
|
|
26
25
|
[Discord.InteractionType.APPLICATION_COMMAND]: i => {
|
|
27
26
|
const data = i.data;
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}
|
|
27
|
+
const command = Commands[data.name];
|
|
28
|
+
if (command === undefined) {
|
|
29
|
+
return Effect.fail(new DefinitionNotFound(i));
|
|
30
|
+
}
|
|
31
|
+
return Effect.provideService(command.handle(i), Ctx.ApplicationCommand, data);
|
|
32
32
|
},
|
|
33
33
|
[Discord.InteractionType.MODAL_SUBMIT]: i => {
|
|
34
34
|
const data = i.data;
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}
|
|
35
|
+
const match = ModalSubmit.find(_ => _.predicate(data.custom_id));
|
|
36
|
+
if (match === undefined) {
|
|
37
|
+
return Effect.fail(new DefinitionNotFound(i));
|
|
38
|
+
}
|
|
39
|
+
return Effect.provideService(match.handle(i), Ctx.ModalSubmitData, data);
|
|
39
40
|
},
|
|
40
41
|
[Discord.InteractionType.MESSAGE_COMPONENT]: i => {
|
|
41
42
|
const data = i.data;
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
}
|
|
43
|
+
const match = MessageComponent.find(_ => _.predicate(data.custom_id));
|
|
44
|
+
if (match === undefined) {
|
|
45
|
+
return Effect.fail(new DefinitionNotFound(i));
|
|
46
|
+
}
|
|
47
|
+
return Effect.provideService(match.handle(i), Ctx.MessageComponentData, data);
|
|
46
48
|
},
|
|
47
49
|
[Discord.InteractionType.APPLICATION_COMMAND_AUTOCOMPLETE]: i => {
|
|
48
50
|
const data = i.data;
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
51
|
+
const option = IxHelpers.focusedOption(data);
|
|
52
|
+
if (option._tag === "None") {
|
|
53
|
+
return Effect.fail(new DefinitionNotFound(i));
|
|
54
|
+
}
|
|
55
|
+
const match = Autocomplete.find(_ => _.predicate(data, option.value));
|
|
56
|
+
if (match === undefined) {
|
|
57
|
+
return Effect.fail(new DefinitionNotFound(i));
|
|
58
|
+
}
|
|
59
|
+
return match.handle(i).pipe(Effect.provideService(Ctx.ApplicationCommand, data), Effect.provideService(Ctx.FocusedOptionContext, option.value));
|
|
58
60
|
}
|
|
59
61
|
};
|
|
60
62
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handlers.mjs","names":["
|
|
1
|
+
{"version":3,"file":"handlers.mjs","names":["Effect","IxHelpers","Ctx","flattenDefinitions","splitDefinitions","Discord","DefinitionNotFound","interaction","_tag","constructor","handlers","definitions","handleResponse","flattened","Autocomplete","Commands","MessageComponent","ModalSubmit","InteractionType","PING","_","succeed","type","InteractionCallbackType","PONG","APPLICATION_COMMAND","i","data","command","name","undefined","fail","provideService","handle","ApplicationCommand","MODAL_SUBMIT","match","find","predicate","custom_id","ModalSubmitData","MESSAGE_COMPONENT","MessageComponentData","APPLICATION_COMMAND_AUTOCOMPLETE","option","focusedOption","value","pipe","FocusedOptionContext"],"sources":["../../src/Interactions/handlers.ts"],"sourcesContent":[null],"mappings":"AACA,OAAO,KAAKA,MAAM,MAAM,eAAe;AACvC,OAAO,KAAKC,SAAS,MAAM,0BAA0B;AACrD,OAAO,KAAKC,GAAG,MAAM,0BAA0B;AAE/C,SAASC,kBAAkB,EAAEC,gBAAgB,QAAQ,wBAAwB;AAC7E,OAAO,KAAKC,OAAO,MAAM,WAAW;AAGpC,OAAM,MAAOC,kBAAkB;EAERC,WAAA;EADZC,IAAI,GAAG,oBAAoB;EACpCC,YAAqBF,WAAgC;IAAhC,KAAAA,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AC/C;MACA,OAAOU,KAAK,CACTH,MAAM,CAACP,CAAC,CAAC,CACTqB,IAAI,CACH/C,MAAM,CAACgC,cAAc,CAAC9B,GAAG,CAACgC,kBAAkB,EAAEP,IAAI,CAAC,EACnD3B,MAAM,CAACgC,cAAc,CAAC9B,GAAG,CAAC8C,oBAAoB,EAAEJ,MAAM,CAACE,KAAK,CAAC,CAC1B;IACzC;GACD;AACH,CAAC","ignoreList":[]}
|
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import * as Effect from "effect/Effect";
|
|
2
1
|
export { response } from "dfx/Helpers/interactions";
|
|
3
2
|
export * from "dfx/Interactions/builder";
|
|
4
3
|
export * from "dfx/Interactions/context";
|
|
5
4
|
export { autocomplete, global, guild, messageComponent, modalSubmit } from "dfx/Interactions/definitions";
|
|
6
5
|
// Filters
|
|
7
|
-
export const id = query => customId =>
|
|
8
|
-
export const idStartsWith = query => customId =>
|
|
9
|
-
export const idRegex = query => customId =>
|
|
10
|
-
export const option = (command, optionName) => (data, focusedOption) =>
|
|
11
|
-
export const optionOnly = optionName => (_, focusedOption) =>
|
|
6
|
+
export const id = query => customId => query === customId;
|
|
7
|
+
export const idStartsWith = query => customId => customId.startsWith(query);
|
|
8
|
+
export const idRegex = query => customId => query.test(customId);
|
|
9
|
+
export const option = (command, optionName) => (data, focusedOption) => data.name === command && focusedOption.name === optionName;
|
|
10
|
+
export const optionOnly = optionName => (_, focusedOption) => focusedOption.name === optionName;
|
|
12
11
|
//# sourceMappingURL=index.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":["
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["response","autocomplete","global","guild","messageComponent","modalSubmit","id","query","customId","idStartsWith","startsWith","idRegex","test","option","command","optionName","data","focusedOption","name","optionOnly","_"],"sources":["../../src/Interactions/index.ts"],"sourcesContent":[null],"mappings":"AAEA,SAASA,QAAQ,QAAQ,0BAA0B;AACnD,cAAc,0BAA0B;AACxC,cAAc,0BAA0B;AACxC,SACEC,YAAY,EACZC,MAAM,EACNC,KAAK,EAELC,gBAAgB,EAChBC,WAAW,QACN,8BAA8B;AAErC;AACA,OAAO,MAAMC,EAAE,GAAIC,KAAa,IAAMC,QAAgB,IAAKD,KAAK,KAAKC,QAAQ;AAE7E,OAAO,MAAMC,YAAY,GAAIF,KAAa,IAAMC,QAAgB,IAC9DA,QAAQ,CAACE,UAAU,CAACH,KAAK,CAAC;AAE5B,OAAO,MAAMI,OAAO,GAAIJ,KAAa,IAAMC,QAAgB,IACzDD,KAAK,CAACK,IAAI,CAACJ,QAAQ,CAAC;AAEtB,OAAO,MAAMK,MAAM,GACjBA,CAACC,OAAe,EAAEC,UAAkB,KACpC,CACEC,IAAmD,EACnDC,aAGC,KAEDD,IAAI,CAACE,IAAI,KAAKJ,OAAO,IAAIG,aAAa,CAACC,IAAI,KAAKH,UAAU;AAE9D,OAAO,MAAMI,UAAU,GACpBJ,UAAkB,IACnB,CACEK,CAAU,EACVH,aAGC,KAEDA,aAAa,CAACC,IAAI,KAAKH,UAAU","ignoreList":[]}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as Chunk from "effect/Chunk";
|
|
2
2
|
import * as Effect from "effect/Effect";
|
|
3
3
|
import * as Ctx from "dfx/Interactions/context";
|
|
4
|
+
import * as ReadonlyArray from "effect/ReadonlyArray";
|
|
4
5
|
const context = {
|
|
5
6
|
resolve: Ctx.resolved,
|
|
6
7
|
option: Ctx.option,
|
|
@@ -8,28 +9,25 @@ const context = {
|
|
|
8
9
|
optionValueOptional: Ctx.optionValueOptional,
|
|
9
10
|
subCommands: Ctx.handleSubCommands
|
|
10
11
|
};
|
|
11
|
-
export const flattenDefinitions = (definitions, handleResponse) =>
|
|
12
|
+
export const flattenDefinitions = (definitions, handleResponse) => ReadonlyArray.map(Chunk.toReadonlyArray(definitions), ([definition, transform]) => ({
|
|
12
13
|
...definition,
|
|
13
|
-
handle:
|
|
14
|
+
handle: Effect.isEffect(definition.handle) ? i => Effect.scoped(transform(Effect.flatMap(definition.handle, _ => handleResponse(i, _)))) : i => Effect.scoped(transform(Effect.flatMap(definition.handle(context), _ => handleResponse(i, _))))
|
|
14
15
|
}));
|
|
15
16
|
export const splitDefinitions = definitions => {
|
|
16
|
-
const grouped =
|
|
17
|
-
Autocomplete:
|
|
18
|
-
GlobalApplicationCommand:
|
|
19
|
-
GuildApplicationCommand:
|
|
20
|
-
MessageComponent:
|
|
21
|
-
ModalSubmit:
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
[d._tag]
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
})
|
|
30
|
-
return
|
|
31
|
-
...grouped,
|
|
32
|
-
Commands
|
|
33
|
-
};
|
|
17
|
+
const grouped = ReadonlyArray.reduce(definitions, {
|
|
18
|
+
Autocomplete: [],
|
|
19
|
+
GlobalApplicationCommand: [],
|
|
20
|
+
GuildApplicationCommand: [],
|
|
21
|
+
MessageComponent: [],
|
|
22
|
+
ModalSubmit: [],
|
|
23
|
+
Commands: {}
|
|
24
|
+
}, (acc, d) => {
|
|
25
|
+
acc[d._tag].push(d);
|
|
26
|
+
if (d._tag === "GlobalApplicationCommand" || d._tag === "GuildApplicationCommand") {
|
|
27
|
+
acc.Commands[d.command.name] = d;
|
|
28
|
+
}
|
|
29
|
+
return acc;
|
|
30
|
+
});
|
|
31
|
+
return grouped;
|
|
34
32
|
};
|
|
35
33
|
//# sourceMappingURL=utils.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.mjs","names":["Chunk","Effect","Ctx","context","resolve","resolved","option","optionValue","optionValueOptional","subCommands","handleSubCommands","flattenDefinitions","definitions","handleResponse","map","definition","transform","handle","
|
|
1
|
+
{"version":3,"file":"utils.mjs","names":["Chunk","Effect","Ctx","ReadonlyArray","context","resolve","resolved","option","optionValue","optionValueOptional","subCommands","handleSubCommands","flattenDefinitions","definitions","handleResponse","map","toReadonlyArray","definition","transform","handle","isEffect","i","scoped","flatMap","_","splitDefinitions","grouped","reduce","Autocomplete","GlobalApplicationCommand","GuildApplicationCommand","MessageComponent","ModalSubmit","Commands","acc","d","_tag","push","command","name"],"sources":["../../src/Interactions/utils.ts"],"sourcesContent":[null],"mappings":"AAAA,OAAO,KAAKA,KAAK,MAAM,cAAc;AACrC,OAAO,KAAKC,MAAM,MAAM,eAAe;AACvC,OAAO,KAAKC,GAAG,MAAM,0BAA0B;AAG/C,OAAO,KAAKC,aAAa,MAAM,sBAAsB;AAgBrD,MAAMC,OAAO,GAAyB;EACpCC,OAAO,EAAEH,GAAG,CAACI,QAAQ;EACrBC,MAAM,EAAEL,GAAG,CAACK,MAAM;EAClBC,WAAW,EAAEN,GAAG,CAACM,WAAW;EAC5BC,mBAAmB,EAAEP,GAAG,CAACO,mBAAmB;EAC5CC,WAAW,EAAER,GAAG,CAACS;CACX;AAER,OAAO,MAAMC,kBAAkB,GAAGA,CAChCC,WAKC,EACDC,cAG2B,KAE3BX,aAAa,CAACY,GAAG,CACff,KAAK,CAACgB,eAAe,CAACH,WAAW,CAAC,EAClC,CAAC,CAACI,UAAU,EAAEC,SAAS,CAAC,MAAM;EAC5B,GAAGD,UAAU;EACbE,MAAM,EAAElB,MAAM,CAACmB,QAAQ,CAACH,UAAU,CAACE,MAAM,CAAC,GACrCE,CAAsB,IACrBpB,MAAM,CAACqB,MAAM,CACXJ,SAAS,CACPjB,MAAM,CAACsB,OAAO,CACZN,UAAU,CAACE,MAAoD,EAC/DK,CAAC,IAAIV,cAAc,CAACO,CAAC,EAAEG,CAAC,CAAC,CAC1B,CACF,CACF,GACFH,CAAsB,IACrBpB,MAAM,CAACqB,MAAM,CACXJ,SAAS,CACPjB,MAAM,CAACsB,OAAO,CAEVN,UAAU,CAACE,MAGZ,CAACf,OAAO,CAAC,EACVoB,CAAC,IAAIV,cAAc,CAACO,CAAC,EAAEG,CAAC,CAAC,CAC1B,CACF;CAEV,CAAC,CACH;AAEH,OAAO,MAAMC,gBAAgB,GAC3BZ,WAA4D,IAC1D;EACF,MAAMa,OAAO,GAAGvB,aAAa,CAACwB,MAAM,CAClCd,WAAW,EACX;IACEe,YAAY,EAAE,EAAE;IAChBC,wBAAwB,EAAE,EAAE;IAC5BC,uBAAuB,EAAE,EAAE;IAC3BC,gBAAgB,EAAE,EAAE;IACpBC,WAAW,EAAE,EAAE;IACfC,QAAQ,EAAE;GAOX,EACD,CAACC,GAAG,EAAEC,CAAC,KAAI;IACTD,GAAG,CAACC,CAAC,CAACC,IAAI,CAAC,CAACC,IAAI,CAACF,CAAQ,CAAC;IAC1B,IACEA,CAAC,CAACC,IAAI,KAAK,0BAA0B,IACrCD,CAAC,CAACC,IAAI,KAAK,yBAAyB,EACpC;MACAF,GAAG,CAACD,QAAQ,CAACE,CAAC,CAACG,OAAO,CAACC,IAAI,CAAC,GAAGJ,CAAQ;IACzC;IACA,OAAOD,GAAG;EACZ,CAAC,CACF;EAED,OAAOR,OAAO;AAChB,CAAC","ignoreList":[]}
|
package/mjs/version.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const LIB_VERSION = "0.
|
|
1
|
+
export const LIB_VERSION = "0.92.0";
|
|
2
2
|
//# sourceMappingURL=version.mjs.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dfx",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.92.0",
|
|
4
4
|
"description": "Effect-TS discord library",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -44,6 +44,6 @@
|
|
|
44
44
|
"utf-8-validate": "^6.0.3",
|
|
45
45
|
"zlib-sync": "^0.1.9"
|
|
46
46
|
},
|
|
47
|
-
"gitHead": "
|
|
47
|
+
"gitHead": "6291412296e712de6a82e26bcdd3dc119c69a3ce",
|
|
48
48
|
"main": "./index.js"
|
|
49
49
|
}
|
|
@@ -43,12 +43,9 @@ export const ModalSubmitData = GenericTag<
|
|
|
43
43
|
export interface DiscordFocusedOption {
|
|
44
44
|
readonly _: unique symbol
|
|
45
45
|
}
|
|
46
|
-
export interface FocusedOptionContext {
|
|
47
|
-
readonly focusedOption: Discord.ApplicationCommandInteractionDataOption
|
|
48
|
-
}
|
|
49
46
|
export const FocusedOptionContext = GenericTag<
|
|
50
47
|
DiscordFocusedOption,
|
|
51
|
-
|
|
48
|
+
Discord.ApplicationCommandInteractionDataOption
|
|
52
49
|
>("dfx/Interactions/FocusedOptionContext")
|
|
53
50
|
|
|
54
51
|
export interface DiscordSubCommand {
|
|
@@ -78,7 +75,7 @@ export const resolved = <A>(
|
|
|
78
75
|
|
|
79
76
|
export const focusedOptionValue = Effect.map(
|
|
80
77
|
FocusedOptionContext,
|
|
81
|
-
_ => _.
|
|
78
|
+
_ => _.value ?? "",
|
|
82
79
|
)
|
|
83
80
|
|
|
84
81
|
export class SubCommandNotFound extends TypeIdError(
|
|
@@ -30,8 +30,7 @@ export class GlobalApplicationCommand<R, E> {
|
|
|
30
30
|
export const global = <
|
|
31
31
|
R,
|
|
32
32
|
E,
|
|
33
|
-
const A extends
|
|
34
|
-
DeepReadonlyObject<Discord.CreateGlobalApplicationCommandParams>,
|
|
33
|
+
const A extends Discord.CreateGlobalApplicationCommandParams,
|
|
35
34
|
>(
|
|
36
35
|
command: A,
|
|
37
36
|
handle: CommandHandler<R, E, A>,
|
|
@@ -52,8 +51,7 @@ export class GuildApplicationCommand<R, E> {
|
|
|
52
51
|
export const guild = <
|
|
53
52
|
R,
|
|
54
53
|
E,
|
|
55
|
-
const A extends
|
|
56
|
-
DeepReadonlyObject<Discord.CreateGuildApplicationCommandParams>,
|
|
54
|
+
const A extends Discord.CreateGuildApplicationCommandParams,
|
|
57
55
|
>(
|
|
58
56
|
command: A,
|
|
59
57
|
handle: CommandHandler<R, E, A>,
|
|
@@ -66,36 +64,36 @@ export const guild = <
|
|
|
66
64
|
export class MessageComponent<R, E> {
|
|
67
65
|
readonly _tag = "MessageComponent"
|
|
68
66
|
constructor(
|
|
69
|
-
readonly predicate: (customId: string) =>
|
|
67
|
+
readonly predicate: (customId: string) => boolean,
|
|
70
68
|
readonly handle: Effect.Effect<Discord.InteractionResponse, E, R>,
|
|
71
69
|
) {}
|
|
72
70
|
}
|
|
73
71
|
|
|
74
|
-
export const messageComponent = <
|
|
75
|
-
pred: (customId: string) =>
|
|
76
|
-
handle: CommandHandler<
|
|
72
|
+
export const messageComponent = <R, E>(
|
|
73
|
+
pred: (customId: string) => boolean,
|
|
74
|
+
handle: CommandHandler<R, E, Discord.InteractionResponse>,
|
|
77
75
|
) =>
|
|
78
76
|
new MessageComponent<
|
|
79
|
-
Exclude<
|
|
80
|
-
|
|
81
|
-
>(pred
|
|
77
|
+
Exclude<R, DiscordInteraction | DiscordMessageComponent | Scope>,
|
|
78
|
+
E
|
|
79
|
+
>(pred, handle as any)
|
|
82
80
|
|
|
83
81
|
export class ModalSubmit<R, E> {
|
|
84
82
|
readonly _tag = "ModalSubmit"
|
|
85
83
|
constructor(
|
|
86
|
-
readonly predicate: (customId: string) =>
|
|
84
|
+
readonly predicate: (customId: string) => boolean,
|
|
87
85
|
readonly handle: Effect.Effect<Discord.InteractionResponse, E, R>,
|
|
88
86
|
) {}
|
|
89
87
|
}
|
|
90
88
|
|
|
91
|
-
export const modalSubmit = <
|
|
92
|
-
pred: (customId: string) =>
|
|
93
|
-
handle: Effect.Effect<Discord.InteractionResponse,
|
|
89
|
+
export const modalSubmit = <R, E>(
|
|
90
|
+
pred: (customId: string) => boolean,
|
|
91
|
+
handle: Effect.Effect<Discord.InteractionResponse, E, R>,
|
|
94
92
|
) =>
|
|
95
93
|
new ModalSubmit<
|
|
96
|
-
Exclude<
|
|
97
|
-
|
|
98
|
-
>(pred
|
|
94
|
+
Exclude<R, DiscordInteraction | DiscordModalSubmit | Scope>,
|
|
95
|
+
E
|
|
96
|
+
>(pred, handle as any)
|
|
99
97
|
|
|
100
98
|
export class Autocomplete<R, E> {
|
|
101
99
|
readonly _tag = "Autocomplete"
|
|
@@ -103,42 +101,30 @@ export class Autocomplete<R, E> {
|
|
|
103
101
|
readonly predicate: (
|
|
104
102
|
data: Discord.ApplicationCommandDatum,
|
|
105
103
|
focusedOption: Discord.ApplicationCommandInteractionDataOption,
|
|
106
|
-
) =>
|
|
104
|
+
) => boolean,
|
|
107
105
|
readonly handle: Effect.Effect<Discord.InteractionResponse, E, R>,
|
|
108
106
|
) {}
|
|
109
107
|
}
|
|
110
108
|
|
|
111
|
-
export const autocomplete = <
|
|
109
|
+
export const autocomplete = <R, E>(
|
|
112
110
|
pred: (
|
|
113
111
|
data: Discord.ApplicationCommandDatum,
|
|
114
112
|
focusedOption: Discord.ApplicationCommandInteractionDataOption,
|
|
115
|
-
) =>
|
|
116
|
-
handle: Effect.Effect<Discord.InteractionResponse,
|
|
113
|
+
) => boolean,
|
|
114
|
+
handle: Effect.Effect<Discord.InteractionResponse, E, R>,
|
|
117
115
|
) =>
|
|
118
116
|
new Autocomplete<
|
|
119
117
|
Exclude<
|
|
120
|
-
|
|
118
|
+
R,
|
|
121
119
|
| DiscordInteraction
|
|
122
120
|
| DiscordApplicationCommand
|
|
123
121
|
| DiscordFocusedOption
|
|
124
122
|
| Scope
|
|
125
123
|
>,
|
|
126
|
-
|
|
127
|
-
>(pred
|
|
124
|
+
E
|
|
125
|
+
>(pred, handle as any)
|
|
128
126
|
|
|
129
127
|
// ==== Command handler helpers
|
|
130
|
-
type DeepReadonly<T> =
|
|
131
|
-
T extends Array<infer R>
|
|
132
|
-
? ReadonlyArray<DeepReadonly<R>>
|
|
133
|
-
: T extends Function
|
|
134
|
-
? T
|
|
135
|
-
: T extends object
|
|
136
|
-
? DeepReadonlyObject<T>
|
|
137
|
-
: T
|
|
138
|
-
type DeepReadonlyObject<T> = {
|
|
139
|
-
readonly [P in keyof T]: DeepReadonly<T[P]>
|
|
140
|
-
}
|
|
141
|
-
|
|
142
128
|
export type CommandHandler<R, E, A = any> =
|
|
143
129
|
| Effect.Effect<Discord.InteractionResponse, E, R>
|
|
144
130
|
| CommandHandlerFn<R, E, A>
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type * as Chunk from "effect/Chunk"
|
|
2
|
-
import * as Option from "effect/Option"
|
|
3
2
|
import * as Effect from "effect/Effect"
|
|
4
3
|
import * as IxHelpers from "dfx/Helpers/interactions"
|
|
5
4
|
import * as Ctx from "dfx/Interactions/context"
|
|
@@ -40,91 +39,66 @@ export const handlers = <R, E, TE, A, B>(
|
|
|
40
39
|
splitDefinitions(flattened)
|
|
41
40
|
|
|
42
41
|
return {
|
|
43
|
-
[Discord.InteractionType.PING]:
|
|
42
|
+
[Discord.InteractionType.PING]: _ =>
|
|
44
43
|
Effect.succeed({
|
|
45
44
|
type: Discord.InteractionCallbackType.PONG,
|
|
46
45
|
} as any),
|
|
47
46
|
|
|
48
47
|
[Discord.InteractionType.APPLICATION_COMMAND]: i => {
|
|
49
48
|
const data = i.data as Discord.ApplicationCommandDatum
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
})
|
|
49
|
+
const command = Commands[data.name]
|
|
50
|
+
if (command === undefined) {
|
|
51
|
+
return Effect.fail(new DefinitionNotFound(i))
|
|
52
|
+
}
|
|
53
|
+
return Effect.provideService(
|
|
54
|
+
command.handle(i),
|
|
55
|
+
Ctx.ApplicationCommand,
|
|
56
|
+
data,
|
|
57
|
+
) as Handler<Exclude<R, Scope>, E, B>
|
|
60
58
|
},
|
|
61
59
|
|
|
62
60
|
[Discord.InteractionType.MODAL_SUBMIT]: i => {
|
|
63
61
|
const data = i.data as Discord.ModalSubmitDatum
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
Effect.provideService(
|
|
73
|
-
match.handle(i),
|
|
74
|
-
Ctx.ModalSubmitData,
|
|
75
|
-
data,
|
|
76
|
-
) as Handler<R, E, B>,
|
|
77
|
-
}),
|
|
78
|
-
),
|
|
62
|
+
const match = ModalSubmit.find(_ => _.predicate(data.custom_id))
|
|
63
|
+
if (match === undefined) {
|
|
64
|
+
return Effect.fail(new DefinitionNotFound(i))
|
|
65
|
+
}
|
|
66
|
+
return Effect.provideService(
|
|
67
|
+
match.handle(i),
|
|
68
|
+
Ctx.ModalSubmitData,
|
|
69
|
+
data,
|
|
79
70
|
) as Handler<Exclude<R, Scope>, E, B>
|
|
80
71
|
},
|
|
81
72
|
|
|
82
73
|
[Discord.InteractionType.MESSAGE_COMPONENT]: i => {
|
|
83
74
|
const data = i.data as Discord.MessageComponentDatum
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
Effect.provideService(
|
|
93
|
-
match.handle(i),
|
|
94
|
-
Ctx.MessageComponentData,
|
|
95
|
-
data,
|
|
96
|
-
) as Handler<R, E, B>,
|
|
97
|
-
}),
|
|
98
|
-
),
|
|
75
|
+
const match = MessageComponent.find(_ => _.predicate(data.custom_id))
|
|
76
|
+
if (match === undefined) {
|
|
77
|
+
return Effect.fail(new DefinitionNotFound(i))
|
|
78
|
+
}
|
|
79
|
+
return Effect.provideService(
|
|
80
|
+
match.handle(i),
|
|
81
|
+
Ctx.MessageComponentData,
|
|
82
|
+
data,
|
|
99
83
|
) as Handler<Exclude<R, Scope>, E, B>
|
|
100
84
|
},
|
|
101
85
|
|
|
102
86
|
[Discord.InteractionType.APPLICATION_COMMAND_AUTOCOMPLETE]: i => {
|
|
103
87
|
const data = i.data as Discord.ApplicationCommandDatum
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
data,
|
|
119
|
-
).pipe(
|
|
120
|
-
Effect.provideService(Ctx.FocusedOptionContext, {
|
|
121
|
-
focusedOption,
|
|
122
|
-
}),
|
|
123
|
-
) as Handler<R, E, B>,
|
|
124
|
-
}),
|
|
125
|
-
),
|
|
126
|
-
),
|
|
127
|
-
}) as Handler<Exclude<R, Scope>, E, B>
|
|
88
|
+
const option = IxHelpers.focusedOption(data)
|
|
89
|
+
if (option._tag === "None") {
|
|
90
|
+
return Effect.fail(new DefinitionNotFound(i))
|
|
91
|
+
}
|
|
92
|
+
const match = Autocomplete.find(_ => _.predicate(data, option.value))
|
|
93
|
+
if (match === undefined) {
|
|
94
|
+
return Effect.fail(new DefinitionNotFound(i))
|
|
95
|
+
}
|
|
96
|
+
return match
|
|
97
|
+
.handle(i)
|
|
98
|
+
.pipe(
|
|
99
|
+
Effect.provideService(Ctx.ApplicationCommand, data),
|
|
100
|
+
Effect.provideService(Ctx.FocusedOptionContext, option.value),
|
|
101
|
+
) as Handler<Exclude<R, Scope>, E, B>
|
|
128
102
|
},
|
|
129
103
|
}
|
|
130
104
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import * as Effect from "effect/Effect"
|
|
2
1
|
import type * as Discord from "dfx/types"
|
|
3
2
|
|
|
4
3
|
export { response } from "dfx/Helpers/interactions"
|
|
@@ -14,14 +13,13 @@ export {
|
|
|
14
13
|
} from "dfx/Interactions/definitions"
|
|
15
14
|
|
|
16
15
|
// Filters
|
|
17
|
-
export const id = (query: string) => (customId: string) =>
|
|
18
|
-
Effect.succeed(query === customId)
|
|
16
|
+
export const id = (query: string) => (customId: string) => query === customId
|
|
19
17
|
|
|
20
18
|
export const idStartsWith = (query: string) => (customId: string) =>
|
|
21
|
-
|
|
19
|
+
customId.startsWith(query)
|
|
22
20
|
|
|
23
21
|
export const idRegex = (query: RegExp) => (customId: string) =>
|
|
24
|
-
|
|
22
|
+
query.test(customId)
|
|
25
23
|
|
|
26
24
|
export const option =
|
|
27
25
|
(command: string, optionName: string) =>
|
|
@@ -32,7 +30,7 @@ export const option =
|
|
|
32
30
|
"name"
|
|
33
31
|
>,
|
|
34
32
|
) =>
|
|
35
|
-
|
|
33
|
+
data.name === command && focusedOption.name === optionName
|
|
36
34
|
|
|
37
35
|
export const optionOnly =
|
|
38
36
|
(optionName: string) =>
|
|
@@ -43,4 +41,4 @@ export const optionOnly =
|
|
|
43
41
|
"name"
|
|
44
42
|
>,
|
|
45
43
|
) =>
|
|
46
|
-
|
|
44
|
+
focusedOption.name === optionName
|