dfx 0.18.1 → 0.19.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/index.d.ts +19 -19
- package/Cache/index.js +14 -14
- package/Cache/index.js.map +1 -1
- package/Cache/prelude.d.ts +29 -12
- package/Cache/prelude.js +104 -18
- package/Cache/prelude.js.map +1 -1
- package/DiscordGateway/DiscordWS/index.d.ts +1 -1
- package/DiscordGateway/Shard/index.d.ts +1 -1
- package/DiscordGateway/Shard/index.js +1 -1
- package/DiscordGateway/Shard/index.js.map +1 -1
- package/DiscordGateway/Sharder/index.d.ts +14 -6
- package/DiscordGateway/Sharder/index.js +48 -47
- package/DiscordGateway/Sharder/index.js.map +1 -1
- package/DiscordGateway/index.d.ts +3 -11
- package/DiscordGateway/index.js +3 -7
- package/DiscordGateway/index.js.map +1 -1
- package/DiscordREST/index.d.ts +178 -6
- package/DiscordREST/index.js +61 -61
- package/DiscordREST/index.js.map +1 -1
- package/DiscordREST/types.d.ts +4 -5
- package/Helpers/permissions.d.ts +6 -0
- package/Helpers/permissions.js +5 -0
- package/Helpers/permissions.js.map +1 -1
- package/Http/index.d.ts +14 -7
- package/Http/index.js +17 -10
- package/Http/index.js.map +1 -1
- package/Interactions/gateway.d.ts +2 -2
- package/Interactions/gateway.js +7 -7
- package/Interactions/gateway.js.map +1 -1
- package/Interactions/index.d.ts +5 -3
- package/Interactions/index.js +17 -10
- package/Interactions/index.js.map +1 -1
- package/RateLimit/index.d.ts +0 -1
- package/RateLimit/index.js +0 -1
- package/RateLimit/index.js.map +1 -1
- package/RateLimit/memory.d.ts +2 -2
- package/RateLimit/memory.js.map +1 -1
- package/gateway.d.ts +6 -6
- package/gateway.js +10 -6
- package/gateway.js.map +1 -1
- package/global.d.ts +1 -1
- package/index.d.ts +3 -3
- package/index.js +3 -3
- package/index.js.map +1 -1
- package/package.json +2 -2
- package/webhooks.d.ts +3 -3
- package/webhooks.js +4 -3
- package/webhooks.js.map +1 -1
- package/Cache/gateway.d.ts +0 -22
- package/Cache/gateway.js +0 -99
- package/Cache/gateway.js.map +0 -1
package/DiscordGateway/index.js
CHANGED
|
@@ -7,23 +7,19 @@ import * as tsplus_module_6 from "callbag-effect-ts/Source/share";
|
|
|
7
7
|
import * as tsplus_module_7 from "@effect/io/Effect";
|
|
8
8
|
import * as tsplus_module_8 from "@fp-ts/data/Context";
|
|
9
9
|
import * as tsplus_module_9 from "@effect/io/Layer";
|
|
10
|
-
import
|
|
11
|
-
import { spawn } from "./Sharder/index.js";
|
|
10
|
+
import { Sharder } from "./Sharder/index.js";
|
|
12
11
|
const fromDispatchFactory = (source) => (event) => tsplus_module_2.map((p) => p.d)(tsplus_module_1.filter((p) => p.t === event)(source));
|
|
13
12
|
const handleDispatchFactory = (source) => (event, handle) => tsplus_module_5.runDrain(tsplus_module_4.chainPar((a) => tsplus_module_3.fromEffect(handle(a.d)))(tsplus_module_1.filter((p) => p.t === event)(source)));
|
|
14
|
-
export const make = tsplus_module_7.flatMap(
|
|
13
|
+
export const make = tsplus_module_7.flatMap(sharder => tsplus_module_7.flatMap(raw => tsplus_module_7.map(dispatch => {
|
|
15
14
|
const fromDispatch = fromDispatchFactory(dispatch);
|
|
16
15
|
const handleDispatch = handleDispatchFactory(dispatch);
|
|
17
16
|
return {
|
|
18
|
-
shards,
|
|
19
17
|
raw,
|
|
20
18
|
dispatch,
|
|
21
19
|
fromDispatch,
|
|
22
20
|
handleDispatch,
|
|
23
21
|
};
|
|
24
|
-
})(tsplus_module_6.share(tsplus_module_4.chainPar((s) => s.dispatch)(shards))))(tsplus_module_6.share(tsplus_module_4.chainPar((s) => s.raw)(shards))))(
|
|
22
|
+
})(tsplus_module_6.share(tsplus_module_4.chainPar((s) => s.dispatch)(sharder.shards))))(tsplus_module_6.share(tsplus_module_4.chainPar((s) => s.raw)(sharder.shards))))(tsplus_module_7.service(Sharder));
|
|
25
23
|
export const DiscordGateway = tsplus_module_8.Tag();
|
|
26
24
|
export const LiveDiscordGateway = tsplus_module_9.fromEffect(DiscordGateway)(make);
|
|
27
|
-
export const fromDispatch = (event) => tsplus_module_10.unwrap(tsplus_module_7.serviceWith(DiscordGateway)((a) => a.fromDispatch(event)));
|
|
28
|
-
export const handleDispatch = (event, handle) => tsplus_module_7.serviceWithEffect(DiscordGateway)((a) => a.handleDispatch(event, handle));
|
|
29
25
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/DiscordGateway/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/DiscordGateway/index.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAA;AAE5C,MAAM,mBAAmB,GACvB,CACE,MAAwE,EACxE,EAAE,CACJ,CACE,KAAQ,EACsC,EAAE,CAChD,oBAAwC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAS,EAA1D,uBAAc,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,KAAK,KAAK,EAAlC,MAAM,CAA6B,CAAwB,CAAA;AAE/D,MAAM,qBAAqB,GACzB,CACE,MAAwE,EACxE,EAAE,CACJ,CACE,KAAQ,EACR,MAA8D,EAChC,EAAE,0BAChC,yBAEY,CAAC,CAAC,EAAE,EAAE,CAAC,2BAAwB,MAAM,CAAC,CAAC,CAAC,CAAQ,CAAC,CAAC,EAF9D,uBACU,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,KAAK,KAAK,EAD9B,MAAM,CACyB,CACgC,CAAS,CAAA;AAE5E,MAAM,CAAC,MAAM,IAAI,2BACT,OAAO,4BACP,GAAG,wBACH,QAAQ;IACd,MAAM,YAAY,GAAG,mBAAmB,CAAC,QAAQ,CAAC,CAAA;IAClD,MAAM,cAAc,GAAG,qBAAqB,CAAC,QAAQ,CAAC,CAAA;IAEtD,OAAO;QACL,GAAG;QACH,QAAQ;QACR,YAAY;QACZ,cAAc;KACf,CAAA;yBATkB,yBAAwB,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,EAAzC,OAAO,CAAC,MAAM,CAA4B,0BAD/C,yBAAwB,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,EAApC,OAAO,CAAC,MAAM,CAAuB,IADjC,wBAAe,OAAO,CAAC,CAYzC,CAAA;AAGF,MAAM,CAAC,MAAM,cAAc,GAAG,gBAAA,GAAG,EAAkB,CAAA;AACnD,MAAM,CAAC,MAAM,kBAAkB,GAAG,2BAAiB,cAAc,CAAC,CAAC,IAAI,CAAC,CAAA"}
|
package/DiscordREST/index.d.ts
CHANGED
|
@@ -1,13 +1,185 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { BucketDetails, FetchError, StatusCodeError, JsonParseError, Discord } from "dfx";
|
|
2
2
|
import { Effect } from "@effect/io/Effect";
|
|
3
3
|
import { Success } from "dfx/utils/effect";
|
|
4
|
-
import { ResponseWithData } from "./types.js";
|
|
5
|
-
declare const make: import("../global.js").Effect<import("../Log/index.js").Log | import("../
|
|
6
|
-
|
|
4
|
+
import { ResponseWithData, RestResponse } from "./types.js";
|
|
5
|
+
declare const make: import("../global.js").Effect<import("../Log/index.js").Log | import("../DiscordConfig/index.js").DiscordConfig | import("../index.js").Http | import("../index.js").RateLimitStore | import("../index.js").RateLimiter, never, {
|
|
6
|
+
addGuildMember: (guildId: string, userId: string, params?: Partial<import("../types.js").AddGuildMemberParams> | undefined, options?: RequestInit | undefined) => RestResponse<import("../types.js").GuildMember>;
|
|
7
|
+
addGuildMemberRole: (guildId: string, userId: string, roleId: string, options?: RequestInit | undefined) => RestResponse<any>;
|
|
8
|
+
addThreadMember: (channelId: string, userId: string, options?: RequestInit | undefined) => RestResponse<any>;
|
|
9
|
+
batchEditApplicationCommandPermissions: (applicationId: string, guildId: string, options?: RequestInit | undefined) => RestResponse<any>;
|
|
10
|
+
beginGuildPrune: (guildId: string, params?: Partial<import("../types.js").BeginGuildPruneParams> | undefined, options?: RequestInit | undefined) => RestResponse<any>;
|
|
11
|
+
bulkDeleteMessages: (channelId: string, params?: Partial<import("../types.js").BulkDeleteMessageParams> | undefined, options?: RequestInit | undefined) => RestResponse<any>;
|
|
12
|
+
bulkOverwriteGlobalApplicationCommands: (applicationId: string, options?: RequestInit | undefined) => RestResponse<import("../types.js").ApplicationCommand[]>;
|
|
13
|
+
bulkOverwriteGuildApplicationCommands: (applicationId: string, guildId: string, params?: Partial<import("../types.js").BulkOverwriteGuildApplicationCommandParams> | undefined, options?: RequestInit | undefined) => RestResponse<import("../types.js").ApplicationCommand[]>;
|
|
14
|
+
createAutoModerationRule: (guildId: string, params?: Partial<import("../types.js").CreateAutoModerationRuleParams> | undefined, options?: RequestInit | undefined) => RestResponse<import("../types.js").AutoModerationRule>;
|
|
15
|
+
createChannelInvite: (channelId: string, params?: Partial<import("../types.js").CreateChannelInviteParams> | undefined, options?: RequestInit | undefined) => RestResponse<import("../types.js").Invite>;
|
|
16
|
+
createDm: (params?: Partial<import("../types.js").CreateDmParams> | undefined, options?: RequestInit | undefined) => RestResponse<import("../types.js").Channel>;
|
|
17
|
+
createFollowupMessage: (applicationId: string, interactionToken: string, options?: RequestInit | undefined) => RestResponse<any>;
|
|
18
|
+
createGlobalApplicationCommand: (applicationId: string, params?: Partial<import("../types.js").CreateGlobalApplicationCommandParams> | undefined, options?: RequestInit | undefined) => RestResponse<import("../types.js").ApplicationCommand>;
|
|
19
|
+
createGroupDm: (params?: Partial<import("../types.js").CreateGroupDmParams> | undefined, options?: RequestInit | undefined) => RestResponse<import("../types.js").Channel>;
|
|
20
|
+
createGuild: (params?: Partial<import("../types.js").CreateGuildParams> | undefined, options?: RequestInit | undefined) => RestResponse<import("../types.js").Guild>;
|
|
21
|
+
createGuildApplicationCommand: (applicationId: string, guildId: string, params?: Partial<import("../types.js").CreateGuildApplicationCommandParams> | undefined, options?: RequestInit | undefined) => RestResponse<import("../types.js").ApplicationCommand>;
|
|
22
|
+
createGuildBan: (guildId: string, userId: string, params?: Partial<import("../types.js").CreateGuildBanParams> | undefined, options?: RequestInit | undefined) => RestResponse<any>;
|
|
23
|
+
createGuildChannel: (guildId: string, params?: Partial<import("../types.js").CreateGuildChannelParams> | undefined, options?: RequestInit | undefined) => RestResponse<import("../types.js").Channel>;
|
|
24
|
+
createGuildEmoji: (guildId: string, params?: Partial<import("../types.js").CreateGuildEmojiParams> | undefined, options?: RequestInit | undefined) => RestResponse<import("../types.js").Emoji>;
|
|
25
|
+
createGuildFromGuildTemplate: (templateCode: string, params?: Partial<import("../types.js").CreateGuildFromGuildTemplateParams> | undefined, options?: RequestInit | undefined) => RestResponse<import("../types.js").Guild>;
|
|
26
|
+
createGuildRole: (guildId: string, params?: Partial<import("../types.js").CreateGuildRoleParams> | undefined, options?: RequestInit | undefined) => RestResponse<import("../types.js").Role>;
|
|
27
|
+
createGuildScheduledEvent: (guildId: string, params?: Partial<import("../types.js").CreateGuildScheduledEventParams> | undefined, options?: RequestInit | undefined) => RestResponse<import("../types.js").GuildScheduledEvent>;
|
|
28
|
+
createGuildSticker: (guildId: string, params?: Partial<import("../types.js").CreateGuildStickerParams> | undefined, options?: RequestInit | undefined) => RestResponse<import("../types.js").Sticker>;
|
|
29
|
+
createGuildTemplate: (guildId: string, params?: Partial<import("../types.js").CreateGuildTemplateParams> | undefined, options?: RequestInit | undefined) => RestResponse<import("../types.js").GuildTemplate>;
|
|
30
|
+
createInteractionResponse: (interactionId: string, interactionToken: string, params?: Partial<import("../types.js").InteractionResponse> | undefined, options?: RequestInit | undefined) => RestResponse<import("../types.js").InteractionResponse>;
|
|
31
|
+
createMessage: (channelId: string, params?: Partial<import("../types.js").CreateMessageParams> | undefined, options?: RequestInit | undefined) => RestResponse<import("../types.js").Message>;
|
|
32
|
+
createReaction: (channelId: string, messageId: string, emoji: string, options?: RequestInit | undefined) => RestResponse<any>;
|
|
33
|
+
createStageInstance: (params?: Partial<import("../types.js").CreateStageInstanceParams> | undefined, options?: RequestInit | undefined) => RestResponse<import("../types.js").StageInstance>;
|
|
34
|
+
createWebhook: (channelId: string, params?: Partial<import("../types.js").CreateWebhookParams> | undefined, options?: RequestInit | undefined) => RestResponse<import("../types.js").Webhook>;
|
|
35
|
+
crosspostMessage: (channelId: string, messageId: string, options?: RequestInit | undefined) => RestResponse<import("../types.js").Message>;
|
|
36
|
+
deleteAllReactions: (channelId: string, messageId: string, options?: RequestInit | undefined) => RestResponse<any>;
|
|
37
|
+
deleteAllReactionsForEmoji: (channelId: string, messageId: string, emoji: string, options?: RequestInit | undefined) => RestResponse<any>;
|
|
38
|
+
deleteAutoModerationRule: (guildId: string, autoModerationRuleId: string, options?: RequestInit | undefined) => RestResponse<any>;
|
|
39
|
+
deleteChannelPermission: (channelId: string, overwriteId: string, options?: RequestInit | undefined) => RestResponse<any>;
|
|
40
|
+
deletecloseChannel: (channelId: string, options?: RequestInit | undefined) => RestResponse<import("../types.js").Channel>;
|
|
41
|
+
deleteFollowupMessage: (applicationId: string, interactionToken: string, messageId: string, options?: RequestInit | undefined) => RestResponse<any>;
|
|
42
|
+
deleteGlobalApplicationCommand: (applicationId: string, commandId: string, options?: RequestInit | undefined) => RestResponse<any>;
|
|
43
|
+
deleteGuild: (guildId: string, options?: RequestInit | undefined) => RestResponse<any>;
|
|
44
|
+
deleteGuildApplicationCommand: (applicationId: string, guildId: string, commandId: string, options?: RequestInit | undefined) => RestResponse<any>;
|
|
45
|
+
deleteGuildEmoji: (guildId: string, emojiId: string, options?: RequestInit | undefined) => RestResponse<any>;
|
|
46
|
+
deleteGuildIntegration: (guildId: string, integrationId: string, options?: RequestInit | undefined) => RestResponse<any>;
|
|
47
|
+
deleteGuildRole: (guildId: string, roleId: string, options?: RequestInit | undefined) => RestResponse<any>;
|
|
48
|
+
deleteGuildScheduledEvent: (guildId: string, guildScheduledEventId: string, options?: RequestInit | undefined) => RestResponse<any>;
|
|
49
|
+
deleteGuildSticker: (guildId: string, stickerId: string, options?: RequestInit | undefined) => RestResponse<any>;
|
|
50
|
+
deleteGuildTemplate: (guildId: string, templateCode: string, options?: RequestInit | undefined) => RestResponse<import("../types.js").GuildTemplate>;
|
|
51
|
+
deleteInvite: (inviteCode: string, options?: RequestInit | undefined) => RestResponse<import("../types.js").Invite>;
|
|
52
|
+
deleteMessage: (channelId: string, messageId: string, options?: RequestInit | undefined) => RestResponse<any>;
|
|
53
|
+
deleteOriginalInteractionResponse: (applicationId: string, interactionToken: string, options?: RequestInit | undefined) => RestResponse<any>;
|
|
54
|
+
deleteOwnReaction: (channelId: string, messageId: string, emoji: string, options?: RequestInit | undefined) => RestResponse<any>;
|
|
55
|
+
deleteStageInstance: (channelId: string, options?: RequestInit | undefined) => RestResponse<any>;
|
|
56
|
+
deleteUserReaction: (channelId: string, messageId: string, emoji: string, userId: string, options?: RequestInit | undefined) => RestResponse<any>;
|
|
57
|
+
deleteWebhook: (webhookId: string, options?: RequestInit | undefined) => RestResponse<any>;
|
|
58
|
+
deleteWebhookMessage: (webhookId: string, webhookToken: string, messageId: string, params?: Partial<import("../types.js").DeleteWebhookMessageParams> | undefined, options?: RequestInit | undefined) => RestResponse<any>;
|
|
59
|
+
deleteWebhookWithToken: (webhookId: string, webhookToken: string, options?: RequestInit | undefined) => RestResponse<any>;
|
|
60
|
+
editApplicationCommandPermissions: (applicationId: string, guildId: string, commandId: string, params?: Partial<import("../types.js").EditApplicationCommandPermissionParams> | undefined, options?: RequestInit | undefined) => RestResponse<import("../types.js").GuildApplicationCommandPermission>;
|
|
61
|
+
editChannelPermissions: (channelId: string, overwriteId: string, params?: Partial<import("../types.js").EditChannelPermissionParams> | undefined, options?: RequestInit | undefined) => RestResponse<any>;
|
|
62
|
+
editFollowupMessage: (applicationId: string, interactionToken: string, messageId: string, options?: RequestInit | undefined) => RestResponse<any>;
|
|
63
|
+
editGlobalApplicationCommand: (applicationId: string, commandId: string, params?: Partial<import("../types.js").EditGlobalApplicationCommandParams> | undefined, options?: RequestInit | undefined) => RestResponse<import("../types.js").ApplicationCommand>;
|
|
64
|
+
editGuildApplicationCommand: (applicationId: string, guildId: string, commandId: string, params?: Partial<import("../types.js").EditGuildApplicationCommandParams> | undefined, options?: RequestInit | undefined) => RestResponse<import("../types.js").ApplicationCommand>;
|
|
65
|
+
editMessage: (channelId: string, messageId: string, params?: Partial<import("../types.js").EditMessageParams> | undefined, options?: RequestInit | undefined) => RestResponse<import("../types.js").Message>;
|
|
66
|
+
editOriginalInteractionResponse: (applicationId: string, interactionToken: string, options?: RequestInit | undefined) => RestResponse<any>;
|
|
67
|
+
editWebhookMessage: (webhookId: string, webhookToken: string, messageId: string, params?: Partial<import("../types.js").EditWebhookMessageParams> | undefined, options?: RequestInit | undefined) => RestResponse<import("../types.js").Message>;
|
|
68
|
+
executeGitHubCompatibleWebhook: (webhookId: string, webhookToken: string, options?: RequestInit | undefined) => RestResponse<any>;
|
|
69
|
+
executeSlackCompatibleWebhook: (webhookId: string, webhookToken: string, options?: RequestInit | undefined) => RestResponse<any>;
|
|
70
|
+
executeWebhook: (webhookId: string, webhookToken: string, params?: Partial<import("../types.js").ExecuteWebhookParams> | undefined, options?: RequestInit | undefined) => RestResponse<any>;
|
|
71
|
+
followAnnouncementChannel: (channelId: string, params?: Partial<import("../types.js").FollowAnnouncementChannelParams> | undefined, options?: RequestInit | undefined) => RestResponse<import("../types.js").FollowedChannel>;
|
|
72
|
+
getApplicationCommandPermissions: (applicationId: string, guildId: string, commandId: string, options?: RequestInit | undefined) => RestResponse<import("../types.js").GuildApplicationCommandPermission>;
|
|
73
|
+
getAutoModerationRule: (guildId: string, autoModerationRuleId: string, options?: RequestInit | undefined) => RestResponse<import("../types.js").AutoModerationRule>;
|
|
74
|
+
getChannel: (channelId: string, options?: RequestInit | undefined) => RestResponse<import("../types.js").Channel>;
|
|
75
|
+
getChannelInvites: (channelId: string, options?: RequestInit | undefined) => RestResponse<import("../types.js").Invite[]>;
|
|
76
|
+
getChannelMessage: (channelId: string, messageId: string, options?: RequestInit | undefined) => RestResponse<import("../types.js").Message>;
|
|
77
|
+
getChannelMessages: (channelId: string, params?: Partial<import("../types.js").GetChannelMessageParams> | undefined, options?: RequestInit | undefined) => RestResponse<import("../types.js").Message[]>;
|
|
78
|
+
getChannelWebhooks: (channelId: string, options?: RequestInit | undefined) => RestResponse<import("../types.js").Webhook[]>;
|
|
79
|
+
getCurrentAuthorizationInformation: (options?: RequestInit | undefined) => RestResponse<import("../types.js").GetCurrentAuthorizationInformationResponse>;
|
|
80
|
+
getCurrentBotApplicationInformation: (options?: RequestInit | undefined) => RestResponse<import("../types.js").Application>;
|
|
81
|
+
getCurrentUser: (options?: RequestInit | undefined) => RestResponse<import("../types.js").User>;
|
|
82
|
+
getCurrentUserGuildMember: (guildId: string, options?: RequestInit | undefined) => RestResponse<import("../types.js").GuildMember>;
|
|
83
|
+
getCurrentUserGuilds: (params?: Partial<import("../types.js").GetCurrentUserGuildParams> | undefined, options?: RequestInit | undefined) => RestResponse<import("../types.js").Guild[]>;
|
|
84
|
+
getFollowupMessage: (applicationId: string, interactionToken: string, messageId: string, options?: RequestInit | undefined) => RestResponse<any>;
|
|
85
|
+
getGateway: (options?: RequestInit | undefined) => RestResponse<any>;
|
|
86
|
+
getGatewayBot: (options?: RequestInit | undefined) => RestResponse<import("../types.js").GetGatewayBotResponse>;
|
|
87
|
+
getGlobalApplicationCommand: (applicationId: string, commandId: string, options?: RequestInit | undefined) => RestResponse<import("../types.js").ApplicationCommand>;
|
|
88
|
+
getGlobalApplicationCommands: (applicationId: string, params?: Partial<import("../types.js").GetGlobalApplicationCommandParams> | undefined, options?: RequestInit | undefined) => RestResponse<import("../types.js").ApplicationCommand[]>;
|
|
89
|
+
getGuild: (guildId: string, params?: Partial<import("../types.js").GetGuildParams> | undefined, options?: RequestInit | undefined) => RestResponse<import("../types.js").Guild>;
|
|
90
|
+
getGuildApplicationCommand: (applicationId: string, guildId: string, commandId: string, options?: RequestInit | undefined) => RestResponse<import("../types.js").ApplicationCommand>;
|
|
91
|
+
getGuildApplicationCommandPermissions: (applicationId: string, guildId: string, options?: RequestInit | undefined) => RestResponse<import("../types.js").GuildApplicationCommandPermission[]>;
|
|
92
|
+
getGuildApplicationCommands: (applicationId: string, guildId: string, params?: Partial<import("../types.js").GetGuildApplicationCommandParams> | undefined, options?: RequestInit | undefined) => RestResponse<import("../types.js").ApplicationCommand[]>;
|
|
93
|
+
getGuildAuditLog: (guildId: string, params?: Partial<import("../types.js").GetGuildAuditLogParams> | undefined, options?: RequestInit | undefined) => RestResponse<import("../types.js").AuditLog>;
|
|
94
|
+
getGuildBan: (guildId: string, userId: string, options?: RequestInit | undefined) => RestResponse<import("../types.js").Ban>;
|
|
95
|
+
getGuildBans: (guildId: string, params?: Partial<import("../types.js").GetGuildBanParams> | undefined, options?: RequestInit | undefined) => RestResponse<import("../types.js").Ban[]>;
|
|
96
|
+
getGuildChannels: (guildId: string, options?: RequestInit | undefined) => RestResponse<import("../types.js").Channel[]>;
|
|
97
|
+
getGuildEmoji: (guildId: string, emojiId: string, options?: RequestInit | undefined) => RestResponse<import("../types.js").Emoji>;
|
|
98
|
+
getGuildIntegrations: (guildId: string, options?: RequestInit | undefined) => RestResponse<import("../types.js").Integration[]>;
|
|
99
|
+
getGuildInvites: (guildId: string, options?: RequestInit | undefined) => RestResponse<import("../types.js").Invite[]>;
|
|
100
|
+
getGuildMember: (guildId: string, userId: string, options?: RequestInit | undefined) => RestResponse<import("../types.js").GuildMember>;
|
|
101
|
+
getGuildPreview: (guildId: string, options?: RequestInit | undefined) => RestResponse<import("../types.js").GuildPreview>;
|
|
102
|
+
getGuildPruneCount: (guildId: string, params?: Partial<import("../types.js").GetGuildPruneCountParams> | undefined, options?: RequestInit | undefined) => RestResponse<any>;
|
|
103
|
+
getGuildRoles: (guildId: string, options?: RequestInit | undefined) => RestResponse<import("../types.js").Role[]>;
|
|
104
|
+
getGuildScheduledEvent: (guildId: string, guildScheduledEventId: string, params?: Partial<import("../types.js").GetGuildScheduledEventParams> | undefined, options?: RequestInit | undefined) => RestResponse<import("../types.js").GuildScheduledEvent>;
|
|
105
|
+
getGuildScheduledEventUsers: (guildId: string, guildScheduledEventId: string, params?: Partial<import("../types.js").GetGuildScheduledEventUserParams> | undefined, options?: RequestInit | undefined) => RestResponse<import("../types.js").GuildScheduledEventUser[]>;
|
|
106
|
+
getGuildSticker: (guildId: string, stickerId: string, options?: RequestInit | undefined) => RestResponse<import("../types.js").Sticker>;
|
|
107
|
+
getGuildTemplate: (templateCode: string, options?: RequestInit | undefined) => RestResponse<import("../types.js").GuildTemplate>;
|
|
108
|
+
getGuildTemplates: (guildId: string, options?: RequestInit | undefined) => RestResponse<import("../types.js").GuildTemplate[]>;
|
|
109
|
+
getGuildVanityUrl: (guildId: string, options?: RequestInit | undefined) => RestResponse<import("../types.js").Invite>;
|
|
110
|
+
getGuildVoiceRegions: (guildId: string, options?: RequestInit | undefined) => RestResponse<import("../types.js").VoiceRegion[]>;
|
|
111
|
+
getGuildWebhooks: (guildId: string, options?: RequestInit | undefined) => RestResponse<import("../types.js").Webhook[]>;
|
|
112
|
+
getGuildWelcomeScreen: (guildId: string, options?: RequestInit | undefined) => RestResponse<import("../types.js").WelcomeScreen>;
|
|
113
|
+
getGuildWidget: (guildId: string, options?: RequestInit | undefined) => RestResponse<import("../types.js").GuildWidget>;
|
|
114
|
+
getGuildWidgetImage: (guildId: string, params?: Partial<import("../types.js").GetGuildWidgetImageParams> | undefined, options?: RequestInit | undefined) => RestResponse<any>;
|
|
115
|
+
getGuildWidgetSettings: (guildId: string, options?: RequestInit | undefined) => RestResponse<import("../types.js").GuildWidgetSetting>;
|
|
116
|
+
getInvite: (inviteCode: string, params?: Partial<import("../types.js").GetInviteParams> | undefined, options?: RequestInit | undefined) => RestResponse<import("../types.js").Invite>;
|
|
117
|
+
getOriginalInteractionResponse: (applicationId: string, interactionToken: string, options?: RequestInit | undefined) => RestResponse<any>;
|
|
118
|
+
getPinnedMessages: (channelId: string, options?: RequestInit | undefined) => RestResponse<import("../types.js").Message[]>;
|
|
119
|
+
getReactions: (channelId: string, messageId: string, emoji: string, params?: Partial<import("../types.js").GetReactionParams> | undefined, options?: RequestInit | undefined) => RestResponse<import("../types.js").User[]>;
|
|
120
|
+
getStageInstance: (channelId: string, options?: RequestInit | undefined) => RestResponse<any>;
|
|
121
|
+
getSticker: (stickerId: string, options?: RequestInit | undefined) => RestResponse<import("../types.js").Sticker>;
|
|
122
|
+
getThreadMember: (channelId: string, userId: string, options?: RequestInit | undefined) => RestResponse<import("../types.js").ThreadMember>;
|
|
123
|
+
getUser: (userId: string, options?: RequestInit | undefined) => RestResponse<import("../types.js").User>;
|
|
124
|
+
getUserConnections: (options?: RequestInit | undefined) => RestResponse<import("../types.js").Connection[]>;
|
|
125
|
+
getWebhook: (webhookId: string, options?: RequestInit | undefined) => RestResponse<import("../types.js").Webhook>;
|
|
126
|
+
getWebhookMessage: (webhookId: string, webhookToken: string, messageId: string, params?: Partial<import("../types.js").GetWebhookMessageParams> | undefined, options?: RequestInit | undefined) => RestResponse<import("../types.js").Message>;
|
|
127
|
+
getWebhookWithToken: (webhookId: string, webhookToken: string, options?: RequestInit | undefined) => RestResponse<any>;
|
|
128
|
+
groupDmAddRecipient: (channelId: string, userId: string, params?: Partial<import("../types.js").GroupDmAddRecipientParams> | undefined, options?: RequestInit | undefined) => RestResponse<any>;
|
|
129
|
+
groupDmRemoveRecipient: (channelId: string, userId: string, options?: RequestInit | undefined) => RestResponse<any>;
|
|
130
|
+
joinThread: (channelId: string, options?: RequestInit | undefined) => RestResponse<any>;
|
|
131
|
+
leaveGuild: (guildId: string, options?: RequestInit | undefined) => RestResponse<any>;
|
|
132
|
+
leaveThread: (channelId: string, options?: RequestInit | undefined) => RestResponse<any>;
|
|
133
|
+
listActiveGuildThreads: (guildId: string, options?: RequestInit | undefined) => RestResponse<import("../types.js").ListActiveGuildThreadResponse>;
|
|
134
|
+
listAutoModerationRulesForGuild: (guildId: string, options?: RequestInit | undefined) => RestResponse<import("../types.js").AutoModerationRule[]>;
|
|
135
|
+
listGuildEmojis: (guildId: string, options?: RequestInit | undefined) => RestResponse<import("../types.js").Emoji[]>;
|
|
136
|
+
listGuildMembers: (guildId: string, params?: Partial<import("../types.js").ListGuildMemberParams> | undefined, options?: RequestInit | undefined) => RestResponse<import("../types.js").GuildMember[]>;
|
|
137
|
+
listGuildStickers: (guildId: string, options?: RequestInit | undefined) => RestResponse<import("../types.js").Sticker[]>;
|
|
138
|
+
listJoinedPrivateArchivedThreads: (channelId: string, params?: Partial<import("../types.js").ListJoinedPrivateArchivedThreadParams> | undefined, options?: RequestInit | undefined) => RestResponse<import("../types.js").ListJoinedPrivateArchivedThreadResponse>;
|
|
139
|
+
listNitroStickerPacks: (options?: RequestInit | undefined) => RestResponse<any>;
|
|
140
|
+
listPrivateArchivedThreads: (channelId: string, params?: Partial<import("../types.js").ListPrivateArchivedThreadParams> | undefined, options?: RequestInit | undefined) => RestResponse<import("../types.js").ListPrivateArchivedThreadResponse>;
|
|
141
|
+
listPublicArchivedThreads: (channelId: string, params?: Partial<import("../types.js").ListPublicArchivedThreadParams> | undefined, options?: RequestInit | undefined) => RestResponse<import("../types.js").ListPublicArchivedThreadResponse>;
|
|
142
|
+
listScheduledEventsForGuild: (guildId: string, params?: Partial<import("../types.js").ListScheduledEventsForGuildParams> | undefined, options?: RequestInit | undefined) => RestResponse<import("../types.js").GuildScheduledEvent[]>;
|
|
143
|
+
listThreadMembers: (channelId: string, options?: RequestInit | undefined) => RestResponse<import("../types.js").ThreadMember[]>;
|
|
144
|
+
listVoiceRegions: (options?: RequestInit | undefined) => RestResponse<import("../types.js").VoiceRegion[]>;
|
|
145
|
+
modifyAutoModerationRule: (guildId: string, autoModerationRuleId: string, params?: Partial<import("../types.js").ModifyAutoModerationRuleParams> | undefined, options?: RequestInit | undefined) => RestResponse<import("../types.js").AutoModerationRule>;
|
|
146
|
+
modifyChannel: (channelId: string, params?: Partial<import("../types.js").ModifyChannelParams> | undefined, options?: RequestInit | undefined) => RestResponse<import("../types.js").Channel>;
|
|
147
|
+
modifyCurrentMember: (guildId: string, params?: Partial<import("../types.js").ModifyCurrentMemberParams> | undefined, options?: RequestInit | undefined) => RestResponse<any>;
|
|
148
|
+
modifyCurrentUser: (params?: Partial<import("../types.js").ModifyCurrentUserParams> | undefined, options?: RequestInit | undefined) => RestResponse<import("../types.js").User>;
|
|
149
|
+
modifyCurrentUserNick: (guildId: string, params?: Partial<import("../types.js").ModifyCurrentUserNickParams> | undefined, options?: RequestInit | undefined) => RestResponse<any>;
|
|
150
|
+
modifyCurrentUserVoiceState: (guildId: string, params?: Partial<import("../types.js").ModifyCurrentUserVoiceStateParams> | undefined, options?: RequestInit | undefined) => RestResponse<any>;
|
|
151
|
+
modifyGuild: (guildId: string, params?: Partial<import("../types.js").ModifyGuildParams> | undefined, options?: RequestInit | undefined) => RestResponse<import("../types.js").Guild>;
|
|
152
|
+
modifyGuildChannelPositions: (guildId: string, params?: Partial<import("../types.js").ModifyGuildChannelPositionParams> | undefined, options?: RequestInit | undefined) => RestResponse<any>;
|
|
153
|
+
modifyGuildEmoji: (guildId: string, emojiId: string, params?: Partial<import("../types.js").ModifyGuildEmojiParams> | undefined, options?: RequestInit | undefined) => RestResponse<import("../types.js").Emoji>;
|
|
154
|
+
modifyGuildMember: (guildId: string, userId: string, params?: Partial<import("../types.js").ModifyGuildMemberParams> | undefined, options?: RequestInit | undefined) => RestResponse<import("../types.js").GuildMember>;
|
|
155
|
+
modifyGuildMfaLevel: (guildId: string, params?: Partial<import("../types.js").ModifyGuildMfaLevelParams> | undefined, options?: RequestInit | undefined) => RestResponse<import("../types.js").MfaLevel>;
|
|
156
|
+
modifyGuildRole: (guildId: string, roleId: string, params?: Partial<import("../types.js").ModifyGuildRoleParams> | undefined, options?: RequestInit | undefined) => RestResponse<import("../types.js").Role>;
|
|
157
|
+
modifyGuildRolePositions: (guildId: string, params?: Partial<import("../types.js").ModifyGuildRolePositionParams> | undefined, options?: RequestInit | undefined) => RestResponse<import("../types.js").Role[]>;
|
|
158
|
+
modifyGuildScheduledEvent: (guildId: string, guildScheduledEventId: string, params?: Partial<import("../types.js").ModifyGuildScheduledEventParams> | undefined, options?: RequestInit | undefined) => RestResponse<import("../types.js").GuildScheduledEvent>;
|
|
159
|
+
modifyGuildSticker: (guildId: string, stickerId: string, params?: Partial<import("../types.js").ModifyGuildStickerParams> | undefined, options?: RequestInit | undefined) => RestResponse<import("../types.js").Sticker>;
|
|
160
|
+
modifyGuildTemplate: (guildId: string, templateCode: string, params?: Partial<import("../types.js").ModifyGuildTemplateParams> | undefined, options?: RequestInit | undefined) => RestResponse<import("../types.js").GuildTemplate>;
|
|
161
|
+
modifyGuildWelcomeScreen: (guildId: string, params?: Partial<import("../types.js").ModifyGuildWelcomeScreenParams> | undefined, options?: RequestInit | undefined) => RestResponse<import("../types.js").WelcomeScreen>;
|
|
162
|
+
modifyGuildWidget: (guildId: string, options?: RequestInit | undefined) => RestResponse<import("../types.js").GuildWidgetSetting>;
|
|
163
|
+
modifyStageInstance: (channelId: string, params?: Partial<import("../types.js").ModifyStageInstanceParams> | undefined, options?: RequestInit | undefined) => RestResponse<import("../types.js").StageInstance>;
|
|
164
|
+
modifyUserVoiceState: (guildId: string, userId: string, params?: Partial<import("../types.js").ModifyUserVoiceStateParams> | undefined, options?: RequestInit | undefined) => RestResponse<any>;
|
|
165
|
+
modifyWebhook: (webhookId: string, params?: Partial<import("../types.js").ModifyWebhookParams> | undefined, options?: RequestInit | undefined) => RestResponse<import("../types.js").Webhook>;
|
|
166
|
+
modifyWebhookWithToken: (webhookId: string, webhookToken: string, options?: RequestInit | undefined) => RestResponse<any>;
|
|
167
|
+
pinMessage: (channelId: string, messageId: string, options?: RequestInit | undefined) => RestResponse<any>;
|
|
168
|
+
removeGuildBan: (guildId: string, userId: string, options?: RequestInit | undefined) => RestResponse<any>;
|
|
169
|
+
removeGuildMember: (guildId: string, userId: string, options?: RequestInit | undefined) => RestResponse<any>;
|
|
170
|
+
removeGuildMemberRole: (guildId: string, userId: string, roleId: string, options?: RequestInit | undefined) => RestResponse<any>;
|
|
171
|
+
removeThreadMember: (channelId: string, userId: string, options?: RequestInit | undefined) => RestResponse<any>;
|
|
172
|
+
searchGuildMembers: (guildId: string, params?: Partial<import("../types.js").SearchGuildMemberParams> | undefined, options?: RequestInit | undefined) => RestResponse<import("../types.js").GuildMember[]>;
|
|
173
|
+
startThreadFromMessage: (channelId: string, messageId: string, params?: Partial<import("../types.js").StartThreadFromMessageParams> | undefined, options?: RequestInit | undefined) => RestResponse<import("../types.js").Channel>;
|
|
174
|
+
startThreadInForumChannel: (channelId: string, params?: Partial<import("../types.js").StartThreadInForumChannelParams> | undefined, options?: RequestInit | undefined) => RestResponse<import("../types.js").Channel>;
|
|
175
|
+
startThreadWithoutMessage: (channelId: string, params?: Partial<import("../types.js").StartThreadWithoutMessageParams> | undefined, options?: RequestInit | undefined) => RestResponse<import("../types.js").Channel>;
|
|
176
|
+
syncGuildTemplate: (guildId: string, templateCode: string, options?: RequestInit | undefined) => RestResponse<import("../types.js").GuildTemplate>;
|
|
177
|
+
triggerTypingIndicator: (channelId: string, options?: RequestInit | undefined) => RestResponse<any>;
|
|
178
|
+
unpinMessage: (channelId: string, messageId: string, options?: RequestInit | undefined) => RestResponse<any>;
|
|
179
|
+
request: <A = unknown>(path: string, init?: RequestInit) => import("../global.js").Effect<never, import("../index.js").FetchError | import("../index.js").StatusCodeError | import("../index.js").JsonParseError, ResponseWithData<A>>;
|
|
7
180
|
}>;
|
|
8
181
|
export interface DiscordREST extends Success<typeof make> {
|
|
9
182
|
}
|
|
10
183
|
export declare const DiscordREST: import("../global.js").Tag<DiscordREST>;
|
|
11
|
-
export declare const LiveDiscordREST: import("../global.js").Layer<import("../Log/index.js").Log | import("../
|
|
12
|
-
export declare const rest: import("../types.js").Endpoints<RequestInit>;
|
|
184
|
+
export declare const LiveDiscordREST: import("../global.js").Layer<import("../Log/index.js").Log | import("../DiscordConfig/index.js").DiscordConfig | import("../index.js").Http | import("../index.js").RateLimitStore | import("../index.js").RateLimiter, never, DiscordREST>;
|
|
13
185
|
export {};
|
package/DiscordREST/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import * as tsplus_module_1 from "
|
|
2
|
-
import * as tsplus_module_2 from "@
|
|
3
|
-
import * as tsplus_module_3 from "@fp-ts/data/
|
|
4
|
-
import * as tsplus_module_4 from "
|
|
1
|
+
import * as tsplus_module_1 from "dfx";
|
|
2
|
+
import * as tsplus_module_2 from "@effect/io/Effect";
|
|
3
|
+
import * as tsplus_module_3 from "@fp-ts/data/Duration";
|
|
4
|
+
import * as tsplus_module_4 from "@fp-ts/data/Option";
|
|
5
5
|
import * as tsplus_module_5 from "@fp-ts/data/HashSet";
|
|
6
6
|
import * as tsplus_module_6 from "@effect/io/Ref";
|
|
7
7
|
import * as tsplus_module_7 from "@fp-ts/data/Context";
|
|
@@ -9,41 +9,41 @@ import * as tsplus_module_8 from "@effect/io/Layer";
|
|
|
9
9
|
import { millis } from "@fp-ts/data/Duration";
|
|
10
10
|
import { rateLimitFromHeaders, routeFromConfig, retryAfter } from "./utils.js";
|
|
11
11
|
import Pkg from "../package.json" assert { type: "json" };
|
|
12
|
-
const make =
|
|
12
|
+
const make = tsplus_module_2.flatMap(http => tsplus_module_2.flatMap(({ token, rest }) => tsplus_module_2.flatMap(log => tsplus_module_2.flatMap(store => tsplus_module_2.flatMap(({ maybeWait }) => {
|
|
13
13
|
const globalRateLimit = maybeWait("dfx.rest.global", rest.globalRateLimit.window, rest.globalRateLimit.limit);
|
|
14
|
-
return
|
|
15
|
-
const addBadRoute = (route) =>
|
|
14
|
+
return tsplus_module_2.map(badRoutesRef => {
|
|
15
|
+
const addBadRoute = (route) => tsplus_module_2.collectAllParDiscard([
|
|
16
16
|
log.info("DiscordREST", "addBadRoute", route),
|
|
17
17
|
tsplus_module_6.update((s) => tsplus_module_5.add(route)(s))(badRoutesRef),
|
|
18
|
-
store.incrementCounter("dfx.rest.invalid",
|
|
18
|
+
store.incrementCounter("dfx.rest.invalid", tsplus_module_3.minutes(10).millis, 10000),
|
|
19
19
|
]);
|
|
20
|
-
const isBadRoute = (route) =>
|
|
20
|
+
const isBadRoute = (route) => tsplus_module_2.map((s) => tsplus_module_5.has(route)(s))(tsplus_module_6.get(badRoutesRef));
|
|
21
21
|
const removeBadRoute = (route) => tsplus_module_6.update((s) => tsplus_module_5.remove(route)(s))(badRoutesRef);
|
|
22
|
-
const invalidRateLimit = (route) =>
|
|
23
|
-
? maybeWait("dfx.rest.invalid",
|
|
24
|
-
:
|
|
22
|
+
const invalidRateLimit = (route) => tsplus_module_2.asUnit(tsplus_module_2.tap((invalid) => invalid
|
|
23
|
+
? maybeWait("dfx.rest.invalid", tsplus_module_3.minutes(10), 10000)
|
|
24
|
+
: tsplus_module_2.unit())(isBadRoute(route)));
|
|
25
25
|
// Request rate limiting
|
|
26
26
|
const requestRateLimit = (path, init) => (() => {
|
|
27
27
|
const route = routeFromConfig(path, init);
|
|
28
|
-
return
|
|
29
|
-
const bucket =
|
|
28
|
+
return tsplus_module_2.flatMap(maybeBucket => {
|
|
29
|
+
const bucket = tsplus_module_4.getOrElse(() => ({
|
|
30
30
|
key: `?.${route}`,
|
|
31
31
|
resetAfter: 5000,
|
|
32
32
|
limit: 1,
|
|
33
33
|
}))(maybeBucket);
|
|
34
34
|
const resetAfter = millis(bucket.resetAfter);
|
|
35
|
-
return
|
|
35
|
+
return tsplus_module_2.flatMap(() => tsplus_module_2.map(() => void 0)(maybeWait(`dfx.rest.${bucket.key}`, resetAfter, bucket.limit)))(invalidRateLimit(route));
|
|
36
36
|
})(store.getBucketForRoute(route));
|
|
37
37
|
})();
|
|
38
38
|
// Update rate limit buckets
|
|
39
|
-
const updateBuckets = (path, init, response) =>
|
|
39
|
+
const updateBuckets = (path, init, response) => tsplus_module_2.ignore((() => {
|
|
40
40
|
const route = routeFromConfig(path, init);
|
|
41
|
-
return
|
|
41
|
+
return tsplus_module_2.flatMap(({ bucket, retryAfter, limit, remaining }) => {
|
|
42
42
|
const effectsToRun = [
|
|
43
43
|
removeBadRoute(route),
|
|
44
44
|
store.putBucketRoute(route, bucket),
|
|
45
45
|
];
|
|
46
|
-
return
|
|
46
|
+
return tsplus_module_2.flatMap(hasBucket => {
|
|
47
47
|
if (!hasBucket || limit - 1 === remaining) {
|
|
48
48
|
effectsToRun.push(store.putBucket({
|
|
49
49
|
key: bucket,
|
|
@@ -51,28 +51,28 @@ const make = tsplus_module_1.flatMap(({ token, rest }) => tsplus_module_1.flatMa
|
|
|
51
51
|
limit: !hasBucket && remaining > 0 ? remaining : limit,
|
|
52
52
|
}));
|
|
53
53
|
}
|
|
54
|
-
return
|
|
54
|
+
return tsplus_module_2.map(() => void 0)(tsplus_module_2.collectAllParDiscard(effectsToRun));
|
|
55
55
|
})(store.hasBucket(bucket));
|
|
56
|
-
})(
|
|
56
|
+
})(tsplus_module_2.fromOption(rateLimitFromHeaders(response.headers)));
|
|
57
57
|
})());
|
|
58
|
-
const request = (path, init = {}) =>
|
|
58
|
+
const request = (path, init = {}) => tsplus_module_2.catchTag("StatusCodeError", (e) => {
|
|
59
59
|
switch (e.code) {
|
|
60
60
|
case 403:
|
|
61
|
-
return
|
|
61
|
+
return tsplus_module_2.flatMap(() => tsplus_module_2.fail(e))(tsplus_module_2.collectAllParDiscard([
|
|
62
62
|
log.info("DiscordREST", "403", path),
|
|
63
63
|
addBadRoute(routeFromConfig(path, init)),
|
|
64
64
|
updateBuckets(path, init, e.response),
|
|
65
65
|
]));
|
|
66
66
|
case 429:
|
|
67
|
-
return
|
|
67
|
+
return tsplus_module_2.flatMap(() => request(path, init))(tsplus_module_2.collectAllParDiscard([
|
|
68
68
|
log.info("DiscordREST", "429", path),
|
|
69
69
|
addBadRoute(routeFromConfig(path, init)),
|
|
70
70
|
updateBuckets(path, init, e.response),
|
|
71
|
-
|
|
71
|
+
tsplus_module_2.sleep(tsplus_module_4.getOrElse(() => tsplus_module_3.seconds(5))(retryAfter(e.response.headers))),
|
|
72
72
|
]));
|
|
73
73
|
}
|
|
74
|
-
return
|
|
75
|
-
})(
|
|
74
|
+
return tsplus_module_2.fail(e);
|
|
75
|
+
})(tsplus_module_2.flatMap(() => tsplus_module_2.flatMap(() => tsplus_module_2.flatMap(response => tsplus_module_2.map(() => response)(updateBuckets(path, init, response.response)))(http.requestWithJson(`${rest.baseUrl}${path}`, {
|
|
76
76
|
...init,
|
|
77
77
|
headers: {
|
|
78
78
|
...(init?.headers ?? {}),
|
|
@@ -80,42 +80,42 @@ const make = tsplus_module_1.flatMap(({ token, rest }) => tsplus_module_1.flatMa
|
|
|
80
80
|
"User-Agent": `DiscordBot (https://github.com/tim-smart/dfx, ${Pkg.version})`,
|
|
81
81
|
},
|
|
82
82
|
})))(globalRateLimit))(requestRateLimit(path, init)));
|
|
83
|
-
|
|
83
|
+
const routes = tsplus_module_1.Discord.createRoutes(({ method, url, params, options = {}, }) => {
|
|
84
|
+
const hasBody = method !== "GET" && method !== "DELETE";
|
|
85
|
+
let hasFormData = typeof options?.body?.append === "function";
|
|
86
|
+
let body = undefined;
|
|
87
|
+
const headers = {};
|
|
88
|
+
if (hasBody && !hasFormData) {
|
|
89
|
+
headers["content-type"] = "application/json";
|
|
90
|
+
}
|
|
91
|
+
const qs = new URLSearchParams();
|
|
92
|
+
if (!hasBody) {
|
|
93
|
+
Object.entries((params ?? {})).forEach(([key, value]) => {
|
|
94
|
+
qs.append(key, value);
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
else if (hasFormData) {
|
|
98
|
+
body = options.body;
|
|
99
|
+
if (params) {
|
|
100
|
+
;
|
|
101
|
+
body.append("payload_json", JSON.stringify(params));
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
else if (params) {
|
|
105
|
+
body = JSON.stringify(params);
|
|
106
|
+
}
|
|
107
|
+
else {
|
|
108
|
+
body = options.body;
|
|
109
|
+
}
|
|
110
|
+
return request(`${url}?${qs.toString()}`, {
|
|
111
|
+
method,
|
|
112
|
+
headers,
|
|
113
|
+
body,
|
|
114
|
+
});
|
|
115
|
+
});
|
|
116
|
+
return { request, ...routes };
|
|
84
117
|
})(tsplus_module_6.make(tsplus_module_5.empty()));
|
|
85
|
-
})(
|
|
118
|
+
})(tsplus_module_2.service(tsplus_module_1.RateLimiter)))(tsplus_module_2.service(tsplus_module_1.RateLimitStore)))(tsplus_module_2.service(tsplus_module_1.Log.Log)))(tsplus_module_2.service(tsplus_module_1.Config.DiscordConfig)))(tsplus_module_2.service(tsplus_module_1.Http));
|
|
86
119
|
export const DiscordREST = tsplus_module_7.Tag();
|
|
87
120
|
export const LiveDiscordREST = tsplus_module_8.fromEffect(DiscordREST)(make);
|
|
88
|
-
export const rest = tsplus_module_4.Discord.createRoutes(({ method, url, params, options = {} }) => tsplus_module_1.serviceWithEffect(DiscordREST)(({ request }) => {
|
|
89
|
-
const hasBody = method !== "GET" && method !== "DELETE";
|
|
90
|
-
let hasFormData = typeof options?.body?.append === "function";
|
|
91
|
-
let body = undefined;
|
|
92
|
-
const headers = {};
|
|
93
|
-
if (hasBody && !hasFormData) {
|
|
94
|
-
headers["content-type"] = "application/json";
|
|
95
|
-
}
|
|
96
|
-
const qs = new URLSearchParams();
|
|
97
|
-
if (!hasBody) {
|
|
98
|
-
Object.entries((params ?? {})).forEach(([key, value]) => {
|
|
99
|
-
qs.append(key, value);
|
|
100
|
-
});
|
|
101
|
-
}
|
|
102
|
-
else if (hasFormData) {
|
|
103
|
-
body = options.body;
|
|
104
|
-
if (params) {
|
|
105
|
-
;
|
|
106
|
-
body.append("payload_json", JSON.stringify(params));
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
else if (params) {
|
|
110
|
-
body = JSON.stringify(params);
|
|
111
|
-
}
|
|
112
|
-
else {
|
|
113
|
-
body = options.body;
|
|
114
|
-
}
|
|
115
|
-
return request(`${url}?${qs.toString()}`, {
|
|
116
|
-
method,
|
|
117
|
-
headers,
|
|
118
|
-
body,
|
|
119
|
-
});
|
|
120
|
-
}));
|
|
121
121
|
//# sourceMappingURL=index.js.map
|
package/DiscordREST/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/DiscordREST/index.ts"],"names":[],"mappings":";;;;;;;;AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAA;AAE7C,OAAO,EAAE,oBAAoB,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAC9E,OAAO,GAAG,MAAM,iBAAiB,CAAC,SAAS,IAAI,EAAE,MAAM,EAAE,CAAA;AAEzD,MAAM,IAAI,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/DiscordREST/index.ts"],"names":[],"mappings":";;;;;;;;AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAA;AAE7C,OAAO,EAAE,oBAAoB,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAC9E,OAAO,GAAG,MAAM,iBAAiB,CAAC,SAAS,IAAI,EAAE,MAAM,EAAE,CAAA;AAEzD,MAAM,IAAI,2BACF,IAAI,6BACJ,EAAE,KAAK,EAAE,IAAI,EAAE,6BAEf,GAAG,4BACH,KAAK,6BACL,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;+BAGK,YAAY;QAClB,MAAM,WAAW,GAAG,CAAC,KAAa,EAAE,EAAE,sCACpC;YACE,GAAG,CAAC,IAAI,CAAC,aAAa,EAAE,aAAa,EAAE,KAAK,CAAC;YAC7C,uBAAoB,CAAC,CAAC,EAAE,EAAE,CAAC,oBAAM,KAAK,EAAX,CAAC,CAAW,EAAvC,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CAAC,GAD/C,wCAAe,IAAI,CAAC,CA0LnC,CAAA;AAGF,MAAM,CAAC,MAAM,WAAW,GAAG,gBAAA,GAAG,EAAe,CAAA;AAC7C,MAAM,CAAC,MAAM,eAAe,GAAG,2BAAiB,WAAW,CAAC,CAAC,IAAI,CAAC,CAAA"}
|
package/DiscordREST/types.d.ts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { Effect } from "@effect/io/Effect";
|
|
2
|
-
import {
|
|
3
|
-
import { DiscordREST } from "./index.js";
|
|
2
|
+
import { JsonParseError, BlobError, FetchError, StatusCodeError } from "dfx";
|
|
4
3
|
export interface ResponseWithData<A> {
|
|
5
4
|
response: Response;
|
|
6
|
-
json: Effect<never,
|
|
5
|
+
json: Effect<never, JsonParseError, A>;
|
|
7
6
|
text: Effect<never, never, string>;
|
|
8
|
-
blob: Effect<never,
|
|
7
|
+
blob: Effect<never, BlobError, Blob>;
|
|
9
8
|
}
|
|
10
|
-
export type RestResponse<T> = Effect<
|
|
9
|
+
export type RestResponse<T> = Effect<never, FetchError | StatusCodeError | JsonParseError, ResponseWithData<T>>;
|
package/Helpers/permissions.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Discord } from "dfx";
|
|
2
|
+
import { Effect } from "@effect/io/Effect";
|
|
2
3
|
/**
|
|
3
4
|
* A constant of all the permissions
|
|
4
5
|
*/
|
|
@@ -32,3 +33,8 @@ export declare const forChannel: (roles: Discord.Role[]) => ({ guild_id, permiss
|
|
|
32
33
|
* Apply permission overwrites to a bitfield.
|
|
33
34
|
*/
|
|
34
35
|
export declare const applyOverwrites: (permissions: bigint) => (overwrites: Discord.Overwrite[]) => bigint;
|
|
36
|
+
interface RolesCache<E> {
|
|
37
|
+
getForParent: (parentId: string) => Effect<never, E, ReadonlyMap<string, Discord.Role>>;
|
|
38
|
+
}
|
|
39
|
+
export declare const hasInChannel: <E>(rolesCache: RolesCache<E>, permission: bigint) => (channel: Discord.Channel, memberOrRole: Discord.GuildMember | Discord.Role) => import("../global.js").Effect<never, E, boolean>;
|
|
40
|
+
export {};
|
package/Helpers/permissions.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as tsplus_module_1 from "dfx";
|
|
2
2
|
import * as tsplus_module_2 from "@fp-ts/data/Function";
|
|
3
|
+
import * as tsplus_module_3 from "@effect/io/Effect";
|
|
3
4
|
/**
|
|
4
5
|
* A constant of all the permissions
|
|
5
6
|
*/
|
|
@@ -66,4 +67,8 @@ export const forChannel = (roles) => ({ guild_id, permission_overwrites: overwri
|
|
|
66
67
|
* Apply permission overwrites to a bitfield.
|
|
67
68
|
*/
|
|
68
69
|
export const applyOverwrites = (permissions) => (overwrites) => overwrites.reduce((permissions, overwrite) => (permissions & ~BigInt(overwrite.deny)) | BigInt(overwrite.allow), permissions);
|
|
70
|
+
export const hasInChannel = (rolesCache, permission) => (channel, memberOrRole) => tsplus_module_3.map(roles => {
|
|
71
|
+
const channelPerms = forChannel([...roles.values()])(channel)(memberOrRole);
|
|
72
|
+
return has(permission)(channelPerms);
|
|
73
|
+
})(rolesCache.getForParent(channel.guild_id));
|
|
69
74
|
//# sourceMappingURL=permissions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"permissions.js","sourceRoot":"","sources":["../../src/Helpers/permissions.ts"],"names":[],"mappings":"
|
|
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,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kB,CAAC,CAAA;AAC7D,CAAC,CAAA;AAEH;;GAEG;AACH,MAAM,CAAC,MAAM,eAAe,GAC1B,CAAC,WAAmB,EAAE,EAAE,CAAC,CAAC,UAA+B,EAAE,EAAE,CAC3D,UAAU,CAAC,MAAM,CACf,CAAC,WAAW,EAAE,SAAS,EAAE,EAAE,CACzB,CAAC,WAAW,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,GAAG,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,EACnE,WAAW,CACZ,CAAA;AAQL,MAAM,CAAC,MAAM,YAAY,GACvB,CAAI,UAAyB,EAAE,UAAkB,EAAE,EAAE,CACrD,CACE,OAAwB,EACxB,YAAgD,EAChD,EAAE,qBAEM,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;GAJpB,UAAU,CAAC,YAAY,CAAC,OAAO,CAAC,QAAS,CAAC,CAK1D,CAAA"}
|
package/Http/index.d.ts
CHANGED
|
@@ -1,3 +1,16 @@
|
|
|
1
|
+
declare const make: () => {
|
|
2
|
+
request: (url: URL | string, init?: RequestInit) => import("../global.js").Effect<never, FetchError | StatusCodeError, Response>;
|
|
3
|
+
requestWithJson: <A = unknown>(url: URL | string, init?: RequestInit) => import("../global.js").Effect<never, FetchError | StatusCodeError, {
|
|
4
|
+
response: Response;
|
|
5
|
+
json: import("../global.js").Effect<never, JsonParseError, A>;
|
|
6
|
+
blob: import("../global.js").Effect<never, BlobError, Blob>;
|
|
7
|
+
text: import("../global.js").Effect<never, never, string>;
|
|
8
|
+
}>;
|
|
9
|
+
};
|
|
10
|
+
export interface Http extends ReturnType<typeof make> {
|
|
11
|
+
}
|
|
12
|
+
export declare const Http: import("../global.js").Tag<Http>;
|
|
13
|
+
export declare const LiveHttp: import("../global.js").Layer<never, never, Http>;
|
|
1
14
|
export declare class FetchError {
|
|
2
15
|
readonly reason: unknown;
|
|
3
16
|
readonly _tag = "FetchError";
|
|
@@ -9,7 +22,6 @@ export declare class StatusCodeError {
|
|
|
9
22
|
readonly code: number;
|
|
10
23
|
constructor(response: Response);
|
|
11
24
|
}
|
|
12
|
-
export declare const request: (url: URL | string, init?: RequestInit) => import("../global.js").Effect<never, FetchError | StatusCodeError, Response>;
|
|
13
25
|
export declare class JsonParseError {
|
|
14
26
|
readonly reason: unknown;
|
|
15
27
|
readonly _tag = "JsonParseError";
|
|
@@ -22,9 +34,4 @@ export declare class BlobError {
|
|
|
22
34
|
constructor(reason: unknown);
|
|
23
35
|
}
|
|
24
36
|
export declare const blob: (r: Response) => import("../global.js").Effect<never, BlobError, Blob>;
|
|
25
|
-
export
|
|
26
|
-
response: Response;
|
|
27
|
-
json: import("../global.js").Effect<never, JsonParseError, A>;
|
|
28
|
-
blob: import("../global.js").Effect<never, BlobError, Blob>;
|
|
29
|
-
text: import("../global.js").Effect<never, never, string>;
|
|
30
|
-
}>;
|
|
37
|
+
export {};
|