dfx 0.45.4 → 0.45.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -2
- package/src/DiscordGateway/Sharder.ts +7 -6
- package/src/package.json +2 -2
- package/tsconfig.json +2 -15
- package/Cache/driver.d.ts +0 -22
- package/Cache/driver.js +0 -3
- package/Cache/driver.js.map +0 -1
- package/Cache/memory.d.ts +0 -3
- package/Cache/memory.js +0 -48
- package/Cache/memory.js.map +0 -1
- package/Cache/memoryTTL.d.ts +0 -20
- package/Cache/memoryTTL.js +0 -121
- package/Cache/memoryTTL.js.map +0 -1
- package/Cache/prelude.d.ts +0 -56
- package/Cache/prelude.js +0 -108
- package/Cache/prelude.js.map +0 -1
- package/Cache.d.ts +0 -75
- package/Cache.js +0 -62
- package/Cache.js.map +0 -1
- package/DiscordConfig.d.ts +0 -28
- package/DiscordConfig.js +0 -29
- package/DiscordConfig.js.map +0 -1
- package/DiscordGateway/DiscordWS.d.ts +0 -31
- package/DiscordGateway/DiscordWS.js +0 -31
- package/DiscordGateway/DiscordWS.js.map +0 -1
- package/DiscordGateway/Shard/heartbeats.d.ts +0 -3
- package/DiscordGateway/Shard/heartbeats.js +0 -17
- package/DiscordGateway/Shard/heartbeats.js.map +0 -1
- package/DiscordGateway/Shard/identify.d.ts +0 -12
- package/DiscordGateway/Shard/identify.js +0 -26
- package/DiscordGateway/Shard/identify.js.map +0 -1
- package/DiscordGateway/Shard/invalidSession.d.ts +0 -3
- package/DiscordGateway/Shard/invalidSession.js +0 -6
- package/DiscordGateway/Shard/invalidSession.js.map +0 -1
- package/DiscordGateway/Shard/sendEvents.d.ts +0 -7
- package/DiscordGateway/Shard/sendEvents.js +0 -25
- package/DiscordGateway/Shard/sendEvents.js.map +0 -1
- package/DiscordGateway/Shard/utils.d.ts +0 -3
- package/DiscordGateway/Shard/utils.js +0 -9
- package/DiscordGateway/Shard/utils.js.map +0 -1
- package/DiscordGateway/Shard.d.ts +0 -16
- package/DiscordGateway/Shard.js +0 -85
- package/DiscordGateway/Shard.js.map +0 -1
- package/DiscordGateway/ShardStore.d.ts +0 -12
- package/DiscordGateway/ShardStore.js +0 -22
- package/DiscordGateway/ShardStore.js.map +0 -1
- package/DiscordGateway/Sharder.d.ts +0 -15
- package/DiscordGateway/Sharder.js +0 -49
- package/DiscordGateway/Sharder.js.map +0 -1
- package/DiscordGateway/WS.d.ts +0 -31
- package/DiscordGateway/WS.js +0 -77
- package/DiscordGateway/WS.js.map +0 -1
- package/DiscordGateway.d.ts +0 -12
- package/DiscordGateway.js +0 -29
- package/DiscordGateway.js.map +0 -1
- package/DiscordREST/types.d.ts +0 -7
- package/DiscordREST/types.js +0 -2
- package/DiscordREST/types.js.map +0 -1
- package/DiscordREST/utils.d.ts +0 -10
- package/DiscordREST/utils.js +0 -21
- package/DiscordREST/utils.js.map +0 -1
- package/DiscordREST.d.ts +0 -16
- package/DiscordREST.js +0 -123
- package/DiscordREST.js.map +0 -1
- package/Helpers/flags.d.ts +0 -27
- package/Helpers/flags.js +0 -36
- package/Helpers/flags.js.map +0 -1
- package/Helpers/intents.d.ts +0 -24
- package/Helpers/intents.js +0 -29
- package/Helpers/intents.js.map +0 -1
- package/Helpers/interactions.d.ts +0 -96
- package/Helpers/interactions.js +0 -97
- package/Helpers/interactions.js.map +0 -1
- package/Helpers/members.d.ts +0 -9
- package/Helpers/members.js +0 -10
- package/Helpers/members.js.map +0 -1
- package/Helpers/permissions.d.ts +0 -40
- package/Helpers/permissions.js +0 -83
- package/Helpers/permissions.js.map +0 -1
- package/Helpers/ui.d.ts +0 -47
- package/Helpers/ui.js +0 -66
- package/Helpers/ui.js.map +0 -1
- package/Interactions/builder.d.ts +0 -48
- package/Interactions/builder.js +0 -68
- package/Interactions/builder.js.map +0 -1
- package/Interactions/context.d.ts +0 -58
- package/Interactions/context.js +0 -61
- package/Interactions/context.js.map +0 -1
- package/Interactions/definitions.d.ts +0 -126
- package/Interactions/definitions.js +0 -53
- package/Interactions/definitions.js.map +0 -1
- package/Interactions/gateway.d.ts +0 -20
- package/Interactions/gateway.js +0 -39
- package/Interactions/gateway.js.map +0 -1
- package/Interactions/handlers.d.ts +0 -10
- package/Interactions/handlers.js +0 -45
- package/Interactions/handlers.js.map +0 -1
- package/Interactions/index.d.ts +0 -10
- package/Interactions/index.js +0 -12
- package/Interactions/index.js.map +0 -1
- package/Interactions/utils.d.ts +0 -78
- package/Interactions/utils.js +0 -74
- package/Interactions/utils.js.map +0 -1
- package/Interactions/webhook.d.ts +0 -45
- package/Interactions/webhook.js +0 -56
- package/Interactions/webhook.js.map +0 -1
- package/Log.d.ts +0 -10
- package/Log.js +0 -17
- package/Log.js.map +0 -1
- package/RateLimit/memory.d.ts +0 -2
- package/RateLimit/memory.js +0 -35
- package/RateLimit/memory.js.map +0 -1
- package/RateLimit/utils.d.ts +0 -2
- package/RateLimit/utils.js +0 -18
- package/RateLimit/utils.js.map +0 -1
- package/RateLimit.d.ts +0 -25
- package/RateLimit.js +0 -25
- package/RateLimit.js.map +0 -1
- package/_common.d.ts +0 -36
- package/_common.js +0 -8
- package/_common.js.map +0 -1
- package/gateway.d.ts +0 -13
- package/gateway.js +0 -25
- package/gateway.js.map +0 -1
- package/global.d.ts +0 -17
- package/global.js +0 -2
- package/global.js.map +0 -1
- package/index.d.ts +0 -13
- package/index.js +0 -14
- package/index.js.map +0 -1
- package/types.d.ts +0 -4449
- package/types.js +0 -1204
- package/types.js.map +0 -1
- package/utils/effect.d.ts +0 -1
- package/utils/effect.js +0 -2
- package/utils/effect.js.map +0 -1
- package/utils/hub.d.ts +0 -11
- package/utils/hub.js +0 -23
- package/utils/hub.js.map +0 -1
- package/utils/tsplus.d.ts +0 -12
- package/utils/tsplus.js +0 -2
- package/utils/tsplus.js.map +0 -1
- package/webhooks.d.ts +0 -9
- package/webhooks.js +0 -22
- package/webhooks.js.map +0 -1
package/Helpers/interactions.js
DELETED
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
import * as tsplus_module_1 from "dfx/_common";
|
|
2
|
-
import * as tsplus_module_2 from "@effect/data/Function";
|
|
3
|
-
import * as tsplus_module_3 from "@effect/data/Option";
|
|
4
|
-
import * as tsplus_module_4 from "@effect/data/HashMap";
|
|
5
|
-
import { Product } from "@effect/data/Option";
|
|
6
|
-
import * as Arr from "@effect/data/ReadonlyArray";
|
|
7
|
-
/**
|
|
8
|
-
* Maybe find a sub-command within the interaction options.
|
|
9
|
-
*/
|
|
10
|
-
export const allSubCommands = (interaction) => tsplus_module_2.pipe(optionsWithNested(interaction), Arr.filter(o => o.type === 1 /* Discord.ApplicationCommandOptionType.SUB_COMMAND */));
|
|
11
|
-
/**
|
|
12
|
-
* Maybe find a sub-command within the interaction options.
|
|
13
|
-
*/
|
|
14
|
-
export const findSubCommand = (name) => (interaction) => tsplus_module_2.pipe(optionsWithNested(interaction), Arr.findFirst(o => o.type === 1 /* Discord.ApplicationCommandOptionType.SUB_COMMAND */ &&
|
|
15
|
-
o.name === name));
|
|
16
|
-
/**
|
|
17
|
-
* If the sub-command exists return `true`, else `false`.
|
|
18
|
-
*/
|
|
19
|
-
export const isSubCommand = (name) => tsplus_module_2.flow(findSubCommand(name), o => tsplus_module_3.isSome(o));
|
|
20
|
-
/**
|
|
21
|
-
* Maybe get the options for a sub-command
|
|
22
|
-
*/
|
|
23
|
-
export const subCommandOptions = (name) => tsplus_module_2.flow(findSubCommand(name), o => tsplus_module_3.flatMapNullable(o, o => o.options));
|
|
24
|
-
/**
|
|
25
|
-
* A lens for accessing nested options in a interaction.
|
|
26
|
-
*/
|
|
27
|
-
export const optionsWithNested = (data) => {
|
|
28
|
-
const optsFromOption = (opt) => tsplus_module_3.match(tsplus_module_3.map(tsplus_module_3.fromNullable(opt.options), opts => [...opts, ...opts.flatMap(optsFromOption)]), () => [], tsplus_module_2.identity);
|
|
29
|
-
return tsplus_module_3.getOrElse(tsplus_module_3.map(tsplus_module_3.fromNullable(data.options), opts => [...opts, ...opts.flatMap(optsFromOption)]), () => []);
|
|
30
|
-
};
|
|
31
|
-
/**
|
|
32
|
-
* Return the interaction options as a name / value map.
|
|
33
|
-
*/
|
|
34
|
-
export const transformOptions = (options) => options.reduce((map, option) => tsplus_module_4.set(map, option.name, option.value), tsplus_module_4.empty());
|
|
35
|
-
/**
|
|
36
|
-
* Return the interaction options as a name / value map.
|
|
37
|
-
*/
|
|
38
|
-
export const optionsMap = tsplus_module_2.flow(optionsWithNested, transformOptions);
|
|
39
|
-
/**
|
|
40
|
-
* Try find a matching option from the interaction.
|
|
41
|
-
*/
|
|
42
|
-
export const getOption = (name) => tsplus_module_2.flow(optionsWithNested, Arr.findFirst(o => o.name === name));
|
|
43
|
-
/**
|
|
44
|
-
* Try find a matching option from the interaction.
|
|
45
|
-
*/
|
|
46
|
-
export const focusedOption = tsplus_module_2.flow(optionsWithNested, Arr.findFirst(o => o.focused === true));
|
|
47
|
-
/**
|
|
48
|
-
* Try find a matching option value from the interaction.
|
|
49
|
-
*/
|
|
50
|
-
export const optionValue = (name) => tsplus_module_2.flow(getOption(name), o => tsplus_module_3.flatMapNullable(o, o => o.value));
|
|
51
|
-
/**
|
|
52
|
-
* Try extract resolved data
|
|
53
|
-
*/
|
|
54
|
-
export const resolved = (data) => tsplus_module_3.flatMapNullable(tsplus_module_3.fromNullable(data.data), a => a.resolved);
|
|
55
|
-
/**
|
|
56
|
-
* Try find a matching option value from the interaction.
|
|
57
|
-
*/
|
|
58
|
-
export const resolveOptionValue = (name, f) => (a) => tsplus_module_3.flatMap(tsplus_module_3.fromNullable(a.data), data => tsplus_module_3.flatMap(tsplus_module_3.flatMapNullable(getOption(name)(data), ({ value }) => value), id => tsplus_module_3.flatMap(resolved(a), r => tsplus_module_3.fromNullable(f(id, r)))));
|
|
59
|
-
/**
|
|
60
|
-
* Try find matching option values from the interaction.
|
|
61
|
-
*/
|
|
62
|
-
export const resolveValues = (f) => (a) => tsplus_module_3.flatMap(tsplus_module_3.flatMapNullable(tsplus_module_3.fromNullable(a.data), a => a.values), values => tsplus_module_3.flatMap(resolved(a), r => Product.productAll(values.map(a => tsplus_module_3.fromNullable(f(a, r))))));
|
|
63
|
-
const extractComponents = (c) => {
|
|
64
|
-
if ("components" in c) {
|
|
65
|
-
return [...c.components, ...c.components.flatMap(extractComponents)];
|
|
66
|
-
}
|
|
67
|
-
return [];
|
|
68
|
-
};
|
|
69
|
-
/**
|
|
70
|
-
* A lens for accessing the components in a interaction.
|
|
71
|
-
*/
|
|
72
|
-
export const components = (a) => [
|
|
73
|
-
...a.components,
|
|
74
|
-
...a.components.flatMap(extractComponents),
|
|
75
|
-
];
|
|
76
|
-
/**
|
|
77
|
-
* A lens for accessing the components in a interaction.
|
|
78
|
-
*/
|
|
79
|
-
export const componentsWithValue = tsplus_module_2.flow(components, Arr.filter(c => "value" in c && c.value !== undefined));
|
|
80
|
-
/**
|
|
81
|
-
* Return the interaction components as an id / value map.
|
|
82
|
-
*/
|
|
83
|
-
export const transformComponents = (options) => options.reduce((map, c) => (c.custom_id ? tsplus_module_4.set(map, c.custom_id, c.value) : map), tsplus_module_4.empty());
|
|
84
|
-
/**
|
|
85
|
-
* Return the interaction components as an id / value map.
|
|
86
|
-
*/
|
|
87
|
-
export const componentsMap = tsplus_module_2.flow(components, transformComponents);
|
|
88
|
-
/**
|
|
89
|
-
* Try find a matching component from the interaction.
|
|
90
|
-
*/
|
|
91
|
-
export const getComponent = (id) => tsplus_module_2.flow(components, Arr.findFirst(o => o.custom_id === id));
|
|
92
|
-
/**
|
|
93
|
-
* Try find a matching component value from the interaction.
|
|
94
|
-
*/
|
|
95
|
-
export const componentValue = (id) => tsplus_module_2.flow(getComponent(id), o => tsplus_module_3.flatMapNullable(o, o => o.value));
|
|
96
|
-
export const response = (r) => r;
|
|
97
|
-
//# sourceMappingURL=interactions.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"interactions.js","sourceRoot":"","sources":["../src/Helpers/interactions.ts"],"names":[],"mappings":";;;;AAA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,IAAI,CAAC,YAAY,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,CACzB,gCAAA,CAAC,EAAiB,CAAC,CAAC,EAAE,CAAE,CAAuB,CAAC,KAAK,CAAC,CACvD,CAAA;AA0BH,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,CAAsB,EAAE,EAAE,CAAC,CAAC,CAAA"}
|
package/Helpers/members.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { Discord } from "dfx/_common";
|
|
2
|
-
/**
|
|
3
|
-
* From a list of roles, filter out the ones the guild member has.
|
|
4
|
-
*/
|
|
5
|
-
export declare const roles: (roles: Discord.Role[]) => (member: Discord.GuildMember) => import("../types.js").Role[];
|
|
6
|
-
/**
|
|
7
|
-
* Type-guard function for checking if the object is a guild member
|
|
8
|
-
*/
|
|
9
|
-
export declare const is: (thing: unknown) => thing is import("../types.js").GuildMember;
|
package/Helpers/members.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* From a list of roles, filter out the ones the guild member has.
|
|
3
|
-
*/
|
|
4
|
-
export const roles = (roles) => (member) => roles.filter(role => member.roles.includes(role.id) || role.name === "@everyone");
|
|
5
|
-
/**
|
|
6
|
-
* Type-guard function for checking if the object is a guild member
|
|
7
|
-
*/
|
|
8
|
-
export const is = (thing) => Object.prototype.hasOwnProperty.call(thing, "roles") &&
|
|
9
|
-
Object.prototype.hasOwnProperty.call(thing, "joined_at");
|
|
10
|
-
//# sourceMappingURL=members.js.map
|
package/Helpers/members.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"members.js","sourceRoot":"","sources":["../src/Helpers/members.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,KAAqB,EAAE,EAAE,CAAC,CAAC,MAA2B,EAAE,EAAE,CAC9E,KAAK,CAAC,MAAM,CACV,IAAI,CAAC,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,IAAI,CAAC,IAAI,KAAK,WAAW,CACpE,CAAA;AAEH;;GAEG;AACH,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAAc,EAAgC,EAAE,CACjE,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,KAAK,EAAE,OAAO,CAAC;IACpD,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,KAAK,EAAE,WAAW,CAAC,CAAA"}
|
package/Helpers/permissions.d.ts
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { Discord, Effect } from "dfx/_common";
|
|
2
|
-
/**
|
|
3
|
-
* A constant of all the permissions
|
|
4
|
-
*/
|
|
5
|
-
export declare const ALL: bigint;
|
|
6
|
-
/**
|
|
7
|
-
* Check if a flag exists in the permissions.
|
|
8
|
-
*/
|
|
9
|
-
export declare const has: (flag: string | bigint) => (bits: string | bigint) => boolean;
|
|
10
|
-
/**
|
|
11
|
-
* Convert a permissions bitfield to a list of flag names.
|
|
12
|
-
*/
|
|
13
|
-
export declare const toList: (bitfield: bigint) => ("CREATE_INSTANT_INVITE" | "KICK_MEMBERS" | "BAN_MEMBERS" | "ADMINISTRATOR" | "MANAGE_CHANNELS" | "MANAGE_GUILD" | "ADD_REACTIONS" | "VIEW_AUDIT_LOG" | "PRIORITY_SPEAKER" | "STREAM" | "VIEW_CHANNEL" | "SEND_MESSAGES" | "SEND_TTS_MESSAGES" | "MANAGE_MESSAGES" | "EMBED_LINKS" | "ATTACH_FILES" | "READ_MESSAGE_HISTORY" | "MENTION_EVERYONE" | "USE_EXTERNAL_EMOJIS" | "VIEW_GUILD_INSIGHTS" | "CONNECT" | "SPEAK" | "MUTE_MEMBERS" | "DEAFEN_MEMBERS" | "MOVE_MEMBERS" | "USE_VAD" | "CHANGE_NICKNAME" | "MANAGE_NICKNAMES" | "MANAGE_ROLES" | "MANAGE_WEBHOOKS" | "MANAGE_GUILD_EXPRESSIONS" | "USE_APPLICATION_COMMANDS" | "REQUEST_TO_SPEAK" | "MANAGE_EVENTS" | "MANAGE_THREADS" | "CREATE_PUBLIC_THREADS" | "CREATE_PRIVATE_THREADS" | "USE_EXTERNAL_STICKERS" | "SEND_MESSAGES_IN_THREADS" | "USE_EMBEDDED_ACTIVITIES" | "MODERATE_MEMBERS" | "VIEW_CREATOR_MONETIZATION_ANALYTICS" | "USE_SOUNDBOARD" | "SEND_VOICE_MESSAGES")[];
|
|
14
|
-
/**
|
|
15
|
-
* Convert a list of flag names to a bitfield.
|
|
16
|
-
*/
|
|
17
|
-
export declare const fromList: (list: ("CREATE_INSTANT_INVITE" | "KICK_MEMBERS" | "BAN_MEMBERS" | "ADMINISTRATOR" | "MANAGE_CHANNELS" | "MANAGE_GUILD" | "ADD_REACTIONS" | "VIEW_AUDIT_LOG" | "PRIORITY_SPEAKER" | "STREAM" | "VIEW_CHANNEL" | "SEND_MESSAGES" | "SEND_TTS_MESSAGES" | "MANAGE_MESSAGES" | "EMBED_LINKS" | "ATTACH_FILES" | "READ_MESSAGE_HISTORY" | "MENTION_EVERYONE" | "USE_EXTERNAL_EMOJIS" | "VIEW_GUILD_INSIGHTS" | "CONNECT" | "SPEAK" | "MUTE_MEMBERS" | "DEAFEN_MEMBERS" | "MOVE_MEMBERS" | "USE_VAD" | "CHANGE_NICKNAME" | "MANAGE_NICKNAMES" | "MANAGE_ROLES" | "MANAGE_WEBHOOKS" | "MANAGE_GUILD_EXPRESSIONS" | "USE_APPLICATION_COMMANDS" | "REQUEST_TO_SPEAK" | "MANAGE_EVENTS" | "MANAGE_THREADS" | "CREATE_PUBLIC_THREADS" | "CREATE_PRIVATE_THREADS" | "USE_EXTERNAL_STICKERS" | "SEND_MESSAGES_IN_THREADS" | "USE_EMBEDDED_ACTIVITIES" | "MODERATE_MEMBERS" | "VIEW_CREATOR_MONETIZATION_ANALYTICS" | "USE_SOUNDBOARD" | "SEND_VOICE_MESSAGES")[]) => bigint;
|
|
18
|
-
/**
|
|
19
|
-
* Reduce a list of roles to a bitfield of all the permissions added together.
|
|
20
|
-
*/
|
|
21
|
-
export declare const forRoles: (roles: Discord.Role[]) => bigint;
|
|
22
|
-
/**
|
|
23
|
-
* From a list of roles, calculate the permissions bitfield for the member.
|
|
24
|
-
*/
|
|
25
|
-
export declare const forMember: (roles: Discord.Role[]) => (member: Discord.GuildMember) => bigint;
|
|
26
|
-
/**
|
|
27
|
-
* From a list of roles and a channel, calculate the permission bitfield for
|
|
28
|
-
* the guild member or role for that channel.
|
|
29
|
-
*/
|
|
30
|
-
export declare const forChannel: (roles: Discord.Role[]) => ({ guild_id, permission_overwrites: overwrites }: Discord.Channel) => (memberOrRole: Discord.GuildMember | Discord.Role) => bigint;
|
|
31
|
-
/**
|
|
32
|
-
* Apply permission overwrites to a bitfield.
|
|
33
|
-
*/
|
|
34
|
-
export declare const applyOverwrites: (permissions: bigint) => (overwrites: Discord.Overwrite[]) => bigint;
|
|
35
|
-
interface RolesCache<E> {
|
|
36
|
-
getForParent: (parentId: string) => Effect<never, E, ReadonlyMap<string, Discord.Role>>;
|
|
37
|
-
}
|
|
38
|
-
export declare const hasInChannel: <E>(rolesCache: RolesCache<E>, permission: bigint) => (channel: Discord.Channel, memberOrRole: Discord.GuildMember | Discord.Role) => import("@effect/io/Effect").Effect<never, E, boolean>;
|
|
39
|
-
export declare const hasInGuild: <E>(rolesCache: RolesCache<E>, permission: bigint) => (guildId: Discord.Snowflake, member: Discord.GuildMember) => import("@effect/io/Effect").Effect<never, E, boolean>;
|
|
40
|
-
export {};
|
package/Helpers/permissions.js
DELETED
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
import * as tsplus_module_1 from "dfx/_common";
|
|
2
|
-
import * as tsplus_module_2 from "@effect/data/Function";
|
|
3
|
-
import * as tsplus_module_3 from "@effect/io/Effect";
|
|
4
|
-
import * as Flags from "dfx/Helpers/flags";
|
|
5
|
-
import * as Members from "dfx/Helpers/members";
|
|
6
|
-
/**
|
|
7
|
-
* A constant of all the permissions
|
|
8
|
-
*/
|
|
9
|
-
export const ALL = Flags.all(tsplus_module_1.Discord.PermissionFlag);
|
|
10
|
-
/**
|
|
11
|
-
* Check if a flag exists in the permissions.
|
|
12
|
-
*/
|
|
13
|
-
export const has = Flags.hasBigInt;
|
|
14
|
-
/**
|
|
15
|
-
* Convert a permissions bitfield to a list of flag names.
|
|
16
|
-
*/
|
|
17
|
-
export const toList = Flags.toList(tsplus_module_1.Discord.PermissionFlag);
|
|
18
|
-
/**
|
|
19
|
-
* Convert a list of flag names to a bitfield.
|
|
20
|
-
*/
|
|
21
|
-
export const fromList = Flags.fromListBigint(tsplus_module_1.Discord.PermissionFlag);
|
|
22
|
-
/**
|
|
23
|
-
* Reduce a list of roles to a bitfield of all the permissions added together.
|
|
24
|
-
*/
|
|
25
|
-
export const forRoles = (roles) => roles.reduce((permissions, role) => permissions | BigInt(role.permissions), BigInt(0));
|
|
26
|
-
/**
|
|
27
|
-
* From a list of roles, calculate the permissions bitfield for the member.
|
|
28
|
-
*/
|
|
29
|
-
export const forMember = (roles) => (member) => tsplus_module_2.pipe(Members.roles(roles)(member), forRoles);
|
|
30
|
-
const overwriteIsForMember = (guildId) => (member) => (overwrite) => {
|
|
31
|
-
if (overwrite.type === 0) {
|
|
32
|
-
return overwrite.id === guildId || member.roles.includes(overwrite.id);
|
|
33
|
-
}
|
|
34
|
-
return overwrite.id === member.user?.id;
|
|
35
|
-
};
|
|
36
|
-
const overwriteIsForRole = (guildId) => (role) => (overwrite) => {
|
|
37
|
-
if (overwrite.type === 0) {
|
|
38
|
-
return overwrite.id === guildId || overwrite.id === role.id;
|
|
39
|
-
}
|
|
40
|
-
return false;
|
|
41
|
-
};
|
|
42
|
-
/**
|
|
43
|
-
* From a list of roles and a channel, calculate the permission bitfield for
|
|
44
|
-
* the guild member or role for that channel.
|
|
45
|
-
*/
|
|
46
|
-
export const forChannel = (roles) => ({ guild_id, permission_overwrites: overwrites = [] }) => (memberOrRole) => {
|
|
47
|
-
const hasAdmin = has(tsplus_module_1.Discord.PermissionFlag.ADMINISTRATOR);
|
|
48
|
-
let basePermissions;
|
|
49
|
-
let filteredOverwrites;
|
|
50
|
-
if (Members.is(memberOrRole)) {
|
|
51
|
-
if (memberOrRole.permissions)
|
|
52
|
-
return BigInt(memberOrRole.permissions);
|
|
53
|
-
const memberRoles = Members.roles(roles)(memberOrRole);
|
|
54
|
-
basePermissions = forRoles(memberRoles);
|
|
55
|
-
filteredOverwrites = overwrites.filter(overwriteIsForMember(guild_id)(memberOrRole));
|
|
56
|
-
}
|
|
57
|
-
else {
|
|
58
|
-
const everyone = roles.find(role => role.name === "@everyone");
|
|
59
|
-
basePermissions =
|
|
60
|
-
BigInt(everyone?.permissions || "0") | BigInt(memberOrRole.permissions);
|
|
61
|
-
filteredOverwrites = overwrites.filter(overwriteIsForRole(guild_id)(memberOrRole));
|
|
62
|
-
}
|
|
63
|
-
if (hasAdmin(basePermissions)) {
|
|
64
|
-
return ALL;
|
|
65
|
-
}
|
|
66
|
-
return applyOverwrites(basePermissions)(filteredOverwrites);
|
|
67
|
-
};
|
|
68
|
-
/**
|
|
69
|
-
* Apply permission overwrites to a bitfield.
|
|
70
|
-
*/
|
|
71
|
-
export const applyOverwrites = (permissions) => (overwrites) => overwrites.reduce((permissions, overwrite) => (permissions & ~BigInt(overwrite.deny)) | BigInt(overwrite.allow), permissions);
|
|
72
|
-
export const hasInChannel = (rolesCache, permission) => (channel, memberOrRole) => tsplus_module_3.map(rolesCache.getForParent(channel.guild_id), roles => {
|
|
73
|
-
const channelPerms = forChannel([...roles.values()])(channel)(memberOrRole);
|
|
74
|
-
return has(permission)(channelPerms);
|
|
75
|
-
});
|
|
76
|
-
export const hasInGuild = (rolesCache, permission) => (guildId, member) => tsplus_module_3.map(rolesCache.getForParent(guildId), roles => {
|
|
77
|
-
const hasPerm = has(permission);
|
|
78
|
-
return member.roles.some(id => {
|
|
79
|
-
const role = roles.get(id);
|
|
80
|
-
return role ? hasPerm(role.permissions) : false;
|
|
81
|
-
});
|
|
82
|
-
});
|
|
83
|
-
//# sourceMappingURL=permissions.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"permissions.js","sourceRoot":"","sources":["../src/Helpers/permissions.ts"],"names":[],"mappings":";;;AAAA,OAAO,KAAK,KAAK,MAAM,mBAAmB,CAAA;AAC1C,OAAO,KAAK,OAAO,MAAM,qBAAqB,CAAA;AAE9C;;GAEG;AACH,MAAM,CAAC,MAAM,GAAG,GAAG,KAAK,CAAC,GAAG,CAAC,gBAAA,OAAO,CAAC,cAAc,CAAC,CAAA;AAEpD;;GAEG;AACH,MAAM,CAAC,MAAM,GAAG,GAAG,KAAK,CAAC,SAAS,CAAA;AAElC;;GAEG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,gBAAA,OAAO,CAAC,cAAc,CAAC,CAAA;AAE1D;;GAEG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,KAAK,CAAC,cAAc,CAAC,gBAAA,OAAO,CAAC,cAAc,CAAC,CAAA;AAEpE;;GAEG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,KAAqB,EAAE,EAAE,CAChD,KAAK,CAAC,MAAM,CACV,CAAC,WAAW,EAAE,IAAI,EAAE,EAAE,CAAC,WAAW,GAAG,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,EAC7D,MAAM,CAAC,CAAC,CAAC,CACV,CAAA;AAEH;;GAEG;AACH,MAAM,CAAC,MAAM,SAAS,GACpB,CAAC,KAAqB,EAAE,EAAE,CAAC,CAAC,MAA2B,EAAE,EAAE,CACzD,gBAAA,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,EAAE,QAAQ,CAAC,CAAA;AAEhD,MAAM,oBAAoB,GACxB,CAAC,OAAgB,EAAE,EAAE,CACrB,CAAC,MAA2B,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C,UAAU,CAAC,CAAC,YAAY,CAAC,CAAA;EACpC,CAAA;AAEN,MAAM,CAAC,MAAM,UAAU,GACrB,CAAI,UAAyB,EAAE,UAAkB,EAAE,EAAE,CACrD,CAAC,OAA0B,EAAE,MAA2B,EAAE,EAAE,qBAExC,UAAU,CAAC,YAAY,CAAC,OAAO,CAAC,EAA1C,KAAK;IACX,MAAM,OAAO,GAAG,GAAG,CAAC,UAAU,CAAC,CAAA;IAE/B,OAAO,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE;QAC5B,MAAM,IAAI,GAAG,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC,CAAA;QAC1B,OAAO,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,KAAK,CAAA;IACjD,CAAC,CAAC,CAAA;EACF,CAAA"}
|
package/Helpers/ui.d.ts
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { ActionRow, Button, Component, SelectMenu, SelectOption, TextInput, TextInputStyle } from "../types.js";
|
|
2
|
-
export type UIComponent = Exclude<Component, ActionRow>;
|
|
3
|
-
/**
|
|
4
|
-
* Helper to create an Action Row grid.
|
|
5
|
-
*/
|
|
6
|
-
export declare const grid: (items: UIComponent[][]) => ActionRow[];
|
|
7
|
-
/**
|
|
8
|
-
* Helper to create a single column of components
|
|
9
|
-
*/
|
|
10
|
-
export declare const singleColumn: (items: UIComponent[]) => ActionRow[];
|
|
11
|
-
/**
|
|
12
|
-
* Helper to create a button component.
|
|
13
|
-
*/
|
|
14
|
-
export declare const button: (button: Partial<Button>) => Button;
|
|
15
|
-
type BasicSelect = Omit<SelectMenu, "type" | "channel_types" | "options">;
|
|
16
|
-
type StringSelect = BasicSelect & {
|
|
17
|
-
options: SelectOption[];
|
|
18
|
-
};
|
|
19
|
-
type ChannelSelect = Omit<SelectMenu, "type" | "options">;
|
|
20
|
-
/**
|
|
21
|
-
* Helper to create a select component.
|
|
22
|
-
*/
|
|
23
|
-
export declare const select: (select: StringSelect) => SelectMenu;
|
|
24
|
-
/**
|
|
25
|
-
* Helper to create a select component.
|
|
26
|
-
*/
|
|
27
|
-
export declare const userSelect: (select: BasicSelect) => SelectMenu;
|
|
28
|
-
/**
|
|
29
|
-
* Helper to create a select component.
|
|
30
|
-
*/
|
|
31
|
-
export declare const roleSelect: (select: BasicSelect) => SelectMenu;
|
|
32
|
-
/**
|
|
33
|
-
* Helper to create a select component.
|
|
34
|
-
*/
|
|
35
|
-
export declare const mentionableSelect: (select: BasicSelect) => SelectMenu;
|
|
36
|
-
/**
|
|
37
|
-
* Helper to create a select component.
|
|
38
|
-
*/
|
|
39
|
-
export declare const channelSelect: (select: ChannelSelect) => SelectMenu;
|
|
40
|
-
type TextInputOpts = Omit<TextInput, "type" | "style"> & {
|
|
41
|
-
style?: TextInputStyle;
|
|
42
|
-
};
|
|
43
|
-
/**
|
|
44
|
-
* Helper to create a text input
|
|
45
|
-
*/
|
|
46
|
-
export declare const textInput: (input: TextInputOpts) => TextInput;
|
|
47
|
-
export {};
|
package/Helpers/ui.js
DELETED
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Helper to create an Action Row grid.
|
|
3
|
-
*/
|
|
4
|
-
export const grid = (items) => items.map((components) => ({
|
|
5
|
-
type: 1 /* ComponentType.ACTION_ROW */,
|
|
6
|
-
components,
|
|
7
|
-
}));
|
|
8
|
-
/**
|
|
9
|
-
* Helper to create a single column of components
|
|
10
|
-
*/
|
|
11
|
-
export const singleColumn = (items) => items.map(c => ({
|
|
12
|
-
type: 1 /* ComponentType.ACTION_ROW */,
|
|
13
|
-
components: [c],
|
|
14
|
-
}));
|
|
15
|
-
/**
|
|
16
|
-
* Helper to create a button component.
|
|
17
|
-
*/
|
|
18
|
-
export const button = (button) => ({
|
|
19
|
-
type: 2 /* ComponentType.BUTTON */,
|
|
20
|
-
style: 1 /* ButtonStyle.PRIMARY */,
|
|
21
|
-
...button,
|
|
22
|
-
});
|
|
23
|
-
/**
|
|
24
|
-
* Helper to create a select component.
|
|
25
|
-
*/
|
|
26
|
-
export const select = (select) => ({
|
|
27
|
-
type: 3 /* ComponentType.STRING_SELECT */,
|
|
28
|
-
...select,
|
|
29
|
-
});
|
|
30
|
-
/**
|
|
31
|
-
* Helper to create a select component.
|
|
32
|
-
*/
|
|
33
|
-
export const userSelect = (select) => ({
|
|
34
|
-
type: 5 /* ComponentType.USER_SELECT */,
|
|
35
|
-
...select,
|
|
36
|
-
});
|
|
37
|
-
/**
|
|
38
|
-
* Helper to create a select component.
|
|
39
|
-
*/
|
|
40
|
-
export const roleSelect = (select) => ({
|
|
41
|
-
type: 6 /* ComponentType.ROLE_SELECT */,
|
|
42
|
-
...select,
|
|
43
|
-
});
|
|
44
|
-
/**
|
|
45
|
-
* Helper to create a select component.
|
|
46
|
-
*/
|
|
47
|
-
export const mentionableSelect = (select) => ({
|
|
48
|
-
type: 7 /* ComponentType.MENTIONABLE_SELECT */,
|
|
49
|
-
...select,
|
|
50
|
-
});
|
|
51
|
-
/**
|
|
52
|
-
* Helper to create a select component.
|
|
53
|
-
*/
|
|
54
|
-
export const channelSelect = (select) => ({
|
|
55
|
-
type: 8 /* ComponentType.CHANNEL_SELECT */,
|
|
56
|
-
...select,
|
|
57
|
-
});
|
|
58
|
-
/**
|
|
59
|
-
* Helper to create a text input
|
|
60
|
-
*/
|
|
61
|
-
export const textInput = (input) => ({
|
|
62
|
-
type: 4 /* ComponentType.TEXT_INPUT */,
|
|
63
|
-
style: 1 /* TextInputStyle.SHORT */,
|
|
64
|
-
...input,
|
|
65
|
-
});
|
|
66
|
-
//# sourceMappingURL=ui.js.map
|
package/Helpers/ui.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ui.js","sourceRoot":"","sources":["../src/Helpers/ui.ts"],"names":[],"mappings":"AAcA;;GAEG;AACH,MAAM,CAAC,MAAM,IAAI,GAAG,CAAC,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;AAMF;;GAEG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,KAAoB,EAAa,EAAE,CAAC,CAAC;IAC7D,IAAI,kCAA0B;IAC9B,KAAK,8BAAsB;IAC3B,GAAG,KAAK;CACT,CAAC,CAAA"}
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { Chunk, Cause } from "dfx/_common";
|
|
2
|
-
import * as Http from "@effect-http/client";
|
|
3
|
-
import { DiscordREST } from "dfx";
|
|
4
|
-
import { Discord, Effect } from "dfx/_common";
|
|
5
|
-
import * as D from "./definitions.js";
|
|
6
|
-
type ExtractTag<A> = A extends {
|
|
7
|
-
_tag: infer Tag;
|
|
8
|
-
} ? Tag extends string ? Tag : never : never;
|
|
9
|
-
/**
|
|
10
|
-
* @tsplus type dfx/InteractionBuilder
|
|
11
|
-
*/
|
|
12
|
-
export declare class InteractionBuilder<R, E, TE> {
|
|
13
|
-
readonly definitions: Chunk<readonly [
|
|
14
|
-
handler: D.InteractionDefinition<R, E>,
|
|
15
|
-
transform: (self: Effect<any, any, any>) => Effect<R, TE, void>
|
|
16
|
-
]>;
|
|
17
|
-
readonly transform: (self: Effect<any, any, any>) => Effect<R, TE, void>;
|
|
18
|
-
constructor(definitions: Chunk<readonly [
|
|
19
|
-
handler: D.InteractionDefinition<R, E>,
|
|
20
|
-
transform: (self: Effect<any, any, any>) => Effect<R, TE, void>
|
|
21
|
-
]>, transform: (self: Effect<any, any, any>) => Effect<R, TE, void>);
|
|
22
|
-
add<R1, E1>(definition: D.InteractionDefinition<R1, E1>): InteractionBuilder<R | R1, E | E1, TE | E1>;
|
|
23
|
-
concat<R1, E1, TE1>(builder: InteractionBuilder<R1, E1, TE1>): InteractionBuilder<R | R1, E | E1, TE | TE1>;
|
|
24
|
-
private transformTransform;
|
|
25
|
-
private transformHandlers;
|
|
26
|
-
catchAllCause<R1, E1>(f: (cause: Cause<TE>) => Effect<R1, E1, void>): InteractionBuilder<R | R1, E, E1>;
|
|
27
|
-
catchAllCauseRespond<R1, E1>(f: (cause: Cause<E>) => Effect<R1, E1, Discord.InteractionResponse>): InteractionBuilder<R | R1, E1, Exclude<TE, Exclude<E, E1>> | Exclude<E1, E>>;
|
|
28
|
-
catchAll<R1, E1>(f: (error: TE) => Effect<R1, E1, void>): InteractionBuilder<R | R1, E, E1>;
|
|
29
|
-
catchAllRespond<R1, E1>(f: (error: E) => Effect<R1, E1, Discord.InteractionResponse>): InteractionBuilder<R | R1, E1, Exclude<TE, Exclude<E, E1>> | Exclude<E1, E>>;
|
|
30
|
-
catchTag<T extends ExtractTag<E>, R1, E1>(tag: T, f: (error: Extract<TE, {
|
|
31
|
-
_tag: T;
|
|
32
|
-
}>) => Effect<R1, E1, void>): InteractionBuilder<R | R1, E, E1 | Exclude<TE, {
|
|
33
|
-
_tag: T;
|
|
34
|
-
}>>;
|
|
35
|
-
catchTagRespond<T extends ExtractTag<E>, R1, E1>(tag: T, f: (error: Extract<E, {
|
|
36
|
-
_tag: T;
|
|
37
|
-
}>) => Effect<R1, E1, Discord.InteractionResponse>): InteractionBuilder<R | R1, E1 | Exclude<E, {
|
|
38
|
-
_tag: T;
|
|
39
|
-
}>, Exclude<TE, Exclude<E, E1 | Exclude<E, {
|
|
40
|
-
_tag: T;
|
|
41
|
-
}>>> | Exclude<E1, E> | Exclude<Exclude<E, {
|
|
42
|
-
_tag: T;
|
|
43
|
-
}>, E>>;
|
|
44
|
-
get syncGlobal(): Effect<DiscordREST, import("../DiscordREST.js").DiscordRESTError | Http.ResponseDecodeError, import("../DiscordREST/types.js").ResponseWithData<Discord.ApplicationCommand[]>>;
|
|
45
|
-
syncGuild(appId: Discord.Snowflake, guildId: Discord.Snowflake): Effect<DiscordREST, import("../DiscordREST.js").DiscordRESTError, import("../DiscordREST/types.js").ResponseWithData<Discord.ApplicationCommand[]>>;
|
|
46
|
-
}
|
|
47
|
-
export declare const builder: InteractionBuilder<never, never, never>;
|
|
48
|
-
export {};
|
package/Interactions/builder.js
DELETED
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import * as tsplus_module_1 from "@effect/data/Chunk";
|
|
2
|
-
import * as tsplus_module_2 from "@effect/io/Effect";
|
|
3
|
-
import * as tsplus_module_3 from "@effect/data/Function";
|
|
4
|
-
import * as Http from "@effect-http/client";
|
|
5
|
-
import { catchTag } from "@effect/io/Effect";
|
|
6
|
-
import { DiscordREST } from "dfx";
|
|
7
|
-
/**
|
|
8
|
-
* @tsplus type dfx/InteractionBuilder
|
|
9
|
-
*/
|
|
10
|
-
export class InteractionBuilder {
|
|
11
|
-
definitions;
|
|
12
|
-
transform;
|
|
13
|
-
constructor(definitions, transform) {
|
|
14
|
-
this.definitions = definitions;
|
|
15
|
-
this.transform = transform;
|
|
16
|
-
}
|
|
17
|
-
add(definition) {
|
|
18
|
-
return new InteractionBuilder(tsplus_module_1.append(this.definitions, [definition, this.transform]), this.transform);
|
|
19
|
-
}
|
|
20
|
-
concat(builder) {
|
|
21
|
-
return new InteractionBuilder(tsplus_module_1.concat(this.definitions, builder.definitions), this.transform);
|
|
22
|
-
}
|
|
23
|
-
transformTransform(f) {
|
|
24
|
-
return new InteractionBuilder(tsplus_module_1.map(this.definitions, ([d, t]) => [d, _ => f(t(_))]), _ => f(this.transform(_)));
|
|
25
|
-
}
|
|
26
|
-
transformHandlers(f) {
|
|
27
|
-
return new InteractionBuilder(tsplus_module_1.map(this.definitions, ([d, t]) => [
|
|
28
|
-
{
|
|
29
|
-
...d,
|
|
30
|
-
handle: tsplus_module_2.isEffect(d.handle)
|
|
31
|
-
? f(d.handle)
|
|
32
|
-
: (_) => f(d.handle(_)),
|
|
33
|
-
},
|
|
34
|
-
t,
|
|
35
|
-
]), this.transform);
|
|
36
|
-
}
|
|
37
|
-
catchAllCause(f) {
|
|
38
|
-
return this.transformTransform(_ => tsplus_module_2.catchAllCause(_, f));
|
|
39
|
-
}
|
|
40
|
-
catchAllCauseRespond(f) {
|
|
41
|
-
return this.transformHandlers(_ => tsplus_module_2.catchAllCause(_, f));
|
|
42
|
-
}
|
|
43
|
-
catchAll(f) {
|
|
44
|
-
return this.transformTransform(_ => tsplus_module_2.catchAll(_, f));
|
|
45
|
-
}
|
|
46
|
-
catchAllRespond(f) {
|
|
47
|
-
return this.transformHandlers(_ => tsplus_module_2.catchAll(_, f));
|
|
48
|
-
}
|
|
49
|
-
catchTag(tag, f) {
|
|
50
|
-
return this.transformTransform(_ => catchTag(_, tag, f));
|
|
51
|
-
}
|
|
52
|
-
catchTagRespond(tag, f) {
|
|
53
|
-
return this.transformHandlers(_ => catchTag(_, tag, f));
|
|
54
|
-
}
|
|
55
|
-
get syncGlobal() {
|
|
56
|
-
const commands = tsplus_module_1.map(tsplus_module_1.filter(tsplus_module_1.map(this.definitions, ([d, _]) => d), (c) => c._tag === "GlobalApplicationCommand"), c => c.command);
|
|
57
|
-
return tsplus_module_2.flatMap(DiscordREST, rest => tsplus_module_2.flatMap(tsplus_module_2.flatMap(rest
|
|
58
|
-
.getCurrentBotApplicationInformation(), r => r.json), app => rest.bulkOverwriteGlobalApplicationCommands(app.id, {
|
|
59
|
-
body: Http.body.json(commands),
|
|
60
|
-
})));
|
|
61
|
-
}
|
|
62
|
-
syncGuild(appId, guildId) {
|
|
63
|
-
const commands = tsplus_module_1.map(tsplus_module_1.filter(tsplus_module_1.map(this.definitions, ([d, _]) => d), (c) => c._tag === "GuildApplicationCommand"), c => c.command);
|
|
64
|
-
return tsplus_module_2.flatMap(DiscordREST, rest => rest.bulkOverwriteGuildApplicationCommands(appId, guildId, commands));
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
export const builder = new InteractionBuilder(tsplus_module_1.empty(), tsplus_module_3.identity);
|
|
68
|
-
//# sourceMappingURL=builder.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"builder.js","sourceRoot":"","sources":["../src/Interactions/builder.ts"],"names":[],"mappings":";;;AAAA,OAAO,KAAK,IAAI,MAAM,qBAAqB,CAAA;AAC3C,OAAO,EA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AE,EAAE,CAAC,CAAC,CAAC,EAEjB,CAAC,CAAC,EAAyC,EAAE,CAC3C,CAAC,CAAC,IAAI,KAAK,0BAA0B,CACxC,EACI,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,CAAA;QAEtB,OAAO,wBAAA,WAAW,EAAS,IAAI,CAAC,EAAE,CAChC,wBAAA,wBAAA,IAAI;aACD,mCAAmC,EAAE,EAC7B,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,EACZ,GAAG,CAAC,EAAE,CACb,IAAI,CAAC,sCAAsC,CAAC,GAAG,CAAC,EAAE,EAAE;YAClD,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC;SAC/B,CAAC,CACH,CACJ,CAAA;IACH,CAAC;IAED,SAAS,CAAC,KAAwB,EAAE,OAA0B;QAC5D,MAAM,QAAQ,GAAG,oBAAA,uBAAA,oBAAA,IAAI,CAAC,WAAW,EAC1B,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAEjB,CAAC,CAAC,EAAwC,EAAE,CAC1C,CAAC,CAAC,IAAI,KAAK,yBAAyB,CACvC,EACI,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,CAAA;QAEtB,OAAO,wBAAA,WAAW,EAAS,IAAI,CAAC,EAAE,CAChC,IAAI,CAAC,qCAAqC,CACxC,KAAK,EACL,OAAO,EACP,QAAe,CAChB,CACF,CAAA;IACH,CAAC;CACF;AAED,MAAM,CAAC,MAAM,OAAO,GAAG,IAAI,kBAAkB,CAC3C,uBAAa,EACb,gBAAA,QAAe,CAChB,CAAA"}
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import { Discord } from "dfx/_common";
|
|
2
|
-
import { Effect, EffectTypeId } from "@effect/io/Effect";
|
|
3
|
-
import { ModalSubmitDatum } from "dfx/types";
|
|
4
|
-
export declare const Interaction: import("@effect/data/Context").Tag<import("dfx/types").Interaction, import("dfx/types").Interaction>;
|
|
5
|
-
export declare const ApplicationCommand: import("@effect/data/Context").Tag<import("dfx/types").ApplicationCommandDatum, import("dfx/types").ApplicationCommandDatum>;
|
|
6
|
-
export declare const MessageComponentData: import("@effect/data/Context").Tag<import("dfx/types").MessageComponentDatum, import("dfx/types").MessageComponentDatum>;
|
|
7
|
-
export declare const ModalSubmitData: import("@effect/data/Context").Tag<ModalSubmitDatum, ModalSubmitDatum>;
|
|
8
|
-
export interface FocusedOptionContext {
|
|
9
|
-
readonly focusedOption: Discord.ApplicationCommandInteractionDataOption;
|
|
10
|
-
}
|
|
11
|
-
export declare const FocusedOptionContext: import("@effect/data/Context").Tag<FocusedOptionContext, FocusedOptionContext>;
|
|
12
|
-
export interface SubCommandContext {
|
|
13
|
-
readonly command: Discord.ApplicationCommandInteractionDataOption;
|
|
14
|
-
}
|
|
15
|
-
export declare const SubCommandContext: import("@effect/data/Context").Tag<SubCommandContext, SubCommandContext>;
|
|
16
|
-
export declare class ResolvedDataNotFound {
|
|
17
|
-
readonly data: Discord.Interaction;
|
|
18
|
-
readonly name?: string | undefined;
|
|
19
|
-
readonly _tag = "ResolvedDataNotFound";
|
|
20
|
-
constructor(data: Discord.Interaction, name?: string | undefined);
|
|
21
|
-
}
|
|
22
|
-
export declare const resolvedValues: <A>(f: (id: Discord.Snowflake, data: Discord.ResolvedDatum) => A | undefined) => Effect<import("dfx/types").Interaction, ResolvedDataNotFound, readonly A[]>;
|
|
23
|
-
export declare const resolved: <A>(name: string, f: (id: Discord.Snowflake, data: Discord.ResolvedDatum) => A | undefined) => Effect<import("dfx/types").Interaction, ResolvedDataNotFound, A>;
|
|
24
|
-
export declare const focusedOptionValue: Effect<FocusedOptionContext, never, string>;
|
|
25
|
-
export declare class SubCommandNotFound {
|
|
26
|
-
readonly data: Discord.ApplicationCommandDatum;
|
|
27
|
-
readonly _tag = "SubCommandNotFound";
|
|
28
|
-
constructor(data: Discord.ApplicationCommandDatum);
|
|
29
|
-
}
|
|
30
|
-
export declare const handleSubCommands: <NER extends Record<string, Effect<any, any, import("dfx/types").InteractionResponse>>>(commands: NER) => Effect<import("dfx/types").Interaction | import("dfx/types").ApplicationCommandDatum | Exclude<[NER[keyof NER]] extends [{
|
|
31
|
-
[EffectTypeId]: {
|
|
32
|
-
_R: (_: never) => infer R;
|
|
33
|
-
};
|
|
34
|
-
}] ? R : never, SubCommandContext>, SubCommandNotFound | ([NER[keyof NER]] extends [{
|
|
35
|
-
[EffectTypeId]: {
|
|
36
|
-
_E: (_: never) => infer E;
|
|
37
|
-
};
|
|
38
|
-
}] ? E : never), import("dfx/types").InteractionResponse>;
|
|
39
|
-
export declare const currentSubCommand: Effect<SubCommandContext, never, import("dfx/types").ApplicationCommandInteractionDataOption>;
|
|
40
|
-
export declare const optionsMap: Effect<import("dfx/types").ApplicationCommandDatum, never, import("../_common.js").HashMap<string, string | undefined>>;
|
|
41
|
-
export declare class RequiredOptionNotFound {
|
|
42
|
-
readonly data: Discord.ApplicationCommandDatum | Discord.ApplicationCommandInteractionDataOption;
|
|
43
|
-
readonly name: string;
|
|
44
|
-
readonly _tag = "RequiredOptionNotFound";
|
|
45
|
-
constructor(data: Discord.ApplicationCommandDatum | Discord.ApplicationCommandInteractionDataOption, name: string);
|
|
46
|
-
}
|
|
47
|
-
export declare const option: (name: string) => Effect<import("dfx/types").ApplicationCommandDatum, never, import("@effect/data/Option").Option<import("dfx/types").ApplicationCommandInteractionDataOption>>;
|
|
48
|
-
export declare const optionValue: (name: string) => Effect<import("dfx/types").ApplicationCommandDatum, RequiredOptionNotFound, string>;
|
|
49
|
-
export declare const optionValueOptional: (name: string) => Effect<import("dfx/types").ApplicationCommandDatum, never, import("@effect/data/Option").Option<string>>;
|
|
50
|
-
export declare const modalValues: Effect<ModalSubmitDatum, never, import("../_common.js").HashMap<string, string | undefined>>;
|
|
51
|
-
export declare const modalValueOption: (name: string) => Effect<ModalSubmitDatum, never, import("@effect/data/Option").Option<string>>;
|
|
52
|
-
export declare class ModalValueNotFound {
|
|
53
|
-
readonly data: ModalSubmitDatum;
|
|
54
|
-
readonly name: string;
|
|
55
|
-
readonly _tag = "ModalValueNotFound";
|
|
56
|
-
constructor(data: ModalSubmitDatum, name: string);
|
|
57
|
-
}
|
|
58
|
-
export declare const modalValue: (name: string) => Effect<ModalSubmitDatum, ModalValueNotFound, string>;
|
package/Interactions/context.js
DELETED
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import * as tsplus_module_1 from "dfx/_common";
|
|
2
|
-
import * as tsplus_module_2 from "@effect/io/Effect";
|
|
3
|
-
import * as tsplus_module_3 from "@effect/data/Option";
|
|
4
|
-
import * as Arr from "@effect/data/ReadonlyArray";
|
|
5
|
-
import { EffectTypeId } from "@effect/io/Effect";
|
|
6
|
-
import * as IxHelpers from "dfx/Helpers/interactions";
|
|
7
|
-
export const Interaction = tsplus_module_1.Tag();
|
|
8
|
-
export const ApplicationCommand = tsplus_module_1.Tag();
|
|
9
|
-
export const MessageComponentData = tsplus_module_1.Tag();
|
|
10
|
-
export const ModalSubmitData = tsplus_module_1.Tag();
|
|
11
|
-
export const FocusedOptionContext = tsplus_module_1.Tag();
|
|
12
|
-
export const SubCommandContext = tsplus_module_1.Tag();
|
|
13
|
-
export class ResolvedDataNotFound {
|
|
14
|
-
data;
|
|
15
|
-
name;
|
|
16
|
-
_tag = "ResolvedDataNotFound";
|
|
17
|
-
constructor(data, name) {
|
|
18
|
-
this.data = data;
|
|
19
|
-
this.name = name;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
export const resolvedValues = (f) => tsplus_module_2.flatMap(Interaction, ix => tsplus_module_2.mapError(IxHelpers.resolveValues(f)(ix), () => new ResolvedDataNotFound(ix)));
|
|
23
|
-
export const resolved = (name, f) => tsplus_module_2.flatMap(Interaction, ix => tsplus_module_2.mapError(IxHelpers.resolveOptionValue(name, f)(ix), () => new ResolvedDataNotFound(ix, name)));
|
|
24
|
-
export const focusedOptionValue = tsplus_module_2.map(FocusedOptionContext, _ => _.focusedOption.value ?? "");
|
|
25
|
-
export class SubCommandNotFound {
|
|
26
|
-
data;
|
|
27
|
-
_tag = "SubCommandNotFound";
|
|
28
|
-
constructor(data) {
|
|
29
|
-
this.data = data;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
export const handleSubCommands = (commands) => tsplus_module_2.flatMap(ApplicationCommand, data => tsplus_module_2.flatMap(tsplus_module_2.mapError(Arr.findFirst(IxHelpers.allSubCommands(data), _ => !!commands[_.name]), () => new SubCommandNotFound(data)), command => tsplus_module_2.provideService(commands[command.name], SubCommandContext, {
|
|
33
|
-
command,
|
|
34
|
-
})));
|
|
35
|
-
export const currentSubCommand = tsplus_module_2.map(SubCommandContext, _ => _.command);
|
|
36
|
-
export const optionsMap = tsplus_module_2.map(ApplicationCommand, IxHelpers.optionsMap);
|
|
37
|
-
export class RequiredOptionNotFound {
|
|
38
|
-
data;
|
|
39
|
-
name;
|
|
40
|
-
_tag = "RequiredOptionNotFound";
|
|
41
|
-
constructor(data, name) {
|
|
42
|
-
this.data = data;
|
|
43
|
-
this.name = name;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
export const option = (name) => tsplus_module_2.map(ApplicationCommand, IxHelpers.getOption(name));
|
|
47
|
-
export const optionValue = (name) => tsplus_module_2.flatMap(option(name), _ => tsplus_module_3.match(tsplus_module_3.flatMapNullable(_, a => a.value), () => tsplus_module_2.flatMap(ApplicationCommand, data => tsplus_module_2.fail(new RequiredOptionNotFound(data, name))), tsplus_module_2.succeed));
|
|
48
|
-
export const optionValueOptional = (name) => tsplus_module_2.map(option(name), o => tsplus_module_3.flatMapNullable(o, o => o.value));
|
|
49
|
-
export const modalValues = tsplus_module_2.map(ModalSubmitData, IxHelpers.componentsMap);
|
|
50
|
-
export const modalValueOption = (name) => tsplus_module_2.map(ModalSubmitData, IxHelpers.componentValue(name));
|
|
51
|
-
export class ModalValueNotFound {
|
|
52
|
-
data;
|
|
53
|
-
name;
|
|
54
|
-
_tag = "ModalValueNotFound";
|
|
55
|
-
constructor(data, name) {
|
|
56
|
-
this.data = data;
|
|
57
|
-
this.name = name;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
export const modalValue = (name) => tsplus_module_2.flatMap(ModalSubmitData, data => tsplus_module_2.mapError(IxHelpers.componentValue(name)(data), () => new ModalValueNotFound(data, name)));
|
|
61
|
-
//# sourceMappingURL=context.js.map
|