dfx 0.45.10 → 0.46.1
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/Helpers/permissions.d.ts +2 -2
- package/Helpers/permissions.d.ts.map +1 -1
- package/Interactions/utils.d.ts +0 -1
- package/Interactions/utils.d.ts.map +1 -1
- package/Interactions/utils.js +0 -37
- package/Interactions/utils.js.map +1 -1
- package/Interactions/webhook.d.ts +22 -2
- package/Interactions/webhook.d.ts.map +1 -1
- package/Interactions/webhook.js +24 -27
- package/Interactions/webhook.js.map +1 -1
- package/package.json +9 -9
- package/src/Interactions/utils.ts +0 -38
- package/src/Interactions/webhook.ts +31 -16
- package/src/package.json +9 -9
- package/src/types.ts +37 -7
- package/types.d.ts +17 -6
- package/types.d.ts.map +1 -1
- package/types.js +12 -5
- package/types.js.map +1 -1
package/Helpers/permissions.d.ts
CHANGED
|
@@ -10,11 +10,11 @@ export declare const has: (flag: string | bigint) => (bits: string | bigint) =>
|
|
|
10
10
|
/**
|
|
11
11
|
* Convert a permissions bitfield to a list of flag names.
|
|
12
12
|
*/
|
|
13
|
-
export declare const toList: (bitfield: bigint) => ("CREATE_INSTANT_INVITE" | "KICK_MEMBERS" | "BAN_MEMBERS" | "ADMINISTRATOR" | "MANAGE_CHANNELS" | "MANAGE_GUILD" | "ADD_REACTIONS" | "VIEW_AUDIT_LOG" | "PRIORITY_SPEAKER" | "STREAM" | "VIEW_CHANNEL" | "SEND_MESSAGES" | "SEND_TTS_MESSAGES" | "MANAGE_MESSAGES" | "EMBED_LINKS" | "ATTACH_FILES" | "READ_MESSAGE_HISTORY" | "MENTION_EVERYONE" | "USE_EXTERNAL_EMOJIS" | "VIEW_GUILD_INSIGHTS" | "CONNECT" | "SPEAK" | "MUTE_MEMBERS" | "DEAFEN_MEMBERS" | "MOVE_MEMBERS" | "USE_VAD" | "CHANGE_NICKNAME" | "MANAGE_NICKNAMES" | "MANAGE_ROLES" | "MANAGE_WEBHOOKS" | "MANAGE_GUILD_EXPRESSIONS" | "USE_APPLICATION_COMMANDS" | "REQUEST_TO_SPEAK" | "MANAGE_EVENTS" | "MANAGE_THREADS" | "CREATE_PUBLIC_THREADS" | "CREATE_PRIVATE_THREADS" | "USE_EXTERNAL_STICKERS" | "SEND_MESSAGES_IN_THREADS" | "USE_EMBEDDED_ACTIVITIES" | "MODERATE_MEMBERS" | "VIEW_CREATOR_MONETIZATION_ANALYTICS" | "USE_SOUNDBOARD" | "SEND_VOICE_MESSAGES")[];
|
|
13
|
+
export declare const toList: (bitfield: bigint) => ("CREATE_INSTANT_INVITE" | "KICK_MEMBERS" | "BAN_MEMBERS" | "ADMINISTRATOR" | "MANAGE_CHANNELS" | "MANAGE_GUILD" | "ADD_REACTIONS" | "VIEW_AUDIT_LOG" | "PRIORITY_SPEAKER" | "STREAM" | "VIEW_CHANNEL" | "SEND_MESSAGES" | "SEND_TTS_MESSAGES" | "MANAGE_MESSAGES" | "EMBED_LINKS" | "ATTACH_FILES" | "READ_MESSAGE_HISTORY" | "MENTION_EVERYONE" | "USE_EXTERNAL_EMOJIS" | "VIEW_GUILD_INSIGHTS" | "CONNECT" | "SPEAK" | "MUTE_MEMBERS" | "DEAFEN_MEMBERS" | "MOVE_MEMBERS" | "USE_VAD" | "CHANGE_NICKNAME" | "MANAGE_NICKNAMES" | "MANAGE_ROLES" | "MANAGE_WEBHOOKS" | "MANAGE_GUILD_EXPRESSIONS" | "USE_APPLICATION_COMMANDS" | "REQUEST_TO_SPEAK" | "MANAGE_EVENTS" | "MANAGE_THREADS" | "CREATE_PUBLIC_THREADS" | "CREATE_PRIVATE_THREADS" | "USE_EXTERNAL_STICKERS" | "SEND_MESSAGES_IN_THREADS" | "USE_EMBEDDED_ACTIVITIES" | "MODERATE_MEMBERS" | "VIEW_CREATOR_MONETIZATION_ANALYTICS" | "USE_SOUNDBOARD" | "USE_EXTERNAL_SOUNDS" | "SEND_VOICE_MESSAGES")[];
|
|
14
14
|
/**
|
|
15
15
|
* Convert a list of flag names to a bitfield.
|
|
16
16
|
*/
|
|
17
|
-
export declare const fromList: (list: ("CREATE_INSTANT_INVITE" | "KICK_MEMBERS" | "BAN_MEMBERS" | "ADMINISTRATOR" | "MANAGE_CHANNELS" | "MANAGE_GUILD" | "ADD_REACTIONS" | "VIEW_AUDIT_LOG" | "PRIORITY_SPEAKER" | "STREAM" | "VIEW_CHANNEL" | "SEND_MESSAGES" | "SEND_TTS_MESSAGES" | "MANAGE_MESSAGES" | "EMBED_LINKS" | "ATTACH_FILES" | "READ_MESSAGE_HISTORY" | "MENTION_EVERYONE" | "USE_EXTERNAL_EMOJIS" | "VIEW_GUILD_INSIGHTS" | "CONNECT" | "SPEAK" | "MUTE_MEMBERS" | "DEAFEN_MEMBERS" | "MOVE_MEMBERS" | "USE_VAD" | "CHANGE_NICKNAME" | "MANAGE_NICKNAMES" | "MANAGE_ROLES" | "MANAGE_WEBHOOKS" | "MANAGE_GUILD_EXPRESSIONS" | "USE_APPLICATION_COMMANDS" | "REQUEST_TO_SPEAK" | "MANAGE_EVENTS" | "MANAGE_THREADS" | "CREATE_PUBLIC_THREADS" | "CREATE_PRIVATE_THREADS" | "USE_EXTERNAL_STICKERS" | "SEND_MESSAGES_IN_THREADS" | "USE_EMBEDDED_ACTIVITIES" | "MODERATE_MEMBERS" | "VIEW_CREATOR_MONETIZATION_ANALYTICS" | "USE_SOUNDBOARD" | "SEND_VOICE_MESSAGES")[]) => bigint;
|
|
17
|
+
export declare const fromList: (list: ("CREATE_INSTANT_INVITE" | "KICK_MEMBERS" | "BAN_MEMBERS" | "ADMINISTRATOR" | "MANAGE_CHANNELS" | "MANAGE_GUILD" | "ADD_REACTIONS" | "VIEW_AUDIT_LOG" | "PRIORITY_SPEAKER" | "STREAM" | "VIEW_CHANNEL" | "SEND_MESSAGES" | "SEND_TTS_MESSAGES" | "MANAGE_MESSAGES" | "EMBED_LINKS" | "ATTACH_FILES" | "READ_MESSAGE_HISTORY" | "MENTION_EVERYONE" | "USE_EXTERNAL_EMOJIS" | "VIEW_GUILD_INSIGHTS" | "CONNECT" | "SPEAK" | "MUTE_MEMBERS" | "DEAFEN_MEMBERS" | "MOVE_MEMBERS" | "USE_VAD" | "CHANGE_NICKNAME" | "MANAGE_NICKNAMES" | "MANAGE_ROLES" | "MANAGE_WEBHOOKS" | "MANAGE_GUILD_EXPRESSIONS" | "USE_APPLICATION_COMMANDS" | "REQUEST_TO_SPEAK" | "MANAGE_EVENTS" | "MANAGE_THREADS" | "CREATE_PUBLIC_THREADS" | "CREATE_PRIVATE_THREADS" | "USE_EXTERNAL_STICKERS" | "SEND_MESSAGES_IN_THREADS" | "USE_EMBEDDED_ACTIVITIES" | "MODERATE_MEMBERS" | "VIEW_CREATOR_MONETIZATION_ANALYTICS" | "USE_SOUNDBOARD" | "USE_EXTERNAL_SOUNDS" | "SEND_VOICE_MESSAGES")[]) => bigint;
|
|
18
18
|
/**
|
|
19
19
|
* Reduce a list of roles to a bitfield of all the permissions added together.
|
|
20
20
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"permissions.d.ts","sourceRoot":"","sources":["../src/Helpers/permissions.ts"],"names":[],"mappings":";AAGA;;GAEG;AACH,eAAO,MAAM,GAAG,QAAoC,CAAA;AAEpD;;GAEG;AACH,eAAO,MAAM,GAAG,+DAAkB,CAAA;AAElC;;GAEG;AACH,eAAO,MAAM,MAAM,
|
|
1
|
+
{"version":3,"file":"permissions.d.ts","sourceRoot":"","sources":["../src/Helpers/permissions.ts"],"names":[],"mappings":";AAGA;;GAEG;AACH,eAAO,MAAM,GAAG,QAAoC,CAAA;AAEpD;;GAEG;AACH,eAAO,MAAM,GAAG,+DAAkB,CAAA;AAElC;;GAEG;AACH,eAAO,MAAM,MAAM,67BAAuC,CAAA;AAE1D;;GAEG;AACH,eAAO,MAAM,QAAQ,y7BAA+C,CAAA;AAEpE;;GAEG;AACH,eAAO,MAAM,QAAQ,UAAW,QAAQ,IAAI,EAAE,WAI3C,CAAA;AAEH;;GAEG;AACH,eAAO,MAAM,SAAS,UACZ,QAAQ,IAAI,EAAE,cAAc,QAAQ,WAAW,WACT,CAAA;AAuBhD;;;GAGG;AACH,eAAO,MAAM,UAAU,UACb,QAAQ,IAAI,EAAE,uDACiC,QAAQ,OAAO,oBACvD,QAAQ,WAAW,GAAG,QAAQ,IAAI,WA4BhD,CAAA;AAEH;;GAEG;AACH,eAAO,MAAM,eAAe,gBACZ,MAAM,kBAAkB,QAAQ,SAAS,EAAE,WAKtD,CAAA;AAEL,UAAU,UAAU,CAAC,CAAC;IACpB,YAAY,EAAE,CACZ,QAAQ,EAAE,MAAM,KACb,MAAM,CAAC,KAAK,EAAE,CAAC,EAAE,WAAW,CAAC,MAAM,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAA;CACzD;AAED,eAAO,MAAM,YAAY,6CACoB,MAAM,eAEtC,QAAQ,OAAO,gBACV,QAAQ,WAAW,GAAG,QAAQ,IAAI,0DAQ9C,CAAA;AAEN,eAAO,MAAM,UAAU,6CACsB,MAAM,eACvC,QAAQ,SAAS,UAAU,QAAQ,WAAW,0DASpD,CAAA"}
|
package/Interactions/utils.d.ts
CHANGED
|
@@ -75,5 +75,4 @@ export declare const splitDefinitions: <R, E, TE, A>(definitions: import("../_co
|
|
|
75
75
|
readonly handle: (_: Discord.Interaction) => import("@effect/io/Effect").Effect<R, TE, A>;
|
|
76
76
|
}>;
|
|
77
77
|
};
|
|
78
|
-
export declare function fromHex(hexString: string): Uint8Array;
|
|
79
78
|
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/Interactions/utils.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,CAAC,MAAM,kBAAkB,CAAA;AAGrC,MAAM,MAAM,mBAAmB,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC,qBAAqB,CACpE,CAAC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|
-
6: 6,
|
|
45
|
-
7: 7,
|
|
46
|
-
8: 8,
|
|
47
|
-
9: 9,
|
|
48
|
-
a: 10,
|
|
49
|
-
b: 11,
|
|
50
|
-
c: 12,
|
|
51
|
-
d: 13,
|
|
52
|
-
e: 14,
|
|
53
|
-
f: 15,
|
|
54
|
-
A: 10,
|
|
55
|
-
B: 11,
|
|
56
|
-
C: 12,
|
|
57
|
-
D: 13,
|
|
58
|
-
E: 14,
|
|
59
|
-
F: 15,
|
|
60
|
-
};
|
|
61
|
-
export function fromHex(hexString) {
|
|
62
|
-
const bytes = new Uint8Array(Math.floor((hexString || "").length / 2));
|
|
63
|
-
let i;
|
|
64
|
-
for (i = 0; i < bytes.length; i++) {
|
|
65
|
-
const a = MAP_HEX[hexString[i * 2]];
|
|
66
|
-
const b = MAP_HEX[hexString[i * 2 + 1]];
|
|
67
|
-
if (a === undefined || b === undefined) {
|
|
68
|
-
break;
|
|
69
|
-
}
|
|
70
|
-
bytes[i] = (a << 4) | b;
|
|
71
|
-
}
|
|
72
|
-
return i === bytes.length ? bytes : bytes.slice(0, i);
|
|
73
|
-
}
|
|
74
37
|
//# sourceMappingURL=utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/Interactions/utils.ts"],"names":[],"mappings":";;AACA,OAAO,KAAK,GAAG,MAAM,cAAc,CAAA;AAkBnC,MAAM,OAAO,GAAyB;IACpC,OAAO,EAAE,GAAG,CAAC,QAAQ;IACrB,MAAM,EAAE,GAAG,CAAC,MAAM;IAClB,WAAW,EAAE,GAAG,CAAC,WAAW;IAC5B,mBAAmB,EAAE,GAAG,CAAC,mBAAmB;IAC5C,WAAW,EAAE,GAAG,CAAC,iBAAiB;CAC5B,CAAA;AAER,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAChC,WAKC,EACD,cAGoB,EACpB,EAAE,CACF,oBAAA,WAAW,EAAK,CAAC,CAAC,UAAU,EAAE,SAAS,CAAC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IAAI,CAAC,EAAE,uBAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAgB,EAAQ,CAAC,CAAC;KAChD,CAAC,CACH,CAAA;IAED,MAAM,QAAQ,GAAG,uBAAA,uBAAA,OAAO,CAAC,wBAAwB,EAC/C,OAAO,CAAC,uBAAuB,CAChC,EACC,EAA6D,EAC7D,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE,CACT,CAAC;QACC,GAAG,GAAG;QACN,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;KACZ,CAAA,CACZ,CAAA;IAED,OAAO;QACL,GAAG,OAAO;QACV,QAAQ;KACT,CAAA;AACH,CAAC,CAAA"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ConfigSecret, Config, Discord, Chunk, Effect, Cause } from "dfx/_common";
|
|
2
|
+
import Verify from "discord-verify";
|
|
2
3
|
import { DefinitionNotFound } from "./handlers.js";
|
|
3
4
|
import { InteractionBuilder } from "./index.js";
|
|
4
5
|
export declare class BadWebhookSignature {
|
|
@@ -8,10 +9,29 @@ export type Headers = Record<string, string | string[] | undefined>;
|
|
|
8
9
|
export interface MakeConfigOpts {
|
|
9
10
|
applicationId: string;
|
|
10
11
|
publicKey: ConfigSecret;
|
|
12
|
+
crypto: SubtleCrypto;
|
|
13
|
+
algorithm: keyof typeof Verify.PlatformAlgorithm;
|
|
11
14
|
}
|
|
12
|
-
declare const makeConfig: ({ applicationId, publicKey }: MakeConfigOpts) => {
|
|
15
|
+
declare const makeConfig: ({ applicationId, publicKey, crypto, algorithm, }: MakeConfigOpts) => {
|
|
13
16
|
applicationId: string;
|
|
14
|
-
publicKey:
|
|
17
|
+
publicKey: string;
|
|
18
|
+
crypto: SubtleCrypto;
|
|
19
|
+
algorithm: string | {
|
|
20
|
+
name: string;
|
|
21
|
+
namedCurve: string;
|
|
22
|
+
public: boolean;
|
|
23
|
+
} | {
|
|
24
|
+
name: string;
|
|
25
|
+
namedCurve: string;
|
|
26
|
+
public: boolean;
|
|
27
|
+
} | {
|
|
28
|
+
name: string;
|
|
29
|
+
namedCurve: string;
|
|
30
|
+
public: boolean;
|
|
31
|
+
} | {
|
|
32
|
+
name: string;
|
|
33
|
+
namedCurve: string;
|
|
34
|
+
};
|
|
15
35
|
};
|
|
16
36
|
export interface WebhookConfig extends ReturnType<typeof makeConfig> {
|
|
17
37
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webhook.d.ts","sourceRoot":"","sources":["../src/Interactions/webhook.ts"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"webhook.d.ts","sourceRoot":"","sources":["../src/Interactions/webhook.ts"],"names":[],"mappings":";AAAA,OAAO,MAAM,MAAM,gBAAgB,CAAA;AAEnC,OAAO,EAAE,kBAAkB,EAAY,MAAM,eAAe,CAAA;AAC5D,OAAO,EAAE,kBAAkB,EAAe,MAAM,YAAY,CAAA;AAE5D,qBAAa,mBAAmB;IAC9B,QAAQ,CAAC,IAAI,yBAAwB;CACtC;AAED,MAAM,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS,CAAC,CAAA;AA4BnE,MAAM,WAAW,cAAc;IAC7B,aAAa,EAAE,MAAM,CAAA;IACrB,SAAS,EAAE,YAAY,CAAA;IACvB,MAAM,EAAE,YAAY,CAAA;IACpB,SAAS,EAAE,MAAM,OAAO,MAAM,CAAC,iBAAiB,CAAA;CACjD;AACD,QAAA,MAAM,UAAU,qDAKb,cAAc;;;;;;;;;;;;;;;;;;;;CAKf,CAAA;AACF,MAAM,WAAW,aAAc,SAAQ,UAAU,CAAC,OAAO,UAAU,CAAC;CAAG;AACvE,eAAO,MAAM,aAAa,kEAAuB,CAAA;AACjD,eAAO,MAAM,eAAe,mGAE3B,CAAA;AACD,eAAO,MAAM,cAAc,MAAO,OAAO,cAAc,CAAC,2GACP,CAAA;AAEjD,qBAAa,iBAAiB;IAEhB,QAAQ,CAAC,MAAM,EAAE,OAAO;IADpC,QAAQ,CAAC,IAAI,uBAAsB;gBACd,MAAM,EAAE,OAAO;CACrC;AAyCD,MAAM,WAAW,iBAAiB,CAAC,CAAC;IAClC,OAAO,EAAE,OAAO,CAAA;IAChB,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,CAAC,CAAC,EAAE,OAAO,CAAC,mBAAmB,KAAK,MAAM,CAAC,KAAK,EAAE,KAAK,EAAE,IAAI,CAAC,CAAA;IACvE,KAAK,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,KAAK,MAAM,CAAC,KAAK,EAAE,KAAK,EAAE,IAAI,CAAC,CAAA;CACnD;;;;;AAKD,eAAO,MAAM,WAAW,6OAcvB,CAAA;;;;;AAKD,eAAO,MAAM,iBAAiB;aAQU,OAAO;UAAQ,MAAM;gKAE5D,CAAA"}
|
package/Interactions/webhook.js
CHANGED
|
@@ -1,32 +1,29 @@
|
|
|
1
|
-
import * as tsplus_module_1 from "@effect/
|
|
2
|
-
import * as tsplus_module_2 from "@effect/data/
|
|
3
|
-
import * as tsplus_module_3 from "@effect/
|
|
4
|
-
import * as tsplus_module_4 from "
|
|
5
|
-
import * as tsplus_module_5 from "
|
|
6
|
-
import * as tsplus_module_6 from "@effect/
|
|
7
|
-
import * as tsplus_module_7 from "@effect/
|
|
8
|
-
import
|
|
9
|
-
import Nacl from "tweetnacl";
|
|
1
|
+
import * as tsplus_module_1 from "@effect/io/Effect";
|
|
2
|
+
import * as tsplus_module_2 from "@effect/data/Function";
|
|
3
|
+
import * as tsplus_module_3 from "@effect/data/Option";
|
|
4
|
+
import * as tsplus_module_4 from "@effect/io/Config/Secret";
|
|
5
|
+
import * as tsplus_module_5 from "dfx/_common";
|
|
6
|
+
import * as tsplus_module_6 from "@effect/io/Layer";
|
|
7
|
+
import * as tsplus_module_7 from "@effect/data/Chunk";
|
|
8
|
+
import Verify from "discord-verify";
|
|
10
9
|
import { handlers } from "./handlers.js";
|
|
11
10
|
import { Interaction } from "./index.js";
|
|
12
|
-
import { fromHex } from "./utils.js";
|
|
13
11
|
export class BadWebhookSignature {
|
|
14
12
|
_tag = "BadWebhookSignature";
|
|
15
13
|
}
|
|
16
|
-
const checkSignature = (publicKey, headers, body) =>
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
})(tsplus_module_1.
|
|
20
|
-
|
|
21
|
-
timestamp: tsplus_module_1.fromNullable(headers["x-signature-timestamp"]),
|
|
22
|
-
}))));
|
|
23
|
-
const makeConfig = ({ applicationId, publicKey }) => ({
|
|
14
|
+
const checkSignature = (publicKey, headers, body, crypto, algorithm) => tsplus_module_1.asUnit(tsplus_module_1.catchAllCause(tsplus_module_1.filterOrFail(tsplus_module_1.flatMap(tsplus_module_3.struct({
|
|
15
|
+
signature: tsplus_module_3.fromNullable(headers["x-signature-ed25519"]),
|
|
16
|
+
timestamp: tsplus_module_3.fromNullable(headers["x-signature-timestamp"]),
|
|
17
|
+
}), _ => tsplus_module_1.promise(() => Verify.verify(body, _.signature, _.timestamp, publicKey, crypto, algorithm))), tsplus_module_2.identity, () => new BadWebhookSignature()), () => tsplus_module_1.fail(new BadWebhookSignature())));
|
|
18
|
+
const makeConfig = ({ applicationId, publicKey, crypto, algorithm, }) => ({
|
|
24
19
|
applicationId,
|
|
25
|
-
publicKey:
|
|
20
|
+
publicKey: tsplus_module_4.value(publicKey),
|
|
21
|
+
crypto,
|
|
22
|
+
algorithm: Verify.PlatformAlgorithm[algorithm],
|
|
26
23
|
});
|
|
27
|
-
export const WebhookConfig =
|
|
28
|
-
export const makeConfigLayer =
|
|
29
|
-
export const makeFromConfig = (a) =>
|
|
24
|
+
export const WebhookConfig = tsplus_module_5.Tag();
|
|
25
|
+
export const makeConfigLayer = tsplus_module_2.flow(makeConfig, _ => tsplus_module_6.succeed(WebhookConfig, _));
|
|
26
|
+
export const makeFromConfig = (a) => tsplus_module_1.toLayer(tsplus_module_1.map(tsplus_module_1.config(a), makeConfig), WebhookConfig);
|
|
30
27
|
export class WebhookParseError {
|
|
31
28
|
reason;
|
|
32
29
|
_tag = "WebhookParseError";
|
|
@@ -34,23 +31,23 @@ export class WebhookParseError {
|
|
|
34
31
|
this.reason = reason;
|
|
35
32
|
}
|
|
36
33
|
}
|
|
37
|
-
const fromHeadersAndBody = (headers, body) =>
|
|
34
|
+
const fromHeadersAndBody = (headers, body) => tsplus_module_1.flatMap(WebhookConfig, ({ publicKey, crypto, algorithm }) => tsplus_module_1.flatMap(checkSignature(publicKey, headers, body, crypto, algorithm), () => tsplus_module_1.tryCatch(() => JSON.parse(body), reason => new WebhookParseError(reason))));
|
|
38
35
|
const run = (definitions, handleResponse) => {
|
|
39
36
|
const handler = handlers(definitions, handleResponse);
|
|
40
|
-
return (headers, body) =>
|
|
37
|
+
return (headers, body) => tsplus_module_1.flatMap(fromHeadersAndBody(headers, body), interaction => tsplus_module_1.provideService(handler[interaction.type](interaction), Interaction, interaction));
|
|
41
38
|
};
|
|
42
39
|
/**
|
|
43
40
|
* @tsplus getter dfx/InteractionBuilder webhookHandler
|
|
44
41
|
*/
|
|
45
42
|
export const makeHandler = (ix) => {
|
|
46
|
-
const handle = run(
|
|
47
|
-
return ({ headers, body, success, error, }) =>
|
|
43
|
+
const handle = run(tsplus_module_7.map(ix.definitions, ([d]) => [d, tsplus_module_2.identity]), (_i, r) => tsplus_module_1.succeed(r));
|
|
44
|
+
return ({ headers, body, success, error, }) => tsplus_module_1.catchAllCause(tsplus_module_1.flatMap(handle(headers, body), success), error);
|
|
48
45
|
};
|
|
49
46
|
/**
|
|
50
47
|
* @tsplus getter dfx/InteractionBuilder simpleWebhookHandler
|
|
51
48
|
*/
|
|
52
49
|
export const makeSimpleHandler = (ix) => {
|
|
53
|
-
const handle = run(
|
|
50
|
+
const handle = run(tsplus_module_7.map(ix.definitions, ([d]) => [d, tsplus_module_2.identity]), (_i, r) => tsplus_module_1.succeed(r));
|
|
54
51
|
return ({ headers, body }) => handle(headers, body);
|
|
55
52
|
};
|
|
56
53
|
//# sourceMappingURL=webhook.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webhook.js","sourceRoot":"","sources":["../src/Interactions/webhook.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"webhook.js","sourceRoot":"","sources":["../src/Interactions/webhook.ts"],"names":[],"mappings":";;;;;;;AAAA,OAAO,MAAM,MAAM,gBAAgB,CAAA;AAEnC,OAAO,EAAsB,QAAQ,EAAE,MAAM,eAAe,CAAA;AAC5D,OAAO,EAAsB,WAAW,EAAE,MAAM,YAAY,CAAA;AAE5D,MAAM,OAAO,mBAAmB;IACrB,IAAI,GAAG,qBAAqB,CAAA;CACtC;AAID,MAAM,cAAc,GAAG,CACrB,SAAiB,EACjB,OAAgB,EAChB,IAAY,EACZ,MAAoB,EACpB,SAAc,EACd,EAAE,wBACF,8BAAA,6BAAA,wBAAA,uBAAa;IACX,SAAS,EAAE,6BAAmB,OAAO,CAAC,qBAAqB,CAAC,CAAC;IAC7D,SAAS,EAAE,6BAAmB,OAAO,CAAC,uBAAuB,CAAC,CAAC;CAChE,CAAC,EACS,CAAC,CAAC,EAAE,CACX,wBAAe,GAAG,EAAE,CAClB,MAAM,CAAC,MAAM,CACX,IAAI,EACJ,CAAC,CAAC,SAAmB,EACrB,CAAC,CAAC,SAAmB,EACrB,SAAS,EACT,MAAM,EACN,SAAS,CACV,CACF,CACF,kBACa,QAAQ,EAAE,GAAG,EAAE,CAAC,IAAI,mBAAmB,EAAE,CAAC,EACzC,GAAG,EAAE,CAAC,qBAAY,IAAI,mBAAmB,EAAE,CAAC,CAAC,CAAO,CAAA;AAQvE,MAAM,UAAU,GAAG,CAAC,EAClB,aAAa,EACb,SAAS,EACT,MAAM,EACN,SAAS,GACM,EAAE,EAAE,CAAC,CAAC;IACrB,aAAa;IACb,SAAS,wBAAE,SAAS,CAAM;IAC1B,MAAM;IACN,SAAS,EAAE,MAAM,CAAC,iBAAiB,CAAC,SAAS,CAAC;CAC/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,GAAG,CAAW,EAAgC,EAAE,EAAE;IACxE,MAAM,MAAM,GAAG,GAAG,CAChB,oBAAA,EAAE,CAAC,WAAW,EAAK,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,kBAAE,QAAQ,CAAQ,CAAC,EACjD,CAAC,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC,wBAAe,CAAC,CAAC,CAC7B,CAAA;IAED,OAAO,CAAC,EACN,OAAO,EACP,IAAI,EACJ,OAAO,EACP,KAAK,GAGN,EAAE,EAAE,CAAC,8BAAA,wBAAA,MAAM,CAAC,OAAO,EAAE,IAAI,CAAC,EAAS,OAAO,CAAC,EAAe,KAAK,CAAC,CAAA;AACnE,CAAC,CAAA;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAC/B,EAAgC,EAChC,EAAE;IACF,MAAM,MAAM,GAAG,GAAG,CAChB,oBAAA,EAAE,CAAC,WAAW,EAAK,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,kBAAE,QAAQ,CAAQ,CAAC,EACjD,CAAC,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC,wBAAe,CAAC,CAAC,CAC7B,CAAA;IAED,OAAO,CAAC,EAAE,OAAO,EAAE,IAAI,EAAsC,EAAE,EAAE,CAC/D,MAAM,CAAC,OAAO,EAAE,IAAI,CAAC,CAAA;AACzB,CAAC,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dfx",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.46.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public",
|
|
@@ -24,9 +24,9 @@
|
|
|
24
24
|
"./*": "./*.js"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
|
-
"@tim-smart/discord-api-docs-parser": "^0.5.
|
|
28
|
-
"@tsplus-types/effect__data": "0.12.
|
|
29
|
-
"@tsplus-types/effect__io": "0.25.
|
|
27
|
+
"@tim-smart/discord-api-docs-parser": "^0.5.5",
|
|
28
|
+
"@tsplus-types/effect__data": "0.12.3-11739c0",
|
|
29
|
+
"@tsplus-types/effect__io": "0.25.13-11739c0",
|
|
30
30
|
"@tsplus-types/effect__stream": "0.21.1-3b576ba",
|
|
31
31
|
"@types/ws": "^8.5.4",
|
|
32
32
|
"dotenv": "^16.0.3",
|
|
@@ -35,11 +35,11 @@
|
|
|
35
35
|
"typescript": "https://cdn.jsdelivr.net/npm/@tsplus/installer@0.0.171/compiler/typescript.tgz"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@effect-http/client": "^0.26.
|
|
39
|
-
"@effect/data": "^0.12.
|
|
40
|
-
"@effect/io": "~0.25.
|
|
38
|
+
"@effect-http/client": "^0.26.1",
|
|
39
|
+
"@effect/data": "^0.12.3",
|
|
40
|
+
"@effect/io": "~0.25.13",
|
|
41
41
|
"@effect/stream": "~0.21.1",
|
|
42
|
-
"
|
|
42
|
+
"discord-verify": "^1.1.0"
|
|
43
43
|
},
|
|
44
44
|
"optionalDependencies": {
|
|
45
45
|
"bufferutil": "^4.0.7",
|
|
@@ -48,5 +48,5 @@
|
|
|
48
48
|
"ws": "^8.13.0"
|
|
49
49
|
},
|
|
50
50
|
"sideEffects": false,
|
|
51
|
-
"gitHead": "
|
|
51
|
+
"gitHead": "9f590136acf51c032e798e3d5585b6ebd048fe5b"
|
|
52
52
|
}
|
|
@@ -84,41 +84,3 @@ export const splitDefinitions = <R, E, TE, A>(
|
|
|
84
84
|
Commands,
|
|
85
85
|
}
|
|
86
86
|
}
|
|
87
|
-
const MAP_HEX: Record<string, number> = {
|
|
88
|
-
0: 0,
|
|
89
|
-
1: 1,
|
|
90
|
-
2: 2,
|
|
91
|
-
3: 3,
|
|
92
|
-
4: 4,
|
|
93
|
-
5: 5,
|
|
94
|
-
6: 6,
|
|
95
|
-
7: 7,
|
|
96
|
-
8: 8,
|
|
97
|
-
9: 9,
|
|
98
|
-
a: 10,
|
|
99
|
-
b: 11,
|
|
100
|
-
c: 12,
|
|
101
|
-
d: 13,
|
|
102
|
-
e: 14,
|
|
103
|
-
f: 15,
|
|
104
|
-
A: 10,
|
|
105
|
-
B: 11,
|
|
106
|
-
C: 12,
|
|
107
|
-
D: 13,
|
|
108
|
-
E: 14,
|
|
109
|
-
F: 15,
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
export function fromHex(hexString: string) {
|
|
113
|
-
const bytes = new Uint8Array(Math.floor((hexString || "").length / 2))
|
|
114
|
-
let i
|
|
115
|
-
for (i = 0; i < bytes.length; i++) {
|
|
116
|
-
const a = MAP_HEX[hexString[i * 2]]
|
|
117
|
-
const b = MAP_HEX[hexString[i * 2 + 1]]
|
|
118
|
-
if (a === undefined || b === undefined) {
|
|
119
|
-
break
|
|
120
|
-
}
|
|
121
|
-
bytes[i] = (a << 4) | b
|
|
122
|
-
}
|
|
123
|
-
return i === bytes.length ? bytes : bytes.slice(0, i)
|
|
124
|
-
}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import
|
|
1
|
+
import Verify from "discord-verify"
|
|
2
2
|
import * as D from "./definitions.js"
|
|
3
3
|
import { DefinitionNotFound, handlers } from "./handlers.js"
|
|
4
4
|
import { InteractionBuilder, Interaction } from "./index.js"
|
|
5
|
-
import { fromHex } from "./utils.js"
|
|
6
5
|
|
|
7
6
|
export class BadWebhookSignature {
|
|
8
7
|
readonly _tag = "BadWebhookSignature"
|
|
@@ -11,31 +10,47 @@ export class BadWebhookSignature {
|
|
|
11
10
|
export type Headers = Record<string, string | string[] | undefined>
|
|
12
11
|
|
|
13
12
|
const checkSignature = (
|
|
14
|
-
publicKey:
|
|
13
|
+
publicKey: string,
|
|
15
14
|
headers: Headers,
|
|
16
15
|
body: string,
|
|
16
|
+
crypto: SubtleCrypto,
|
|
17
|
+
algorithm: any,
|
|
17
18
|
) =>
|
|
18
19
|
Maybe.struct({
|
|
19
20
|
signature: Maybe.fromNullable(headers["x-signature-ed25519"]),
|
|
20
21
|
timestamp: Maybe.fromNullable(headers["x-signature-timestamp"]),
|
|
21
22
|
})
|
|
22
|
-
.
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
23
|
+
.flatMap(_ =>
|
|
24
|
+
Effect.promise(() =>
|
|
25
|
+
Verify.verify(
|
|
26
|
+
body,
|
|
27
|
+
_.signature as string,
|
|
28
|
+
_.timestamp as string,
|
|
29
|
+
publicKey,
|
|
30
|
+
crypto,
|
|
31
|
+
algorithm,
|
|
32
|
+
),
|
|
33
|
+
),
|
|
34
|
+
)
|
|
35
|
+
.filterOrFail(identity, () => new BadWebhookSignature())
|
|
36
|
+
.catchAllCause(() => Effect.fail(new BadWebhookSignature())).asUnit
|
|
31
37
|
|
|
32
38
|
export interface MakeConfigOpts {
|
|
33
39
|
applicationId: string
|
|
34
40
|
publicKey: ConfigSecret
|
|
41
|
+
crypto: SubtleCrypto
|
|
42
|
+
algorithm: keyof typeof Verify.PlatformAlgorithm
|
|
35
43
|
}
|
|
36
|
-
const makeConfig = ({
|
|
44
|
+
const makeConfig = ({
|
|
45
|
+
applicationId,
|
|
46
|
+
publicKey,
|
|
47
|
+
crypto,
|
|
48
|
+
algorithm,
|
|
49
|
+
}: MakeConfigOpts) => ({
|
|
37
50
|
applicationId,
|
|
38
|
-
publicKey:
|
|
51
|
+
publicKey: publicKey.value,
|
|
52
|
+
crypto,
|
|
53
|
+
algorithm: Verify.PlatformAlgorithm[algorithm],
|
|
39
54
|
})
|
|
40
55
|
export interface WebhookConfig extends ReturnType<typeof makeConfig> {}
|
|
41
56
|
export const WebhookConfig = Tag<WebhookConfig>()
|
|
@@ -52,8 +67,8 @@ export class WebhookParseError {
|
|
|
52
67
|
|
|
53
68
|
const fromHeadersAndBody = (headers: Headers, body: string) =>
|
|
54
69
|
Do($ => {
|
|
55
|
-
const { publicKey } = $(WebhookConfig)
|
|
56
|
-
$(checkSignature(publicKey, headers, body))
|
|
70
|
+
const { publicKey, crypto, algorithm } = $(WebhookConfig)
|
|
71
|
+
$(checkSignature(publicKey, headers, body, crypto, algorithm))
|
|
57
72
|
return $(
|
|
58
73
|
Effect.tryCatch(
|
|
59
74
|
() => JSON.parse(body) as Discord.Interaction,
|
package/src/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dfx",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.46.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public",
|
|
@@ -24,9 +24,9 @@
|
|
|
24
24
|
"./*": "./*.js"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
|
-
"@tim-smart/discord-api-docs-parser": "^0.5.
|
|
28
|
-
"@tsplus-types/effect__data": "0.12.
|
|
29
|
-
"@tsplus-types/effect__io": "0.25.
|
|
27
|
+
"@tim-smart/discord-api-docs-parser": "^0.5.5",
|
|
28
|
+
"@tsplus-types/effect__data": "0.12.3-11739c0",
|
|
29
|
+
"@tsplus-types/effect__io": "0.25.13-11739c0",
|
|
30
30
|
"@tsplus-types/effect__stream": "0.21.1-3b576ba",
|
|
31
31
|
"@types/ws": "^8.5.4",
|
|
32
32
|
"dotenv": "^16.0.3",
|
|
@@ -35,11 +35,11 @@
|
|
|
35
35
|
"typescript": "https://cdn.jsdelivr.net/npm/@tsplus/installer@0.0.171/compiler/typescript.tgz"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@effect-http/client": "^0.26.
|
|
39
|
-
"@effect/data": "^0.12.
|
|
40
|
-
"@effect/io": "~0.25.
|
|
38
|
+
"@effect-http/client": "^0.26.1",
|
|
39
|
+
"@effect/data": "^0.12.3",
|
|
40
|
+
"@effect/io": "~0.25.13",
|
|
41
41
|
"@effect/stream": "~0.21.1",
|
|
42
|
-
"
|
|
42
|
+
"discord-verify": "^1.1.0"
|
|
43
43
|
},
|
|
44
44
|
"optionalDependencies": {
|
|
45
45
|
"bufferutil": "^4.0.7",
|
|
@@ -48,5 +48,5 @@
|
|
|
48
48
|
"ws": "^8.13.0"
|
|
49
49
|
},
|
|
50
50
|
"sideEffects": false,
|
|
51
|
-
"gitHead": "
|
|
51
|
+
"gitHead": "9f590136acf51c032e798e3d5585b6ebd048fe5b"
|
|
52
52
|
}
|
package/src/types.ts
CHANGED
|
@@ -1212,10 +1212,11 @@ export function createRoutes<O = any>(
|
|
|
1212
1212
|
params,
|
|
1213
1213
|
options,
|
|
1214
1214
|
}),
|
|
1215
|
-
createFollowupMessage: (applicationId, interactionToken, options) =>
|
|
1215
|
+
createFollowupMessage: (applicationId, interactionToken, params, options) =>
|
|
1216
1216
|
fetch({
|
|
1217
1217
|
method: "POST",
|
|
1218
1218
|
url: `/webhooks/${applicationId}/${interactionToken}`,
|
|
1219
|
+
params,
|
|
1219
1220
|
options,
|
|
1220
1221
|
}),
|
|
1221
1222
|
createGlobalApplicationCommand: (applicationId, params, options) =>
|
|
@@ -1536,11 +1537,13 @@ export function createRoutes<O = any>(
|
|
|
1536
1537
|
applicationId,
|
|
1537
1538
|
interactionToken,
|
|
1538
1539
|
messageId,
|
|
1540
|
+
params,
|
|
1539
1541
|
options,
|
|
1540
1542
|
) =>
|
|
1541
1543
|
fetch({
|
|
1542
1544
|
method: "PATCH",
|
|
1543
1545
|
url: `/webhooks/${applicationId}/${interactionToken}/messages/${messageId}`,
|
|
1546
|
+
params,
|
|
1544
1547
|
options,
|
|
1545
1548
|
}),
|
|
1546
1549
|
editGlobalApplicationCommand: (applicationId, commandId, params, options) =>
|
|
@@ -1573,11 +1576,13 @@ export function createRoutes<O = any>(
|
|
|
1573
1576
|
editOriginalInteractionResponse: (
|
|
1574
1577
|
applicationId,
|
|
1575
1578
|
interactionToken,
|
|
1579
|
+
params,
|
|
1576
1580
|
options,
|
|
1577
1581
|
) =>
|
|
1578
1582
|
fetch({
|
|
1579
1583
|
method: "PATCH",
|
|
1580
1584
|
url: `/webhooks/${applicationId}/${interactionToken}/messages/@original`,
|
|
1585
|
+
params,
|
|
1581
1586
|
options,
|
|
1582
1587
|
}),
|
|
1583
1588
|
editWebhookMessage: (webhookId, webhookToken, messageId, params, options) =>
|
|
@@ -1698,10 +1703,17 @@ export function createRoutes<O = any>(
|
|
|
1698
1703
|
params,
|
|
1699
1704
|
options,
|
|
1700
1705
|
}),
|
|
1701
|
-
getFollowupMessage: (
|
|
1706
|
+
getFollowupMessage: (
|
|
1707
|
+
applicationId,
|
|
1708
|
+
interactionToken,
|
|
1709
|
+
messageId,
|
|
1710
|
+
params,
|
|
1711
|
+
options,
|
|
1712
|
+
) =>
|
|
1702
1713
|
fetch({
|
|
1703
1714
|
method: "GET",
|
|
1704
1715
|
url: `/webhooks/${applicationId}/${interactionToken}/messages/${messageId}`,
|
|
1716
|
+
params,
|
|
1705
1717
|
options,
|
|
1706
1718
|
}),
|
|
1707
1719
|
getGateway: options =>
|
|
@@ -1920,11 +1932,13 @@ export function createRoutes<O = any>(
|
|
|
1920
1932
|
getOriginalInteractionResponse: (
|
|
1921
1933
|
applicationId,
|
|
1922
1934
|
interactionToken,
|
|
1935
|
+
params,
|
|
1923
1936
|
options,
|
|
1924
1937
|
) =>
|
|
1925
1938
|
fetch({
|
|
1926
1939
|
method: "GET",
|
|
1927
1940
|
url: `/webhooks/${applicationId}/${interactionToken}/messages/@original`,
|
|
1941
|
+
params,
|
|
1928
1942
|
options,
|
|
1929
1943
|
}),
|
|
1930
1944
|
getPinnedMessages: (channelId, options) =>
|
|
@@ -2667,6 +2681,7 @@ export interface Endpoints<O> {
|
|
|
2667
2681
|
createFollowupMessage: (
|
|
2668
2682
|
applicationId: string,
|
|
2669
2683
|
interactionToken: string,
|
|
2684
|
+
params?: Partial<ExecuteWebhookParams>,
|
|
2670
2685
|
options?: O,
|
|
2671
2686
|
) => RestResponse<any>
|
|
2672
2687
|
createGlobalApplicationCommand: (
|
|
@@ -2930,8 +2945,9 @@ The emoji must be URL Encoded or the request will fail with 10014: Unknown Emoji
|
|
|
2930
2945
|
applicationId: string,
|
|
2931
2946
|
interactionToken: string,
|
|
2932
2947
|
messageId: string,
|
|
2948
|
+
params?: Partial<EditWebhookMessageParams>,
|
|
2933
2949
|
options?: O,
|
|
2934
|
-
) => RestResponse<
|
|
2950
|
+
) => RestResponse<Message>
|
|
2935
2951
|
editGlobalApplicationCommand: (
|
|
2936
2952
|
applicationId: string,
|
|
2937
2953
|
commandId: string,
|
|
@@ -2956,8 +2972,9 @@ The emoji must be URL Encoded or the request will fail with 10014: Unknown Emoji
|
|
|
2956
2972
|
editOriginalInteractionResponse: (
|
|
2957
2973
|
applicationId: string,
|
|
2958
2974
|
interactionToken: string,
|
|
2975
|
+
params?: Partial<EditWebhookMessageParams>,
|
|
2959
2976
|
options?: O,
|
|
2960
|
-
) => RestResponse<
|
|
2977
|
+
) => RestResponse<Message>
|
|
2961
2978
|
/** Edits a previously-sent webhook message from the same token. Returns a message object on success. */
|
|
2962
2979
|
editWebhookMessage: (
|
|
2963
2980
|
webhookId: string,
|
|
@@ -3055,8 +3072,9 @@ The emoji must be URL Encoded or the request will fail with 10014: Unknown Emoji
|
|
|
3055
3072
|
applicationId: string,
|
|
3056
3073
|
interactionToken: string,
|
|
3057
3074
|
messageId: string,
|
|
3075
|
+
params?: Partial<GetWebhookMessageParams>,
|
|
3058
3076
|
options?: O,
|
|
3059
|
-
) => RestResponse<
|
|
3077
|
+
) => RestResponse<Message>
|
|
3060
3078
|
getGateway: (options?: O) => RestResponse<any>
|
|
3061
3079
|
getGatewayBot: (options?: O) => RestResponse<GetGatewayBotResponse>
|
|
3062
3080
|
/** Fetch a global command for your application. Returns an application command object. */
|
|
@@ -3216,8 +3234,9 @@ The emoji must be URL Encoded or the request will fail with 10014: Unknown Emoji
|
|
|
3216
3234
|
getOriginalInteractionResponse: (
|
|
3217
3235
|
applicationId: string,
|
|
3218
3236
|
interactionToken: string,
|
|
3237
|
+
params?: Partial<GetWebhookMessageParams>,
|
|
3219
3238
|
options?: O,
|
|
3220
|
-
) => RestResponse<
|
|
3239
|
+
) => RestResponse<Message>
|
|
3221
3240
|
/** Returns all pinned messages in the channel as an array of message objects. */
|
|
3222
3241
|
getPinnedMessages: (channelId: string, options?: O) => RestResponse<Message[]>
|
|
3223
3242
|
/** Get a list of users that reacted with this emoji. Returns an array of user objects on success.
|
|
@@ -3912,6 +3931,8 @@ export interface Guild {
|
|
|
3912
3931
|
readonly stickers?: Sticker[]
|
|
3913
3932
|
/** whether the guild has the boost progress bar enabled */
|
|
3914
3933
|
readonly premium_progress_bar_enabled: boolean
|
|
3934
|
+
/** the id of the channel where admins and moderators of Community guilds receive safety alerts from Discord */
|
|
3935
|
+
readonly safety_alerts_channel_id?: Snowflake | null
|
|
3915
3936
|
}
|
|
3916
3937
|
export interface GuildApplicationCommandPermission {
|
|
3917
3938
|
/** ID of the command or the application ID */
|
|
@@ -4005,6 +4026,8 @@ export const enum GuildFeature {
|
|
|
4005
4026
|
PARTNERED = "PARTNERED",
|
|
4006
4027
|
/** guild can be previewed before joining via Membership Screening or the directory */
|
|
4007
4028
|
PREVIEW_ENABLED = "PREVIEW_ENABLED",
|
|
4029
|
+
/** guild has disabled alerts for join raids in the configured safety alerts channel */
|
|
4030
|
+
RAID_ALERTS_DISABLED = "RAID_ALERTS_DISABLED",
|
|
4008
4031
|
/** guild is able to set role icons */
|
|
4009
4032
|
ROLE_ICONS = "ROLE_ICONS",
|
|
4010
4033
|
/** guild has role subscriptions that can be purchased */
|
|
@@ -5166,6 +5189,8 @@ export interface ModifyGuildParams {
|
|
|
5166
5189
|
readonly description?: string | null
|
|
5167
5190
|
/** whether the guild's boost progress bar should be enabled */
|
|
5168
5191
|
readonly premium_progress_bar_enabled: boolean
|
|
5192
|
+
/** the id of the channel where admins and moderators of Community guilds receive safety alerts from Discord */
|
|
5193
|
+
readonly safety_alerts_channel_id?: Snowflake | null
|
|
5169
5194
|
}
|
|
5170
5195
|
export interface ModifyGuildRoleParams {
|
|
5171
5196
|
/** name of the role, max 100 characters */
|
|
@@ -5255,8 +5280,9 @@ export interface ModifyWebhookParams {
|
|
|
5255
5280
|
}
|
|
5256
5281
|
export const enum MutableGuildFeature {
|
|
5257
5282
|
COMMUNITY = "COMMUNITY",
|
|
5258
|
-
INVITES_DISABLED = "INVITES_DISABLED",
|
|
5259
5283
|
DISCOVERABLE = "DISCOVERABLE",
|
|
5284
|
+
INVITES_DISABLED = "INVITES_DISABLED",
|
|
5285
|
+
RAID_ALERTS_DISABLED = "RAID_ALERTS_DISABLED",
|
|
5260
5286
|
}
|
|
5261
5287
|
export const enum OAuth2Scope {
|
|
5262
5288
|
/** allows your app to fetch data from a user's "Now Playing/Recently Played" list — not currently available for apps */
|
|
@@ -5429,6 +5455,8 @@ export const PermissionFlag = {
|
|
|
5429
5455
|
VIEW_CREATOR_MONETIZATION_ANALYTICS: BigInt(1) << BigInt(41),
|
|
5430
5456
|
/** Allows for using soundboard in a voice channel */
|
|
5431
5457
|
USE_SOUNDBOARD: BigInt(1) << BigInt(42),
|
|
5458
|
+
/** Allows the usage of custom soundboard sounds from other servers */
|
|
5459
|
+
USE_EXTERNAL_SOUNDS: BigInt(1) << BigInt(45),
|
|
5432
5460
|
/** Allows sending voice messages */
|
|
5433
5461
|
SEND_VOICE_MESSAGES: BigInt(1) << BigInt(46),
|
|
5434
5462
|
} as const
|
|
@@ -6091,6 +6119,8 @@ export interface TriggerMetadatum {
|
|
|
6091
6119
|
readonly allow_list: string[]
|
|
6092
6120
|
/** MENTION_SPAM */
|
|
6093
6121
|
readonly mention_total_limit: number
|
|
6122
|
+
/** MENTION_SPAM */
|
|
6123
|
+
readonly mention_raid_protection_enabled: boolean
|
|
6094
6124
|
}
|
|
6095
6125
|
export const enum TriggerType {
|
|
6096
6126
|
/** check if content contains words from a user defined list of keywords */
|