dfx 0.45.4 → 0.45.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -2
- package/src/DiscordGateway/Sharder.ts +7 -6
- package/src/package.json +2 -2
- package/tsconfig.json +2 -15
- package/Cache/driver.d.ts +0 -22
- package/Cache/driver.js +0 -3
- package/Cache/driver.js.map +0 -1
- package/Cache/memory.d.ts +0 -3
- package/Cache/memory.js +0 -48
- package/Cache/memory.js.map +0 -1
- package/Cache/memoryTTL.d.ts +0 -20
- package/Cache/memoryTTL.js +0 -121
- package/Cache/memoryTTL.js.map +0 -1
- package/Cache/prelude.d.ts +0 -56
- package/Cache/prelude.js +0 -108
- package/Cache/prelude.js.map +0 -1
- package/Cache.d.ts +0 -75
- package/Cache.js +0 -62
- package/Cache.js.map +0 -1
- package/DiscordConfig.d.ts +0 -28
- package/DiscordConfig.js +0 -29
- package/DiscordConfig.js.map +0 -1
- package/DiscordGateway/DiscordWS.d.ts +0 -31
- package/DiscordGateway/DiscordWS.js +0 -31
- package/DiscordGateway/DiscordWS.js.map +0 -1
- package/DiscordGateway/Shard/heartbeats.d.ts +0 -3
- package/DiscordGateway/Shard/heartbeats.js +0 -17
- package/DiscordGateway/Shard/heartbeats.js.map +0 -1
- package/DiscordGateway/Shard/identify.d.ts +0 -12
- package/DiscordGateway/Shard/identify.js +0 -26
- package/DiscordGateway/Shard/identify.js.map +0 -1
- package/DiscordGateway/Shard/invalidSession.d.ts +0 -3
- package/DiscordGateway/Shard/invalidSession.js +0 -6
- package/DiscordGateway/Shard/invalidSession.js.map +0 -1
- package/DiscordGateway/Shard/sendEvents.d.ts +0 -7
- package/DiscordGateway/Shard/sendEvents.js +0 -25
- package/DiscordGateway/Shard/sendEvents.js.map +0 -1
- package/DiscordGateway/Shard/utils.d.ts +0 -3
- package/DiscordGateway/Shard/utils.js +0 -9
- package/DiscordGateway/Shard/utils.js.map +0 -1
- package/DiscordGateway/Shard.d.ts +0 -16
- package/DiscordGateway/Shard.js +0 -85
- package/DiscordGateway/Shard.js.map +0 -1
- package/DiscordGateway/ShardStore.d.ts +0 -12
- package/DiscordGateway/ShardStore.js +0 -22
- package/DiscordGateway/ShardStore.js.map +0 -1
- package/DiscordGateway/Sharder.d.ts +0 -15
- package/DiscordGateway/Sharder.js +0 -49
- package/DiscordGateway/Sharder.js.map +0 -1
- package/DiscordGateway/WS.d.ts +0 -31
- package/DiscordGateway/WS.js +0 -77
- package/DiscordGateway/WS.js.map +0 -1
- package/DiscordGateway.d.ts +0 -12
- package/DiscordGateway.js +0 -29
- package/DiscordGateway.js.map +0 -1
- package/DiscordREST/types.d.ts +0 -7
- package/DiscordREST/types.js +0 -2
- package/DiscordREST/types.js.map +0 -1
- package/DiscordREST/utils.d.ts +0 -10
- package/DiscordREST/utils.js +0 -21
- package/DiscordREST/utils.js.map +0 -1
- package/DiscordREST.d.ts +0 -16
- package/DiscordREST.js +0 -123
- package/DiscordREST.js.map +0 -1
- package/Helpers/flags.d.ts +0 -27
- package/Helpers/flags.js +0 -36
- package/Helpers/flags.js.map +0 -1
- package/Helpers/intents.d.ts +0 -24
- package/Helpers/intents.js +0 -29
- package/Helpers/intents.js.map +0 -1
- package/Helpers/interactions.d.ts +0 -96
- package/Helpers/interactions.js +0 -97
- package/Helpers/interactions.js.map +0 -1
- package/Helpers/members.d.ts +0 -9
- package/Helpers/members.js +0 -10
- package/Helpers/members.js.map +0 -1
- package/Helpers/permissions.d.ts +0 -40
- package/Helpers/permissions.js +0 -83
- package/Helpers/permissions.js.map +0 -1
- package/Helpers/ui.d.ts +0 -47
- package/Helpers/ui.js +0 -66
- package/Helpers/ui.js.map +0 -1
- package/Interactions/builder.d.ts +0 -48
- package/Interactions/builder.js +0 -68
- package/Interactions/builder.js.map +0 -1
- package/Interactions/context.d.ts +0 -58
- package/Interactions/context.js +0 -61
- package/Interactions/context.js.map +0 -1
- package/Interactions/definitions.d.ts +0 -126
- package/Interactions/definitions.js +0 -53
- package/Interactions/definitions.js.map +0 -1
- package/Interactions/gateway.d.ts +0 -20
- package/Interactions/gateway.js +0 -39
- package/Interactions/gateway.js.map +0 -1
- package/Interactions/handlers.d.ts +0 -10
- package/Interactions/handlers.js +0 -45
- package/Interactions/handlers.js.map +0 -1
- package/Interactions/index.d.ts +0 -10
- package/Interactions/index.js +0 -12
- package/Interactions/index.js.map +0 -1
- package/Interactions/utils.d.ts +0 -78
- package/Interactions/utils.js +0 -74
- package/Interactions/utils.js.map +0 -1
- package/Interactions/webhook.d.ts +0 -45
- package/Interactions/webhook.js +0 -56
- package/Interactions/webhook.js.map +0 -1
- package/Log.d.ts +0 -10
- package/Log.js +0 -17
- package/Log.js.map +0 -1
- package/RateLimit/memory.d.ts +0 -2
- package/RateLimit/memory.js +0 -35
- package/RateLimit/memory.js.map +0 -1
- package/RateLimit/utils.d.ts +0 -2
- package/RateLimit/utils.js +0 -18
- package/RateLimit/utils.js.map +0 -1
- package/RateLimit.d.ts +0 -25
- package/RateLimit.js +0 -25
- package/RateLimit.js.map +0 -1
- package/_common.d.ts +0 -36
- package/_common.js +0 -8
- package/_common.js.map +0 -1
- package/gateway.d.ts +0 -13
- package/gateway.js +0 -25
- package/gateway.js.map +0 -1
- package/global.d.ts +0 -17
- package/global.js +0 -2
- package/global.js.map +0 -1
- package/index.d.ts +0 -13
- package/index.js +0 -14
- package/index.js.map +0 -1
- package/types.d.ts +0 -4449
- package/types.js +0 -1204
- package/types.js.map +0 -1
- package/utils/effect.d.ts +0 -1
- package/utils/effect.js +0 -2
- package/utils/effect.js.map +0 -1
- package/utils/hub.d.ts +0 -11
- package/utils/hub.js +0 -23
- package/utils/hub.js.map +0 -1
- package/utils/tsplus.d.ts +0 -12
- package/utils/tsplus.js +0 -2
- package/utils/tsplus.js.map +0 -1
- package/webhooks.d.ts +0 -9
- package/webhooks.js +0 -22
- package/webhooks.js.map +0 -1
package/DiscordGateway/WS.js
DELETED
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import * as tsplus_module_1 from "@effect/io/Effect";
|
|
2
|
-
import * as tsplus_module_2 from "@effect/io/Ref";
|
|
3
|
-
import * as tsplus_module_3 from "@effect/io/Runtime";
|
|
4
|
-
import * as tsplus_module_4 from "@effect/data/Duration";
|
|
5
|
-
import * as tsplus_module_5 from "@effect/io/Queue";
|
|
6
|
-
import * as tsplus_module_6 from "dfx/_common";
|
|
7
|
-
import { Log } from "dfx/Log";
|
|
8
|
-
import WebSocket from "isomorphic-ws";
|
|
9
|
-
export const Reconnect = Symbol();
|
|
10
|
-
export class WebSocketError {
|
|
11
|
-
reason;
|
|
12
|
-
error;
|
|
13
|
-
_tag = "WebSocketError";
|
|
14
|
-
constructor(reason, error) {
|
|
15
|
-
this.reason = reason;
|
|
16
|
-
this.error = error;
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
export class WebSocketCloseError {
|
|
20
|
-
code;
|
|
21
|
-
reason;
|
|
22
|
-
_tag = "WebSocketCloseError";
|
|
23
|
-
constructor(code, reason) {
|
|
24
|
-
this.code = code;
|
|
25
|
-
this.reason = reason;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
const isReconnect = (e) => e._tag === "WebSocketCloseError" && e.code === 1012;
|
|
29
|
-
const socket = (urlRef) => tsplus_module_1.acquireRelease(tsplus_module_1.map(tsplus_module_2.get(urlRef), _ => new WebSocket(_)), ws => tsplus_module_1.sync(() => {
|
|
30
|
-
;
|
|
31
|
-
ws.removeAllListeners?.();
|
|
32
|
-
ws.close();
|
|
33
|
-
}));
|
|
34
|
-
const offer = (ws, queue, log) => tsplus_module_1.flatMap(tsplus_module_1.runtime(), runtime => tsplus_module_1.async(resume => {
|
|
35
|
-
const run = tsplus_module_3.runFork(runtime);
|
|
36
|
-
ws.addEventListener("message", message => {
|
|
37
|
-
run(tsplus_module_1.zipLeft(queue
|
|
38
|
-
.offer(message.data), log.debug("WS", "offer", message.data)));
|
|
39
|
-
});
|
|
40
|
-
ws.addEventListener("error", cause => {
|
|
41
|
-
resume(tsplus_module_1.fail(new WebSocketError("error", cause)));
|
|
42
|
-
});
|
|
43
|
-
ws.addEventListener("close", e => {
|
|
44
|
-
resume(tsplus_module_1.fail(new WebSocketCloseError(e.code, e.reason)));
|
|
45
|
-
});
|
|
46
|
-
}));
|
|
47
|
-
const waitForOpen = (ws, timeout) => tsplus_module_1.timeoutFail(tsplus_module_1.suspend(() => {
|
|
48
|
-
if (ws.readyState === WebSocket.OPEN) {
|
|
49
|
-
return tsplus_module_1.unit();
|
|
50
|
-
}
|
|
51
|
-
return tsplus_module_1.async(resume => {
|
|
52
|
-
ws.addEventListener("open", () => resume(tsplus_module_1.unit()), {
|
|
53
|
-
once: true,
|
|
54
|
-
});
|
|
55
|
-
});
|
|
56
|
-
}), () => new WebSocketError("open-timeout"), timeout);
|
|
57
|
-
const send = (ws, take, log) => tsplus_module_1.forever(tsplus_module_1.tap(tsplus_module_1.tap(take, data => log.debug("WS", "send", data)), data => {
|
|
58
|
-
if (data === Reconnect) {
|
|
59
|
-
return tsplus_module_1.failSync(() => {
|
|
60
|
-
ws.close(1012, "reconnecting");
|
|
61
|
-
return new WebSocketCloseError(1012, "reconnecting");
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
return tsplus_module_1.sync(() => {
|
|
65
|
-
ws.send(data);
|
|
66
|
-
});
|
|
67
|
-
}));
|
|
68
|
-
const make = tsplus_module_1.map(Log, log => {
|
|
69
|
-
const connect = (url, takeOutbound, onConnecting = tsplus_module_1.unit(), openTimeout = tsplus_module_4.seconds(3)) => tsplus_module_1.map(tsplus_module_5.unbounded(), queue => {
|
|
70
|
-
const run = tsplus_module_1.retryWhile(tsplus_module_1.scoped(tsplus_module_1.flatMap(tsplus_module_1.zipRight(onConnecting, socket(url)), ws => tsplus_module_1.zipParLeft(offer(ws, queue, log), tsplus_module_1.zipRight(waitForOpen(ws, openTimeout), send(ws, takeOutbound, log))))), isReconnect);
|
|
71
|
-
return { run, take: queue.take() };
|
|
72
|
-
});
|
|
73
|
-
return { connect };
|
|
74
|
-
});
|
|
75
|
-
export const WS = tsplus_module_6.Tag();
|
|
76
|
-
export const LiveWS = tsplus_module_1.toLayer(make, WS);
|
|
77
|
-
//# sourceMappingURL=WS.js.map
|
package/DiscordGateway/WS.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"WS.js","sourceRoot":"","sources":["../src/DiscordGateway/WS.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,SAAS,CAAA;AAC7B,OAAO,SAAS,MAAM,eAAe,CAAA;AAErC,MAAM,CAAC,MAAM,SAAS,GAAG,MAAM,EAAE,CAAA;AAIjC,MAAM,OAAO,cAAc;IAGd;IACA;IAHF,IAAI,GAAG,gBAAgB,CAAA;IAChC,YACW,MAAgC,EAChC,KAAe;QADf,WAAM,GAAN,MAAM,CAA0B;QAChC,UAAK,GAAL,KAAK,CAAU;IACvB,CAAC;CACL;AAED,MAAM,OAAO,mBAAmB;IAET;IAAuB;IADnC,IAAI,GAAG,qBAAqB,CAAA;IACrC,YAAqB,IAAY,EAAW,MAAc;QAArC,SAAI,GAAJ,IAAI,CAAQ;QAAW,WAAM,GAAN,MAAM,CAAQ;IAAG,CAAC;CAC/D;AAED,MAAM,WAAW,GAAG,CAClB,CAAuC,EACb,EAAE,CAC5B,CAAC,CAAC,IAAI,KAAK,qBAAqB,IAAI,CAAC,CAAC,IAAI,KAAK,IAAI,CAAA;AAErD,MAAM,MAAM,GAAG,CAAC,MAAmB,EAAE,EAAE,CACrC,+BAAA,wCAAA,MAAM,GACC,CAAC,CAAC,EAAE,CAAC,IAAI,SAAS,CAAC,CAAC,CAAgC,CAAC,EAC1C,EAAE,CAAC,EAAE,CACnB,qBAAY,GAAG,EAAE;IACf,CAAC;IAAC,EAAU,CAAC,kBAAkB,EAAE,EAAE,CAAA;IACnC,EAAE,CAAC,KAAK,EAAE,CAAA;AACZ,CAAC,CAAC,CACH,CAA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,KAAK,CAAC,IAAI,EAAE,EAAW,CAAA;MAC3C,CAAA;IAEJ,OAAO,EAAE,OAAO,EAAW,CAAA;EAC3B,CAAA;AAGF,MAAM,CAAC,MAAM,EAAE,GAAG,gBAAA,GAAG,EAAM,CAAA;AAC3B,MAAM,CAAC,MAAM,MAAM,GAAG,wBAAA,IAAI,EAAS,EAAE,CAAC,CAAA"}
|
package/DiscordGateway.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { Stream, Discord, Hub, Effect } from "dfx/_common";
|
|
2
|
-
import { Sharder } from "./DiscordGateway/Sharder.js";
|
|
3
|
-
export declare const make: import("@effect/io/Effect").Effect<Sharder, never, {
|
|
4
|
-
run: import("@effect/io/Effect").Effect<never, import("./DiscordGateway/WS.js").WebSocketError | import("./DiscordGateway/WS.js").WebSocketCloseError, never>;
|
|
5
|
-
dispatch: import("@effect-http/client/_common").Stream<never, never, import("./types.js").GatewayPayload<import("./types.js").ReceiveEvent>>;
|
|
6
|
-
fromDispatch: <K extends keyof import("./types.js").ReceiveEvents>(event: K) => import("@effect-http/client/_common").Stream<never, never, import("./types.js").ReceiveEvents[K]>;
|
|
7
|
-
handleDispatch: <K_1 extends keyof import("./types.js").ReceiveEvents, R, E, A>(event: K_1, handle: (event: import("./types.js").ReceiveEvents[K_1]) => import("@effect/io/Effect").Effect<R, E, A>) => import("@effect/io/Effect").Effect<R, E, never>;
|
|
8
|
-
}>;
|
|
9
|
-
export interface DiscordGateway extends Effect.Success<typeof make> {
|
|
10
|
-
}
|
|
11
|
-
export declare const DiscordGateway: import("@effect/data/Context").Tag<DiscordGateway, DiscordGateway>;
|
|
12
|
-
export declare const LiveDiscordGateway: import("@effect-http/client/_common").Layer<import("./DiscordREST.js").DiscordREST | import("./DiscordConfig.js").DiscordConfig | import("./Log.js").Log | import("./RateLimit.js").RateLimitStore | import("./DiscordGateway/DiscordWS.js").DiscordWSCodec | import("./DiscordGateway/ShardStore.js").ShardStore, never, DiscordGateway>;
|
package/DiscordGateway.js
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import * as tsplus_module_1 from "@effect/stream/Stream";
|
|
2
|
-
import * as tsplus_module_2 from "@effect/io/Effect";
|
|
3
|
-
import * as tsplus_module_3 from "dfx/utils/hub";
|
|
4
|
-
import * as tsplus_module_4 from "@effect/io/Hub";
|
|
5
|
-
import * as tsplus_module_5 from "dfx/_common";
|
|
6
|
-
import * as tsplus_module_6 from "@effect/io/Layer";
|
|
7
|
-
import { LiveSharder, Sharder } from "./DiscordGateway/Sharder.js";
|
|
8
|
-
const fromDispatchFactory = (source) => (event) => tsplus_module_1.map(tsplus_module_1.filter(source, p => p.t === event), p => p.d);
|
|
9
|
-
const handleDispatchFactory = (hub) => (event, handle) => tsplus_module_3.subscribeForEachPar(hub, _ => {
|
|
10
|
-
if (_.t === event) {
|
|
11
|
-
return handle(_.d);
|
|
12
|
-
}
|
|
13
|
-
return tsplus_module_2.unit();
|
|
14
|
-
});
|
|
15
|
-
export const make = tsplus_module_2.flatMap(Sharder, sharder => tsplus_module_2.map(tsplus_module_4.unbounded(), hub => {
|
|
16
|
-
const dispatch = tsplus_module_1.fromHub(hub);
|
|
17
|
-
const fromDispatch = fromDispatchFactory(dispatch);
|
|
18
|
-
const handleDispatch = handleDispatchFactory(hub);
|
|
19
|
-
const run = sharder.run(hub);
|
|
20
|
-
return {
|
|
21
|
-
run,
|
|
22
|
-
dispatch,
|
|
23
|
-
fromDispatch,
|
|
24
|
-
handleDispatch,
|
|
25
|
-
};
|
|
26
|
-
}));
|
|
27
|
-
export const DiscordGateway = tsplus_module_5.Tag();
|
|
28
|
-
export const LiveDiscordGateway = tsplus_module_6.provide(tsplus_module_2.toLayer(make, DiscordGateway))(LiveSharder);
|
|
29
|
-
//# sourceMappingURL=DiscordGateway.js.map
|
package/DiscordGateway.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"DiscordGateway.js","sourceRoot":"","sources":["src/Discord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 @@
|
|
|
1
|
-
import * as Http from "@effect-http/client";
|
|
2
|
-
import { DiscordRESTError } from "dfx/DiscordREST";
|
|
3
|
-
import { Effect } from "dfx/_common";
|
|
4
|
-
export interface ResponseWithData<A> extends Http.response.Response {
|
|
5
|
-
readonly json: Effect<never, Http.ResponseDecodeError, A>;
|
|
6
|
-
}
|
|
7
|
-
export type RestResponse<T> = Effect<never, DiscordRESTError, ResponseWithData<T>>;
|
package/DiscordREST/types.js
DELETED
package/DiscordREST/types.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/DiscordREST/types.ts"],"names":[],"mappings":""}
|
package/DiscordREST/utils.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export declare const routeFromConfig: (path: string, method: string) => string;
|
|
2
|
-
export declare const numberHeader: (headers: Headers) => (key: string) => import("@effect/data/Option").Option<number>;
|
|
3
|
-
export declare const retryAfter: (headers: Headers) => import("@effect/data/Option").Option<import("../_common.js").Duration>;
|
|
4
|
-
export declare const rateLimitFromHeaders: (headers: Headers) => import("@effect/data/Option").Option<{
|
|
5
|
-
bucket: string;
|
|
6
|
-
retryAfter: import("../_common.js").Duration;
|
|
7
|
-
limit: number;
|
|
8
|
-
remaining: number;
|
|
9
|
-
}>;
|
|
10
|
-
export type RateLimitDetails = ReturnType<typeof rateLimitFromHeaders>;
|
package/DiscordREST/utils.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import * as tsplus_module_1 from "@effect/data/Option";
|
|
2
|
-
import * as tsplus_module_2 from "@effect/data/Duration";
|
|
3
|
-
const majorResources = ["channels", "guilds", "webhooks"];
|
|
4
|
-
export const routeFromConfig = (path, method) => {
|
|
5
|
-
// Only keep major ID's
|
|
6
|
-
const routeURL = path
|
|
7
|
-
.split("?")[0]
|
|
8
|
-
.replace(/\/([A-Za-z]+)\/(\d{16,21}|@me)/g, (match, resource) => majorResources.includes(resource) ? match : `/${resource}`)
|
|
9
|
-
// Strip reactions
|
|
10
|
-
.replace(/\/reactions\/(.*)/, "/reactions");
|
|
11
|
-
return `${method}-${routeURL}`;
|
|
12
|
-
};
|
|
13
|
-
export const numberHeader = (headers) => (key) => tsplus_module_1.filter(n => !isNaN(n))(tsplus_module_1.map(tsplus_module_1.fromNullable(headers.get(key)), parseFloat));
|
|
14
|
-
export const retryAfter = (headers) => tsplus_module_1.map(tsplus_module_1.orElse(numberHeader(headers)("x-ratelimit-reset-after"), () => numberHeader(headers)("retry-after")), tsplus_module_2.seconds);
|
|
15
|
-
export const rateLimitFromHeaders = (headers) => tsplus_module_1.struct({
|
|
16
|
-
bucket: tsplus_module_1.fromNullable(headers.get("x-ratelimit-bucket")),
|
|
17
|
-
retryAfter: retryAfter(headers),
|
|
18
|
-
limit: numberHeader(headers)("x-ratelimit-limit"),
|
|
19
|
-
remaining: numberHeader(headers)("x-ratelimit-remaining"),
|
|
20
|
-
});
|
|
21
|
-
//# sourceMappingURL=utils.js.map
|
package/DiscordREST/utils.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/DiscordREST/utils.ts"],"names":[],"mappings":";;AAAA,MAAM,cAAc,GAAG,CAAC,UAAU,EAAE,QAAQ,EAAE,UAAU,CAAU,CAAA;AAElE,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,IAAY,EAAE,MAAc,EAAE,EAAE;IAC9D,uBAAuB;IACvB,MAAM,QAAQ,GAAG,IAAI;SAClB,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;SACb,OAAO,CAAC,iCAAiC,EAAE,CAAC,KAAK,EAAE,QAAQ,EAAE,EAAE,CAC9D,cAAc,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,QAAQ,EAAE,CAC3D;QACD,kBAAkB;SACjB,OAAO,CAAC,mBAAmB,EAAE,YAAY,CAAC,CAAA;IAE7C,OAAO,GAAG,MAAM,IAAI,QAAQ,EAAE,CAAA;AAChC,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,OAAgB,EAAE,EAAE,CAAC,CAAC,GAAW,EAAE,EAAE,CAChE,uBAEU,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAFxB,oBAAA,6BAAmB,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,EAC7B,UAAU,CAAC,CACO,CAAA;AAE3B,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,OAAgB,EAAE,EAAE,CAC7C,oBAAA,uBAAA,YAAY,CAAC,OAAO,CAAC,CAAC,yBAAyB,CAAC,EACtC,GAAG,EAAE,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC,aAAa,CAAC,CAAC,0BAC7B,CAAA;AAE1B,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,OAAgB,EAAE,EAAE,CACvD,uBAAa;IACX,MAAM,EAAE,6BAAmB,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAC;IAC7D,UAAU,EAAE,UAAU,CAAC,OAAO,CAAC;IAC/B,KAAK,EAAE,YAAY,CAAC,OAAO,CAAC,CAAC,mBAAmB,CAAC;IACjD,SAAS,EAAE,YAAY,CAAC,OAAO,CAAC,CAAC,uBAAuB,CAAC;CAC1D,CAAC,CAAA"}
|
package/DiscordREST.d.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { Effect, Discord } from "dfx/_common";
|
|
2
|
-
import * as Http from "@effect-http/client";
|
|
3
|
-
import { DiscordConfig } from "./DiscordConfig.js";
|
|
4
|
-
import { ResponseWithData } from "./DiscordREST/types.js";
|
|
5
|
-
import { Log } from "./Log.js";
|
|
6
|
-
import { RateLimitStore } from "./RateLimit.js";
|
|
7
|
-
export declare class DiscordRESTError {
|
|
8
|
-
readonly error: Http.HttpClientError;
|
|
9
|
-
readonly _tag = "DiscordRESTError";
|
|
10
|
-
constructor(error: Http.HttpClientError);
|
|
11
|
-
}
|
|
12
|
-
export interface DiscordREST extends Discord.Endpoints<Partial<Http.MakeOptions>> {
|
|
13
|
-
readonly executor: <A = unknown>(request: Http.Request) => Effect<never, DiscordRESTError, ResponseWithData<A>>;
|
|
14
|
-
}
|
|
15
|
-
export declare const DiscordREST: import("@effect/data/Context").Tag<DiscordREST, DiscordREST>;
|
|
16
|
-
export declare const LiveDiscordREST: import("@effect-http/client/_common").Layer<DiscordConfig | Log | RateLimitStore | Http.HttpRequestExecutor, never, DiscordREST>;
|
package/DiscordREST.js
DELETED
|
@@ -1,123 +0,0 @@
|
|
|
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 "@effect/data/Option";
|
|
6
|
-
import * as tsplus_module_6 from "@effect/io/Config/Secret";
|
|
7
|
-
import * as tsplus_module_7 from "@effect-http/client/Request/Executor";
|
|
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 "@effect/io/Layer";
|
|
11
|
-
import * as Http from "@effect-http/client";
|
|
12
|
-
import { millis } from "@effect/data/Duration";
|
|
13
|
-
import { DiscordConfig } from "./DiscordConfig.js";
|
|
14
|
-
import { rateLimitFromHeaders, retryAfter, routeFromConfig, } from "./DiscordREST/utils.js";
|
|
15
|
-
import { Log } from "./Log.js";
|
|
16
|
-
import { LiveRateLimiter, RateLimitStore, RateLimiter, } from "./RateLimit.js";
|
|
17
|
-
import Pkg from "./package.json" assert { type: "json" };
|
|
18
|
-
export class DiscordRESTError {
|
|
19
|
-
error;
|
|
20
|
-
_tag = "DiscordRESTError";
|
|
21
|
-
constructor(error) {
|
|
22
|
-
this.error = error;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
const make = tsplus_module_3.flatMap(DiscordConfig, ({ token, rest }) => tsplus_module_3.flatMap(Http.HttpRequestExecutor, http => tsplus_module_3.flatMap(Log, log => tsplus_module_3.flatMap(RateLimitStore, store => tsplus_module_3.flatMap(RateLimiter, ({ maybeWait }) => {
|
|
26
|
-
const globalRateLimit = maybeWait("dfx.rest.global", rest.globalRateLimit.window, rest.globalRateLimit.limit);
|
|
27
|
-
return tsplus_module_3.map(tsplus_module_9.make(tsplus_module_8.empty()), badRoutesRef => {
|
|
28
|
-
const addBadRoute = (route) => tsplus_module_3.allParDiscard([
|
|
29
|
-
log.info("DiscordREST", "addBadRoute", route),
|
|
30
|
-
tsplus_module_9.update(badRoutesRef, s => tsplus_module_8.add(s, route)),
|
|
31
|
-
store.incrementCounter("dfx.rest.invalid", tsplus_module_4.minutes(10).millis, 10000),
|
|
32
|
-
]);
|
|
33
|
-
const isBadRoute = (route) => tsplus_module_3.map(tsplus_module_9.get(badRoutesRef), s => tsplus_module_8.has(s, route));
|
|
34
|
-
const removeBadRoute = (route) => tsplus_module_9.update(badRoutesRef, s => tsplus_module_8.remove(s, route));
|
|
35
|
-
const invalidRateLimit = (route) => tsplus_module_3.asUnit(tsplus_module_3.tap(isBadRoute(route), invalid => invalid
|
|
36
|
-
? maybeWait("dfx.rest.invalid", tsplus_module_4.minutes(10), 10000)
|
|
37
|
-
: tsplus_module_3.unit()));
|
|
38
|
-
// Request rate limiting
|
|
39
|
-
const requestRateLimit = (path, request) => (() => {
|
|
40
|
-
const route = routeFromConfig(path, request.method);
|
|
41
|
-
return tsplus_module_3.flatMap(store.getBucketForRoute(route), maybeBucket => {
|
|
42
|
-
const bucket = tsplus_module_5.getOrElse(maybeBucket, () => ({
|
|
43
|
-
key: `?.${route}`,
|
|
44
|
-
resetAfter: 5000,
|
|
45
|
-
limit: 1,
|
|
46
|
-
}));
|
|
47
|
-
const resetAfter = millis(bucket.resetAfter);
|
|
48
|
-
return tsplus_module_3.flatMap(invalidRateLimit(route), () => tsplus_module_3.map(maybeWait(`dfx.rest.${bucket.key}`, resetAfter, bucket.limit), () => void 0));
|
|
49
|
-
});
|
|
50
|
-
})();
|
|
51
|
-
// Update rate limit buckets
|
|
52
|
-
const updateBuckets = (request, response) => tsplus_module_3.ignore((() => {
|
|
53
|
-
const route = routeFromConfig(request.url, request.method);
|
|
54
|
-
return tsplus_module_3.flatMap(rateLimitFromHeaders(response.headers), ({ bucket, retryAfter, limit, remaining }) => {
|
|
55
|
-
const effectsToRun = [
|
|
56
|
-
removeBadRoute(route),
|
|
57
|
-
store.putBucketRoute(route, bucket),
|
|
58
|
-
];
|
|
59
|
-
return tsplus_module_3.flatMap(store.hasBucket(bucket), hasBucket => {
|
|
60
|
-
if (!hasBucket || limit - 1 === remaining) {
|
|
61
|
-
effectsToRun.push(store.removeCounter(`dfx.rest.?.${route}`), store.putBucket({
|
|
62
|
-
key: bucket,
|
|
63
|
-
resetAfter: retryAfter.millis,
|
|
64
|
-
limit: !hasBucket && remaining > 0 ? remaining : limit,
|
|
65
|
-
}));
|
|
66
|
-
}
|
|
67
|
-
return tsplus_module_3.map(tsplus_module_3.allParDiscard(effectsToRun), () => void 0);
|
|
68
|
-
});
|
|
69
|
-
});
|
|
70
|
-
})());
|
|
71
|
-
const httpExecutor = tsplus_module_7.catchAll(tsplus_module_7.contramap(tsplus_module_7.filterStatusOk(http.execute), _ => tsplus_module_1.setHeaders(tsplus_module_1.updateUrl(_, _ => `${rest.baseUrl}${_}`), {
|
|
72
|
-
Authorization: `Bot ${tsplus_module_6.value(token)}`,
|
|
73
|
-
"User-Agent": `DiscordBot (https://github.com/tim-smart/dfx, ${Pkg.version})`,
|
|
74
|
-
})), _ => tsplus_module_3.fail(new DiscordRESTError(_)));
|
|
75
|
-
const executor = (request) => tsplus_module_3.catchTag(tsplus_module_3.flatMap(requestRateLimit(request.url, request), () => tsplus_module_3.flatMap(globalRateLimit, () => tsplus_module_3.flatMap(httpExecutor(request), response => tsplus_module_3.map(updateBuckets(request, response), () => response)))), "DiscordRESTError", e => {
|
|
76
|
-
if (e.error._tag !== "StatusCodeError") {
|
|
77
|
-
return tsplus_module_3.fail(e);
|
|
78
|
-
}
|
|
79
|
-
const response = e.error.response;
|
|
80
|
-
switch (e.error.status) {
|
|
81
|
-
case 403:
|
|
82
|
-
return tsplus_module_3.flatMap(tsplus_module_3.allParDiscard([
|
|
83
|
-
log.info("DiscordREST", "403", request.url),
|
|
84
|
-
addBadRoute(routeFromConfig(request.url, request.method)),
|
|
85
|
-
updateBuckets(request, response),
|
|
86
|
-
]), () => tsplus_module_3.fail(e));
|
|
87
|
-
case 429:
|
|
88
|
-
return tsplus_module_3.flatMap(tsplus_module_3.allParDiscard([
|
|
89
|
-
log.info("DiscordREST", "429", request.url),
|
|
90
|
-
addBadRoute(routeFromConfig(request.url, request.method)),
|
|
91
|
-
updateBuckets(request, response),
|
|
92
|
-
tsplus_module_3.sleep(tsplus_module_5.getOrElse(retryAfter(response.headers), () => tsplus_module_4.seconds(5))),
|
|
93
|
-
]), () => executor(request));
|
|
94
|
-
}
|
|
95
|
-
return tsplus_module_3.fail(e);
|
|
96
|
-
});
|
|
97
|
-
const routes = tsplus_module_2.Discord.createRoutes(({ method, url, params, options = {}, }) => {
|
|
98
|
-
const hasBody = method !== "GET" && method !== "DELETE";
|
|
99
|
-
let request = Http.make(method)(url, options);
|
|
100
|
-
if (!hasBody) {
|
|
101
|
-
if (params) {
|
|
102
|
-
request = tsplus_module_1.appendParams(request, params);
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
else if (params &&
|
|
106
|
-
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.jsonBody(request, params);
|
|
112
|
-
}
|
|
113
|
-
return executor(request);
|
|
114
|
-
});
|
|
115
|
-
return {
|
|
116
|
-
...routes,
|
|
117
|
-
executor,
|
|
118
|
-
};
|
|
119
|
-
});
|
|
120
|
-
})))));
|
|
121
|
-
export const DiscordREST = tsplus_module_2.Tag();
|
|
122
|
-
export const LiveDiscordREST = tsplus_module_10.provide(tsplus_module_10.effect(DiscordREST, make))(LiveRateLimiter);
|
|
123
|
-
//# sourceMappingURL=DiscordREST.js.map
|
package/DiscordREST.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"DiscordREST.js","sourceRoot":"","sources":["src/DiscordREST.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,OAAO,KAAK,IAAI,MAAM,qBAAqB,CAAA;AAC3C,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAA;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAElD,OAAO,EACL,oBAAoB,EACpB,UAAU,EACV,eAAe,GAChB,MAAM,wBAAwB,CAAA;AAC/B,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAA;AAC9B,OAAO,EAEL,eAAe,EACf,cAAc,EACd,WAAW,GACZ,MAAM,gBAAgB,CAAA;AACvB,OAAO,GAAG,MAAM,gBAAgB,CAAC,SAAS,IAAI,EAAE,MAAM,EAAE,CAAA;AAExD,MAAM,OAAO,gBAAgB;IAEN;IADZ,IAAI,GAAG,kBAAkB,CAAA;IAClC,YAAqB,KAA2B;QAA3B,UAAK,GAAL,KAAK,CAAsB;IAAG,CAAC;CACrD;AAED,MAAM,IAAI,2BACkB,aAAa,GAAjC,EAAE,KAAK,EAAE,IAAI,EAAE,6BAEN,IAAI,CAAC,mBAAmB,EAAjC,IAAI,4BACI,GAAG,EAAX,GAAG,4BACO,cAAc,EAAxB,KAAK,4BACa,WAAW,GAA7B,EAAE,SAAS,EAAE;IAEnB,MAAM,eAAe,GAAG,SAAS,CAC/B,iBAAiB,EACjB,IA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OAAO,QAAQ,CAAC,OAAO,CAAC,CAAA;QAC1B,CAAC,CACF,CAAA;QAED,OAAO;YACL,GAAG,MAAM;YACT,QAAQ;SACT,CAAA;;MACD,CAAA;AASF,MAAM,CAAC,MAAM,WAAW,GAAG,gBAAA,GAAG,EAAe,CAAA;AAC7C,MAAM,CAAC,MAAM,eAAe,4BACP,wBAAa,WAAW,EAAE,IAAI,CAAC,EAAlD,eAAe,CAAmC,CAAA"}
|
package/Helpers/flags.d.ts
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
export type Flags<T extends number | bigint> = Record<string, T>;
|
|
2
|
-
/**
|
|
3
|
-
* Returns all the flags OR'ed together.
|
|
4
|
-
*/
|
|
5
|
-
export declare function all(flags: Flags<number>): number;
|
|
6
|
-
export declare function all(flags: Flags<bigint>): bigint;
|
|
7
|
-
/**
|
|
8
|
-
* Returns a function that converts a bitfield to a list of flag names.
|
|
9
|
-
*/
|
|
10
|
-
export declare function toList<T extends Flags<number>>(flags: T): (bitfield: number) => (keyof T)[];
|
|
11
|
-
export declare function toList<T extends Flags<bigint>>(flags: T): (bitfield: bigint) => (keyof T)[];
|
|
12
|
-
/**
|
|
13
|
-
* Returns a function that converts a list of flags names to a bigint bitfield.
|
|
14
|
-
*/
|
|
15
|
-
export declare const fromListBigint: <T extends Flags<bigint>>(flags: T) => (list: (keyof T)[]) => bigint;
|
|
16
|
-
/**
|
|
17
|
-
* Returns a function that converts a list of flags names to a bitfield.
|
|
18
|
-
*/
|
|
19
|
-
export declare const fromList: <T extends Flags<number>>(flags: T) => (list: (keyof T)[]) => number;
|
|
20
|
-
/**
|
|
21
|
-
* Checks if a bigint bitfield contains and a flag value.
|
|
22
|
-
*/
|
|
23
|
-
export declare const hasBigInt: (flag: bigint | string) => (bits: bigint | string) => boolean;
|
|
24
|
-
/**
|
|
25
|
-
* Checks if a bitfield contains and a flag value.
|
|
26
|
-
*/
|
|
27
|
-
export declare const has: (flag: number | string) => (bits: number | string) => boolean;
|
package/Helpers/flags.js
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
export function all(flags) {
|
|
2
|
-
return Object.values(flags).reduce((acc, flag) => acc | flag);
|
|
3
|
-
}
|
|
4
|
-
export function toList(flags) {
|
|
5
|
-
const entries = Object.entries(flags);
|
|
6
|
-
return val => entries.reduce((acc, [key, flag]) => ((val & flag) === flag ? [...acc, key] : acc), []);
|
|
7
|
-
}
|
|
8
|
-
/**
|
|
9
|
-
* Returns a function that converts a list of flags names to a bigint bitfield.
|
|
10
|
-
*/
|
|
11
|
-
export const fromListBigint = (flags) => (list) => list.reduce((acc, key) => acc | flags[key], BigInt(0));
|
|
12
|
-
/**
|
|
13
|
-
* Returns a function that converts a list of flags names to a bitfield.
|
|
14
|
-
*/
|
|
15
|
-
export const fromList = (flags) => (list) => list.reduce((acc, key) => acc | flags[key], 0);
|
|
16
|
-
/**
|
|
17
|
-
* Checks if a bigint bitfield contains and a flag value.
|
|
18
|
-
*/
|
|
19
|
-
export const hasBigInt = (flag) => {
|
|
20
|
-
const flagBigInt = BigInt(flag);
|
|
21
|
-
return (bits) => {
|
|
22
|
-
const bitsBigInt = BigInt(bits);
|
|
23
|
-
return (bitsBigInt & flagBigInt) === flagBigInt;
|
|
24
|
-
};
|
|
25
|
-
};
|
|
26
|
-
/**
|
|
27
|
-
* Checks if a bitfield contains and a flag value.
|
|
28
|
-
*/
|
|
29
|
-
export const has = (flag) => {
|
|
30
|
-
const flagNumber = +flag;
|
|
31
|
-
return (bits) => {
|
|
32
|
-
const bitsNumber = +bits;
|
|
33
|
-
return (bitsNumber & flagNumber) === flagNumber;
|
|
34
|
-
};
|
|
35
|
-
};
|
|
36
|
-
//# sourceMappingURL=flags.js.map
|
package/Helpers/flags.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"flags.js","sourceRoot":"","sources":["../src/Helpers/flags.ts"],"names":[],"mappings":"AAOA,MAAM,UAAU,GAAG,CAAC,KAAiB;IACnC,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M,CAAC,IAAI,CAAC,CAAA;QAC/B,OAAO,CAAC,UAAU,GAAG,UAAU,CAAC,KAAK,UAAU,CAAA;IACjD,CAAC,CAAA;AACH,CAAC,CAAA;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,GAAG,GAAG,CAAC,IAAqB,EAAE,EAAE;IAC3C,MAAM,UAAU,GAAG,CAAC,IAAI,CAAA;IACxB,OAAO,CAAC,IAAqB,EAAE,EAAE;QAC/B,MAAM,UAAU,GAAG,CAAC,IAAI,CAAA;QACxB,OAAO,CAAC,UAAU,GAAG,UAAU,CAAC,KAAK,UAAU,CAAA;IACjD,CAAC,CAAA;AACH,CAAC,CAAA"}
|
package/Helpers/intents.d.ts
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* All the intents
|
|
3
|
-
*/
|
|
4
|
-
export declare const ALL: number;
|
|
5
|
-
/**
|
|
6
|
-
* Privileged intents
|
|
7
|
-
*/
|
|
8
|
-
export declare const PRIVILEGED: number;
|
|
9
|
-
/**
|
|
10
|
-
* Un-privileged intents
|
|
11
|
-
*/
|
|
12
|
-
export declare const UNPRIVILEGED: number;
|
|
13
|
-
/**
|
|
14
|
-
* Function that converts a intents bitfield value to a list of intent names.
|
|
15
|
-
*/
|
|
16
|
-
export declare const toList: (bitfield: number) => ("GUILDS" | "GUILD_MEMBERS" | "GUILD_MODERATION" | "GUILD_EMOJIS_AND_STICKERS" | "GUILD_INTEGRATIONS" | "GUILD_WEBHOOKS" | "GUILD_INVITES" | "GUILD_VOICE_STATES" | "GUILD_PRESENCES" | "GUILD_MESSAGES" | "GUILD_MESSAGE_REACTIONS" | "GUILD_MESSAGE_TYPING" | "DIRECT_MESSAGES" | "DIRECT_MESSAGE_REACTIONS" | "DIRECT_MESSAGE_TYPING" | "MESSAGE_CONTENT" | "GUILD_SCHEDULED_EVENTS" | "AUTO_MODERATION_CONFIGURATION" | "AUTO_MODERATION_EXECUTION")[];
|
|
17
|
-
/**
|
|
18
|
-
* Function that converts a list of intent names to a bitfield value.
|
|
19
|
-
*/
|
|
20
|
-
export declare const fromList: (list: ("GUILDS" | "GUILD_MEMBERS" | "GUILD_MODERATION" | "GUILD_EMOJIS_AND_STICKERS" | "GUILD_INTEGRATIONS" | "GUILD_WEBHOOKS" | "GUILD_INVITES" | "GUILD_VOICE_STATES" | "GUILD_PRESENCES" | "GUILD_MESSAGES" | "GUILD_MESSAGE_REACTIONS" | "GUILD_MESSAGE_TYPING" | "DIRECT_MESSAGES" | "DIRECT_MESSAGE_REACTIONS" | "DIRECT_MESSAGE_TYPING" | "MESSAGE_CONTENT" | "GUILD_SCHEDULED_EVENTS" | "AUTO_MODERATION_CONFIGURATION" | "AUTO_MODERATION_EXECUTION")[]) => number;
|
|
21
|
-
/**
|
|
22
|
-
* Check if an intent flag exists in the permissions.
|
|
23
|
-
*/
|
|
24
|
-
export declare const has: (flag: string | number) => (bits: string | number) => boolean;
|
package/Helpers/intents.js
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import * as tsplus_module_1 from "dfx/_common";
|
|
2
|
-
import * as Flags from "dfx/Helpers/flags";
|
|
3
|
-
/**
|
|
4
|
-
* All the intents
|
|
5
|
-
*/
|
|
6
|
-
export const ALL = Flags.all(tsplus_module_1.Discord.GatewayIntents);
|
|
7
|
-
/**
|
|
8
|
-
* Privileged intents
|
|
9
|
-
*/
|
|
10
|
-
export const PRIVILEGED = tsplus_module_1.Discord.GatewayIntents.GUILD_PRESENCES |
|
|
11
|
-
tsplus_module_1.Discord.GatewayIntents.GUILD_MEMBERS |
|
|
12
|
-
tsplus_module_1.Discord.GatewayIntents.MESSAGE_CONTENT;
|
|
13
|
-
/**
|
|
14
|
-
* Un-privileged intents
|
|
15
|
-
*/
|
|
16
|
-
export const UNPRIVILEGED = ALL ^ PRIVILEGED;
|
|
17
|
-
/**
|
|
18
|
-
* Function that converts a intents bitfield value to a list of intent names.
|
|
19
|
-
*/
|
|
20
|
-
export const toList = Flags.toList(tsplus_module_1.Discord.GatewayIntents);
|
|
21
|
-
/**
|
|
22
|
-
* Function that converts a list of intent names to a bitfield value.
|
|
23
|
-
*/
|
|
24
|
-
export const fromList = Flags.fromList(tsplus_module_1.Discord.GatewayIntents);
|
|
25
|
-
/**
|
|
26
|
-
* Check if an intent flag exists in the permissions.
|
|
27
|
-
*/
|
|
28
|
-
export const has = Flags.has;
|
|
29
|
-
//# sourceMappingURL=intents.js.map
|
package/Helpers/intents.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"intents.js","sourceRoot":"","sources":["../src/Helpers/intents.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,KAAK,MAAM,mBAAmB,CAAA;AAE1C;;GAEG;AACH,MAAM,CAAC,MAAM,GAAG,GAAG,KAAK,CAAC,GAAG,CAAC,gBAAA,OAAO,CAAC,cAAc,CAAC,CAAA;AAEpD;;GAEG;AACH,MAAM,CAAC,MAAM,UAAU,GACrB,gBAAA,OAAO,CAAC,cAAc,CAAC,eAAe;IACtC,gBAAA,OAAO,CAAC,cAAc,CAAC,aAAa;IACpC,gBAAA,OAAO,CAAC,cAAc,CAAC,eAAe,CAAA;AAExC;;GAEG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,GAAG,GAAG,UAAU,CAAA;AAE5C;;GAEG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,gBAAA,OAAO,CAAC,cAAc,CAAC,CAAA;AAE1D;;GAEG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,KAAK,CAAC,QAAQ,CAAC,gBAAA,OAAO,CAAC,cAAc,CAAC,CAAA;AAE9D;;GAEG;AACH,MAAM,CAAC,MAAM,GAAG,GAAG,KAAK,CAAC,GAAG,CAAA"}
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
import { Discord } from "dfx/_common";
|
|
2
|
-
import { Option as Maybe } from "@effect/data/Option";
|
|
3
|
-
/**
|
|
4
|
-
* Maybe find a sub-command within the interaction options.
|
|
5
|
-
*/
|
|
6
|
-
export declare const allSubCommands: (interaction: Discord.ApplicationCommandDatum) => import("../types.js").ApplicationCommandInteractionDataOption[];
|
|
7
|
-
/**
|
|
8
|
-
* Maybe find a sub-command within the interaction options.
|
|
9
|
-
*/
|
|
10
|
-
export declare const findSubCommand: (name: string) => (interaction: Discord.ApplicationCommandDatum) => Maybe<import("../types.js").ApplicationCommandInteractionDataOption>;
|
|
11
|
-
/**
|
|
12
|
-
* If the sub-command exists return `true`, else `false`.
|
|
13
|
-
*/
|
|
14
|
-
export declare const isSubCommand: (name: string) => (interaction: import("../types.js").ApplicationCommandDatum) => boolean;
|
|
15
|
-
/**
|
|
16
|
-
* Maybe get the options for a sub-command
|
|
17
|
-
*/
|
|
18
|
-
export declare const subCommandOptions: (name: string) => (interaction: import("../types.js").ApplicationCommandDatum) => Maybe<import("../types.js").ApplicationCommandInteractionDataOption[]>;
|
|
19
|
-
/**
|
|
20
|
-
* A lens for accessing nested options in a interaction.
|
|
21
|
-
*/
|
|
22
|
-
export declare const optionsWithNested: (data: Pick<Discord.ApplicationCommandDatum, "options">) => Discord.ApplicationCommandInteractionDataOption[];
|
|
23
|
-
/**
|
|
24
|
-
* Return the interaction options as a name / value map.
|
|
25
|
-
*/
|
|
26
|
-
export declare const transformOptions: (options: Discord.ApplicationCommandInteractionDataOption[]) => import("../_common.js").HashMap<string, string | undefined>;
|
|
27
|
-
/**
|
|
28
|
-
* Return the interaction options as a name / value map.
|
|
29
|
-
*/
|
|
30
|
-
export declare const optionsMap: (data: Pick<import("../types.js").ApplicationCommandDatum, "options">) => import("../_common.js").HashMap<string, string | undefined>;
|
|
31
|
-
/**
|
|
32
|
-
* Try find a matching option from the interaction.
|
|
33
|
-
*/
|
|
34
|
-
export declare const getOption: (name: string) => (data: Pick<import("../types.js").ApplicationCommandDatum, "options">) => Maybe<import("../types.js").ApplicationCommandInteractionDataOption>;
|
|
35
|
-
/**
|
|
36
|
-
* Try find a matching option from the interaction.
|
|
37
|
-
*/
|
|
38
|
-
export declare const focusedOption: (data: Pick<import("../types.js").ApplicationCommandDatum, "options">) => Maybe<import("../types.js").ApplicationCommandInteractionDataOption>;
|
|
39
|
-
/**
|
|
40
|
-
* Try find a matching option value from the interaction.
|
|
41
|
-
*/
|
|
42
|
-
export declare const optionValue: (name: string) => (data: Pick<import("../types.js").ApplicationCommandDatum, "options">) => Maybe<string>;
|
|
43
|
-
/**
|
|
44
|
-
* Try extract resolved data
|
|
45
|
-
*/
|
|
46
|
-
export declare const resolved: (data: Discord.Interaction) => Maybe<import("../types.js").ResolvedDatum>;
|
|
47
|
-
/**
|
|
48
|
-
* Try find a matching option value from the interaction.
|
|
49
|
-
*/
|
|
50
|
-
export declare const resolveOptionValue: <T>(name: string, f: (id: Discord.Snowflake, data: Discord.ResolvedDatum) => T | undefined) => (a: Discord.Interaction) => Maybe<T>;
|
|
51
|
-
/**
|
|
52
|
-
* Try find matching option values from the interaction.
|
|
53
|
-
*/
|
|
54
|
-
export declare const resolveValues: <T>(f: (id: Discord.Snowflake, data: Discord.ResolvedDatum) => T | undefined) => (a: Discord.Interaction) => Maybe<readonly T[]>;
|
|
55
|
-
/**
|
|
56
|
-
* A lens for accessing the components in a interaction.
|
|
57
|
-
*/
|
|
58
|
-
export declare const components: (a: Discord.ModalSubmitDatum) => Discord.Component[];
|
|
59
|
-
/**
|
|
60
|
-
* A lens for accessing the components in a interaction.
|
|
61
|
-
*/
|
|
62
|
-
export declare const componentsWithValue: (a: import("../types.js").ModalSubmitDatum) => import("../types.js").Component[];
|
|
63
|
-
/**
|
|
64
|
-
* Return the interaction components as an id / value map.
|
|
65
|
-
*/
|
|
66
|
-
export declare const transformComponents: (options: Discord.Component[]) => import("../_common.js").HashMap<string, string | undefined>;
|
|
67
|
-
/**
|
|
68
|
-
* Return the interaction components as an id / value map.
|
|
69
|
-
*/
|
|
70
|
-
export declare const componentsMap: (a: import("../types.js").ModalSubmitDatum) => import("../_common.js").HashMap<string, string | undefined>;
|
|
71
|
-
/**
|
|
72
|
-
* Try find a matching component from the interaction.
|
|
73
|
-
*/
|
|
74
|
-
export declare const getComponent: (id: string) => (a: import("../types.js").ModalSubmitDatum) => Maybe<import("../types.js").Component>;
|
|
75
|
-
/**
|
|
76
|
-
* Try find a matching component value from the interaction.
|
|
77
|
-
*/
|
|
78
|
-
export declare const componentValue: (id: string) => (a: import("../types.js").ModalSubmitDatum) => Maybe<string>;
|
|
79
|
-
export type InteractionResponse = {
|
|
80
|
-
type: Discord.InteractionCallbackType.CHANNEL_MESSAGE_WITH_SOURCE;
|
|
81
|
-
data: Discord.InteractionCallbackMessage;
|
|
82
|
-
} | {
|
|
83
|
-
type: Discord.InteractionCallbackType.UPDATE_MESSAGE;
|
|
84
|
-
data: Discord.InteractionCallbackMessage;
|
|
85
|
-
} | {
|
|
86
|
-
type: Discord.InteractionCallbackType.MODAL;
|
|
87
|
-
data: Discord.InteractionCallbackModal;
|
|
88
|
-
} | {
|
|
89
|
-
type: Discord.InteractionCallbackType.DEFERRED_UPDATE_MESSAGE;
|
|
90
|
-
} | {
|
|
91
|
-
type: Discord.InteractionCallbackType.DEFERRED_CHANNEL_MESSAGE_WITH_SOURCE;
|
|
92
|
-
} | {
|
|
93
|
-
type: Discord.InteractionCallbackType.APPLICATION_COMMAND_AUTOCOMPLETE_RESULT;
|
|
94
|
-
data: Discord.InteractionCallbackAutocomplete;
|
|
95
|
-
};
|
|
96
|
-
export declare const response: (r: InteractionResponse) => InteractionResponse;
|