dfx 0.9.8 → 0.9.9
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/DiscordConfig/index.d.ts +39 -0
- package/DiscordConfig/index.js +29 -0
- package/DiscordConfig/index.js.map +1 -0
- package/DiscordGateway/DiscordWS/index.d.ts +23 -0
- package/DiscordGateway/DiscordWS/index.js +26 -0
- package/DiscordGateway/DiscordWS/index.js.map +1 -0
- package/DiscordGateway/Shard/heartbeats.d.ts +3 -0
- package/DiscordGateway/Shard/heartbeats.js +24 -0
- package/DiscordGateway/Shard/heartbeats.js.map +1 -0
- package/DiscordGateway/Shard/identify.d.ts +12 -0
- package/DiscordGateway/Shard/identify.js +30 -0
- package/DiscordGateway/Shard/identify.js.map +1 -0
- package/DiscordGateway/Shard/index.d.ts +9 -0
- package/DiscordGateway/Shard/index.js +52 -0
- package/DiscordGateway/Shard/index.js.map +1 -0
- package/DiscordGateway/Shard/invalidSession.d.ts +3 -0
- package/DiscordGateway/Shard/invalidSession.js +10 -0
- package/DiscordGateway/Shard/invalidSession.js.map +1 -0
- package/DiscordGateway/Shard/sendEvents.d.ts +7 -0
- package/DiscordGateway/Shard/sendEvents.js +26 -0
- package/DiscordGateway/Shard/sendEvents.js.map +1 -0
- package/DiscordGateway/Shard/utils.d.ts +3 -0
- package/DiscordGateway/Shard/utils.js +9 -0
- package/DiscordGateway/Shard/utils.js.map +1 -0
- package/DiscordGateway/ShardStore/index.d.ts +12 -0
- package/DiscordGateway/ShardStore/index.js +22 -0
- package/DiscordGateway/ShardStore/index.js.map +1 -0
- package/DiscordGateway/Sharder/index.d.ts +9 -0
- package/DiscordGateway/Sharder/index.js +61 -0
- package/DiscordGateway/Sharder/index.js.map +1 -0
- package/DiscordGateway/WS/index.d.ts +27 -0
- package/DiscordGateway/WS/index.js +82 -0
- package/DiscordGateway/WS/index.js.map +1 -0
- package/DiscordGateway/index.d.ts +20 -0
- package/DiscordGateway/index.js +27 -0
- package/DiscordGateway/index.js.map +1 -0
- package/DiscordREST/index.d.ts +12 -0
- package/DiscordREST/index.js +85 -0
- package/DiscordREST/index.js.map +1 -0
- package/DiscordREST/types.d.ts +9 -0
- package/DiscordREST/types.js +2 -0
- package/DiscordREST/types.js.map +1 -0
- package/DiscordREST/utils.d.ts +10 -0
- package/DiscordREST/utils.js +22 -0
- package/DiscordREST/utils.js.map +1 -0
- package/Helpers/flags.d.ts +27 -0
- package/Helpers/flags.js +36 -0
- package/Helpers/flags.js.map +1 -0
- package/Helpers/intents.d.ts +24 -0
- package/Helpers/intents.js +28 -0
- package/Helpers/intents.js.map +1 -0
- package/Helpers/interactions.d.ts +73 -0
- package/Helpers/interactions.js +93 -0
- package/Helpers/interactions.js.map +1 -0
- package/Helpers/members.d.ts +9 -0
- package/Helpers/members.js +10 -0
- package/Helpers/members.js.map +1 -0
- package/Helpers/permissions.d.ts +34 -0
- package/Helpers/permissions.js +69 -0
- package/Helpers/permissions.js.map +1 -0
- package/Helpers/ui.d.ts +47 -0
- package/Helpers/ui.js +67 -0
- package/Helpers/ui.js.map +1 -0
- package/Http/index.d.ts +30 -0
- package/Http/index.js +53 -0
- package/Http/index.js.map +1 -0
- package/Interactions/context.d.ts +36 -0
- package/Interactions/context.js +34 -0
- package/Interactions/context.js.map +1 -0
- package/Interactions/definitions.d.ts +60 -0
- package/Interactions/definitions.js +52 -0
- package/Interactions/definitions.js.map +1 -0
- package/Interactions/gateway.d.ts +6 -0
- package/Interactions/gateway.js +21 -0
- package/Interactions/gateway.js.map +1 -0
- package/Interactions/handlers.d.ts +8 -0
- package/Interactions/handlers.js +49 -0
- package/Interactions/handlers.js.map +1 -0
- package/Interactions/index.d.ts +17 -0
- package/Interactions/index.js +39 -0
- package/Interactions/index.js.map +1 -0
- package/Interactions/utils.d.ts +10 -0
- package/Interactions/utils.js +61 -0
- package/Interactions/utils.js.map +1 -0
- package/Interactions/webhook.d.ts +32 -0
- package/Interactions/webhook.js +42 -0
- package/Interactions/webhook.js.map +1 -0
- package/Log/index.d.ts +12 -0
- package/Log/index.js +19 -0
- package/Log/index.js.map +1 -0
- package/RateLimitStore/index.d.ts +24 -0
- package/RateLimitStore/index.js +24 -0
- package/RateLimitStore/index.js.map +1 -0
- package/RateLimitStore/memory.d.ts +2 -0
- package/RateLimitStore/memory.js +31 -0
- package/RateLimitStore/memory.js.map +1 -0
- package/RateLimitStore/utils.d.ts +2 -0
- package/RateLimitStore/utils.js +18 -0
- package/RateLimitStore/utils.js.map +1 -0
- package/common-gateway.d.ts +5 -0
- package/common-gateway.js +6 -0
- package/common-gateway.js.map +1 -0
- package/common.d.ts +28 -0
- package/common.js +16 -0
- package/common.js.map +1 -0
- package/global.d.ts +17 -0
- package/global.js +2 -0
- package/global.js.map +1 -0
- package/index.d.ts +21 -0
- package/index.js +29 -0
- package/index.js.map +1 -0
- package/package.json +2 -6
- package/types.d.ts +4228 -0
- package/types.js +1796 -0
- package/types.js.map +1 -0
- package/utils/effect.d.ts +2 -0
- package/utils/effect.js +2 -0
- package/utils/effect.js.map +1 -0
- package/utils/tsplus.d.ts +13 -0
- package/utils/tsplus.js +2 -0
- package/utils/tsplus.js.map +1 -0
- package/webhooks.d.ts +15 -0
- package/webhooks.js +23 -0
- package/webhooks.js.map +1 -0
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import * as tsplus_module_1 from "dfx/common";
|
|
2
|
+
import * as tsplus_module_2 from "@fp-ts/data/Function";
|
|
3
|
+
/**
|
|
4
|
+
* A constant of all the permissions
|
|
5
|
+
*/
|
|
6
|
+
export const ALL = tsplus_module_1.Flags.all(tsplus_module_1.Discord.PermissionFlag);
|
|
7
|
+
/**
|
|
8
|
+
* Check if a flag exists in the permissions.
|
|
9
|
+
*/
|
|
10
|
+
export const has = tsplus_module_1.Flags.hasBigInt;
|
|
11
|
+
/**
|
|
12
|
+
* Convert a permissions bitfield to a list of flag names.
|
|
13
|
+
*/
|
|
14
|
+
export const toList = tsplus_module_1.Flags.toList(tsplus_module_1.Discord.PermissionFlag);
|
|
15
|
+
/**
|
|
16
|
+
* Convert a list of flag names to a bitfield.
|
|
17
|
+
*/
|
|
18
|
+
export const fromList = tsplus_module_1.Flags.fromListBigint(tsplus_module_1.Discord.PermissionFlag);
|
|
19
|
+
/**
|
|
20
|
+
* Reduce a list of roles to a bitfield of all the permissions added together.
|
|
21
|
+
*/
|
|
22
|
+
export const forRoles = (roles) => roles.reduce((permissions, role) => permissions | BigInt(role.permissions), BigInt(0));
|
|
23
|
+
/**
|
|
24
|
+
* From a list of roles, calculate the permissions bitfield for the member.
|
|
25
|
+
*/
|
|
26
|
+
export const forMember = (roles) => (member) => tsplus_module_2.pipe(tsplus_module_1.Members.roles(roles)(member), forRoles);
|
|
27
|
+
const overwriteIsForMember = (guildId) => (member) => (overwrite) => {
|
|
28
|
+
if (overwrite.type === 0) {
|
|
29
|
+
return overwrite.id === guildId || member.roles.includes(overwrite.id);
|
|
30
|
+
}
|
|
31
|
+
return overwrite.id === member.user?.id;
|
|
32
|
+
};
|
|
33
|
+
const overwriteIsForRole = (guildId) => (role) => (overwrite) => {
|
|
34
|
+
if (overwrite.type === 0) {
|
|
35
|
+
return overwrite.id === guildId || overwrite.id === role.id;
|
|
36
|
+
}
|
|
37
|
+
return false;
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* From a list of roles and a channel, calculate the permission bitfield for
|
|
41
|
+
* the guild member or role for that channel.
|
|
42
|
+
*/
|
|
43
|
+
export const forChannel = (roles) => ({ guild_id, permission_overwrites: overwrites = [] }) => (memberOrRole) => {
|
|
44
|
+
const hasAdmin = has(tsplus_module_1.Discord.PermissionFlag.ADMINISTRATOR);
|
|
45
|
+
let basePermissions;
|
|
46
|
+
let filteredOverwrites;
|
|
47
|
+
if (tsplus_module_1.Members.is(memberOrRole)) {
|
|
48
|
+
if (memberOrRole.permissions)
|
|
49
|
+
return BigInt(memberOrRole.permissions);
|
|
50
|
+
const memberRoles = tsplus_module_1.Members.roles(roles)(memberOrRole);
|
|
51
|
+
basePermissions = forRoles(memberRoles);
|
|
52
|
+
filteredOverwrites = overwrites.filter(overwriteIsForMember(guild_id)(memberOrRole));
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
const everyone = roles.find((role) => role.name === "@everyone");
|
|
56
|
+
basePermissions =
|
|
57
|
+
BigInt(everyone?.permissions || "0") | BigInt(memberOrRole.permissions);
|
|
58
|
+
filteredOverwrites = overwrites.filter(overwriteIsForRole(guild_id)(memberOrRole));
|
|
59
|
+
}
|
|
60
|
+
if (hasAdmin(basePermissions)) {
|
|
61
|
+
return ALL;
|
|
62
|
+
}
|
|
63
|
+
return applyOverwrites(basePermissions)(filteredOverwrites);
|
|
64
|
+
};
|
|
65
|
+
/**
|
|
66
|
+
* Apply permission overwrites to a bitfield.
|
|
67
|
+
*/
|
|
68
|
+
export const applyOverwrites = (permissions) => (overwrites) => overwrites.reduce((permissions, overwrite) => (permissions & ~BigInt(overwrite.deny)) | BigInt(overwrite.allow), permissions);
|
|
69
|
+
//# sourceMappingURL=permissions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"permissions.js","sourceRoot":"","sources":["../../src/Helpers/permissions.ts"],"names":[],"mappings":";;AAAA;;GAEG;AACH,MAAM,CAAC,MAAM,GAAG,GAAG,gBAAA,KAAK,CAAC,GAAG,CAAC,gBAAA,OAAO,CAAC,cAAc,CAAC,CAAA;AAEpD;;GAEG;AACH,MAAM,CAAC,MAAM,GAAG,GAAG,gBAAA,KAAK,CAAC,SAAS,CAAA;AAElC;;GAEG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,gBAAA,KAAK,CAAC,MAAM,CAAC,gBAAA,OAAO,CAAC,cAAc,CAAC,CAAA;AAE1D;;GAEG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,gBAAA,KAAK,CAAC,cAAc,CAAC,gBAAA,OAAO,CAAC,cAAc,CAAC,CAAA;AAEpE;;GAEG;AACH,MAAM,CAAC,MAAM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f,CAAC,WAAW,EAAE,SAAS,EAAE,EAAE,CACzB,CAAC,WAAW,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,GAAG,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,EACnE,WAAW,CACZ,CAAA"}
|
package/Helpers/ui.d.ts
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { ActionRow, Button, Component, SelectMenu, SelectOption, TextInput, TextInputStyle } from "../types.js";
|
|
2
|
+
export type UIComponent = Exclude<Component, ActionRow>;
|
|
3
|
+
/**
|
|
4
|
+
* Helper to create an Action Row grid.
|
|
5
|
+
*/
|
|
6
|
+
export declare const grid: (items: UIComponent[][]) => ActionRow[];
|
|
7
|
+
/**
|
|
8
|
+
* Helper to create a single column of components
|
|
9
|
+
*/
|
|
10
|
+
export declare const singleColumn: (items: UIComponent[]) => ActionRow[];
|
|
11
|
+
/**
|
|
12
|
+
* Helper to create a button component.
|
|
13
|
+
*/
|
|
14
|
+
export declare const button: (button: Partial<Button>) => Button;
|
|
15
|
+
type BasicSelect = Omit<SelectMenu, "type" | "channel_types" | "options">;
|
|
16
|
+
type StringSelect = BasicSelect & {
|
|
17
|
+
options: SelectOption[];
|
|
18
|
+
};
|
|
19
|
+
type ChannelSelect = Omit<SelectMenu, "type" | "options">;
|
|
20
|
+
/**
|
|
21
|
+
* Helper to create a select component.
|
|
22
|
+
*/
|
|
23
|
+
export declare const select: (select: StringSelect) => SelectMenu;
|
|
24
|
+
/**
|
|
25
|
+
* Helper to create a select component.
|
|
26
|
+
*/
|
|
27
|
+
export declare const userSelect: (select: BasicSelect) => SelectMenu;
|
|
28
|
+
/**
|
|
29
|
+
* Helper to create a select component.
|
|
30
|
+
*/
|
|
31
|
+
export declare const roleSelect: (select: BasicSelect) => SelectMenu;
|
|
32
|
+
/**
|
|
33
|
+
* Helper to create a select component.
|
|
34
|
+
*/
|
|
35
|
+
export declare const mentionableSelect: (select: BasicSelect) => SelectMenu;
|
|
36
|
+
/**
|
|
37
|
+
* Helper to create a select component.
|
|
38
|
+
*/
|
|
39
|
+
export declare const channelSelect: (select: ChannelSelect) => SelectMenu;
|
|
40
|
+
type TextInputOpts = Omit<TextInput, "type" | "style"> & {
|
|
41
|
+
style?: TextInputStyle;
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* Helper to create a text input
|
|
45
|
+
*/
|
|
46
|
+
export declare const textInput: (input: TextInputOpts) => TextInput;
|
|
47
|
+
export {};
|
package/Helpers/ui.js
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { ButtonStyle, ComponentType, TextInputStyle, } from "../types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Helper to create an Action Row grid.
|
|
4
|
+
*/
|
|
5
|
+
export const grid = (items) => items.map((components) => ({
|
|
6
|
+
type: ComponentType.ACTION_ROW,
|
|
7
|
+
components,
|
|
8
|
+
}));
|
|
9
|
+
/**
|
|
10
|
+
* Helper to create a single column of components
|
|
11
|
+
*/
|
|
12
|
+
export const singleColumn = (items) => items.map((c) => ({
|
|
13
|
+
type: ComponentType.ACTION_ROW,
|
|
14
|
+
components: [c],
|
|
15
|
+
}));
|
|
16
|
+
/**
|
|
17
|
+
* Helper to create a button component.
|
|
18
|
+
*/
|
|
19
|
+
export const button = (button) => ({
|
|
20
|
+
type: ComponentType.BUTTON,
|
|
21
|
+
style: ButtonStyle.PRIMARY,
|
|
22
|
+
...button,
|
|
23
|
+
});
|
|
24
|
+
/**
|
|
25
|
+
* Helper to create a select component.
|
|
26
|
+
*/
|
|
27
|
+
export const select = (select) => ({
|
|
28
|
+
type: ComponentType.STRING_SELECT,
|
|
29
|
+
...select,
|
|
30
|
+
});
|
|
31
|
+
/**
|
|
32
|
+
* Helper to create a select component.
|
|
33
|
+
*/
|
|
34
|
+
export const userSelect = (select) => ({
|
|
35
|
+
type: ComponentType.USER_SELECT,
|
|
36
|
+
...select,
|
|
37
|
+
});
|
|
38
|
+
/**
|
|
39
|
+
* Helper to create a select component.
|
|
40
|
+
*/
|
|
41
|
+
export const roleSelect = (select) => ({
|
|
42
|
+
type: ComponentType.ROLE_SELECT,
|
|
43
|
+
...select,
|
|
44
|
+
});
|
|
45
|
+
/**
|
|
46
|
+
* Helper to create a select component.
|
|
47
|
+
*/
|
|
48
|
+
export const mentionableSelect = (select) => ({
|
|
49
|
+
type: ComponentType.MENTIONABLE_SELECT,
|
|
50
|
+
...select,
|
|
51
|
+
});
|
|
52
|
+
/**
|
|
53
|
+
* Helper to create a select component.
|
|
54
|
+
*/
|
|
55
|
+
export const channelSelect = (select) => ({
|
|
56
|
+
type: ComponentType.CHANNEL_SELECT,
|
|
57
|
+
...select,
|
|
58
|
+
});
|
|
59
|
+
/**
|
|
60
|
+
* Helper to create a text input
|
|
61
|
+
*/
|
|
62
|
+
export const textInput = (input) => ({
|
|
63
|
+
type: ComponentType.TEXT_INPUT,
|
|
64
|
+
style: TextInputStyle.SHORT,
|
|
65
|
+
...input,
|
|
66
|
+
});
|
|
67
|
+
//# sourceMappingURL=ui.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ui.js","sourceRoot":"","sources":["../../src/Helpers/ui.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,WAAW,EAEX,aAAa,EAIb,cAAc,GACf,MAAM,aAAa,CAAA;AAIpB;;GAEG;AACH,MAAM,CAAC,MAAM,IAAI,GAAG,CAAC,KAAsB,EAAe,EAAE,CAC1D,KAAK,CAAC,GAAG,CACP,CAAC,UAAU,EAAa,EAAE,CAAC,CAAC;IAC1B,IAAI,EAAE,aAAa,CAAC,UAAU;IAC9B,UAAU;CACX,CAAC,CACH,CAAA;AAEH;;GAEG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,KAAoB,EAAe,EAAE,CAChE,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IAChB,IAAI,EAAE,aAAa,CAAC,UAAU;IAC9B,UAAU,EAAE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
package/Http/index.d.ts
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export declare class FetchError {
|
|
2
|
+
readonly reason: unknown;
|
|
3
|
+
readonly _tag = "FetchError";
|
|
4
|
+
constructor(reason: unknown);
|
|
5
|
+
}
|
|
6
|
+
export declare class StatusCodeError {
|
|
7
|
+
readonly response: Response;
|
|
8
|
+
readonly _tag = "StatusCodeError";
|
|
9
|
+
readonly code: number;
|
|
10
|
+
constructor(response: Response);
|
|
11
|
+
}
|
|
12
|
+
export declare const request: (url: URL | string, init?: RequestInit) => import("../common.js").Effect<never, FetchError | StatusCodeError, Response>;
|
|
13
|
+
export declare class JsonParseError {
|
|
14
|
+
readonly reason: unknown;
|
|
15
|
+
readonly _tag = "JsonParseError";
|
|
16
|
+
constructor(reason: unknown);
|
|
17
|
+
}
|
|
18
|
+
export declare const json: <A = unknown>(r: Response) => import("../common.js").Effect<never, JsonParseError, A>;
|
|
19
|
+
export declare class BlobError {
|
|
20
|
+
readonly reason: unknown;
|
|
21
|
+
readonly _tag = "BlobError";
|
|
22
|
+
constructor(reason: unknown);
|
|
23
|
+
}
|
|
24
|
+
export declare const blob: (r: Response) => import("../common.js").Effect<never, BlobError, Blob>;
|
|
25
|
+
export declare const requestWithJson: <A = unknown>(url: URL | string, init?: RequestInit) => import("../common.js").Effect<never, FetchError | StatusCodeError, {
|
|
26
|
+
response: Response;
|
|
27
|
+
json: import("../common.js").Effect<never, JsonParseError, A>;
|
|
28
|
+
blob: import("../common.js").Effect<never, BlobError, Blob>;
|
|
29
|
+
text: import("../common.js").Effect<never, never, string>;
|
|
30
|
+
}>;
|
package/Http/index.js
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import * as tsplus_module_1 from "@effect/io/Effect";
|
|
2
|
+
import * as tsplus_module_2 from "@fp-ts/data/Either";
|
|
3
|
+
export class FetchError {
|
|
4
|
+
reason;
|
|
5
|
+
_tag = "FetchError";
|
|
6
|
+
constructor(reason) {
|
|
7
|
+
this.reason = reason;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
export class StatusCodeError {
|
|
11
|
+
response;
|
|
12
|
+
_tag = "StatusCodeError";
|
|
13
|
+
code;
|
|
14
|
+
constructor(response) {
|
|
15
|
+
this.response = response;
|
|
16
|
+
this.code = response.status;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
export const request = (url, init = {}) => tsplus_module_1.filterOrElseWith((r) => r.status < 300, (r) => tsplus_module_1.fail(new StatusCodeError(r)))(tsplus_module_1.asyncInterrupt((resume) => {
|
|
20
|
+
const controller = new AbortController();
|
|
21
|
+
fetch(url, {
|
|
22
|
+
...init,
|
|
23
|
+
signal: controller.signal,
|
|
24
|
+
})
|
|
25
|
+
.then((a) => resume(tsplus_module_1.succeed(a)))
|
|
26
|
+
.catch((e) => resume(tsplus_module_1.fail(new FetchError(e))));
|
|
27
|
+
return tsplus_module_2.left(tsplus_module_1.sync(() => {
|
|
28
|
+
controller.abort();
|
|
29
|
+
}));
|
|
30
|
+
}));
|
|
31
|
+
export class JsonParseError {
|
|
32
|
+
reason;
|
|
33
|
+
_tag = "JsonParseError";
|
|
34
|
+
constructor(reason) {
|
|
35
|
+
this.reason = reason;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
export const json = (r) => tsplus_module_1.tryCatchPromise(() => r.json(), (reason) => new JsonParseError(reason));
|
|
39
|
+
export class BlobError {
|
|
40
|
+
reason;
|
|
41
|
+
_tag = "BlobError";
|
|
42
|
+
constructor(reason) {
|
|
43
|
+
this.reason = reason;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
export const blob = (r) => tsplus_module_1.tryCatchPromise(() => r.blob(), (reason) => new BlobError(reason));
|
|
47
|
+
export const requestWithJson = (url, init = {}) => tsplus_module_1.map((response) => ({
|
|
48
|
+
response,
|
|
49
|
+
json: json(response),
|
|
50
|
+
blob: blob(response),
|
|
51
|
+
text: tsplus_module_1.promise(() => response.text()),
|
|
52
|
+
}))(request(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AA;AAEH,MAAM,OAAO,cAAc;IAEJ;IADZ,IAAI,GAAG,gBAAgB,CAAA;IAChC,YAAqB,MAAe;QAAf,WAAM,GAAN,MAAM,CAAS;IAAG,CAAC;CACzC;AAED,MAAM,CAAC,MAAM,IAAI,GAAG,CAAc,CAAW,EAAE,EAAE,CAC/C,gCACE,GAAe,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,EAC1B,CAAC,MAAM,EAAE,EAAE,CAAC,IAAI,cAAc,CAAC,MAAM,CAAC,CACvC,CAAA;AAEH,MAAM,OAAO,SAAS;IAEC;IADZ,IAAI,GAAG,WAAW,CAAA;IAC3B,YAAqB,MAAe;QAAf,WAAM,GAAN,MAAM,CAAS;IAAG,CAAC;CACzC;AAED,MAAM,CAAC,MAAM,IAAI,GAAG,CAAC,CAAW,EAAE,EAAE,CAClC,gCACE,GAAG,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,EACd,CAAC,MAAM,EAAE,EAAE,CAAC,IAAI,SAAS,CAAC,MAAM,CAAC,CAClC,CAAA;AAEH,MAAM,CAAC,MAAM,eAAe,GAAG,CAC7B,GAAiB,EACjB,OAAoB,EAAE,EACtB,EAAE,CACF,oBAAuB,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;IACpC,QAAQ;IACR,IAAI,EAAE,IAAI,CAAI,QAAQ,CAAC;IACvB,IAAI,EAAE,IAAI,CAAC,QAAQ,CAAC;IACpB,IAAI,EAAE,wBAAe,GAAG,EAAE,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC;CAC5C,CAAC,EALF,OAAO,CAAC,GAAG,EAAE,IAAI,CAAC,CAKf,CAAA"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { Discord, Effect, Maybe } from "dfx/common";
|
|
2
|
+
import { InteractionResponse } from "./definitions.js";
|
|
3
|
+
export declare const InteractionContext: import("../common.js").Tag<import("../types.js").Interaction>;
|
|
4
|
+
export declare const ApplicationCommandContext: import("../common.js").Tag<import("../types.js").ApplicationCommandDatum>;
|
|
5
|
+
export declare const MessageComponentContext: import("../common.js").Tag<import("../types.js").MessageComponentDatum>;
|
|
6
|
+
export declare const ModalSubmitContext: import("../common.js").Tag<import("../types.js").ModalSubmitDatum>;
|
|
7
|
+
export interface FocusedOptionContext {
|
|
8
|
+
readonly focusedOption: Discord.ApplicationCommandInteractionDataOption;
|
|
9
|
+
}
|
|
10
|
+
export declare const FocusedOptionContext: import("../common.js").Tag<FocusedOptionContext>;
|
|
11
|
+
export interface SubCommandContext {
|
|
12
|
+
readonly command: Discord.ApplicationCommandInteractionDataOption;
|
|
13
|
+
}
|
|
14
|
+
export declare const SubCommandContext: import("../common.js").Tag<SubCommandContext>;
|
|
15
|
+
export declare const getCommand: import("../common.js").Effect<import("../types.js").ApplicationCommandDatum, never, import("../types.js").ApplicationCommandDatum>;
|
|
16
|
+
export declare class ResolvedDataNotFound {
|
|
17
|
+
readonly data: Discord.ApplicationCommandDatum;
|
|
18
|
+
readonly name: string;
|
|
19
|
+
readonly _tag = "ResolvedDataNotFound";
|
|
20
|
+
constructor(data: Discord.ApplicationCommandDatum, name: string);
|
|
21
|
+
}
|
|
22
|
+
export declare const getResolved: <A>(name: string, f: (id: Discord.Snowflake, data: Discord.ResolvedDatum) => A | undefined) => import("../common.js").Effect<import("../types.js").ApplicationCommandDatum, ResolvedDataNotFound, A>;
|
|
23
|
+
export declare const focusedOptionValue: import("../common.js").Effect<FocusedOptionContext, never, string>;
|
|
24
|
+
export declare const commandOptionsMap: import("../common.js").Effect<import("../types.js").ApplicationCommandDatum, never, Record<string, string | undefined>>;
|
|
25
|
+
export declare const handleSubCommands: <NER extends Record<string, import("../common.js").Effect<any, any, import("../common.js").Maybe<InteractionResponse>>>>(commands: NER) => import("../common.js").Effect<import("../types.js").Interaction | import("../types.js").ApplicationCommandDatum | Exclude<[NER[keyof NER]] extends [{
|
|
26
|
+
[EffectTypeId]: {
|
|
27
|
+
_R: (_: never) => infer R;
|
|
28
|
+
};
|
|
29
|
+
}] ? R : never, SubCommandContext>, [NER[keyof NER]] extends [{
|
|
30
|
+
[EffectTypeId]: {
|
|
31
|
+
_E: (_: never) => infer E;
|
|
32
|
+
};
|
|
33
|
+
}] ? E : never, import("../common.js").Maybe<InteractionResponse>>;
|
|
34
|
+
export declare const getSubCommand: import("../common.js").Effect<SubCommandContext, never, import("../types.js").ApplicationCommandInteractionDataOption>;
|
|
35
|
+
export declare const subCommandOptionsMap: import("../common.js").Effect<SubCommandContext, never, Record<string, string | undefined>>;
|
|
36
|
+
export declare const modalValues: import("../common.js").Effect<import("../types.js").ModalSubmitDatum, never, Record<string, string | undefined>>;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import * as tsplus_module_1 from "dfx/common";
|
|
2
|
+
import * as tsplus_module_2 from "@effect/io/Effect";
|
|
3
|
+
import * as tsplus_module_3 from "@fp-ts/data/Option";
|
|
4
|
+
import * as tsplus_module_4 from "@fp-ts/data/Function";
|
|
5
|
+
import { InteractionNotFound } from "./handlers.js";
|
|
6
|
+
import * as Arr from "@fp-ts/data/ReadonlyArray";
|
|
7
|
+
import { optionsMap } from "dfx/Helpers/interactions";
|
|
8
|
+
export const InteractionContext = tsplus_module_1.Tag();
|
|
9
|
+
export const ApplicationCommandContext = tsplus_module_1.Tag();
|
|
10
|
+
export const MessageComponentContext = tsplus_module_1.Tag();
|
|
11
|
+
export const ModalSubmitContext = tsplus_module_1.Tag();
|
|
12
|
+
export const FocusedOptionContext = tsplus_module_1.Tag();
|
|
13
|
+
export const SubCommandContext = tsplus_module_1.Tag();
|
|
14
|
+
export const getCommand = tsplus_module_2.service(ApplicationCommandContext);
|
|
15
|
+
export class ResolvedDataNotFound {
|
|
16
|
+
data;
|
|
17
|
+
name;
|
|
18
|
+
_tag = "ResolvedDataNotFound";
|
|
19
|
+
constructor(data, name) {
|
|
20
|
+
this.data = data;
|
|
21
|
+
this.name = name;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
export const getResolved = (name, f) => tsplus_module_2.serviceWithEffect(ApplicationCommandContext)((a) => tsplus_module_3.match(() => tsplus_module_2.fail(new ResolvedDataNotFound(a, name)), tsplus_module_2.succeed)(tsplus_module_1.IxHelpers.resolveOptionValue(name, f)(a)));
|
|
25
|
+
export const focusedOptionValue = tsplus_module_2.serviceWith(FocusedOptionContext)((a) => a.focusedOption.value ?? "");
|
|
26
|
+
export const commandOptionsMap = tsplus_module_2.serviceWith(ApplicationCommandContext)(optionsMap);
|
|
27
|
+
export const handleSubCommands = (commands) => tsplus_module_2.flatMap(({ interaction, data }) => tsplus_module_4.pipe(tsplus_module_1.IxHelpers.allSubCommands(data), Arr.findFirst((a) => !!commands[a.name]), (o) => tsplus_module_3.toEither(() => new InteractionNotFound(interaction))(o), tsplus_module_2.fromEither, (a) => tsplus_module_2.flatMap((command) => tsplus_module_4.pipe(commands[command.name], tsplus_module_2.provideService(SubCommandContext)({ command })))(a)))(tsplus_module_2.struct({
|
|
28
|
+
interaction: tsplus_module_2.service(InteractionContext),
|
|
29
|
+
data: tsplus_module_2.service(ApplicationCommandContext),
|
|
30
|
+
}));
|
|
31
|
+
export const getSubCommand = tsplus_module_2.serviceWith(SubCommandContext)((a) => a.command);
|
|
32
|
+
export const subCommandOptionsMap = tsplus_module_2.map(tsplus_module_1.IxHelpers.optionsMap)(getSubCommand);
|
|
33
|
+
export const modalValues = tsplus_module_2.serviceWith(ModalSubmitContext)(tsplus_module_1.IxHelpers.componentsMap);
|
|
34
|
+
//# sourceMappingURL=context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../src/Interactions/context.ts"],"names":[],"mappings":";;;;AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAA;AACnD,OAAO,KAAK,GAAG,MAAM,2BAA2B,CAAA;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAA;AAErD,MAAM,CAAC,MAAM,kBAAkB,GAAG,gBAAA,GAA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,EAAE,WAAW,EAAE,IAAI,EAAE,EAAE,EAAE,CACnC,gBAAA,IAAI,CACF,gBAAA,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,EAC9B,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,EACxC,CAAC,CAAC,EAAE,EAAE,CAAC,yBAAW,GAAG,EAAE,CAAC,IAAI,mBAAmB,CAAC,WAAW,CAAC,EAArD,CAAC,CAAqD,8BAE7D,CAAC,CAAC,EAAE,EAAE,CACJ,wBAAU,CAAC,OAAO,EAAE,EAAE,CACpB,gBAAA,IAAI,CACF,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,EACtB,+BAAsB,iBAAiB,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,CACtD,EAJH,CAAC,CAKA,CACJ,EAhBH,uBAAc;IACZ,WAAW,EAAE,wBAAe,kBAAkB,CAAC;IAC/C,IAAI,EAAE,wBAAe,yBAAyB,CAAC;CAChD,CAAC,CAcD,CAAA;AAEH,MAAM,CAAC,MAAM,aAAa,GAAG,4BAAmB,iBAAiB,CAAC,CAChE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CACjB,CAAA;AAED,MAAM,CAAC,MAAM,oBAAoB,GAAG,oBAAkB,gBAAA,SAAS,CAAC,UAAU,EAAtC,aAAa,CAA0B,CAAA;AAE3E,MAAM,CAAC,MAAM,WAAW,GAAG,4BAAmB,kBAAkB,CAAC,CAC/D,gBAAA,SAAS,CAAC,aAAa,CACxB,CAAA"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { Discord, Effect, Maybe } from "dfx/common";
|
|
2
|
+
export type InteractionResponse = {
|
|
3
|
+
type: Discord.InteractionCallbackType.CHANNEL_MESSAGE_WITH_SOURCE;
|
|
4
|
+
data: Discord.InteractionCallbackMessage;
|
|
5
|
+
} | {
|
|
6
|
+
type: Discord.InteractionCallbackType.UPDATE_MESSAGE;
|
|
7
|
+
data: Discord.InteractionCallbackMessage;
|
|
8
|
+
} | {
|
|
9
|
+
type: Discord.InteractionCallbackType.MODAL;
|
|
10
|
+
data: Discord.InteractionCallbackModal;
|
|
11
|
+
} | {
|
|
12
|
+
type: Discord.InteractionCallbackType.DEFERRED_UPDATE_MESSAGE;
|
|
13
|
+
} | {
|
|
14
|
+
type: Discord.InteractionCallbackType.DEFERRED_CHANNEL_MESSAGE_WITH_SOURCE;
|
|
15
|
+
} | {
|
|
16
|
+
type: Discord.InteractionCallbackType.APPLICATION_COMMAND_AUTOCOMPLETE_RESULT;
|
|
17
|
+
data: Discord.InteractionCallbackAutocomplete;
|
|
18
|
+
};
|
|
19
|
+
type DescriptionMissing<A> = A extends {
|
|
20
|
+
type: Exclude<Discord.ApplicationCommandType, 1>;
|
|
21
|
+
} ? false : A extends {
|
|
22
|
+
description: string;
|
|
23
|
+
} ? false : true;
|
|
24
|
+
export type InteractionDefinition<R, E> = GlobalApplicationCommand<R, E> | GuildApplicationCommand<R, E> | MessageComponent<R, E> | ModalSubmit<R, E> | Autocomplete<R, E>;
|
|
25
|
+
export declare class GlobalApplicationCommand<R, E> {
|
|
26
|
+
readonly command: Discord.CreateGlobalApplicationCommandParams;
|
|
27
|
+
readonly handle: Effect<R, E, Maybe<InteractionResponse>>;
|
|
28
|
+
readonly _tag = "GlobalApplicationCommand";
|
|
29
|
+
constructor(command: Discord.CreateGlobalApplicationCommandParams, handle: Effect<R, E, Maybe<InteractionResponse>>);
|
|
30
|
+
}
|
|
31
|
+
export declare const global: <R, E, A extends import("../types.js").CreateGlobalApplicationCommandParams>(command: A, handle: DescriptionMissing<A> extends true ? "command description is missing" : import("../common.js").Effect<R, E, import("../common.js").Maybe<InteractionResponse>>) => GlobalApplicationCommand<Exclude<R, import("../types.js").Interaction | import("../types.js").ApplicationCommandDatum>, E>;
|
|
32
|
+
export declare class GuildApplicationCommand<R, E> {
|
|
33
|
+
readonly command: Discord.CreateGuildApplicationCommandParams;
|
|
34
|
+
readonly handle: Effect<R, E, Maybe<InteractionResponse>>;
|
|
35
|
+
readonly _tag = "GuildApplicationCommand";
|
|
36
|
+
constructor(command: Discord.CreateGuildApplicationCommandParams, handle: Effect<R, E, Maybe<InteractionResponse>>);
|
|
37
|
+
}
|
|
38
|
+
export declare const guild: <R, E, A extends import("../types.js").CreateGuildApplicationCommandParams>(command: A, handle: DescriptionMissing<A> extends true ? "command description is missing" : import("../common.js").Effect<R, E, import("../common.js").Maybe<InteractionResponse>>) => GuildApplicationCommand<Exclude<R, import("../types.js").Interaction | import("../types.js").ApplicationCommandDatum>, E>;
|
|
39
|
+
export declare class MessageComponent<R, E> {
|
|
40
|
+
readonly predicate: (customId: string) => Effect<R, E, boolean>;
|
|
41
|
+
readonly handle: Effect<R, E, Maybe<InteractionResponse>>;
|
|
42
|
+
readonly _tag = "MessageComponent";
|
|
43
|
+
constructor(predicate: (customId: string) => Effect<R, E, boolean>, handle: Effect<R, E, Maybe<InteractionResponse>>);
|
|
44
|
+
}
|
|
45
|
+
export declare const messageComponent: <R1, R2, E1, E2>(pred: (customId: string) => import("../common.js").Effect<R1, E1, boolean>, handle: import("../common.js").Effect<R2, E2, import("../common.js").Maybe<InteractionResponse>>) => MessageComponent<Exclude<R1, import("../types.js").Interaction | import("../types.js").MessageComponentDatum> | Exclude<R2, import("../types.js").Interaction | import("../types.js").MessageComponentDatum>, E1 | E2>;
|
|
46
|
+
export declare class ModalSubmit<R, E> {
|
|
47
|
+
readonly predicate: (customId: string) => Effect<R, E, boolean>;
|
|
48
|
+
readonly handle: Effect<R, E, Maybe<InteractionResponse>>;
|
|
49
|
+
readonly _tag = "ModalSubmit";
|
|
50
|
+
constructor(predicate: (customId: string) => Effect<R, E, boolean>, handle: Effect<R, E, Maybe<InteractionResponse>>);
|
|
51
|
+
}
|
|
52
|
+
export declare const modalSubmit: <R1, R2, E1, E2>(pred: (customId: string) => import("../common.js").Effect<R1, E1, boolean>, handle: import("../common.js").Effect<R2, E2, import("../common.js").Maybe<InteractionResponse>>) => ModalSubmit<Exclude<R1, import("../types.js").Interaction | import("../types.js").ModalSubmitDatum> | Exclude<R2, import("../types.js").Interaction | import("../types.js").ModalSubmitDatum>, E1 | E2>;
|
|
53
|
+
export declare class Autocomplete<R, E> {
|
|
54
|
+
readonly predicate: (focusedOption: Discord.ApplicationCommandInteractionDataOption) => Effect<R, E, boolean>;
|
|
55
|
+
readonly handle: Effect<R, E, Maybe<InteractionResponse>>;
|
|
56
|
+
readonly _tag = "Autocomplete";
|
|
57
|
+
constructor(predicate: (focusedOption: Discord.ApplicationCommandInteractionDataOption) => Effect<R, E, boolean>, handle: Effect<R, E, Maybe<InteractionResponse>>);
|
|
58
|
+
}
|
|
59
|
+
export declare const autocomplete: <R1, R2, E1, E2>(pred: (focusedOption: Discord.ApplicationCommandInteractionDataOption) => import("../common.js").Effect<R1, E1, boolean>, handle: import("../common.js").Effect<R2, E2, import("../common.js").Maybe<InteractionResponse>>) => Autocomplete<Exclude<R1, import("../types.js").Interaction | import("../types.js").ApplicationCommandDatum | import("../types.js").ApplicationCommandInteractionDataOption> | Exclude<R2, import("../types.js").Interaction | import("../types.js").ApplicationCommandDatum | import("../types.js").ApplicationCommandInteractionDataOption>, E1 | E2>;
|
|
60
|
+
export {};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import * as tsplus_module_1 from "dfx/common";
|
|
2
|
+
export class GlobalApplicationCommand {
|
|
3
|
+
command;
|
|
4
|
+
handle;
|
|
5
|
+
_tag = "GlobalApplicationCommand";
|
|
6
|
+
constructor(command, handle) {
|
|
7
|
+
this.command = command;
|
|
8
|
+
this.handle = handle;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
export const global = (command, handle) => new GlobalApplicationCommand(command, handle);
|
|
12
|
+
export class GuildApplicationCommand {
|
|
13
|
+
command;
|
|
14
|
+
handle;
|
|
15
|
+
_tag = "GuildApplicationCommand";
|
|
16
|
+
constructor(command, handle) {
|
|
17
|
+
this.command = command;
|
|
18
|
+
this.handle = handle;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
export const guild = (command, handle) => new GuildApplicationCommand(command, handle);
|
|
22
|
+
export class MessageComponent {
|
|
23
|
+
predicate;
|
|
24
|
+
handle;
|
|
25
|
+
_tag = "MessageComponent";
|
|
26
|
+
constructor(predicate, handle) {
|
|
27
|
+
this.predicate = predicate;
|
|
28
|
+
this.handle = handle;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
export const messageComponent = (pred, handle) => new MessageComponent(pred, handle);
|
|
32
|
+
export class ModalSubmit {
|
|
33
|
+
predicate;
|
|
34
|
+
handle;
|
|
35
|
+
_tag = "ModalSubmit";
|
|
36
|
+
constructor(predicate, handle) {
|
|
37
|
+
this.predicate = predicate;
|
|
38
|
+
this.handle = handle;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
export const modalSubmit = (pred, handle) => new ModalSubmit(pred, handle);
|
|
42
|
+
export class Autocomplete {
|
|
43
|
+
predicate;
|
|
44
|
+
handle;
|
|
45
|
+
_tag = "Autocomplete";
|
|
46
|
+
constructor(predicate, handle) {
|
|
47
|
+
this.predicate = predicate;
|
|
48
|
+
this.handle = handle;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
export const autocomplete = (pred, handle) => new Autocomplete(pred, handle);
|
|
52
|
+
//# sourceMappingURL=definitions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/Interactions/definitions.ts"],"names":[],"mappings":";AAuCA,MAAM,OAAO,wBAAwB;IAGxB;IACA;IAHF,IAAI,GAAG,0BAA0B,CAAA;IAC1C,YACW,OAAqD,EACrD,MAAgD;QADhD,YAAO,GAAP,OAAO,CAA8C;QACrD,WAAM,GAAN,MAAM,CAA0C;IACxD,CAAC;CACL;AAED,MAAM,CAAC,MAAM,MAAM,GAAG,CAKpB,OAAU,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AC1B,IAE4B,EAC5B,MAAkD,EAClD,EAAE,CACF,IAAI,YAAY,CAQd,IAAW,EAAE,MAAa,CAAC,CAAA"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Http, Effect } from "dfx/common";
|
|
2
|
+
import { InteractionBuilder } from "./index.js";
|
|
3
|
+
export interface RunOpts {
|
|
4
|
+
sync?: boolean;
|
|
5
|
+
}
|
|
6
|
+
export declare const run: <R2, E, E2>(catchAll: (e: import("../Http/index.js").FetchError | import("../Http/index.js").StatusCodeError | import("../Http/index.js").JsonParseError | E) => import("../common.js").Effect<R2, E2, any>, { sync }?: RunOpts) => <R>(ix: InteractionBuilder<R, E>) => import("../common.js").Effect<import("../index.js").DiscordREST | import("../DiscordGateway/index.js").DiscordGateway | R2 | R, import("../Http/index.js").FetchError | import("../Http/index.js").StatusCodeError | import("../Http/index.js").JsonParseError | E2, void>;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import * as tsplus_module_1 from "@effect/io/Effect";
|
|
2
|
+
import * as tsplus_module_2 from "dfx/common";
|
|
3
|
+
import * as tsplus_module_3 from "@fp-ts/data/Option";
|
|
4
|
+
import * as tsplus_module_4 from "dfx/common-gateway";
|
|
5
|
+
import { handlers } from "./handlers.js";
|
|
6
|
+
import { splitDefinitions } from "./utils.js";
|
|
7
|
+
export const run = (catchAll, { sync = true } = {}) => (ix) => (() => {
|
|
8
|
+
const { GlobalApplicationCommand, GuildApplicationCommand } = splitDefinitions(ix.definitions);
|
|
9
|
+
return tsplus_module_1.flatMap(application => {
|
|
10
|
+
const globalSync = tsplus_module_2.Rest.rest.bulkOverwriteGlobalApplicationCommands(application.id, {
|
|
11
|
+
body: JSON.stringify(GlobalApplicationCommand.map((a) => a.command)),
|
|
12
|
+
});
|
|
13
|
+
const guildSync = GuildApplicationCommand.length
|
|
14
|
+
? tsplus_module_4.Gateway.handleDispatch("GUILD_CREATE", (a) => tsplus_module_2.Rest.rest.bulkOverwriteGuildApplicationCommands(application.id, a.id, GuildApplicationCommand.map((a) => a.command)))
|
|
15
|
+
: tsplus_module_1.unit();
|
|
16
|
+
const handle = handlers(ix.definitions);
|
|
17
|
+
const run = tsplus_module_4.Gateway.handleDispatch("INTERACTION_CREATE", (i) => tsplus_module_1.catchAll(catchAll)(tsplus_module_1.tap((r) => tsplus_module_3.match(tsplus_module_1.unit, (r) => tsplus_module_2.Rest.rest.createInteractionResponse(i.id, i.token, r))(r))(handle[i.type](i))));
|
|
18
|
+
return tsplus_module_1.map(() => void 0)(sync ? tsplus_module_1.zipPar(guildSync)(tsplus_module_1.zipPar(globalSync)(run)) : run);
|
|
19
|
+
})(tsplus_module_1.flatMap((a) => a.json)(tsplus_module_2.Rest.rest.getCurrentBotApplicationInformation()));
|
|
20
|
+
})();
|
|
21
|
+
//# sourceMappingURL=gateway.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gateway.js","sourceRoot":"","sources":["../../src/Interactions/gateway.ts"],"names":[],"mappings":";;;;AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAExC,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA;AAM7C,MAAM,CAAC,MAAM,GAAG,GACd,CACE,QAEwB,EACxB,EAAE,IAAI,GAAG,IAAI,KAAc,EAAE,EAC7B,EAAE,CACJ,CAAI,EAA4B,EAAE,EAAE;IAEhC,MAAM,EAAE,wBAAwB,EAAE,uBAAuB,EAAE,GACzD,gBAAgB,CAAC,EAAE,CAAC,WAAW,CAAC,CAAA;mCAE5B,WAAW;QAIjB,MAAM,UAAU,GAAG,gBAAA,IAAI,CAAC,IAAI,CAAC,sCAAsC,CACjE,WAAW,CAAC,EAAE,EACd;YACE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,wBAAwB,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;SACrE,CACF,CAAA;QAED,MAAM,SAAS,GAAG,uBAAuB,CAAC,MAAM;YAC9C,CAAC,CAAC,gBAAA,OAAO,CAAC,cAAc,CAAC,cAAc,EAAE,CAAC,CAAC,EAAE,EAAE,CAC3C,gBAAA,IAAI,CAAC,IAAI,CAAC,qCAAqC,CAC7C,WAAW,CAAC,EAAE,EACd,CAAC,CAAC,EAAE,EACJ,uBAAuB,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAQ,CACrD,CACF;YACH,CAAC,CAAC,sBAAa,CAAA;QAEjB,MAAM,MAAM,GAAG,QAAQ,CAAC,EAAE,CAAC,WAAW,CAAC,CAAA;QAEvC,MAAM,GAAG,GAAG,gBAAA,OAAO,CAAC,cAAc,CAAC,oBAAoB,EAAE,CAAC,CAAC,EAAE,EAAE,CAC7D,yBAMY,QAAQ,EANpB,oBACO,CAAC,CAAC,EAAE,EAAE,CACT,4CAAqB,CAAC,CAAC,EAAE,EAAE,CACzB,gBAAA,IAAI,CAAC,IAAI,CAAC,yBAAyB,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,EADvD,CAAC,CAEA,EAJL,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAKd,CACkB,CACtB,CAAA;iDAEC,IAAI,CAAC,CAAC,CAAC,uBAA8B,SAAS,EAAvC,uBAAW,UAAU,EAArB,GAAG,CAAmB,CAAkB,CAAC,CAAC,CAAC,GAAG;OAhCrD,wBAAwD,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAArE,gBAAA,IAAI,CAAC,IAAI,CAAC,mCAAmC,EAAE,CAAuB;IAiCxE,CAAA"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Discord, Effect, Maybe } from "dfx/common";
|
|
2
|
+
import * as D from "./definitions.js";
|
|
3
|
+
export declare class InteractionNotFound {
|
|
4
|
+
readonly interaction: Discord.Interaction;
|
|
5
|
+
readonly _tag = "InteractionNotFound";
|
|
6
|
+
constructor(interaction: Discord.Interaction);
|
|
7
|
+
}
|
|
8
|
+
export declare const handlers: <R, E>(definitions: D.InteractionDefinition<R, E>[]) => Record<import("../types.js").InteractionType, (i: Discord.Interaction) => import("../common.js").Effect<R, E, import("../common.js").Maybe<import("../types.js").InteractionResponse>>>;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import * as tsplus_module_1 from "dfx/common";
|
|
2
|
+
import * as tsplus_module_2 from "@effect/io/Effect";
|
|
3
|
+
import * as tsplus_module_3 from "@fp-ts/data/Option";
|
|
4
|
+
import * as tsplus_module_4 from "@fp-ts/data/Function";
|
|
5
|
+
import * as tsplus_module_5 from "@fp-ts/data/Chunk";
|
|
6
|
+
import * as Ctx from "./context.js";
|
|
7
|
+
import * as Arr from "@fp-ts/data/ReadonlyArray";
|
|
8
|
+
import { splitDefinitions } from "./utils.js";
|
|
9
|
+
export class InteractionNotFound {
|
|
10
|
+
interaction;
|
|
11
|
+
_tag = "InteractionNotFound";
|
|
12
|
+
constructor(interaction) {
|
|
13
|
+
this.interaction = interaction;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
export const handlers = (definitions) => {
|
|
17
|
+
const { Commands, Autocomplete, MessageComponent, ModalSubmit } = splitDefinitions(definitions);
|
|
18
|
+
return {
|
|
19
|
+
[tsplus_module_1.Discord.InteractionType.PING]: () => tsplus_module_2.asSome(tsplus_module_2.succeed({
|
|
20
|
+
type: tsplus_module_1.Discord.InteractionCallbackType.PONG,
|
|
21
|
+
})),
|
|
22
|
+
[tsplus_module_1.Discord.InteractionType.APPLICATION_COMMAND]: (i) => {
|
|
23
|
+
const data = i.data;
|
|
24
|
+
return tsplus_module_4.pipe(tsplus_module_3.match(() => tsplus_module_2.fail(new InteractionNotFound(i)), (command) => command.handle)(tsplus_module_3.fromNullable(Commands[data.name])), tsplus_module_2.provideService(Ctx.InteractionContext)(i), tsplus_module_2.provideService(Ctx.ApplicationCommandContext)(data));
|
|
25
|
+
},
|
|
26
|
+
[tsplus_module_1.Discord.InteractionType.MODAL_SUBMIT]: (i) => {
|
|
27
|
+
const data = i.data;
|
|
28
|
+
return tsplus_module_4.pipe(ModalSubmit, Arr.map((a) => tsplus_module_2.struct({
|
|
29
|
+
command: tsplus_module_2.succeed(a),
|
|
30
|
+
match: a.predicate(data.custom_id),
|
|
31
|
+
})), (a) => tsplus_module_2.flatMap((a) => tsplus_module_3.match(() => tsplus_module_2.fail(new InteractionNotFound(i)), (a) => a.command.handle)(tsplus_module_5.findFirst((a) => a.match)(a)))(tsplus_module_2.collectAllPar(a)), tsplus_module_2.provideService(Ctx.InteractionContext)(i), tsplus_module_2.provideService(Ctx.ModalSubmitContext)(data));
|
|
32
|
+
},
|
|
33
|
+
[tsplus_module_1.Discord.InteractionType.MESSAGE_COMPONENT]: (i) => {
|
|
34
|
+
const data = i.data;
|
|
35
|
+
return tsplus_module_4.pipe(MessageComponent, Arr.map((a) => tsplus_module_2.struct({
|
|
36
|
+
command: tsplus_module_2.succeed(a),
|
|
37
|
+
match: a.predicate(data.custom_id),
|
|
38
|
+
})), (a) => tsplus_module_2.flatMap((a) => tsplus_module_3.match(() => tsplus_module_2.fail(new InteractionNotFound(i)), (a) => a.command.handle)(tsplus_module_5.findFirst((a) => a.match)(a)))(tsplus_module_2.collectAllPar(a)), tsplus_module_2.provideService(Ctx.InteractionContext)(i), tsplus_module_2.provideService(Ctx.MessageComponentContext)(data));
|
|
39
|
+
},
|
|
40
|
+
[tsplus_module_1.Discord.InteractionType.APPLICATION_COMMAND_AUTOCOMPLETE]: (i) => {
|
|
41
|
+
const data = i.data;
|
|
42
|
+
return tsplus_module_3.getOrElse(() => tsplus_module_2.fail(new InteractionNotFound(i)))(tsplus_module_3.map((focusedOption) => tsplus_module_4.pipe(Autocomplete, Arr.map((a) => tsplus_module_2.struct({
|
|
43
|
+
command: tsplus_module_2.succeed(a),
|
|
44
|
+
match: a.predicate(focusedOption),
|
|
45
|
+
})), (a) => tsplus_module_2.flatMap((a) => tsplus_module_3.match(() => tsplus_module_2.fail(new InteractionNotFound(i)), (a) => a.command.handle)(tsplus_module_5.findFirst((a) => a.match)(a)))(tsplus_module_2.collectAllPar(a)), tsplus_module_2.provideService(Ctx.InteractionContext)(i), tsplus_module_2.provideService(Ctx.ApplicationCommandContext)(data), tsplus_module_2.provideService(Ctx.FocusedOptionContext)({ focusedOption })))(tsplus_module_1.IxHelpers.focusedOption(data)));
|
|
46
|
+
},
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
//# sourceMappingURL=handlers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handlers.js","sourceRoot":"","sources":["../../src/Interactions/handlers.ts"],"names":[],"mappings":";;;;;AAAA,OAAO,KAAK,GAAG,MAAM,cAAc,CAAA;AAEnC,OAAO,KAAK,GAAG,MAAM,2BAA2B,CAAA;AAChD,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA;AAE7C,MAAM,OAAO,mBAAmB;IAET;IADZ,IAAI,GAAG,qBAAqB,CAAA;IACrC,YAAqB,WAAgC;QAAhC,gBAAW,GAAX,WAAW,CAAqB;IAAG,CAAC;CAC1D;AAED,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;IAE/B,OAAO;QACL,CAAC,gBAAA,OAAO,CAAC,eAAe,CAAC,IAAI,CAAC,EAAE,GAAG,EAAE,wBACnC,wBAAe;YACb,IAAI,EAAE,gBAAA,OAAO,CAAC,uBAAuB,CAAC,IAAI;SAC3C,CAAC,CAAO;QAEX,CAAC,gBAAA,OAAO,CAAC,eAAe,CAAC,mBAAmB,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE;YACnD,MAAM,IAAI,GAAG,CAAC,CAAC,IAAuC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;aAClC,CAAC,CACH,EACD,CAAC,CAAC,EAAE,EAAE,CACJ,wBAAwB,CAAC,CAAC,EAAE,EAAE,CAC5B,sBAGI,GAAG,EAAE,CACH,qBAAY,IAAI,mBAAmB,CAAC,CAAC,CAAC,CAIrC,EACH,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,EAT3B,0BACa,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,EAD3B,CAAC,CAC2B,CASzB,gCAXL,CAAC,EAYA,EACH,+BAAsB,GAAG,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC,EAChD,+BAAsB,GAAG,CAAC,yBAAyB,CAAC,CAAC,IAAI,CAAC,EAC1D,+BAAsB,GAAG,CAAC,oBAAoB,CAAC,CAAC,EAAE,aAAa,EAAE,CAAC,CACnE,EA3BE,gBAAA,SAAS,CAAC,aAAa,CAAC,IAAI,CAAC,CA4BjC,CAC+D,CAAA;QACpE,CAAC;KACF,CAAA;AACH,CAAC,CAAA"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Rest, Discord } from "dfx/common";
|
|
2
|
+
import * as D from "./definitions.js";
|
|
3
|
+
export * from "./context.js";
|
|
4
|
+
export { global, guild, messageComponent, modalSubmit, autocomplete, InteractionDefinition, InteractionResponse, } from "./definitions.js";
|
|
5
|
+
export { makeConfigLayer as makeWebhookConfig, makeHandler as makeWebhookHandler, MakeConfigOpts as MakeWebhookConfigOpts, WebhookConfig, WebhookParseError, BadWebhookSignature, } from "./webhook.js";
|
|
6
|
+
export declare class InteractionBuilder<R, E> {
|
|
7
|
+
readonly definitions: D.InteractionDefinition<R, E>[];
|
|
8
|
+
constructor(definitions: D.InteractionDefinition<R, E>[]);
|
|
9
|
+
add<R1, E1>(definition: D.InteractionDefinition<R1, E1>): InteractionBuilder<R | R1, E | E1>;
|
|
10
|
+
get syncGlobal(): import("../common.js").Effect<import("../index.js").DiscordREST, import("../Http/index.js").FetchError | import("../Http/index.js").StatusCodeError | import("../Http/index.js").JsonParseError, import("../DiscordREST/types.js").ResponseWithData<import("../types.js").ApplicationCommand[]>>;
|
|
11
|
+
syncGuild(appId: Discord.Snowflake, guildId: Discord.Snowflake): import("../DiscordREST/types.js").RestResponse<import("../types.js").ApplicationCommand[]>;
|
|
12
|
+
}
|
|
13
|
+
export declare const builder: InteractionBuilder<never, never>;
|
|
14
|
+
export declare const id: (query: string) => (customId: string) => import("../common.js").Effect<never, never, boolean>;
|
|
15
|
+
export declare const idStartsWith: (query: string) => (customId: string) => import("../common.js").Effect<never, never, boolean>;
|
|
16
|
+
export declare const regex: (query: RegExp) => (customId: string) => import("../common.js").Effect<never, never, boolean>;
|
|
17
|
+
export declare const option: (name: string) => (focusedOption: Discord.ApplicationCommandInteractionDataOption) => import("../common.js").Effect<never, never, boolean>;
|