dfx 0.21.22 → 0.22.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/Cache/memory.d.ts +2 -2
- package/Cache/memoryTTL.d.ts +2 -2
- package/Cache/memoryTTL.js +11 -11
- package/Cache/memoryTTL.js.map +1 -1
- package/Cache/prelude.d.ts +5 -5
- package/Cache/prelude.js +52 -52
- package/Cache/prelude.js.map +1 -1
- package/Cache.d.ts +69 -0
- package/{Cache/index.js → Cache.js} +15 -15
- package/Cache.js.map +1 -0
- package/{DiscordConfig/index.d.ts → DiscordConfig.d.ts} +3 -3
- package/{DiscordConfig/index.js → DiscordConfig.js} +2 -2
- package/DiscordConfig.js.map +1 -0
- package/DiscordGateway/{DiscordWS/index.d.ts → DiscordWS.d.ts} +5 -5
- package/DiscordGateway/{DiscordWS/index.js → DiscordWS.js} +9 -9
- package/DiscordGateway/DiscordWS.js.map +1 -0
- package/DiscordGateway/Shard/heartbeats.d.ts +1 -1
- package/DiscordGateway/Shard/heartbeats.js +7 -7
- package/DiscordGateway/Shard/heartbeats.js.map +1 -1
- package/DiscordGateway/Shard/identify.d.ts +1 -1
- package/DiscordGateway/Shard/identify.js +3 -3
- package/DiscordGateway/Shard/identify.js.map +1 -1
- package/DiscordGateway/Shard/invalidSession.d.ts +1 -1
- package/DiscordGateway/Shard/invalidSession.js +1 -1
- package/DiscordGateway/Shard/invalidSession.js.map +1 -1
- package/DiscordGateway/Shard/utils.d.ts +2 -2
- package/DiscordGateway/Shard/utils.js +3 -3
- package/DiscordGateway/Shard/utils.js.map +1 -1
- package/DiscordGateway/Shard.d.ts +9 -0
- package/DiscordGateway/Shard.js +44 -0
- package/DiscordGateway/Shard.js.map +1 -0
- package/DiscordGateway/{ShardStore/index.d.ts → ShardStore.d.ts} +2 -2
- package/DiscordGateway/{ShardStore/index.js → ShardStore.js} +1 -1
- package/DiscordGateway/ShardStore.js.map +1 -0
- package/DiscordGateway/Sharder.d.ts +16 -0
- package/DiscordGateway/Sharder.js +42 -0
- package/DiscordGateway/Sharder.js.map +1 -0
- package/DiscordGateway/{WS/index.d.ts → WS.d.ts} +1 -1
- package/DiscordGateway/{WS/index.js → WS.js} +10 -10
- package/DiscordGateway/WS.js.map +1 -0
- package/DiscordGateway.d.ts +12 -0
- package/DiscordGateway.js +20 -0
- package/DiscordGateway.js.map +1 -0
- package/DiscordREST/types.d.ts +5 -7
- package/DiscordREST/utils.d.ts +1 -1
- package/DiscordREST/utils.js +3 -4
- package/DiscordREST/utils.js.map +1 -1
- package/DiscordREST.d.ts +194 -0
- package/DiscordREST.js +120 -0
- package/DiscordREST.js.map +1 -0
- package/Helpers/interactions.js +10 -10
- package/Helpers/interactions.js.map +1 -1
- package/Helpers/permissions.d.ts +2 -2
- package/Helpers/permissions.js +4 -4
- package/Helpers/permissions.js.map +1 -1
- package/Interactions/context.d.ts +6 -6
- package/Interactions/context.js +6 -6
- package/Interactions/context.js.map +1 -1
- package/Interactions/gateway.d.ts +4 -2
- package/Interactions/gateway.js +6 -7
- package/Interactions/gateway.js.map +1 -1
- package/Interactions/handlers.js +6 -6
- package/Interactions/handlers.js.map +1 -1
- package/Interactions/index.d.ts +3 -2
- package/Interactions/index.js +5 -4
- package/Interactions/index.js.map +1 -1
- package/Interactions/webhook.d.ts +3 -3
- package/Interactions/webhook.js +9 -9
- package/Interactions/webhook.js.map +1 -1
- package/Log.d.ts +12 -0
- package/{Log/index.js → Log.js} +1 -1
- package/Log.js.map +1 -0
- package/RateLimit/memory.d.ts +1 -1
- package/RateLimit/memory.js +3 -3
- package/RateLimit/memory.js.map +1 -1
- package/{RateLimit/index.d.ts → RateLimit.d.ts} +6 -6
- package/{RateLimit/index.js → RateLimit.js} +8 -8
- package/RateLimit.js.map +1 -0
- package/gateway.d.ts +10 -10
- package/gateway.js +11 -12
- package/gateway.js.map +1 -1
- package/global.d.ts +1 -1
- package/index.d.ts +5 -6
- package/index.js +5 -6
- package/index.js.map +1 -1
- package/package.json +8 -6
- package/webhooks.d.ts +4 -4
- package/webhooks.js +3 -4
- package/webhooks.js.map +1 -1
- package/Cache/index.d.ts +0 -69
- package/Cache/index.js.map +0 -1
- package/DiscordConfig/index.js.map +0 -1
- package/DiscordGateway/DiscordWS/index.js.map +0 -1
- package/DiscordGateway/Shard/index.d.ts +0 -9
- package/DiscordGateway/Shard/index.js +0 -44
- package/DiscordGateway/Shard/index.js.map +0 -1
- package/DiscordGateway/ShardStore/index.js.map +0 -1
- package/DiscordGateway/Sharder/index.d.ts +0 -16
- package/DiscordGateway/Sharder/index.js +0 -42
- package/DiscordGateway/Sharder/index.js.map +0 -1
- package/DiscordGateway/WS/index.js.map +0 -1
- package/DiscordGateway/index.d.ts +0 -12
- package/DiscordGateway/index.js +0 -20
- package/DiscordGateway/index.js.map +0 -1
- package/DiscordREST/index.d.ts +0 -188
- package/DiscordREST/index.js +0 -122
- package/DiscordREST/index.js.map +0 -1
- package/Http/index.d.ts +0 -37
- package/Http/index.js +0 -51
- package/Http/index.js.map +0 -1
- package/Log/index.d.ts +0 -12
- package/Log/index.js.map +0 -1
- package/RateLimit/index.js.map +0 -1
package/DiscordREST.d.ts
ADDED
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
import { BucketDetails } from "dfx";
|
|
2
|
+
import { Effect, Discord } from "dfx/_common";
|
|
3
|
+
import { ResponseWithData, RestResponse } from "./DiscordREST/types.js";
|
|
4
|
+
import * as Http from "@effect-http/client";
|
|
5
|
+
export declare class DiscordRESTError {
|
|
6
|
+
readonly error: Http.HttpClientError;
|
|
7
|
+
readonly _tag = "DiscordRESTError";
|
|
8
|
+
constructor(error: Http.HttpClientError);
|
|
9
|
+
}
|
|
10
|
+
declare const make: import("@effect-http/client/_common").Effect<import("./DiscordConfig.js").DiscordConfig | import("./Log.js").Log | import("./RateLimit.js").RateLimitStore | import("./RateLimit.js").RateLimiter, never, {
|
|
11
|
+
addGuildMember: (guildId: string, userId: string, params?: Partial<import("./types.js").AddGuildMemberParams> | undefined, options?: Partial<Http.MakeOptions> | undefined) => RestResponse<import("./types.js").GuildMember>;
|
|
12
|
+
addGuildMemberRole: (guildId: string, userId: string, roleId: string, options?: Partial<Http.MakeOptions> | undefined) => RestResponse<any>;
|
|
13
|
+
addThreadMember: (channelId: string, userId: string, options?: Partial<Http.MakeOptions> | undefined) => RestResponse<any>;
|
|
14
|
+
batchEditApplicationCommandPermissions: (applicationId: string, guildId: string, options?: Partial<Http.MakeOptions> | undefined) => RestResponse<any>;
|
|
15
|
+
beginGuildPrune: (guildId: string, params?: Partial<import("./types.js").BeginGuildPruneParams> | undefined, options?: Partial<Http.MakeOptions> | undefined) => RestResponse<any>;
|
|
16
|
+
bulkDeleteMessages: (channelId: string, params?: Partial<import("./types.js").BulkDeleteMessageParams> | undefined, options?: Partial<Http.MakeOptions> | undefined) => RestResponse<any>;
|
|
17
|
+
bulkOverwriteGlobalApplicationCommands: (applicationId: string, options?: Partial<Http.MakeOptions> | undefined) => RestResponse<import("./types.js").ApplicationCommand[]>;
|
|
18
|
+
bulkOverwriteGuildApplicationCommands: (applicationId: string, guildId: string, params?: Partial<import("./types.js").BulkOverwriteGuildApplicationCommandParams> | undefined, options?: Partial<Http.MakeOptions> | undefined) => RestResponse<import("./types.js").ApplicationCommand[]>;
|
|
19
|
+
createAutoModerationRule: (guildId: string, params?: Partial<import("./types.js").CreateAutoModerationRuleParams> | undefined, options?: Partial<Http.MakeOptions> | undefined) => RestResponse<import("./types.js").AutoModerationRule>;
|
|
20
|
+
createChannelInvite: (channelId: string, params?: Partial<import("./types.js").CreateChannelInviteParams> | undefined, options?: Partial<Http.MakeOptions> | undefined) => RestResponse<import("./types.js").Invite>;
|
|
21
|
+
createDm: (params?: Partial<import("./types.js").CreateDmParams> | undefined, options?: Partial<Http.MakeOptions> | undefined) => RestResponse<import("./types.js").Channel>;
|
|
22
|
+
createFollowupMessage: (applicationId: string, interactionToken: string, options?: Partial<Http.MakeOptions> | undefined) => RestResponse<any>;
|
|
23
|
+
createGlobalApplicationCommand: (applicationId: string, params?: Partial<import("./types.js").CreateGlobalApplicationCommandParams> | undefined, options?: Partial<Http.MakeOptions> | undefined) => RestResponse<import("./types.js").ApplicationCommand>;
|
|
24
|
+
createGroupDm: (params?: Partial<import("./types.js").CreateGroupDmParams> | undefined, options?: Partial<Http.MakeOptions> | undefined) => RestResponse<import("./types.js").Channel>;
|
|
25
|
+
createGuild: (params?: Partial<import("./types.js").CreateGuildParams> | undefined, options?: Partial<Http.MakeOptions> | undefined) => RestResponse<import("./types.js").Guild>;
|
|
26
|
+
createGuildApplicationCommand: (applicationId: string, guildId: string, params?: Partial<import("./types.js").CreateGuildApplicationCommandParams> | undefined, options?: Partial<Http.MakeOptions> | undefined) => RestResponse<import("./types.js").ApplicationCommand>;
|
|
27
|
+
createGuildBan: (guildId: string, userId: string, params?: Partial<import("./types.js").CreateGuildBanParams> | undefined, options?: Partial<Http.MakeOptions> | undefined) => RestResponse<any>;
|
|
28
|
+
createGuildChannel: (guildId: string, params?: Partial<import("./types.js").CreateGuildChannelParams> | undefined, options?: Partial<Http.MakeOptions> | undefined) => RestResponse<import("./types.js").Channel>;
|
|
29
|
+
createGuildEmoji: (guildId: string, params?: Partial<import("./types.js").CreateGuildEmojiParams> | undefined, options?: Partial<Http.MakeOptions> | undefined) => RestResponse<import("./types.js").Emoji>;
|
|
30
|
+
createGuildFromGuildTemplate: (templateCode: string, params?: Partial<import("./types.js").CreateGuildFromGuildTemplateParams> | undefined, options?: Partial<Http.MakeOptions> | undefined) => RestResponse<import("./types.js").Guild>;
|
|
31
|
+
createGuildRole: (guildId: string, params?: Partial<import("./types.js").CreateGuildRoleParams> | undefined, options?: Partial<Http.MakeOptions> | undefined) => RestResponse<import("./types.js").Role>;
|
|
32
|
+
createGuildScheduledEvent: (guildId: string, params?: Partial<import("./types.js").CreateGuildScheduledEventParams> | undefined, options?: Partial<Http.MakeOptions> | undefined) => RestResponse<import("./types.js").GuildScheduledEvent>;
|
|
33
|
+
createGuildSticker: (guildId: string, params?: Partial<import("./types.js").CreateGuildStickerParams> | undefined, options?: Partial<Http.MakeOptions> | undefined) => RestResponse<import("./types.js").Sticker>;
|
|
34
|
+
createGuildTemplate: (guildId: string, params?: Partial<import("./types.js").CreateGuildTemplateParams> | undefined, options?: Partial<Http.MakeOptions> | undefined) => RestResponse<import("./types.js").GuildTemplate>;
|
|
35
|
+
createInteractionResponse: (interactionId: string, interactionToken: string, params?: Partial<import("./types.js").InteractionResponse> | undefined, options?: Partial<Http.MakeOptions> | undefined) => RestResponse<import("./types.js").InteractionResponse>;
|
|
36
|
+
createMessage: (channelId: string, params?: Partial<import("./types.js").CreateMessageParams> | undefined, options?: Partial<Http.MakeOptions> | undefined) => RestResponse<import("./types.js").Message>;
|
|
37
|
+
createReaction: (channelId: string, messageId: string, emoji: string, options?: Partial<Http.MakeOptions> | undefined) => RestResponse<any>;
|
|
38
|
+
createStageInstance: (params?: Partial<import("./types.js").CreateStageInstanceParams> | undefined, options?: Partial<Http.MakeOptions> | undefined) => RestResponse<import("./types.js").StageInstance>;
|
|
39
|
+
createWebhook: (channelId: string, params?: Partial<import("./types.js").CreateWebhookParams> | undefined, options?: Partial<Http.MakeOptions> | undefined) => RestResponse<import("./types.js").Webhook>;
|
|
40
|
+
crosspostMessage: (channelId: string, messageId: string, options?: Partial<Http.MakeOptions> | undefined) => RestResponse<import("./types.js").Message>;
|
|
41
|
+
deleteAllReactions: (channelId: string, messageId: string, options?: Partial<Http.MakeOptions> | undefined) => RestResponse<any>;
|
|
42
|
+
deleteAllReactionsForEmoji: (channelId: string, messageId: string, emoji: string, options?: Partial<Http.MakeOptions> | undefined) => RestResponse<any>;
|
|
43
|
+
deleteAutoModerationRule: (guildId: string, autoModerationRuleId: string, options?: Partial<Http.MakeOptions> | undefined) => RestResponse<any>;
|
|
44
|
+
deleteChannelPermission: (channelId: string, overwriteId: string, options?: Partial<Http.MakeOptions> | undefined) => RestResponse<any>;
|
|
45
|
+
deletecloseChannel: (channelId: string, options?: Partial<Http.MakeOptions> | undefined) => RestResponse<import("./types.js").Channel>;
|
|
46
|
+
deleteFollowupMessage: (applicationId: string, interactionToken: string, messageId: string, options?: Partial<Http.MakeOptions> | undefined) => RestResponse<any>;
|
|
47
|
+
deleteGlobalApplicationCommand: (applicationId: string, commandId: string, options?: Partial<Http.MakeOptions> | undefined) => RestResponse<any>;
|
|
48
|
+
deleteGuild: (guildId: string, options?: Partial<Http.MakeOptions> | undefined) => RestResponse<any>;
|
|
49
|
+
deleteGuildApplicationCommand: (applicationId: string, guildId: string, commandId: string, options?: Partial<Http.MakeOptions> | undefined) => RestResponse<any>;
|
|
50
|
+
deleteGuildEmoji: (guildId: string, emojiId: string, options?: Partial<Http.MakeOptions> | undefined) => RestResponse<any>;
|
|
51
|
+
deleteGuildIntegration: (guildId: string, integrationId: string, options?: Partial<Http.MakeOptions> | undefined) => RestResponse<any>;
|
|
52
|
+
deleteGuildRole: (guildId: string, roleId: string, options?: Partial<Http.MakeOptions> | undefined) => RestResponse<any>;
|
|
53
|
+
deleteGuildScheduledEvent: (guildId: string, guildScheduledEventId: string, options?: Partial<Http.MakeOptions> | undefined) => RestResponse<any>;
|
|
54
|
+
deleteGuildSticker: (guildId: string, stickerId: string, options?: Partial<Http.MakeOptions> | undefined) => RestResponse<any>;
|
|
55
|
+
deleteGuildTemplate: (guildId: string, templateCode: string, options?: Partial<Http.MakeOptions> | undefined) => RestResponse<import("./types.js").GuildTemplate>;
|
|
56
|
+
deleteInvite: (inviteCode: string, options?: Partial<Http.MakeOptions> | undefined) => RestResponse<import("./types.js").Invite>;
|
|
57
|
+
deleteMessage: (channelId: string, messageId: string, options?: Partial<Http.MakeOptions> | undefined) => RestResponse<any>;
|
|
58
|
+
deleteOriginalInteractionResponse: (applicationId: string, interactionToken: string, options?: Partial<Http.MakeOptions> | undefined) => RestResponse<any>;
|
|
59
|
+
deleteOwnReaction: (channelId: string, messageId: string, emoji: string, options?: Partial<Http.MakeOptions> | undefined) => RestResponse<any>;
|
|
60
|
+
deleteStageInstance: (channelId: string, options?: Partial<Http.MakeOptions> | undefined) => RestResponse<any>;
|
|
61
|
+
deleteUserReaction: (channelId: string, messageId: string, emoji: string, userId: string, options?: Partial<Http.MakeOptions> | undefined) => RestResponse<any>;
|
|
62
|
+
deleteWebhook: (webhookId: string, options?: Partial<Http.MakeOptions> | undefined) => RestResponse<any>;
|
|
63
|
+
deleteWebhookMessage: (webhookId: string, webhookToken: string, messageId: string, params?: Partial<import("./types.js").DeleteWebhookMessageParams> | undefined, options?: Partial<Http.MakeOptions> | undefined) => RestResponse<any>;
|
|
64
|
+
deleteWebhookWithToken: (webhookId: string, webhookToken: string, options?: Partial<Http.MakeOptions> | undefined) => RestResponse<any>;
|
|
65
|
+
editApplicationCommandPermissions: (applicationId: string, guildId: string, commandId: string, params?: Partial<import("./types.js").EditApplicationCommandPermissionParams> | undefined, options?: Partial<Http.MakeOptions> | undefined) => RestResponse<import("./types.js").GuildApplicationCommandPermission>;
|
|
66
|
+
editChannelPermissions: (channelId: string, overwriteId: string, params?: Partial<import("./types.js").EditChannelPermissionParams> | undefined, options?: Partial<Http.MakeOptions> | undefined) => RestResponse<any>;
|
|
67
|
+
editFollowupMessage: (applicationId: string, interactionToken: string, messageId: string, options?: Partial<Http.MakeOptions> | undefined) => RestResponse<any>;
|
|
68
|
+
editGlobalApplicationCommand: (applicationId: string, commandId: string, params?: Partial<import("./types.js").EditGlobalApplicationCommandParams> | undefined, options?: Partial<Http.MakeOptions> | undefined) => RestResponse<import("./types.js").ApplicationCommand>;
|
|
69
|
+
editGuildApplicationCommand: (applicationId: string, guildId: string, commandId: string, params?: Partial<import("./types.js").EditGuildApplicationCommandParams> | undefined, options?: Partial<Http.MakeOptions> | undefined) => RestResponse<import("./types.js").ApplicationCommand>;
|
|
70
|
+
editMessage: (channelId: string, messageId: string, params?: Partial<import("./types.js").EditMessageParams> | undefined, options?: Partial<Http.MakeOptions> | undefined) => RestResponse<import("./types.js").Message>;
|
|
71
|
+
editOriginalInteractionResponse: (applicationId: string, interactionToken: string, options?: Partial<Http.MakeOptions> | undefined) => RestResponse<any>;
|
|
72
|
+
editWebhookMessage: (webhookId: string, webhookToken: string, messageId: string, params?: Partial<import("./types.js").EditWebhookMessageParams> | undefined, options?: Partial<Http.MakeOptions> | undefined) => RestResponse<import("./types.js").Message>;
|
|
73
|
+
executeGitHubCompatibleWebhook: (webhookId: string, webhookToken: string, options?: Partial<Http.MakeOptions> | undefined) => RestResponse<any>;
|
|
74
|
+
executeSlackCompatibleWebhook: (webhookId: string, webhookToken: string, options?: Partial<Http.MakeOptions> | undefined) => RestResponse<any>;
|
|
75
|
+
executeWebhook: (webhookId: string, webhookToken: string, params?: Partial<import("./types.js").ExecuteWebhookParams> | undefined, options?: Partial<Http.MakeOptions> | undefined) => RestResponse<any>;
|
|
76
|
+
followAnnouncementChannel: (channelId: string, params?: Partial<import("./types.js").FollowAnnouncementChannelParams> | undefined, options?: Partial<Http.MakeOptions> | undefined) => RestResponse<import("./types.js").FollowedChannel>;
|
|
77
|
+
getApplicationCommandPermissions: (applicationId: string, guildId: string, commandId: string, options?: Partial<Http.MakeOptions> | undefined) => RestResponse<import("./types.js").GuildApplicationCommandPermission>;
|
|
78
|
+
getApplicationRoleConnectionMetadataRecords: (applicationId: string, options?: Partial<Http.MakeOptions> | undefined) => RestResponse<import("./types.js").ApplicationRoleConnectionMetadatum[]>;
|
|
79
|
+
getAutoModerationRule: (guildId: string, autoModerationRuleId: string, options?: Partial<Http.MakeOptions> | undefined) => RestResponse<import("./types.js").AutoModerationRule>;
|
|
80
|
+
getChannel: (channelId: string, options?: Partial<Http.MakeOptions> | undefined) => RestResponse<import("./types.js").Channel>;
|
|
81
|
+
getChannelInvites: (channelId: string, options?: Partial<Http.MakeOptions> | undefined) => RestResponse<import("./types.js").Invite[]>;
|
|
82
|
+
getChannelMessage: (channelId: string, messageId: string, options?: Partial<Http.MakeOptions> | undefined) => RestResponse<import("./types.js").Message>;
|
|
83
|
+
getChannelMessages: (channelId: string, params?: Partial<import("./types.js").GetChannelMessageParams> | undefined, options?: Partial<Http.MakeOptions> | undefined) => RestResponse<import("./types.js").Message[]>;
|
|
84
|
+
getChannelWebhooks: (channelId: string, options?: Partial<Http.MakeOptions> | undefined) => RestResponse<import("./types.js").Webhook[]>;
|
|
85
|
+
getCurrentAuthorizationInformation: (options?: Partial<Http.MakeOptions> | undefined) => RestResponse<import("./types.js").GetCurrentAuthorizationInformationResponse>;
|
|
86
|
+
getCurrentBotApplicationInformation: (options?: Partial<Http.MakeOptions> | undefined) => RestResponse<import("./types.js").Application>;
|
|
87
|
+
getCurrentUser: (options?: Partial<Http.MakeOptions> | undefined) => RestResponse<import("./types.js").User>;
|
|
88
|
+
getCurrentUserGuildMember: (guildId: string, options?: Partial<Http.MakeOptions> | undefined) => RestResponse<import("./types.js").GuildMember>;
|
|
89
|
+
getCurrentUserGuilds: (params?: Partial<import("./types.js").GetCurrentUserGuildParams> | undefined, options?: Partial<Http.MakeOptions> | undefined) => RestResponse<import("./types.js").Guild[]>;
|
|
90
|
+
getFollowupMessage: (applicationId: string, interactionToken: string, messageId: string, options?: Partial<Http.MakeOptions> | undefined) => RestResponse<any>;
|
|
91
|
+
getGateway: (options?: Partial<Http.MakeOptions> | undefined) => RestResponse<any>;
|
|
92
|
+
getGatewayBot: (options?: Partial<Http.MakeOptions> | undefined) => RestResponse<import("./types.js").GetGatewayBotResponse>;
|
|
93
|
+
getGlobalApplicationCommand: (applicationId: string, commandId: string, options?: Partial<Http.MakeOptions> | undefined) => RestResponse<import("./types.js").ApplicationCommand>;
|
|
94
|
+
getGlobalApplicationCommands: (applicationId: string, params?: Partial<import("./types.js").GetGlobalApplicationCommandParams> | undefined, options?: Partial<Http.MakeOptions> | undefined) => RestResponse<import("./types.js").ApplicationCommand[]>;
|
|
95
|
+
getGuild: (guildId: string, params?: Partial<import("./types.js").GetGuildParams> | undefined, options?: Partial<Http.MakeOptions> | undefined) => RestResponse<import("./types.js").Guild>;
|
|
96
|
+
getGuildApplicationCommand: (applicationId: string, guildId: string, commandId: string, options?: Partial<Http.MakeOptions> | undefined) => RestResponse<import("./types.js").ApplicationCommand>;
|
|
97
|
+
getGuildApplicationCommandPermissions: (applicationId: string, guildId: string, options?: Partial<Http.MakeOptions> | undefined) => RestResponse<import("./types.js").GuildApplicationCommandPermission[]>;
|
|
98
|
+
getGuildApplicationCommands: (applicationId: string, guildId: string, params?: Partial<import("./types.js").GetGuildApplicationCommandParams> | undefined, options?: Partial<Http.MakeOptions> | undefined) => RestResponse<import("./types.js").ApplicationCommand[]>;
|
|
99
|
+
getGuildAuditLog: (guildId: string, params?: Partial<import("./types.js").GetGuildAuditLogParams> | undefined, options?: Partial<Http.MakeOptions> | undefined) => RestResponse<import("./types.js").AuditLog>;
|
|
100
|
+
getGuildBan: (guildId: string, userId: string, options?: Partial<Http.MakeOptions> | undefined) => RestResponse<import("./types.js").Ban>;
|
|
101
|
+
getGuildBans: (guildId: string, params?: Partial<import("./types.js").GetGuildBanParams> | undefined, options?: Partial<Http.MakeOptions> | undefined) => RestResponse<import("./types.js").Ban[]>;
|
|
102
|
+
getGuildChannels: (guildId: string, options?: Partial<Http.MakeOptions> | undefined) => RestResponse<import("./types.js").Channel[]>;
|
|
103
|
+
getGuildEmoji: (guildId: string, emojiId: string, options?: Partial<Http.MakeOptions> | undefined) => RestResponse<import("./types.js").Emoji>;
|
|
104
|
+
getGuildIntegrations: (guildId: string, options?: Partial<Http.MakeOptions> | undefined) => RestResponse<import("./types.js").Integration[]>;
|
|
105
|
+
getGuildInvites: (guildId: string, options?: Partial<Http.MakeOptions> | undefined) => RestResponse<import("./types.js").Invite[]>;
|
|
106
|
+
getGuildMember: (guildId: string, userId: string, options?: Partial<Http.MakeOptions> | undefined) => RestResponse<import("./types.js").GuildMember>;
|
|
107
|
+
getGuildPreview: (guildId: string, options?: Partial<Http.MakeOptions> | undefined) => RestResponse<import("./types.js").GuildPreview>;
|
|
108
|
+
getGuildPruneCount: (guildId: string, params?: Partial<import("./types.js").GetGuildPruneCountParams> | undefined, options?: Partial<Http.MakeOptions> | undefined) => RestResponse<any>;
|
|
109
|
+
getGuildRoles: (guildId: string, options?: Partial<Http.MakeOptions> | undefined) => RestResponse<import("./types.js").Role[]>;
|
|
110
|
+
getGuildScheduledEvent: (guildId: string, guildScheduledEventId: string, params?: Partial<import("./types.js").GetGuildScheduledEventParams> | undefined, options?: Partial<Http.MakeOptions> | undefined) => RestResponse<import("./types.js").GuildScheduledEvent>;
|
|
111
|
+
getGuildScheduledEventUsers: (guildId: string, guildScheduledEventId: string, params?: Partial<import("./types.js").GetGuildScheduledEventUserParams> | undefined, options?: Partial<Http.MakeOptions> | undefined) => RestResponse<import("./types.js").GuildScheduledEventUser[]>;
|
|
112
|
+
getGuildSticker: (guildId: string, stickerId: string, options?: Partial<Http.MakeOptions> | undefined) => RestResponse<import("./types.js").Sticker>;
|
|
113
|
+
getGuildTemplate: (templateCode: string, options?: Partial<Http.MakeOptions> | undefined) => RestResponse<import("./types.js").GuildTemplate>;
|
|
114
|
+
getGuildTemplates: (guildId: string, options?: Partial<Http.MakeOptions> | undefined) => RestResponse<import("./types.js").GuildTemplate[]>;
|
|
115
|
+
getGuildVanityUrl: (guildId: string, options?: Partial<Http.MakeOptions> | undefined) => RestResponse<import("./types.js").Invite>;
|
|
116
|
+
getGuildVoiceRegions: (guildId: string, options?: Partial<Http.MakeOptions> | undefined) => RestResponse<import("./types.js").VoiceRegion[]>;
|
|
117
|
+
getGuildWebhooks: (guildId: string, options?: Partial<Http.MakeOptions> | undefined) => RestResponse<import("./types.js").Webhook[]>;
|
|
118
|
+
getGuildWelcomeScreen: (guildId: string, options?: Partial<Http.MakeOptions> | undefined) => RestResponse<import("./types.js").WelcomeScreen>;
|
|
119
|
+
getGuildWidget: (guildId: string, options?: Partial<Http.MakeOptions> | undefined) => RestResponse<import("./types.js").GuildWidget>;
|
|
120
|
+
getGuildWidgetImage: (guildId: string, params?: Partial<import("./types.js").GetGuildWidgetImageParams> | undefined, options?: Partial<Http.MakeOptions> | undefined) => RestResponse<any>;
|
|
121
|
+
getGuildWidgetSettings: (guildId: string, options?: Partial<Http.MakeOptions> | undefined) => RestResponse<import("./types.js").GuildWidgetSetting>;
|
|
122
|
+
getInvite: (inviteCode: string, params?: Partial<import("./types.js").GetInviteParams> | undefined, options?: Partial<Http.MakeOptions> | undefined) => RestResponse<import("./types.js").Invite>;
|
|
123
|
+
getOriginalInteractionResponse: (applicationId: string, interactionToken: string, options?: Partial<Http.MakeOptions> | undefined) => RestResponse<any>;
|
|
124
|
+
getPinnedMessages: (channelId: string, options?: Partial<Http.MakeOptions> | undefined) => RestResponse<import("./types.js").Message[]>;
|
|
125
|
+
getReactions: (channelId: string, messageId: string, emoji: string, params?: Partial<import("./types.js").GetReactionParams> | undefined, options?: Partial<Http.MakeOptions> | undefined) => RestResponse<import("./types.js").User[]>;
|
|
126
|
+
getStageInstance: (channelId: string, options?: Partial<Http.MakeOptions> | undefined) => RestResponse<any>;
|
|
127
|
+
getSticker: (stickerId: string, options?: Partial<Http.MakeOptions> | undefined) => RestResponse<import("./types.js").Sticker>;
|
|
128
|
+
getThreadMember: (channelId: string, userId: string, params?: Partial<import("./types.js").GetThreadMemberParams> | undefined, options?: Partial<Http.MakeOptions> | undefined) => RestResponse<import("./types.js").ThreadMember>;
|
|
129
|
+
getUser: (userId: string, options?: Partial<Http.MakeOptions> | undefined) => RestResponse<import("./types.js").User>;
|
|
130
|
+
getUserApplicationRoleConnection: (applicationId: string, options?: Partial<Http.MakeOptions> | undefined) => RestResponse<import("./types.js").ApplicationRoleConnection>;
|
|
131
|
+
getUserConnections: (options?: Partial<Http.MakeOptions> | undefined) => RestResponse<import("./types.js").Connection[]>;
|
|
132
|
+
getWebhook: (webhookId: string, options?: Partial<Http.MakeOptions> | undefined) => RestResponse<import("./types.js").Webhook>;
|
|
133
|
+
getWebhookMessage: (webhookId: string, webhookToken: string, messageId: string, params?: Partial<import("./types.js").GetWebhookMessageParams> | undefined, options?: Partial<Http.MakeOptions> | undefined) => RestResponse<import("./types.js").Message>;
|
|
134
|
+
getWebhookWithToken: (webhookId: string, webhookToken: string, options?: Partial<Http.MakeOptions> | undefined) => RestResponse<any>;
|
|
135
|
+
groupDmAddRecipient: (channelId: string, userId: string, params?: Partial<import("./types.js").GroupDmAddRecipientParams> | undefined, options?: Partial<Http.MakeOptions> | undefined) => RestResponse<any>;
|
|
136
|
+
groupDmRemoveRecipient: (channelId: string, userId: string, options?: Partial<Http.MakeOptions> | undefined) => RestResponse<any>;
|
|
137
|
+
joinThread: (channelId: string, options?: Partial<Http.MakeOptions> | undefined) => RestResponse<any>;
|
|
138
|
+
leaveGuild: (guildId: string, options?: Partial<Http.MakeOptions> | undefined) => RestResponse<any>;
|
|
139
|
+
leaveThread: (channelId: string, options?: Partial<Http.MakeOptions> | undefined) => RestResponse<any>;
|
|
140
|
+
listActiveGuildThreads: (guildId: string, options?: Partial<Http.MakeOptions> | undefined) => RestResponse<import("./types.js").ListActiveGuildThreadResponse>;
|
|
141
|
+
listAutoModerationRulesForGuild: (guildId: string, options?: Partial<Http.MakeOptions> | undefined) => RestResponse<import("./types.js").AutoModerationRule[]>;
|
|
142
|
+
listGuildEmojis: (guildId: string, options?: Partial<Http.MakeOptions> | undefined) => RestResponse<import("./types.js").Emoji[]>;
|
|
143
|
+
listGuildMembers: (guildId: string, params?: Partial<import("./types.js").ListGuildMemberParams> | undefined, options?: Partial<Http.MakeOptions> | undefined) => RestResponse<import("./types.js").GuildMember[]>;
|
|
144
|
+
listGuildStickers: (guildId: string, options?: Partial<Http.MakeOptions> | undefined) => RestResponse<import("./types.js").Sticker[]>;
|
|
145
|
+
listJoinedPrivateArchivedThreads: (channelId: string, params?: Partial<import("./types.js").ListJoinedPrivateArchivedThreadParams> | undefined, options?: Partial<Http.MakeOptions> | undefined) => RestResponse<import("./types.js").ListJoinedPrivateArchivedThreadResponse>;
|
|
146
|
+
listNitroStickerPacks: (options?: Partial<Http.MakeOptions> | undefined) => RestResponse<any>;
|
|
147
|
+
listPrivateArchivedThreads: (channelId: string, params?: Partial<import("./types.js").ListPrivateArchivedThreadParams> | undefined, options?: Partial<Http.MakeOptions> | undefined) => RestResponse<import("./types.js").ListPrivateArchivedThreadResponse>;
|
|
148
|
+
listPublicArchivedThreads: (channelId: string, params?: Partial<import("./types.js").ListPublicArchivedThreadParams> | undefined, options?: Partial<Http.MakeOptions> | undefined) => RestResponse<import("./types.js").ListPublicArchivedThreadResponse>;
|
|
149
|
+
listScheduledEventsForGuild: (guildId: string, params?: Partial<import("./types.js").ListScheduledEventsForGuildParams> | undefined, options?: Partial<Http.MakeOptions> | undefined) => RestResponse<import("./types.js").GuildScheduledEvent[]>;
|
|
150
|
+
listThreadMembers: (channelId: string, params?: Partial<import("./types.js").ListThreadMemberParams> | undefined, options?: Partial<Http.MakeOptions> | undefined) => RestResponse<import("./types.js").ThreadMember[]>;
|
|
151
|
+
listVoiceRegions: (options?: Partial<Http.MakeOptions> | undefined) => RestResponse<import("./types.js").VoiceRegion[]>;
|
|
152
|
+
modifyAutoModerationRule: (guildId: string, autoModerationRuleId: string, params?: Partial<import("./types.js").ModifyAutoModerationRuleParams> | undefined, options?: Partial<Http.MakeOptions> | undefined) => RestResponse<import("./types.js").AutoModerationRule>;
|
|
153
|
+
modifyChannel: (channelId: string, params?: Partial<import("./types.js").ModifyChannelParams> | undefined, options?: Partial<Http.MakeOptions> | undefined) => RestResponse<import("./types.js").Channel>;
|
|
154
|
+
modifyCurrentMember: (guildId: string, params?: Partial<import("./types.js").ModifyCurrentMemberParams> | undefined, options?: Partial<Http.MakeOptions> | undefined) => RestResponse<any>;
|
|
155
|
+
modifyCurrentUser: (params?: Partial<import("./types.js").ModifyCurrentUserParams> | undefined, options?: Partial<Http.MakeOptions> | undefined) => RestResponse<import("./types.js").User>;
|
|
156
|
+
modifyCurrentUserNick: (guildId: string, params?: Partial<import("./types.js").ModifyCurrentUserNickParams> | undefined, options?: Partial<Http.MakeOptions> | undefined) => RestResponse<any>;
|
|
157
|
+
modifyCurrentUserVoiceState: (guildId: string, params?: Partial<import("./types.js").ModifyCurrentUserVoiceStateParams> | undefined, options?: Partial<Http.MakeOptions> | undefined) => RestResponse<any>;
|
|
158
|
+
modifyGuild: (guildId: string, params?: Partial<import("./types.js").ModifyGuildParams> | undefined, options?: Partial<Http.MakeOptions> | undefined) => RestResponse<import("./types.js").Guild>;
|
|
159
|
+
modifyGuildChannelPositions: (guildId: string, params?: Partial<import("./types.js").ModifyGuildChannelPositionParams> | undefined, options?: Partial<Http.MakeOptions> | undefined) => RestResponse<any>;
|
|
160
|
+
modifyGuildEmoji: (guildId: string, emojiId: string, params?: Partial<import("./types.js").ModifyGuildEmojiParams> | undefined, options?: Partial<Http.MakeOptions> | undefined) => RestResponse<import("./types.js").Emoji>;
|
|
161
|
+
modifyGuildMember: (guildId: string, userId: string, params?: Partial<import("./types.js").ModifyGuildMemberParams> | undefined, options?: Partial<Http.MakeOptions> | undefined) => RestResponse<import("./types.js").GuildMember>;
|
|
162
|
+
modifyGuildMfaLevel: (guildId: string, params?: Partial<import("./types.js").ModifyGuildMfaLevelParams> | undefined, options?: Partial<Http.MakeOptions> | undefined) => RestResponse<import("./types.js").MfaLevel>;
|
|
163
|
+
modifyGuildRole: (guildId: string, roleId: string, params?: Partial<import("./types.js").ModifyGuildRoleParams> | undefined, options?: Partial<Http.MakeOptions> | undefined) => RestResponse<import("./types.js").Role>;
|
|
164
|
+
modifyGuildRolePositions: (guildId: string, params?: Partial<import("./types.js").ModifyGuildRolePositionParams> | undefined, options?: Partial<Http.MakeOptions> | undefined) => RestResponse<import("./types.js").Role[]>;
|
|
165
|
+
modifyGuildScheduledEvent: (guildId: string, guildScheduledEventId: string, params?: Partial<import("./types.js").ModifyGuildScheduledEventParams> | undefined, options?: Partial<Http.MakeOptions> | undefined) => RestResponse<import("./types.js").GuildScheduledEvent>;
|
|
166
|
+
modifyGuildSticker: (guildId: string, stickerId: string, params?: Partial<import("./types.js").ModifyGuildStickerParams> | undefined, options?: Partial<Http.MakeOptions> | undefined) => RestResponse<import("./types.js").Sticker>;
|
|
167
|
+
modifyGuildTemplate: (guildId: string, templateCode: string, params?: Partial<import("./types.js").ModifyGuildTemplateParams> | undefined, options?: Partial<Http.MakeOptions> | undefined) => RestResponse<import("./types.js").GuildTemplate>;
|
|
168
|
+
modifyGuildWelcomeScreen: (guildId: string, params?: Partial<import("./types.js").ModifyGuildWelcomeScreenParams> | undefined, options?: Partial<Http.MakeOptions> | undefined) => RestResponse<import("./types.js").WelcomeScreen>;
|
|
169
|
+
modifyGuildWidget: (guildId: string, options?: Partial<Http.MakeOptions> | undefined) => RestResponse<import("./types.js").GuildWidgetSetting>;
|
|
170
|
+
modifyStageInstance: (channelId: string, params?: Partial<import("./types.js").ModifyStageInstanceParams> | undefined, options?: Partial<Http.MakeOptions> | undefined) => RestResponse<import("./types.js").StageInstance>;
|
|
171
|
+
modifyUserVoiceState: (guildId: string, userId: string, params?: Partial<import("./types.js").ModifyUserVoiceStateParams> | undefined, options?: Partial<Http.MakeOptions> | undefined) => RestResponse<any>;
|
|
172
|
+
modifyWebhook: (webhookId: string, params?: Partial<import("./types.js").ModifyWebhookParams> | undefined, options?: Partial<Http.MakeOptions> | undefined) => RestResponse<import("./types.js").Webhook>;
|
|
173
|
+
modifyWebhookWithToken: (webhookId: string, webhookToken: string, options?: Partial<Http.MakeOptions> | undefined) => RestResponse<any>;
|
|
174
|
+
pinMessage: (channelId: string, messageId: string, options?: Partial<Http.MakeOptions> | undefined) => RestResponse<any>;
|
|
175
|
+
removeGuildBan: (guildId: string, userId: string, options?: Partial<Http.MakeOptions> | undefined) => RestResponse<any>;
|
|
176
|
+
removeGuildMember: (guildId: string, userId: string, options?: Partial<Http.MakeOptions> | undefined) => RestResponse<any>;
|
|
177
|
+
removeGuildMemberRole: (guildId: string, userId: string, roleId: string, options?: Partial<Http.MakeOptions> | undefined) => RestResponse<any>;
|
|
178
|
+
removeThreadMember: (channelId: string, userId: string, options?: Partial<Http.MakeOptions> | undefined) => RestResponse<any>;
|
|
179
|
+
searchGuildMembers: (guildId: string, params?: Partial<import("./types.js").SearchGuildMemberParams> | undefined, options?: Partial<Http.MakeOptions> | undefined) => RestResponse<import("./types.js").GuildMember[]>;
|
|
180
|
+
startThreadFromMessage: (channelId: string, messageId: string, params?: Partial<import("./types.js").StartThreadFromMessageParams> | undefined, options?: Partial<Http.MakeOptions> | undefined) => RestResponse<import("./types.js").Channel>;
|
|
181
|
+
startThreadInForumChannel: (channelId: string, params?: Partial<import("./types.js").StartThreadInForumChannelParams> | undefined, options?: Partial<Http.MakeOptions> | undefined) => RestResponse<import("./types.js").Channel>;
|
|
182
|
+
startThreadWithoutMessage: (channelId: string, params?: Partial<import("./types.js").StartThreadWithoutMessageParams> | undefined, options?: Partial<Http.MakeOptions> | undefined) => RestResponse<import("./types.js").Channel>;
|
|
183
|
+
syncGuildTemplate: (guildId: string, templateCode: string, options?: Partial<Http.MakeOptions> | undefined) => RestResponse<import("./types.js").GuildTemplate>;
|
|
184
|
+
triggerTypingIndicator: (channelId: string, options?: Partial<Http.MakeOptions> | undefined) => RestResponse<any>;
|
|
185
|
+
unpinMessage: (channelId: string, messageId: string, options?: Partial<Http.MakeOptions> | undefined) => RestResponse<any>;
|
|
186
|
+
updateApplicationRoleConnectionMetadataRecords: (applicationId: string, options?: Partial<Http.MakeOptions> | undefined) => RestResponse<import("./types.js").ApplicationRoleConnectionMetadatum[]>;
|
|
187
|
+
updateUserApplicationRoleConnection: (applicationId: string, params?: Partial<import("./types.js").UpdateUserApplicationRoleConnectionParams> | undefined, options?: Partial<Http.MakeOptions> | undefined) => RestResponse<import("./types.js").ApplicationRoleConnection>;
|
|
188
|
+
executor: <A = unknown>(request: Http.Request) => import("@effect-http/client/_common").Effect<never, DiscordRESTError, ResponseWithData<A>>;
|
|
189
|
+
}>;
|
|
190
|
+
export interface DiscordREST extends Effect.Success<typeof make> {
|
|
191
|
+
}
|
|
192
|
+
export declare const DiscordREST: import("@effect-http/client/_common").Tag<DiscordREST>;
|
|
193
|
+
export declare const LiveDiscordREST: import("./_common.js").Layer<import("./DiscordConfig.js").DiscordConfig | import("./Log.js").Log | import("./RateLimit.js").RateLimitStore | import("./RateLimit.js").RateLimiter, never, DiscordREST>;
|
|
194
|
+
export {};
|
package/DiscordREST.js
ADDED
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import * as tsplus_module_1 from "@effect-http/client/Request";
|
|
2
|
+
import * as tsplus_module_2 from "dfx/_common";
|
|
3
|
+
import * as tsplus_module_3 from "@effect/io/Effect";
|
|
4
|
+
import * as tsplus_module_4 from "@effect/data/Duration";
|
|
5
|
+
import * as tsplus_module_5 from "@fp-ts/core/Option";
|
|
6
|
+
import * as tsplus_module_6 from "@effect-http/client/Request/FetchExecutor";
|
|
7
|
+
import * as tsplus_module_7 from "@effect/io/Config/Secret";
|
|
8
|
+
import * as tsplus_module_8 from "@effect/data/HashSet";
|
|
9
|
+
import * as tsplus_module_9 from "@effect/io/Ref";
|
|
10
|
+
import * as tsplus_module_10 from "dfx";
|
|
11
|
+
import * as tsplus_module_11 from "@effect/io/Layer";
|
|
12
|
+
import { millis } from "@effect/data/Duration";
|
|
13
|
+
import Pkg from "../package.json" assert { type: "json" };
|
|
14
|
+
import { rateLimitFromHeaders, retryAfter, routeFromConfig, } from "./DiscordREST/utils.js";
|
|
15
|
+
import * as Http from "@effect-http/client";
|
|
16
|
+
export class DiscordRESTError {
|
|
17
|
+
error;
|
|
18
|
+
_tag = "DiscordRESTError";
|
|
19
|
+
constructor(error) {
|
|
20
|
+
this.error = error;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
const make = tsplus_module_3.flatMap(tsplus_module_3.service(tsplus_module_10.DiscordConfig.DiscordConfig), ({ token, rest }) => tsplus_module_3.flatMap(tsplus_module_3.service(tsplus_module_10.Log.Log), log => tsplus_module_3.flatMap(tsplus_module_3.service(tsplus_module_10.RateLimitStore), store => tsplus_module_3.flatMap(tsplus_module_3.service(tsplus_module_10.RateLimiter), ({ maybeWait }) => {
|
|
24
|
+
const globalRateLimit = maybeWait("dfx.rest.global", rest.globalRateLimit.window, rest.globalRateLimit.limit);
|
|
25
|
+
return tsplus_module_3.map(tsplus_module_9.make(tsplus_module_8.empty()), badRoutesRef => {
|
|
26
|
+
const addBadRoute = (route) => tsplus_module_3.collectAllParDiscard([
|
|
27
|
+
log.info("DiscordREST", "addBadRoute", route),
|
|
28
|
+
tsplus_module_9.update(badRoutesRef, s => tsplus_module_8.add(s, route)),
|
|
29
|
+
store.incrementCounter("dfx.rest.invalid", tsplus_module_4.minutes(10).millis, 10000),
|
|
30
|
+
]);
|
|
31
|
+
const isBadRoute = (route) => tsplus_module_3.map(tsplus_module_9.get(badRoutesRef), s => tsplus_module_8.has(s, route));
|
|
32
|
+
const removeBadRoute = (route) => tsplus_module_9.update(badRoutesRef, s => tsplus_module_8.remove(s, route));
|
|
33
|
+
const invalidRateLimit = (route) => tsplus_module_3.asUnit(tsplus_module_3.tap(isBadRoute(route), invalid => invalid
|
|
34
|
+
? maybeWait("dfx.rest.invalid", tsplus_module_4.minutes(10), 10000)
|
|
35
|
+
: tsplus_module_3.unit()));
|
|
36
|
+
// Request rate limiting
|
|
37
|
+
const requestRateLimit = (path, request) => (() => {
|
|
38
|
+
const route = routeFromConfig(path, request.method);
|
|
39
|
+
return tsplus_module_3.flatMap(store.getBucketForRoute(route), maybeBucket => {
|
|
40
|
+
const bucket = tsplus_module_5.getOrElse(maybeBucket, () => ({
|
|
41
|
+
key: `?.${route}`,
|
|
42
|
+
resetAfter: 5000,
|
|
43
|
+
limit: 1,
|
|
44
|
+
}));
|
|
45
|
+
const resetAfter = millis(bucket.resetAfter);
|
|
46
|
+
return tsplus_module_3.flatMap(invalidRateLimit(route), () => tsplus_module_3.map(maybeWait(`dfx.rest.${bucket.key}`, resetAfter, bucket.limit), () => void 0));
|
|
47
|
+
});
|
|
48
|
+
})();
|
|
49
|
+
// Update rate limit buckets
|
|
50
|
+
const updateBuckets = (request, response) => tsplus_module_3.ignore((() => {
|
|
51
|
+
const route = routeFromConfig(request.url, request.method);
|
|
52
|
+
return tsplus_module_3.flatMap(tsplus_module_3.fromOption(rateLimitFromHeaders(response.headers)), ({ bucket, retryAfter, limit, remaining }) => {
|
|
53
|
+
const effectsToRun = [
|
|
54
|
+
removeBadRoute(route),
|
|
55
|
+
store.putBucketRoute(route, bucket),
|
|
56
|
+
];
|
|
57
|
+
return tsplus_module_3.flatMap(store.hasBucket(bucket), hasBucket => {
|
|
58
|
+
if (!hasBucket || limit - 1 === remaining) {
|
|
59
|
+
effectsToRun.push(store.removeCounter(`dfx.rest.?.${route}`), store.putBucket({
|
|
60
|
+
key: bucket,
|
|
61
|
+
resetAfter: retryAfter.millis,
|
|
62
|
+
limit: !hasBucket && remaining > 0 ? remaining : limit,
|
|
63
|
+
}));
|
|
64
|
+
}
|
|
65
|
+
return tsplus_module_3.map(tsplus_module_3.collectAllParDiscard(effectsToRun), () => void 0);
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
})());
|
|
69
|
+
const executor = (request) => tsplus_module_3.catchTag(tsplus_module_3.flatMap(requestRateLimit(request.url, request), () => tsplus_module_3.flatMap(globalRateLimit, () => {
|
|
70
|
+
const requestWithCreds = tsplus_module_1.addHeaders({
|
|
71
|
+
Authorization: `Bot ${tsplus_module_7.value(token)}`,
|
|
72
|
+
"User-Agent": `DiscordBot (https://github.com/tim-smart/dfx, ${Pkg.version})`,
|
|
73
|
+
})(tsplus_module_1.updateUrl(_ => `${rest.baseUrl}${_}`)(request));
|
|
74
|
+
console.trace(requestWithCreds);
|
|
75
|
+
return tsplus_module_3.flatMap(tsplus_module_3.mapError(tsplus_module_6.fetch_()(requestWithCreds), _ => new DiscordRESTError(_)), response => tsplus_module_3.map(updateBuckets(request, response), () => response));
|
|
76
|
+
})), "DiscordRESTError", e => {
|
|
77
|
+
if (e.error._tag !== "StatusCodeError") {
|
|
78
|
+
return tsplus_module_3.fail(e);
|
|
79
|
+
}
|
|
80
|
+
const response = e.error.response;
|
|
81
|
+
switch (e.error.status) {
|
|
82
|
+
case 403:
|
|
83
|
+
return tsplus_module_3.flatMap(tsplus_module_3.collectAllParDiscard([
|
|
84
|
+
log.info("DiscordREST", "403", request.url),
|
|
85
|
+
addBadRoute(routeFromConfig(request.url, request.method)),
|
|
86
|
+
updateBuckets(request, response),
|
|
87
|
+
]), () => tsplus_module_3.fail(e));
|
|
88
|
+
case 429:
|
|
89
|
+
return tsplus_module_3.flatMap(tsplus_module_3.collectAllParDiscard([
|
|
90
|
+
log.info("DiscordREST", "429", request.url),
|
|
91
|
+
addBadRoute(routeFromConfig(request.url, request.method)),
|
|
92
|
+
updateBuckets(request, response),
|
|
93
|
+
tsplus_module_3.sleep(tsplus_module_5.getOrElse(retryAfter(response.headers), () => tsplus_module_4.seconds(5))),
|
|
94
|
+
]), () => executor(request));
|
|
95
|
+
}
|
|
96
|
+
return tsplus_module_3.fail(e);
|
|
97
|
+
});
|
|
98
|
+
const routes = tsplus_module_2.Discord.createRoutes(({ method, url, params, options = {}, }) => {
|
|
99
|
+
const hasBody = method !== "GET" && method !== "DELETE";
|
|
100
|
+
let request = Http.make(method)(url, options);
|
|
101
|
+
if (!hasBody) {
|
|
102
|
+
if (params) {
|
|
103
|
+
request = tsplus_module_1.appendParams(params)(request);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
else if (request.body._tag === "Some" &&
|
|
107
|
+
request.body.value._tag === "FormDataBody") {
|
|
108
|
+
request.body.value.value.append("payload_json", JSON.stringify(params));
|
|
109
|
+
}
|
|
110
|
+
else if (params) {
|
|
111
|
+
request = tsplus_module_1.json(params)(request);
|
|
112
|
+
}
|
|
113
|
+
return executor(request);
|
|
114
|
+
});
|
|
115
|
+
return { executor, ...routes };
|
|
116
|
+
});
|
|
117
|
+
}))));
|
|
118
|
+
export const DiscordREST = tsplus_module_2.Tag();
|
|
119
|
+
export const LiveDiscordREST = tsplus_module_11.effect(DiscordREST, make);
|
|
120
|
+
//# sourceMappingURL=DiscordREST.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DiscordREST.js","sourceRoot":"","sources":["../src/DiscordREST.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAA;AAC9C,OAAO,GAAG,MAAM,iBAAiB,CAAC,SAAS,IAAI,EAAE,MAAM,EAAE,CAAA;AAEzD,OAAO,EACL,oBAAoB,EACpB,UAAU,EACV,eAAe,GAChB,MAAM,wBAAwB,CAAA;AAC/B,OAAO,KAAK,IAAI,MAAM,qBAAqB,CAAA;AAE3C,MAAM,OAAO,gBAAgB;IAEN;IADZ,IAAI,GAAG,kBAAkB,CAAA;IAClC,YAAqB,KAA2B;QAA3B,UAAK,GAAL,KAAK,CAAsB;IAAG,CAAC;CACrD;AAED,MAAM,IAAI,2BACkB,wBAAe,iBAAA,aAAa,CAAC,aAAa,CAAC,GAA/D,EAAE,KAAK,EAAE,IAAI,EAAE,6BAEP,wBAAe,iBAAA,GAAG,CAAC,GAAG,CAAC,EAA/B,GAAG,4BACO,yCAAe,cAAc,CAAC,EAAxC,KAAK,4BACa,yCAAe,WAAW,CAAC,GAA7C,EAAE,SAAS,EAAE;IAEnB,MAAM,eAAe,GAAG,SAAS,CAC/B,iBAAiB,EACjB,IAAI,CAAC,eAAe,CAAC,MAAM,EAC3B,IAAI,CAAC,eAAe,CAAC,KAAK,CAC3B,CAAA;+BAGsB,qBAAS,uBAAuB,CAAC,EAAlD,YAAY;QAClB,MAAM,WAAW,GAAG,CAAC,KAAa,EAAE,EAAE,sCACpC;YACE,GAAG,CAAC,IAAI,CAAC,aAAa,EAAE,aAAa,EAAE,KAAK,CAAC;YAC7C,uBAAA,YAAY,EAAQ,CAAC,CAAC,EAAE,CAAC,oBAAA,CAAC,EAAK,KAAK,CAAC,CAAC;YACtC,KAAK,CAAC,gBAAgB,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;QACvB,CAAC,CAAC,CAAA;QAEJ,MAAM,MAAM,GAAG,gBAAA,OAAO,CAAC,YAAY,CACjC,CAAO,EACL,MAAM,EACN,GAAG,EACH,MAAM,EACN,OAAO,GAAG,EAAE,GACgC,EAAmB,EAAE;YACjE,MAAM,OAAO,GAAG,MAAM,KAAK,KAAK,IAAI,MAAM,KAAK,QAAQ,CAAA;YACvD,IAAI,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,MAAa,CAAC,CAAC,GAAG,EAAE,OAAO,CAAC,CAAA;YAEpD,IAAI,CAAC,OAAO,EAAE;gBACZ,IAAI,MAAM,EAAE;oBACV,OAAO,GAAG,6BAAqB,MAAa,EAAlC,OAAO,CAA4B,CAAA;iBAC9C;aACF;iBAAM,IACL,OAAO,CAAC,IAAI,CAAC,IAAI,KAAK,MAAM;gBAC5B,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,KAAK,cAAc,EAC1C;gBACA,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,cAAc,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAA;aACxE;iBAAM,IAAI,MAAM,EAAE;gBACjB,OAAO,GAAG,qBAAa,MAAM,EAAnB,OAAO,CAAa,CAAA;aAC/B;YAED,OAAO,QAAQ,CAAC,OAAO,CAAC,CAAA;QAC1B,CAAC,CACF,CAAA;QAED,OAAO,EAAE,QAAQ,EAAE,GAAG,MAAM,EAAE,CAAA;;KAC9B,CAAA;AAGF,MAAM,CAAC,MAAM,WAAW,GAAG,gBAAA,GAAG,EAAe,CAAA;AAC7C,MAAM,CAAC,MAAM,eAAe,GAAG,wBAAa,WAAW,EAAE,IAAI,CAAC,CAAA"}
|
package/Helpers/interactions.js
CHANGED
|
@@ -20,18 +20,18 @@ export const isSubCommand = (name) => tsplus_module_2.flow(findSubCommand(name),
|
|
|
20
20
|
/**
|
|
21
21
|
* Maybe get the options for a sub-command
|
|
22
22
|
*/
|
|
23
|
-
export const subCommandOptions = (name) => tsplus_module_2.flow(findSubCommand(name), o => tsplus_module_3.flatMapNullable(o => o.options)
|
|
23
|
+
export const subCommandOptions = (name) => tsplus_module_2.flow(findSubCommand(name), o => tsplus_module_3.flatMapNullable(o, o => o.options));
|
|
24
24
|
/**
|
|
25
25
|
* A lens for accessing nested options in a interaction.
|
|
26
26
|
*/
|
|
27
27
|
export const optionsWithNested = (data) => {
|
|
28
|
-
const optsFromOption = (opt) => tsplus_module_3.match(
|
|
29
|
-
return tsplus_module_3.getOrElse(
|
|
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
30
|
};
|
|
31
31
|
/**
|
|
32
32
|
* Return the interaction options as a name / value map.
|
|
33
33
|
*/
|
|
34
|
-
export const transformOptions = (options) => options.reduce((map, option) => tsplus_module_4.set(option.name, option.value)
|
|
34
|
+
export const transformOptions = (options) => options.reduce((map, option) => tsplus_module_4.set(map, option.name, option.value), tsplus_module_4.empty());
|
|
35
35
|
/**
|
|
36
36
|
* Return the interaction options as a name / value map.
|
|
37
37
|
*/
|
|
@@ -47,19 +47,19 @@ export const focusedOption = tsplus_module_2.flow(optionsWithNested, Arr.findFir
|
|
|
47
47
|
/**
|
|
48
48
|
* Try find a matching option value from the interaction.
|
|
49
49
|
*/
|
|
50
|
-
export const optionValue = (name) => tsplus_module_2.flow(getOption(name), o => tsplus_module_3.flatMapNullable(o => o.value)
|
|
50
|
+
export const optionValue = (name) => tsplus_module_2.flow(getOption(name), o => tsplus_module_3.flatMapNullable(o, o => o.value));
|
|
51
51
|
/**
|
|
52
52
|
* Try extract resolved data
|
|
53
53
|
*/
|
|
54
|
-
export const resolved = (data) => tsplus_module_3.flatMapNullable(
|
|
54
|
+
export const resolved = (data) => tsplus_module_3.flatMapNullable(tsplus_module_3.fromNullable(data.data), a => a.resolved);
|
|
55
55
|
/**
|
|
56
56
|
* Try find a matching option value from the interaction.
|
|
57
57
|
*/
|
|
58
|
-
export const resolveOptionValue = (name, f) => (a) => tsplus_module_3.flatMap(
|
|
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
59
|
/**
|
|
60
60
|
* Try find matching option values from the interaction.
|
|
61
61
|
*/
|
|
62
|
-
export const resolveValues = (f) => (a) => tsplus_module_3.flatMap(values => tsplus_module_3.flatMap(r => Product.productAll(values.map(a => tsplus_module_3.fromNullable(f(a, r)))))
|
|
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
63
|
const extractComponents = (c) => {
|
|
64
64
|
if ("components" in c) {
|
|
65
65
|
return [...c.components, ...c.components.flatMap(extractComponents)];
|
|
@@ -80,7 +80,7 @@ export const componentsWithValue = tsplus_module_2.flow(components, Arr.filter(c
|
|
|
80
80
|
/**
|
|
81
81
|
* Return the interaction components as an id / value map.
|
|
82
82
|
*/
|
|
83
|
-
export const transformComponents = (options) => options.reduce((map, c) => (c.custom_id ? tsplus_module_4.set(c.custom_id, c.value)
|
|
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
84
|
/**
|
|
85
85
|
* Return the interaction components as an id / value map.
|
|
86
86
|
*/
|
|
@@ -92,6 +92,6 @@ export const getComponent = (id) => tsplus_module_2.flow(components, Arr.findFir
|
|
|
92
92
|
/**
|
|
93
93
|
* Try find a matching component value from the interaction.
|
|
94
94
|
*/
|
|
95
|
-
export const componentValue = (id) => tsplus_module_2.flow(getComponent(id), o => tsplus_module_3.flatMapNullable(o => o.value)
|
|
95
|
+
export const componentValue = (id) => tsplus_module_2.flow(getComponent(id), o => tsplus_module_3.flatMapNullable(o, o => o.value));
|
|
96
96
|
export const response = (r) => r;
|
|
97
97
|
//# sourceMappingURL=interactions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interactions.js","sourceRoot":"","sources":["../../src/Helpers/interactions.ts"],"names":[],"mappings":";;;;AAAA,OAAO,EAAmB,OAAO,EAAE,MAAM,oBAAoB,CAAA;AAC7D,OAAO,KAAK,GAAG,MAAM,2BAA2B,CAAA;AAEhD;;GAEG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,WAA4C,EAAE,EAAE,CAC7E,gBAAA,IAAI,CACF,iBAAiB,CAAC,WAAW,CAAC,EAC9B,GAAG,CAAC,MAAM,CACR,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,6DAAqD,CACjE,CACF,CAAA;AAEH;;GAEG;AACH,MAAM,CAAC,MAAM,cAAc,GACzB,CAAC,IAAY,EAAE,EAAE,CAAC,CAAC,WAA4C,EAAE,EAAE,CACjE,gBAAA,IAAI,CACF,iBAAiB,CAAC,WAAW,CAAC,EAC9B,GAAG,CAAC,SAAS,CACX,CAAC,CAAC,EAAE,CACF,CAAC,CAAC,IAAI,6DAAqD;IAC3D,CAAC,CAAC,IAAI,KAAK,IAAI,CAClB,CACF,CAAA;AAEL;;GAEG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,IAAY,EAAE,EAAE,CAC3C,gBAAA,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,uBAAA,CAAC,CAA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AM,YAAY,GAAG,CAAC,EAAU,EAAE,EAAE,CACzC,gBAAA,IAAI,CACF,UAAU,EACV,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,CAAE,CAAuB,CAAC,SAAS,KAAK,EAAE,CAAC,CAC9D,CAAA;AAEH;;GAEG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,EAAU,EAAE,EAAE,CAC3C,gBAAA,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/permissions.d.ts
CHANGED
|
@@ -35,6 +35,6 @@ export declare const applyOverwrites: (permissions: bigint) => (overwrites: Disc
|
|
|
35
35
|
interface RolesCache<E> {
|
|
36
36
|
getForParent: (parentId: string) => Effect<never, E, ReadonlyMap<string, Discord.Role>>;
|
|
37
37
|
}
|
|
38
|
-
export declare const hasInChannel: <E>(rolesCache: RolesCache<E>, permission: bigint) => (channel: Discord.Channel, memberOrRole: Discord.GuildMember | Discord.Role) => import("
|
|
39
|
-
export declare const hasInGuild: <E>(rolesCache: RolesCache<E>, permission: bigint) => (guildId: Discord.Snowflake, member: Discord.GuildMember) => import("
|
|
38
|
+
export declare const hasInChannel: <E>(rolesCache: RolesCache<E>, permission: bigint) => (channel: Discord.Channel, memberOrRole: Discord.GuildMember | Discord.Role) => import("@effect-http/client/_common").Effect<never, E, boolean>;
|
|
39
|
+
export declare const hasInGuild: <E>(rolesCache: RolesCache<E>, permission: bigint) => (guildId: Discord.Snowflake, member: Discord.GuildMember) => import("@effect-http/client/_common").Effect<never, E, boolean>;
|
|
40
40
|
export {};
|
package/Helpers/permissions.js
CHANGED
|
@@ -68,15 +68,15 @@ export const forChannel = (roles) => ({ guild_id, permission_overwrites: overwri
|
|
|
68
68
|
* Apply permission overwrites to a bitfield.
|
|
69
69
|
*/
|
|
70
70
|
export const applyOverwrites = (permissions) => (overwrites) => overwrites.reduce((permissions, overwrite) => (permissions & ~BigInt(overwrite.deny)) | BigInt(overwrite.allow), permissions);
|
|
71
|
-
export const hasInChannel = (rolesCache, permission) => (channel, memberOrRole) => tsplus_module_4.map(roles => {
|
|
71
|
+
export const hasInChannel = (rolesCache, permission) => (channel, memberOrRole) => tsplus_module_4.map(rolesCache.getForParent(channel.guild_id), roles => {
|
|
72
72
|
const channelPerms = forChannel([...roles.values()])(channel)(memberOrRole);
|
|
73
73
|
return has(permission)(channelPerms);
|
|
74
|
-
})
|
|
75
|
-
export const hasInGuild = (rolesCache, permission) => (guildId, member) => tsplus_module_4.map(roles => {
|
|
74
|
+
});
|
|
75
|
+
export const hasInGuild = (rolesCache, permission) => (guildId, member) => tsplus_module_4.map(rolesCache.getForParent(guildId), roles => {
|
|
76
76
|
const hasPerm = has(permission);
|
|
77
77
|
return member.roles.some(id => {
|
|
78
78
|
const role = roles.get(id);
|
|
79
79
|
return role ? hasPerm(role.permissions) : false;
|
|
80
80
|
});
|
|
81
|
-
})
|
|
81
|
+
});
|
|
82
82
|
//# sourceMappingURL=permissions.js.map
|
|
@@ -1 +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,M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CACE,OAAwB,EACxB,YAAgD,EAChD,EAAE,qBAEgB,UAAU,CAAC,YAAY,CAAC,OAAO,CAAC,QAAS,CAAC,EAApD,KAAK;IACX,MAAM,YAAY,GAAG,UAAU,CAAC,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,CAC3D,YAAY,CACb,CAAA;IACD,OAAO,GAAG,CAAC,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"}
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { Discord } from "dfx/_common";
|
|
2
2
|
import { Effect, EffectTypeId } from "@effect/io/Effect";
|
|
3
|
-
export declare const InteractionContext: import("
|
|
4
|
-
export declare const ApplicationCommandContext: import("
|
|
5
|
-
export declare const MessageComponentContext: import("
|
|
6
|
-
export declare const ModalSubmitContext: import("
|
|
3
|
+
export declare const InteractionContext: import("@effect-http/client/_common").Tag<import("../types.js").Interaction>;
|
|
4
|
+
export declare const ApplicationCommandContext: import("@effect-http/client/_common").Tag<import("../types.js").ApplicationCommandDatum>;
|
|
5
|
+
export declare const MessageComponentContext: import("@effect-http/client/_common").Tag<import("../types.js").MessageComponentDatum>;
|
|
6
|
+
export declare const ModalSubmitContext: import("@effect-http/client/_common").Tag<import("../types.js").ModalSubmitDatum>;
|
|
7
7
|
export interface FocusedOptionContext {
|
|
8
8
|
readonly focusedOption: Discord.ApplicationCommandInteractionDataOption;
|
|
9
9
|
}
|
|
10
|
-
export declare const FocusedOptionContext: import("
|
|
10
|
+
export declare const FocusedOptionContext: import("@effect-http/client/_common").Tag<FocusedOptionContext>;
|
|
11
11
|
export interface SubCommandContext {
|
|
12
12
|
readonly command: Discord.ApplicationCommandInteractionDataOption;
|
|
13
13
|
}
|
|
14
|
-
export declare const SubCommandContext: import("
|
|
14
|
+
export declare const SubCommandContext: import("@effect-http/client/_common").Tag<SubCommandContext>;
|
|
15
15
|
export declare const interaction: Effect<import("../types.js").Interaction, never, import("../types.js").Interaction>;
|
|
16
16
|
export declare const command: Effect<import("../types.js").ApplicationCommandDatum, never, import("../types.js").ApplicationCommandDatum>;
|
|
17
17
|
export declare class ResolvedDataNotFound {
|
package/Interactions/context.js
CHANGED
|
@@ -22,8 +22,8 @@ export class ResolvedDataNotFound {
|
|
|
22
22
|
this.name = name;
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
|
-
export const resolvedValues = (f) => tsplus_module_2.serviceWithEffect(InteractionContext, a => tsplus_module_4.match(() => tsplus_module_2.fail(new ResolvedDataNotFound(a)), tsplus_module_2.succeed)
|
|
26
|
-
export const resolved = (name, f) => tsplus_module_2.serviceWithEffect(InteractionContext, a => tsplus_module_4.match(() => tsplus_module_2.fail(new ResolvedDataNotFound(a, name)), tsplus_module_2.succeed)
|
|
25
|
+
export const resolvedValues = (f) => tsplus_module_2.serviceWithEffect(InteractionContext, a => tsplus_module_4.match(tsplus_module_3.IxHelpers.resolveValues(f)(a), () => tsplus_module_2.fail(new ResolvedDataNotFound(a)), tsplus_module_2.succeed));
|
|
26
|
+
export const resolved = (name, f) => tsplus_module_2.serviceWithEffect(InteractionContext, a => tsplus_module_4.match(tsplus_module_3.IxHelpers.resolveOptionValue(name, f)(a), () => tsplus_module_2.fail(new ResolvedDataNotFound(a, name)), tsplus_module_2.succeed));
|
|
27
27
|
export const focusedOptionValue = tsplus_module_2.serviceWith(FocusedOptionContext, a => a.focusedOption.value ?? "");
|
|
28
28
|
export class SubCommandNotFound {
|
|
29
29
|
data;
|
|
@@ -32,9 +32,9 @@ export class SubCommandNotFound {
|
|
|
32
32
|
this.data = data;
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
|
-
export const handleSubCommands = (commands) => tsplus_module_2.flatMap(data => tsplus_module_5.pipe(tsplus_module_3.IxHelpers.allSubCommands(data), Arr.findFirst(a => !!commands[a.name]), o => tsplus_module_4.toEither(
|
|
35
|
+
export const handleSubCommands = (commands) => tsplus_module_2.flatMap(tsplus_module_2.service(ApplicationCommandContext), data => tsplus_module_5.pipe(tsplus_module_3.IxHelpers.allSubCommands(data), Arr.findFirst(a => !!commands[a.name]), o => tsplus_module_4.toEither(() => new SubCommandNotFound(data))(o), tsplus_module_2.fromEither, a => tsplus_module_2.flatMap(a, command => tsplus_module_2.provideService(commands[command.name], SubCommandContext, {
|
|
36
36
|
command,
|
|
37
|
-
})
|
|
37
|
+
}))));
|
|
38
38
|
export const currentSubCommand = tsplus_module_2.serviceWith(SubCommandContext, a => a.command);
|
|
39
39
|
export const optionsMap = tsplus_module_2.serviceWith(ApplicationCommandContext, tsplus_module_3.IxHelpers.optionsMap);
|
|
40
40
|
export class RequiredOptionNotFound {
|
|
@@ -47,7 +47,7 @@ export class RequiredOptionNotFound {
|
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
49
|
export const option = (name) => tsplus_module_2.serviceWith(ApplicationCommandContext, tsplus_module_3.IxHelpers.getOption(name));
|
|
50
|
-
export const optionValue = (name) => tsplus_module_2.flatMap(o => tsplus_module_4.match(() => tsplus_module_2.flatMap(data => tsplus_module_2.fail(new RequiredOptionNotFound(data, name)))
|
|
51
|
-
export const optionValueOptional = (name) => tsplus_module_2.map(o => tsplus_module_4.flatMapNullable(a => a.value)
|
|
50
|
+
export const optionValue = (name) => tsplus_module_2.flatMap(option(name), o => tsplus_module_4.match(tsplus_module_4.flatMapNullable(o, a => a.value), () => tsplus_module_2.flatMap(command, data => tsplus_module_2.fail(new RequiredOptionNotFound(data, name))), tsplus_module_2.succeed));
|
|
51
|
+
export const optionValueOptional = (name) => tsplus_module_2.map(option(name), o => tsplus_module_4.flatMapNullable(o, a => a.value));
|
|
52
52
|
export const modalValues = tsplus_module_2.serviceWith(ModalSubmitContext, tsplus_module_3.IxHelpers.componentsMap);
|
|
53
53
|
//# sourceMappingURL=context.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../src/Interactions/context.ts"],"names":[],"mappings":";;;;;AAAA,OAAO,KAAK,GAAG,MAAM,2BAA2B,CAAA;AAChD,OAAO,EAAU,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAExD,MAAM,CAAC,MAAM,kBAAkB,GAAG,gBAAA,GAAG,EAAuB,CAAA;AAC5D,MAAM,CAAC,MAAM,yBAAyB,GAAG,gBAAA,GAAG,EAAmC,CAAA;AAC/E,MAAM,CAAC,MAAM,uBAAuB,GAAG,gBAAA,GAAG,EAAiC,CAAA;AAC3E,MAAM,CAAC,MAAM,kBAAkB,GAAG,gBAAA,GAAG,EAA4B,CAAA;AAKjE,MAAM,CAAC,MAAM,oBAAoB,GAAG,gBAAA,GAAG,EAAwB,CAAA;AAK/D,MAAM,CAAC,MAAM,iBAAiB,GAAG,gBAAA,GAAG,EAAqB,CAAA;AAEzD,MAAM,CAAC,MAAM,WAAW,GAAG,wBAAe,kBAAkB,CAAC,CAAA;AAE7D,MAAM,CAAC,MAAM,OAAO,GAAG,wBAAe,yBAAyB,CAAC,CAAA;AAEhE,MAAM,OAAO,oBAAoB;IAEV;IAAoC;IADhD,IAAI,GAAG,sBAAsB,CAAA;IACtC,YAAqB,IAAyB,EAAW,IAAa;QAAjD,SAAI,GAAJ,I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