@buape/carbon 0.1.3 → 0.3.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/dist/package.json +7 -2
- package/dist/src/abstracts/BaseCommand.d.ts +1 -6
- package/dist/src/abstracts/BaseCommand.d.ts.map +1 -1
- package/dist/src/abstracts/BaseCommand.js +0 -5
- package/dist/src/abstracts/BaseCommand.js.map +1 -1
- package/dist/src/abstracts/BaseComponentInteraction.d.ts +6 -1
- package/dist/src/abstracts/BaseComponentInteraction.d.ts.map +1 -1
- package/dist/src/abstracts/BaseComponentInteraction.js +12 -0
- package/dist/src/abstracts/BaseComponentInteraction.js.map +1 -1
- package/dist/src/abstracts/BaseInteraction.d.ts +14 -7
- package/dist/src/abstracts/BaseInteraction.d.ts.map +1 -1
- package/dist/src/abstracts/BaseInteraction.js +29 -8
- package/dist/src/abstracts/BaseInteraction.js.map +1 -1
- package/dist/src/classes/Client.d.ts +11 -0
- package/dist/src/classes/Client.d.ts.map +1 -1
- package/dist/src/classes/Client.js +43 -11
- package/dist/src/classes/Client.js.map +1 -1
- package/dist/src/classes/Modal.d.ts +21 -0
- package/dist/src/classes/Modal.d.ts.map +1 -0
- package/dist/src/classes/Modal.js +14 -0
- package/dist/src/classes/Modal.js.map +1 -0
- package/dist/src/classes/Row.d.ts +7 -9
- package/dist/src/classes/Row.d.ts.map +1 -1
- package/dist/src/classes/Row.js +5 -4
- package/dist/src/classes/Row.js.map +1 -1
- package/dist/src/classes/TextInput.d.ts +40 -0
- package/dist/src/classes/TextInput.d.ts.map +1 -0
- package/dist/src/classes/TextInput.js +44 -0
- package/dist/src/classes/TextInput.js.map +1 -0
- package/dist/src/index.d.ts +3 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +3 -0
- package/dist/src/index.js.map +1 -1
- package/dist/src/internals/AutocompleteInteraction.d.ts +1 -1
- package/dist/src/internals/CommandHandler.d.ts +4 -0
- package/dist/src/internals/CommandHandler.d.ts.map +1 -1
- package/dist/src/internals/CommandHandler.js +4 -0
- package/dist/src/internals/CommandHandler.js.map +1 -1
- package/dist/src/internals/ComponentHandler.d.ts +11 -0
- package/dist/src/internals/ComponentHandler.d.ts.map +1 -1
- package/dist/src/internals/ComponentHandler.js +15 -4
- package/dist/src/internals/ComponentHandler.js.map +1 -1
- package/dist/src/internals/FieldsHandler.d.ts +27 -0
- package/dist/src/internals/FieldsHandler.d.ts.map +1 -0
- package/dist/src/internals/FieldsHandler.js +37 -0
- package/dist/src/internals/FieldsHandler.js.map +1 -0
- package/dist/src/internals/ModalHandler.d.ts +17 -0
- package/dist/src/internals/ModalHandler.d.ts.map +1 -0
- package/dist/src/internals/ModalHandler.js +25 -0
- package/dist/src/internals/ModalHandler.js.map +1 -0
- package/dist/src/internals/ModalInteraction.d.ts +10 -0
- package/dist/src/internals/ModalInteraction.d.ts.map +1 -0
- package/dist/src/internals/ModalInteraction.js +12 -0
- package/dist/src/internals/ModalInteraction.js.map +1 -0
- package/dist/src/internals/OptionsHandler.d.ts +33 -17
- package/dist/src/internals/OptionsHandler.d.ts.map +1 -1
- package/dist/src/internals/OptionsHandler.js +52 -58
- package/dist/src/internals/OptionsHandler.js.map +1 -1
- package/dist/src/utils.d.ts +3 -0
- package/dist/src/utils.d.ts.map +1 -1
- package/dist/src/utils.js +54 -0
- package/dist/src/utils.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +6 -1
- package/.turbo/turbo-build.log +0 -5
- package/.turbo/turbo-dev.log +0 -175
- package/.turbo/turbo-docs.log +0 -12
- package/CHANGELOG.md +0 -34
- package/dist/src/abstracts/ButtonInteraction.d.ts +0 -8
- package/dist/src/abstracts/ButtonInteraction.d.ts.map +0 -1
- package/dist/src/abstracts/ButtonInteraction.js +0 -18
- package/dist/src/abstracts/ButtonInteraction.js.map +0 -1
- package/dist/src/abstracts/ChannelSelectMenuInteraction.d.ts +0 -7
- package/dist/src/abstracts/ChannelSelectMenuInteraction.d.ts.map +0 -1
- package/dist/src/abstracts/ChannelSelectMenuInteraction.js +0 -11
- package/dist/src/abstracts/ChannelSelectMenuInteraction.js.map +0 -1
- package/dist/src/abstracts/CommandHandler.d.ts +0 -6
- package/dist/src/abstracts/CommandHandler.d.ts.map +0 -1
- package/dist/src/abstracts/CommandHandler.js +0 -65
- package/dist/src/abstracts/CommandHandler.js.map +0 -1
- package/dist/src/abstracts/CommandInteraction.d.ts +0 -15
- package/dist/src/abstracts/CommandInteraction.d.ts.map +0 -1
- package/dist/src/abstracts/CommandInteraction.js +0 -60
- package/dist/src/abstracts/CommandInteraction.js.map +0 -1
- package/dist/src/abstracts/ComponentHandler.d.ts +0 -6
- package/dist/src/abstracts/ComponentHandler.d.ts.map +0 -1
- package/dist/src/abstracts/ComponentHandler.js +0 -64
- package/dist/src/abstracts/ComponentHandler.js.map +0 -1
- package/dist/src/abstracts/MentionableSelectMenuInteraction.d.ts +0 -8
- package/dist/src/abstracts/MentionableSelectMenuInteraction.d.ts.map +0 -1
- package/dist/src/abstracts/MentionableSelectMenuInteraction.js +0 -15
- package/dist/src/abstracts/MentionableSelectMenuInteraction.js.map +0 -1
- package/dist/src/abstracts/RoleSelectMenuInteraction.d.ts +0 -8
- package/dist/src/abstracts/RoleSelectMenuInteraction.d.ts.map +0 -1
- package/dist/src/abstracts/RoleSelectMenuInteraction.js +0 -14
- package/dist/src/abstracts/RoleSelectMenuInteraction.js.map +0 -1
- package/dist/src/abstracts/StringSelectMenuInteraction.d.ts +0 -8
- package/dist/src/abstracts/StringSelectMenuInteraction.d.ts.map +0 -1
- package/dist/src/abstracts/StringSelectMenuInteraction.js +0 -14
- package/dist/src/abstracts/StringSelectMenuInteraction.js.map +0 -1
- package/dist/src/abstracts/UserSelectMenuInteraction.d.ts +0 -8
- package/dist/src/abstracts/UserSelectMenuInteraction.d.ts.map +0 -1
- package/dist/src/abstracts/UserSelectMenuInteraction.js +0 -14
- package/dist/src/abstracts/UserSelectMenuInteraction.js.map +0 -1
- package/dist/src/classes/Paginator.d.ts +0 -3
- package/dist/src/classes/Paginator.d.ts.map +0 -1
- package/dist/src/classes/Paginator.js +0 -3
- package/dist/src/classes/Paginator.js.map +0 -1
- package/dist/src/structures/AnySelectMenu.d.ts +0 -31
- package/dist/src/structures/AnySelectMenu.d.ts.map +0 -1
- package/dist/src/structures/AnySelectMenu.js +0 -19
- package/dist/src/structures/AnySelectMenu.js.map +0 -1
- package/dist/src/structures/AnySelectMenuInteraction.d.ts +0 -12
- package/dist/src/structures/AnySelectMenuInteraction.d.ts.map +0 -1
- package/dist/src/structures/AnySelectMenuInteraction.js +0 -21
- package/dist/src/structures/AnySelectMenuInteraction.js.map +0 -1
- package/dist/src/structures/Base.d.ts +0 -10
- package/dist/src/structures/Base.d.ts.map +0 -1
- package/dist/src/structures/Base.js +0 -11
- package/dist/src/structures/Base.js.map +0 -1
- package/dist/src/structures/BaseCommand.d.ts +0 -64
- package/dist/src/structures/BaseCommand.d.ts.map +0 -1
- package/dist/src/structures/BaseCommand.js +0 -58
- package/dist/src/structures/BaseCommand.js.map +0 -1
- package/dist/src/structures/BaseComponent.d.ts +0 -34
- package/dist/src/structures/BaseComponent.d.ts.map +0 -1
- package/dist/src/structures/BaseComponent.js +0 -30
- package/dist/src/structures/BaseComponent.js.map +0 -1
- package/dist/src/structures/BaseComponentInteraction.d.ts +0 -9
- package/dist/src/structures/BaseComponentInteraction.d.ts.map +0 -1
- package/dist/src/structures/BaseComponentInteraction.js +0 -14
- package/dist/src/structures/BaseComponentInteraction.js.map +0 -1
- package/dist/src/structures/BaseInteraction.d.ts +0 -81
- package/dist/src/structures/BaseInteraction.d.ts.map +0 -1
- package/dist/src/structures/BaseInteraction.js +0 -99
- package/dist/src/structures/BaseInteraction.js.map +0 -1
- package/dist/src/structures/ButtonInteraction.d.ts +0 -8
- package/dist/src/structures/ButtonInteraction.d.ts.map +0 -1
- package/dist/src/structures/ButtonInteraction.js +0 -18
- package/dist/src/structures/ButtonInteraction.js.map +0 -1
- package/dist/src/structures/ChannelSelectMenuInteraction.d.ts +0 -7
- package/dist/src/structures/ChannelSelectMenuInteraction.d.ts.map +0 -1
- package/dist/src/structures/ChannelSelectMenuInteraction.js +0 -11
- package/dist/src/structures/ChannelSelectMenuInteraction.js.map +0 -1
- package/dist/src/structures/CommandHandler.d.ts +0 -6
- package/dist/src/structures/CommandHandler.d.ts.map +0 -1
- package/dist/src/structures/CommandHandler.js +0 -70
- package/dist/src/structures/CommandHandler.js.map +0 -1
- package/dist/src/structures/CommandInteraction.d.ts +0 -15
- package/dist/src/structures/CommandInteraction.d.ts.map +0 -1
- package/dist/src/structures/CommandInteraction.js +0 -60
- package/dist/src/structures/CommandInteraction.js.map +0 -1
- package/dist/src/structures/ComponentHandler.d.ts +0 -6
- package/dist/src/structures/ComponentHandler.d.ts.map +0 -1
- package/dist/src/structures/ComponentHandler.js +0 -64
- package/dist/src/structures/ComponentHandler.js.map +0 -1
- package/dist/src/structures/MentionableSelectMenuInteraction.d.ts +0 -8
- package/dist/src/structures/MentionableSelectMenuInteraction.d.ts.map +0 -1
- package/dist/src/structures/MentionableSelectMenuInteraction.js +0 -15
- package/dist/src/structures/MentionableSelectMenuInteraction.js.map +0 -1
- package/dist/src/structures/RoleSelectMenuInteraction.d.ts +0 -8
- package/dist/src/structures/RoleSelectMenuInteraction.d.ts.map +0 -1
- package/dist/src/structures/RoleSelectMenuInteraction.js +0 -14
- package/dist/src/structures/RoleSelectMenuInteraction.js.map +0 -1
- package/dist/src/structures/StringSelectMenuInteraction.d.ts +0 -8
- package/dist/src/structures/StringSelectMenuInteraction.d.ts.map +0 -1
- package/dist/src/structures/StringSelectMenuInteraction.js +0 -14
- package/dist/src/structures/StringSelectMenuInteraction.js.map +0 -1
- package/dist/src/structures/UserSelectMenuInteraction.d.ts +0 -8
- package/dist/src/structures/UserSelectMenuInteraction.d.ts.map +0 -1
- package/dist/src/structures/UserSelectMenuInteraction.js +0 -14
- package/dist/src/structures/UserSelectMenuInteraction.js.map +0 -1
- package/dist/src/types.d.ts +0 -31
- package/dist/src/types.d.ts.map +0 -1
- package/dist/src/types.js +0 -33
- package/dist/src/types.js.map +0 -1
- package/docs/classes/AnySelectMenu.mdx +0 -114
- package/docs/classes/AnySelectMenuInteraction.mdx +0 -175
- package/docs/classes/AutocompleteInteraction.mdx +0 -166
- package/docs/classes/AutocompleteOptionsHandler.mdx +0 -243
- package/docs/classes/BaseChannel.mdx +0 -97
- package/docs/classes/BaseCommand.mdx +0 -61
- package/docs/classes/BaseComponent.mdx +0 -55
- package/docs/classes/BaseComponentInteraction.mdx +0 -160
- package/docs/classes/BaseGuildChannel.mdx +0 -262
- package/docs/classes/BaseGuildTextChannel.mdx +0 -360
- package/docs/classes/BaseInteraction.mdx +0 -137
- package/docs/classes/Button.mdx +0 -99
- package/docs/classes/ButtonInteraction.mdx +0 -155
- package/docs/classes/ChannelSelectMenu.mdx +0 -122
- package/docs/classes/ChannelSelectMenuInteraction.mdx +0 -171
- package/docs/classes/Client.mdx +0 -48
- package/docs/classes/Command.mdx +0 -111
- package/docs/classes/CommandHandler.mdx +0 -65
- package/docs/classes/CommandInteraction.mdx +0 -155
- package/docs/classes/CommandWithSubcommandGroups.mdx +0 -73
- package/docs/classes/CommandWithSubcommands.mdx +0 -76
- package/docs/classes/ComponentHandler.mdx +0 -49
- package/docs/classes/DmChannel.mdx +0 -118
- package/docs/classes/GroupDmChannel.mdx +0 -197
- package/docs/classes/Guild.mdx +0 -157
- package/docs/classes/GuildAnnouncementChannel.mdx +0 -377
- package/docs/classes/GuildCategoryChannel.mdx +0 -272
- package/docs/classes/GuildForumChannel.mdx +0 -333
- package/docs/classes/GuildMediaChannel.mdx +0 -327
- package/docs/classes/GuildStageChannel.mdx +0 -276
- package/docs/classes/GuildStageOrVoiceChannel.mdx +0 -292
- package/docs/classes/GuildTextChannel.mdx +0 -367
- package/docs/classes/GuildThreadChannel.mdx +0 -425
- package/docs/classes/GuildThreadOnlyChannel.mdx +0 -333
- package/docs/classes/GuildVoiceChannel.mdx +0 -276
- package/docs/classes/LinkButton.mdx +0 -84
- package/docs/classes/MentionableSelectMenu.mdx +0 -120
- package/docs/classes/MentionableSelectMenuInteraction.mdx +0 -171
- package/docs/classes/Message.mdx +0 -126
- package/docs/classes/OptionsHandler.mdx +0 -203
- package/docs/classes/PremiumButton.mdx +0 -84
- package/docs/classes/Role.mdx +0 -228
- package/docs/classes/RoleSelectMenu.mdx +0 -120
- package/docs/classes/RoleSelectMenuInteraction.mdx +0 -171
- package/docs/classes/Row.mdx +0 -88
- package/docs/classes/StringSelectMenu.mdx +0 -120
- package/docs/classes/StringSelectMenuInteraction.mdx +0 -171
- package/docs/classes/User.mdx +0 -119
- package/docs/classes/UserSelectMenu.mdx +0 -120
- package/docs/classes/UserSelectMenuInteraction.mdx +0 -171
- package/docs/enumerations/ClientMode.mdx +0 -16
- package/docs/functions/channelFactory.mdx +0 -16
- package/docs/index.mdx +0 -83
- package/docs/type-aliases/AnySelectMenuComponentType.mdx +0 -5
- package/docs/type-aliases/ClientOptions.mdx +0 -20
- package/docs/type-aliases/CommandOptions.mdx +0 -5
- package/docs/type-aliases/ComponentAdditionalData.mdx +0 -9
- package/docs/type-aliases/InteractionFileData.mdx +0 -15
- package/docs/type-aliases/InteractionReplyData.mdx +0 -14
- package/docs/type-aliases/InteractionReplyOptions.mdx +0 -13
- package/docs/type-aliases/RawOptions.mdx +0 -9
- package/docs/type-aliases/meta.json +0 -3
- package/src/README.md +0 -7
- package/src/abstracts/AnySelectMenu.ts +0 -63
- package/src/abstracts/AnySelectMenuInteraction.ts +0 -29
- package/src/abstracts/Base.ts +0 -12
- package/src/abstracts/BaseChannel.ts +0 -73
- package/src/abstracts/BaseCommand.ts +0 -99
- package/src/abstracts/BaseComponent.ts +0 -49
- package/src/abstracts/BaseComponentInteraction.ts +0 -19
- package/src/abstracts/BaseGuildChannel.ts +0 -152
- package/src/abstracts/BaseGuildTextChannel.ts +0 -77
- package/src/abstracts/BaseInteraction.ts +0 -177
- package/src/abstracts/GuildThreadOnlyChannel.ts +0 -71
- package/src/classes/Button.ts +0 -95
- package/src/classes/ChannelSelectMenu.ts +0 -21
- package/src/classes/Client.ts +0 -254
- package/src/classes/Command.ts +0 -53
- package/src/classes/CommandWithSubcommandGroups.ts +0 -47
- package/src/classes/CommandWithSubcommands.ts +0 -35
- package/src/classes/MentionableSelectMenu.ts +0 -19
- package/src/classes/RoleSelectMenu.ts +0 -19
- package/src/classes/Row.ts +0 -44
- package/src/classes/StringSelectMenu.ts +0 -19
- package/src/classes/UserSelectMenu.ts +0 -19
- package/src/factories/channelFactory.ts +0 -43
- package/src/index.ts +0 -59
- package/src/internals/AutocompleteInteraction.ts +0 -107
- package/src/internals/ButtonInteraction.ts +0 -26
- package/src/internals/ChannelSelectMenuInteraction.ts +0 -15
- package/src/internals/CommandHandler.ts +0 -123
- package/src/internals/CommandInteraction.ts +0 -49
- package/src/internals/ComponentHandler.ts +0 -81
- package/src/internals/MentionableSelectMenuInteraction.ts +0 -21
- package/src/internals/OptionsHandler.ts +0 -148
- package/src/internals/RoleSelectMenuInteraction.ts +0 -20
- package/src/internals/StringSelectMenuInteraction.ts +0 -20
- package/src/internals/UserSelectMenuInteraction.ts +0 -20
- package/src/structures/DmChannel.ts +0 -31
- package/src/structures/GroupDmChannel.ts +0 -132
- package/src/structures/Guild.ts +0 -154
- package/src/structures/GuildAnnouncementChannel.ts +0 -20
- package/src/structures/GuildCategoryChannel.ts +0 -16
- package/src/structures/GuildForumChannel.ts +0 -20
- package/src/structures/GuildMediaChannel.ts +0 -13
- package/src/structures/GuildMember.ts +0 -231
- package/src/structures/GuildStageOrVoiceChannel.ts +0 -46
- package/src/structures/GuildTextChannel.ts +0 -21
- package/src/structures/GuildThreadChannel.ts +0 -150
- package/src/structures/Message.ts +0 -124
- package/src/structures/Role.ts +0 -201
- package/src/structures/User.ts +0 -153
- package/src/utils.ts +0 -13
- package/tests/index.test.ts +0 -4
- package/tsconfig.json +0 -12
- package/typedoc.json +0 -9
package/dist/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@buape/carbon",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/src/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -11,8 +11,13 @@
|
|
|
11
11
|
"license": "MIT",
|
|
12
12
|
"dependencies": {
|
|
13
13
|
"@buape/carbon-request": "workspace:*",
|
|
14
|
+
"@types/node": "20",
|
|
14
15
|
"discord-api-types": "0.37.99",
|
|
15
16
|
"discord-verify": "1.2.0",
|
|
16
17
|
"itty-router": "5.0.18"
|
|
17
|
-
}
|
|
18
|
+
},
|
|
19
|
+
"files": [
|
|
20
|
+
"dist",
|
|
21
|
+
"LICENSE"
|
|
22
|
+
]
|
|
18
23
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ApplicationCommandType, type RESTPostAPIApplicationCommandsJSONBody } from "discord-api-types/v10";
|
|
2
|
-
import { ApplicationIntegrationType,
|
|
2
|
+
import { ApplicationIntegrationType, InteractionContextType } from "../index.js";
|
|
3
3
|
/**
|
|
4
4
|
* Represents the base data of a command that the user creates
|
|
5
5
|
*/
|
|
@@ -34,11 +34,6 @@ export declare abstract class BaseCommand {
|
|
|
34
34
|
* @beta API types are not finalized
|
|
35
35
|
*/
|
|
36
36
|
contexts: InteractionContextType[];
|
|
37
|
-
/**
|
|
38
|
-
* All the components that the command is able to use.
|
|
39
|
-
* You mount these here so the handler can access them
|
|
40
|
-
*/
|
|
41
|
-
components?: BaseComponent[];
|
|
42
37
|
/**
|
|
43
38
|
* All the paginators that the command is able to use.
|
|
44
39
|
* You mount these here so the handler can access them
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BaseCommand.d.ts","sourceRoot":"","sources":["../../../src/abstracts/BaseCommand.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,sBAAsB,EACtB,KAAK,sCAAsC,EAC3C,MAAM,uBAAuB,CAAA;AAC9B,OAAO,
|
|
1
|
+
{"version":3,"file":"BaseCommand.d.ts","sourceRoot":"","sources":["../../../src/abstracts/BaseCommand.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,sBAAsB,EACtB,KAAK,sCAAsC,EAC3C,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAAE,0BAA0B,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAA;AAEhF;;GAEG;AACH,8BAAsB,WAAW;IAChC;;OAEG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB;;OAEG;IACH,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAA;IAC5B;;OAEG;IACH,KAAK,UAAQ;IACb;;OAEG;IACH,SAAS,UAAQ;IACjB;;OAEG;IACH,QAAQ,CAAC,IAAI,EAAE,sBAAsB,CAAA;IACrC;;;OAGG;IACH,gBAAgB,EAAE,0BAA0B,EAAE,CAG7C;IACD;;;OAGG;IACH,QAAQ,EAAE,sBAAsB,EAAE,CAIjC;IAED;;;OAGG;IAGH;;;OAGG;IACH,SAAS;IAyBT;;;OAGG;IACH,QAAQ,CAAC,gBAAgB,IAAI,sCAAsC,CAAC,SAAS,CAAC;CAC9E"}
|
|
@@ -29,11 +29,6 @@ export class BaseCommand {
|
|
|
29
29
|
InteractionContextType.BotDM,
|
|
30
30
|
InteractionContextType.PrivateChannel
|
|
31
31
|
];
|
|
32
|
-
/**
|
|
33
|
-
* All the components that the command is able to use.
|
|
34
|
-
* You mount these here so the handler can access them
|
|
35
|
-
*/
|
|
36
|
-
components = [];
|
|
37
32
|
/**
|
|
38
33
|
* All the paginators that the command is able to use.
|
|
39
34
|
* You mount these here so the handler can access them
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BaseCommand.js","sourceRoot":"","sources":["../../../src/abstracts/BaseCommand.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,sBAAsB,EAEtB,MAAM,u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I,CAAC,QAAQ;SACvB,CAAA;QAED,OAAO,IAAI,CAAA;IACZ,CAAC;CAOD"}
|
|
@@ -1,9 +1,14 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type APIMessageComponentInteraction, type ComponentType } from "discord-api-types/v10";
|
|
2
2
|
import type { Client } from "../classes/Client.js";
|
|
3
3
|
import { BaseInteraction } from "./BaseInteraction.js";
|
|
4
4
|
export declare class BaseComponentInteraction extends BaseInteraction<APIMessageComponentInteraction> {
|
|
5
5
|
customId: string;
|
|
6
6
|
componentType: ComponentType;
|
|
7
7
|
constructor(client: Client, data: APIMessageComponentInteraction);
|
|
8
|
+
/**
|
|
9
|
+
* Acknowledge the interaction, the user does not see a loading state.
|
|
10
|
+
* This can only be used for component interactions
|
|
11
|
+
*/
|
|
12
|
+
acknowledge(): Promise<void>;
|
|
8
13
|
}
|
|
9
14
|
//# sourceMappingURL=BaseComponentInteraction.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BaseComponentInteraction.d.ts","sourceRoot":"","sources":["../../../src/abstracts/BaseComponentInteraction.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"BaseComponentInteraction.d.ts","sourceRoot":"","sources":["../../../src/abstracts/BaseComponentInteraction.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,KAAK,8BAA8B,EACnC,KAAK,aAAa,EAGlB,MAAM,uBAAuB,CAAA;AAC9B,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAA;AAElD,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAEtD,qBAAa,wBAAyB,SAAQ,eAAe,CAAC,8BAA8B,CAAC;IAC5F,QAAQ,EAAE,MAAM,CAAA;IAChB,aAAa,EAAE,aAAa,CAAA;gBAChB,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,8BAA8B;IAQhE;;;OAGG;IACG,WAAW;CAUjB"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { InteractionResponseType, Routes } from "discord-api-types/v10";
|
|
1
2
|
import { splitCustomId } from "../utils.js";
|
|
2
3
|
import { BaseInteraction } from "./BaseInteraction.js";
|
|
3
4
|
export class BaseComponentInteraction extends BaseInteraction {
|
|
@@ -10,5 +11,16 @@ export class BaseComponentInteraction extends BaseInteraction {
|
|
|
10
11
|
this.customId = splitCustomId(data.data.custom_id)[0];
|
|
11
12
|
this.componentType = data.data.component_type;
|
|
12
13
|
}
|
|
14
|
+
/**
|
|
15
|
+
* Acknowledge the interaction, the user does not see a loading state.
|
|
16
|
+
* This can only be used for component interactions
|
|
17
|
+
*/
|
|
18
|
+
async acknowledge() {
|
|
19
|
+
await this.client.rest.post(Routes.interactionCallback(this.rawData.id, this.rawData.token), {
|
|
20
|
+
body: {
|
|
21
|
+
type: InteractionResponseType.DeferredMessageUpdate
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
}
|
|
13
25
|
}
|
|
14
26
|
//# sourceMappingURL=BaseComponentInteraction.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BaseComponentInteraction.js","sourceRoot":"","sources":["../../../src/abstracts/BaseComponentInteraction.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"BaseComponentInteraction.js","sourceRoot":"","sources":["../../../src/abstracts/BaseComponentInteraction.ts"],"names":[],"mappings":"AAAA,OAAO,EAGN,uBAAuB,EACvB,MAAM,EACN,MAAM,uBAAuB,CAAA;AAE9B,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAC3C,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAEtD,MAAM,OAAO,wBAAyB,SAAQ,eAA+C;IAC5F,QAAQ,CAAQ;IAChB,aAAa,CAAe;IAC5B,YAAY,MAAc,EAAE,IAAoC;QAC/D,KAAK,CAAC,MAAM,EAAE,IAAI,CAAC,CAAA;QACnB,IAAI,CAAC,IAAI,CAAC,IAAI;YACb,MAAM,IAAI,KAAK,CAAC,wDAAwD,CAAC,CAAA;QAC1E,IAAI,CAAC,QAAQ,GAAG,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAA;QACrD,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,IAAI,CAAC,cAAc,CAAA;IAC9C,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,WAAW;QAChB,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAC1B,MAAM,CAAC,mBAAmB,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,EAAE,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,EAC/D;YACC,IAAI,EAAE;gBACL,IAAI,EAAE,uBAAuB,CAAC,qBAAqB;aACnD;SACD,CACD,CAAA;IACF,CAAC;CACD"}
|
|
@@ -1,11 +1,6 @@
|
|
|
1
1
|
import { type APIInteraction, type InteractionType } from "discord-api-types/v10";
|
|
2
|
-
import type
|
|
3
|
-
import type { Row } from "../classes/Row.js";
|
|
4
|
-
import { Guild } from "../structures/Guild.js";
|
|
2
|
+
import { Base, type Client, Guild, Message, type Modal, type Row, User } from "../index.js";
|
|
5
3
|
import { GuildMember } from "../structures/GuildMember.js";
|
|
6
|
-
import { Message } from "../structures/Message.js";
|
|
7
|
-
import { User } from "../structures/User.js";
|
|
8
|
-
import { Base } from "./Base.js";
|
|
9
4
|
/**
|
|
10
5
|
* The data to reply to an interaction
|
|
11
6
|
*/
|
|
@@ -27,6 +22,10 @@ export type InteractionReplyOptions = {
|
|
|
27
22
|
* The files to send in the interaction
|
|
28
23
|
*/
|
|
29
24
|
files?: InteractionFileData[];
|
|
25
|
+
/**
|
|
26
|
+
* Whether the interaction should be ephemeral
|
|
27
|
+
*/
|
|
28
|
+
ephemeral?: boolean;
|
|
30
29
|
};
|
|
31
30
|
/**
|
|
32
31
|
* The data for a file to send in an interaction
|
|
@@ -67,7 +66,10 @@ export declare abstract class BaseInteraction<T extends APIInteraction> extends
|
|
|
67
66
|
* @internal
|
|
68
67
|
*/
|
|
69
68
|
_deferred: boolean;
|
|
70
|
-
|
|
69
|
+
private defaultEphemeral;
|
|
70
|
+
constructor(client: Client, data: T, defaults?: {
|
|
71
|
+
ephemeral?: boolean;
|
|
72
|
+
});
|
|
71
73
|
get message(): Message | null;
|
|
72
74
|
get guild(): Guild | null;
|
|
73
75
|
get user(): User | null;
|
|
@@ -85,5 +87,10 @@ export declare abstract class BaseInteraction<T extends APIInteraction> extends
|
|
|
85
87
|
* @internal
|
|
86
88
|
*/
|
|
87
89
|
defer(): Promise<void>;
|
|
90
|
+
/**
|
|
91
|
+
* Show a modal to the user
|
|
92
|
+
* This can only be used if the interaction is not deferred
|
|
93
|
+
*/
|
|
94
|
+
showModal(modal: Modal): Promise<void>;
|
|
88
95
|
}
|
|
89
96
|
//# sourceMappingURL=BaseInteraction.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BaseInteraction.d.ts","sourceRoot":"","sources":["../../../src/abstracts/BaseInteraction.ts"],"names":[],"mappings":"AAAA,OAAO,EAEN,KAAK,cAAc,EAEnB,KAAK,eAAe,EAEpB,MAAM,uBAAuB,CAAA;AAC9B,OAAO,
|
|
1
|
+
{"version":3,"file":"BaseInteraction.d.ts","sourceRoot":"","sources":["../../../src/abstracts/BaseInteraction.ts"],"names":[],"mappings":"AAAA,OAAO,EAEN,KAAK,cAAc,EAEnB,KAAK,eAAe,EAEpB,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EACN,IAAI,EACJ,KAAK,MAAM,EACX,KAAK,EACL,OAAO,EACP,KAAK,KAAK,EACV,KAAK,GAAG,EACR,IAAI,EAEJ,MAAM,aAAa,CAAA;AACpB,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAA;AAE1D;;GAEG;AACH,MAAM,MAAM,oBAAoB,GAAG;IAClC;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAA;IA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types/v10";
|
|
2
|
-
import { channelFactory } from "../
|
|
3
|
-
import { Guild } from "../structures/Guild.js";
|
|
2
|
+
import { Base, Guild, Message, User, channelFactory } from "../index.js";
|
|
4
3
|
import { GuildMember } from "../structures/GuildMember.js";
|
|
5
|
-
import { Message } from "../structures/Message.js";
|
|
6
|
-
import { User } from "../structures/User.js";
|
|
7
|
-
import { Base } from "./Base.js";
|
|
8
4
|
/**
|
|
9
5
|
* This is the base type interaction, all interaction types extend from this
|
|
10
6
|
*/
|
|
@@ -26,12 +22,15 @@ export class BaseInteraction extends Base {
|
|
|
26
22
|
* @internal
|
|
27
23
|
*/
|
|
28
24
|
_deferred = false;
|
|
29
|
-
|
|
25
|
+
defaultEphemeral = false;
|
|
26
|
+
constructor(client, data, defaults = {}) {
|
|
30
27
|
super(client);
|
|
31
28
|
this.rawData = data;
|
|
32
29
|
this.type = data.type;
|
|
33
30
|
this.userId =
|
|
34
31
|
this.rawData.user?.id || this.rawData.member?.user.id || undefined;
|
|
32
|
+
if (defaults.ephemeral)
|
|
33
|
+
this.defaultEphemeral = defaults.ephemeral;
|
|
35
34
|
}
|
|
36
35
|
get message() {
|
|
37
36
|
if (!this.rawData.message)
|
|
@@ -68,6 +67,11 @@ export class BaseInteraction extends Base {
|
|
|
68
67
|
* @param data The response data
|
|
69
68
|
*/
|
|
70
69
|
async reply(data, options = {}) {
|
|
70
|
+
data.components?.map((row) => {
|
|
71
|
+
row.components.map((component) => {
|
|
72
|
+
this.client.componentHandler.registerComponent(component);
|
|
73
|
+
});
|
|
74
|
+
});
|
|
71
75
|
if (this._deferred) {
|
|
72
76
|
await this.client.rest.patch(Routes.webhookMessage(this.client.options.clientId, this.rawData.token, "@original"), {
|
|
73
77
|
body: {
|
|
@@ -83,7 +87,8 @@ export class BaseInteraction extends Base {
|
|
|
83
87
|
type: InteractionResponseType.ChannelMessageWithSource,
|
|
84
88
|
data: {
|
|
85
89
|
...data,
|
|
86
|
-
components: data.components?.map((row) => row.serialize())
|
|
90
|
+
components: data.components?.map((row) => row.serialize()),
|
|
91
|
+
ephemeral: options.ephemeral ?? this.defaultEphemeral
|
|
87
92
|
}
|
|
88
93
|
},
|
|
89
94
|
files: options.files
|
|
@@ -101,7 +106,23 @@ export class BaseInteraction extends Base {
|
|
|
101
106
|
this._deferred = true;
|
|
102
107
|
await this.client.rest.post(Routes.interactionCallback(this.rawData.id, this.rawData.token), {
|
|
103
108
|
body: {
|
|
104
|
-
type: InteractionResponseType.DeferredChannelMessageWithSource
|
|
109
|
+
type: InteractionResponseType.DeferredChannelMessageWithSource,
|
|
110
|
+
ephemeral: this.defaultEphemeral
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Show a modal to the user
|
|
116
|
+
* This can only be used if the interaction is not deferred
|
|
117
|
+
*/
|
|
118
|
+
async showModal(modal) {
|
|
119
|
+
if (this._deferred)
|
|
120
|
+
throw new Error("You cannot defer an interaction that shows a modal");
|
|
121
|
+
this.client.modalHandler.registerModal(modal);
|
|
122
|
+
await this.client.rest.post(Routes.interactionCallback(this.rawData.id, this.rawData.token), {
|
|
123
|
+
body: {
|
|
124
|
+
type: InteractionResponseType.Modal,
|
|
125
|
+
data: modal.serialize()
|
|
105
126
|
}
|
|
106
127
|
});
|
|
107
128
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BaseInteraction.js","sourceRoot":"","sources":["../../../src/abstracts/BaseInteraction.ts"],"names":[],"mappings":"AAAA,OAAO,EAGN,uBAAuB,EAEvB,MAAM,EACN,MAAM,uBAAuB,CAAA;
|
|
1
|
+
{"version":3,"file":"BaseInteraction.js","sourceRoot":"","sources":["../../../src/abstracts/BaseInteraction.ts"],"names":[],"mappings":"AAAA,OAAO,EAGN,uBAAuB,EAEvB,MAAM,EACN,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EACN,IAAI,EAEJ,KAAK,EACL,OAAO,EAGP,IAAI,EACJ,cAAc,EACd,MAA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AAC,SAAS,CAAC,KAAY;QAC3B,IAAI,IAAI,CAAC,SAAS;YACjB,MAAM,IAAI,KAAK,CAAC,oDAAoD,CAAC,CAAA;QACtE,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,aAAa,CAAC,KAAK,CAAC,CAAA;QAC7C,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAC1B,MAAM,CAAC,mBAAmB,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,EAAE,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,EAC/D;YACC,IAAI,EAAE;gBACL,IAAI,EAAE,uBAAuB,CAAC,KAAK;gBACnC,IAAI,EAAE,KAAK,CAAC,SAAS,EAAE;aACvB;SACD,CACD,CAAA;IACF,CAAC;CACD"}
|
|
@@ -3,6 +3,7 @@ import { AutoRouter, type IRequestStrict } from "itty-router";
|
|
|
3
3
|
import type { BaseCommand } from "../abstracts/BaseCommand.js";
|
|
4
4
|
import { CommandHandler } from "../internals/CommandHandler.js";
|
|
5
5
|
import { ComponentHandler } from "../internals/ComponentHandler.js";
|
|
6
|
+
import { ModalHandler } from "../internals/ModalHandler.js";
|
|
6
7
|
/**
|
|
7
8
|
* The mode that the client is running in.
|
|
8
9
|
* Different platforms have different requirements for how processes are handled.
|
|
@@ -89,9 +90,19 @@ export declare class Client {
|
|
|
89
90
|
rest: RequestClient;
|
|
90
91
|
/**
|
|
91
92
|
* The handler for the component interactions sent from Discord
|
|
93
|
+
* @internal
|
|
92
94
|
*/
|
|
93
95
|
componentHandler: ComponentHandler;
|
|
96
|
+
/**
|
|
97
|
+
* The handler for the modal interactions sent from Discord
|
|
98
|
+
* @internal
|
|
99
|
+
*/
|
|
94
100
|
commandHandler: CommandHandler;
|
|
101
|
+
/**
|
|
102
|
+
* The handler for the modal interactions sent from Discord
|
|
103
|
+
* @internal
|
|
104
|
+
*/
|
|
105
|
+
modalHandler: ModalHandler;
|
|
95
106
|
/**
|
|
96
107
|
* Creates a new client
|
|
97
108
|
* @param options The options used to initialize the client
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Client.d.ts","sourceRoot":"","sources":["../../../src/classes/Client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,KAAK,oBAAoB,EAAE,MAAM,uBAAuB,CAAA;
|
|
1
|
+
{"version":3,"file":"Client.d.ts","sourceRoot":"","sources":["../../../src/classes/Client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,KAAK,oBAAoB,EAAE,MAAM,uBAAuB,CAAA;AAOhF,OAAO,EAAE,UAAU,EAAE,KAAK,cAAc,EAAqB,MAAM,aAAa,CAAA;AAChF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAA;AAC9D,OAAO,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAA;AAC/D,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAA;AACnE,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAA;AAG3D;;;GAGG;AACH,oBAAY,UAAU;IACrB,MAAM,SAAS;IACf,iBAAiB,eAAe;IAChC,GAAG,QAAQ;IACX,MAAM,WAAW;IACjB,GAAG,QAAQ;CACX;AAED;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG;IAC3B;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAA;IAChB;;OAEG;IACH,SAAS,EAAE,MAAM,CAAA;IACjB;;OAEG;IACH,KAAK,EAAE,MAAM,CAAA;IACb;;;;;;;;;;;;;OAaG;IACH,IAAI,EAAE,UAAU,CAAA;IAChB;;;OAGG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB;;OAEG;IACH,cAAc,CAAC,EAAE,oBAAoB,CAAA;IACrC;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAA;IACb;;OAEG;IACH,UAAU,CAAC,EAAE,OAAO,CAAA;CACpB,CAAA;AAED;;GAEG;AACH,qBAAa,MAAM;IAClB;;OAEG;IACH,OAAO,EAAE,aAAa,CAAA;IACtB;;OAEG;IACH,QAAQ,EAAE,WAAW,EAAE,CAAA;IACvB;;OAEG;IACH,MAAM,EAAE,UAAU,CAAC,OAAO,UAAU,CAAC,cAAc,CAAC,CAAC,CAAA;IACrD;;OAEG;IACH,IAAI,EAAE,aAAa,CAAA;IACnB;;;OAGG;IACH,gBAAgB,EAAE,gBAAgB,CAAA;IAClC;;;OAGG;IACH,cAAc,EAAE,cAAc,CAAA;IAC9B;;;OAGG;IACH,YAAY,EAAE,YAAY,CAAA;IAE1B;;;;OAIG;gBACS,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,WAAW,EAAE;IAoB3D;;;OAGG;IACG,cAAc;IAepB;;OAEG;IACH,OAAO,CAAC,WAAW;IAcnB;;;;;OAKG;IACU,MAAM,CAAC,GAAG,EAAE,OAAO,EAAE,GAAG,CAAC,EAAE,gBAAgB;IAgExD;;;OAGG;YACW,mBAAmB;CAiCjC;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAEhC,SAAS,CAAC,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,GAAG,IAAI,CAAA;CACtC"}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { RequestClient } from "@buape/carbon-request";
|
|
2
2
|
import { InteractionResponseType, InteractionType, Routes } from "discord-api-types/v10";
|
|
3
|
-
import { PlatformAlgorithm, isValidRequest } from "discord-verify";
|
|
4
3
|
import { AutoRouter, StatusError, json } from "itty-router";
|
|
5
4
|
import { CommandHandler } from "../internals/CommandHandler.js";
|
|
6
5
|
import { ComponentHandler } from "../internals/ComponentHandler.js";
|
|
6
|
+
import { ModalHandler } from "../internals/ModalHandler.js";
|
|
7
|
+
import { concatUint8Arrays, subtleCrypto, valueToUint8Array } from "../utils.js";
|
|
7
8
|
/**
|
|
8
9
|
* The mode that the client is running in.
|
|
9
10
|
* Different platforms have different requirements for how processes are handled.
|
|
@@ -38,9 +39,19 @@ export class Client {
|
|
|
38
39
|
rest;
|
|
39
40
|
/**
|
|
40
41
|
* The handler for the component interactions sent from Discord
|
|
42
|
+
* @internal
|
|
41
43
|
*/
|
|
42
44
|
componentHandler;
|
|
45
|
+
/**
|
|
46
|
+
* The handler for the modal interactions sent from Discord
|
|
47
|
+
* @internal
|
|
48
|
+
*/
|
|
43
49
|
commandHandler;
|
|
50
|
+
/**
|
|
51
|
+
* The handler for the modal interactions sent from Discord
|
|
52
|
+
* @internal
|
|
53
|
+
*/
|
|
54
|
+
modalHandler;
|
|
44
55
|
/**
|
|
45
56
|
* Creates a new client
|
|
46
57
|
* @param options The options used to initialize the client
|
|
@@ -63,6 +74,7 @@ export class Client {
|
|
|
63
74
|
this.rest = new RequestClient(options.token, options.requestOptions);
|
|
64
75
|
this.componentHandler = new ComponentHandler(this);
|
|
65
76
|
this.commandHandler = new CommandHandler(this);
|
|
77
|
+
this.modalHandler = new ModalHandler(this);
|
|
66
78
|
this.setupRoutes();
|
|
67
79
|
if (this.options.autoDeploy)
|
|
68
80
|
this.deployCommands();
|
|
@@ -146,6 +158,16 @@ export class Client {
|
|
|
146
158
|
await this.componentHandler.handleInteraction(rawInteraction);
|
|
147
159
|
}
|
|
148
160
|
}
|
|
161
|
+
if (rawInteraction.type === InteractionType.ModalSubmit) {
|
|
162
|
+
if (ctx?.waitUntil) {
|
|
163
|
+
ctx.waitUntil((async () => {
|
|
164
|
+
await this.modalHandler.handleInteraction(rawInteraction);
|
|
165
|
+
})());
|
|
166
|
+
}
|
|
167
|
+
else {
|
|
168
|
+
await this.modalHandler.handleInteraction(rawInteraction);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
149
171
|
return new Response(null, { status: 202 });
|
|
150
172
|
}
|
|
151
173
|
/**
|
|
@@ -153,17 +175,27 @@ export class Client {
|
|
|
153
175
|
* @param req The request to validate
|
|
154
176
|
*/
|
|
155
177
|
async validateInteraction(req) {
|
|
156
|
-
|
|
157
|
-
|
|
178
|
+
const body = await req.clone().text();
|
|
179
|
+
const signature = req.headers.get("X-Signature-Ed25519");
|
|
180
|
+
const timestamp = req.headers.get("X-Signature-Timestamp");
|
|
181
|
+
if (!timestamp || !signature || req.method !== "POST" || !body) {
|
|
182
|
+
throw new StatusError(401);
|
|
183
|
+
}
|
|
184
|
+
try {
|
|
185
|
+
const timestampData = valueToUint8Array(timestamp);
|
|
186
|
+
const bodyData = valueToUint8Array(body);
|
|
187
|
+
const message = concatUint8Arrays(timestampData, bodyData);
|
|
188
|
+
const isValid = await subtleCrypto.verify({
|
|
189
|
+
name: "ed25519"
|
|
190
|
+
}, await subtleCrypto.importKey("raw", valueToUint8Array(this.options.publicKey, "hex"), {
|
|
191
|
+
name: "ed25519",
|
|
192
|
+
namedCurve: "ed25519"
|
|
193
|
+
}, false, ["verify"]), valueToUint8Array(signature, "hex"), message);
|
|
194
|
+
return isValid;
|
|
195
|
+
}
|
|
196
|
+
catch (_) {
|
|
197
|
+
return false;
|
|
158
198
|
}
|
|
159
|
-
const isValid = await isValidRequest(req, this.options.publicKey, this.options.mode === ClientMode.CloudflareWorkers
|
|
160
|
-
? PlatformAlgorithm.Cloudflare
|
|
161
|
-
: this.options.mode === ClientMode.Vercel
|
|
162
|
-
? PlatformAlgorithm.VercelProd
|
|
163
|
-
: this.options.mode === ClientMode.Web
|
|
164
|
-
? PlatformAlgorithm.Web
|
|
165
|
-
: PlatformAlgorithm.NewNode);
|
|
166
|
-
return isValid;
|
|
167
199
|
}
|
|
168
200
|
}
|
|
169
201
|
//# sourceMappingURL=Client.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Client.js","sourceRoot":"","sources":["../../../src/classes/Client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAA6B,MAAM,uBAAuB,CAAA;AAChF,OAAO,EAEN,uBAAuB,EACvB,eAAe,EACf,MAAM,EACN,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAAE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,CAAC,SAAS,CAC3B,KAAK,EACL,iBAAiB,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,KAAK,CAAC,EAChD;gBACC,IAAI,EAAE,SAAS;gBACf,UAAU,EAAE,SAAS;aACrB,EACD,KAAK,EACL,CAAC,QAAQ,CAAC,CACV,EACD,iBAAiB,CAAC,SAAS,EAAE,KAAK,CAAC,EACnC,OAAO,CACP,CAAA;YACD,OAAO,OAAO,CAAA;QACf,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACZ,OAAO,KAAK,CAAA;QACb,CAAC;IACF,CAAC;CACD"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { APIModalInteractionResponseCallbackData } from "discord-api-types/v10";
|
|
2
|
+
import type { ModalInteraction } from "../internals/ModalInteraction.js";
|
|
3
|
+
import type { Row } from "./Row.js";
|
|
4
|
+
import type { TextInput } from "./TextInput.js";
|
|
5
|
+
export declare abstract class Modal {
|
|
6
|
+
/**
|
|
7
|
+
* The title of the modal
|
|
8
|
+
*/
|
|
9
|
+
abstract title: string;
|
|
10
|
+
/**
|
|
11
|
+
* The components of the modal
|
|
12
|
+
*/
|
|
13
|
+
components: Row<TextInput>[];
|
|
14
|
+
/**
|
|
15
|
+
* The custom ID of the modal
|
|
16
|
+
*/
|
|
17
|
+
abstract customId: string;
|
|
18
|
+
abstract run(interaction: ModalInteraction): Promise<void>;
|
|
19
|
+
serialize: () => APIModalInteractionResponseCallbackData;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=Modal.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Modal.d.ts","sourceRoot":"","sources":["../../../src/classes/Modal.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEX,uCAAuC,EAEvC,MAAM,uBAAuB,CAAA;AAC9B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAA;AACxE,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,UAAU,CAAA;AACnC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAE/C,8BAAsB,KAAK;IAC1B;;OAEG;IACH,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IAEtB;;OAEG;IACH,UAAU,EAAE,GAAG,CAAC,SAAS,CAAC,EAAE,CAAK;IAEjC;;OAEG;IACH,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;IAEzB,QAAQ,CAAC,GAAG,CAAC,WAAW,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC;IAE1D,SAAS,QAAO,uCAAuC,CAStD;CACD"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export class Modal {
|
|
2
|
+
/**
|
|
3
|
+
* The components of the modal
|
|
4
|
+
*/
|
|
5
|
+
components = [];
|
|
6
|
+
serialize = () => {
|
|
7
|
+
return {
|
|
8
|
+
title: this.title,
|
|
9
|
+
custom_id: this.customId,
|
|
10
|
+
components: this.components.map((row) => row.serialize())
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=Modal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Modal.js","sourceRoot":"","sources":["../../../src/classes/Modal.ts"],"names":[],"mappings":"AASA,MAAM,OAAgB,KAAK;IAM1B;;OAEG;IACH,UAAU,GAAqB,EAAE,CAAA;IASjC,SAAS,GAAG,GAA4C,EAAE;QACzD,OAAO;YACN,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,SAAS,EAAE,IAAI,CAAC,QAAQ;YACxB,UAAU,EAAE,IAAI,CAAC,UAAU,CAAC,GAAG,CAC9B,CAAC,GAAG,EAAE,EAAE,CACP,GAAG,CAAC,SAAS,EAA6D,CAC3E;SACD,CAAA;IACF,CAAC,CAAA;CACD"}
|
|
@@ -1,27 +1,25 @@
|
|
|
1
|
+
import type { APIActionRowComponent, APIActionRowComponentTypes } from "discord-api-types/v10";
|
|
1
2
|
import type { BaseComponent } from "../abstracts/BaseComponent.js";
|
|
2
|
-
export declare class Row {
|
|
3
|
+
export declare class Row<T extends BaseComponent = BaseComponent> {
|
|
3
4
|
/**
|
|
4
5
|
* The components in the action row
|
|
5
6
|
*/
|
|
6
|
-
components:
|
|
7
|
-
constructor(components
|
|
7
|
+
components: T[];
|
|
8
|
+
constructor(components?: T[]);
|
|
8
9
|
/**
|
|
9
10
|
* Add a component to the action row
|
|
10
11
|
* @param component The component to add
|
|
11
12
|
*/
|
|
12
|
-
addComponent(component:
|
|
13
|
+
addComponent(component: T): void;
|
|
13
14
|
/**
|
|
14
15
|
* Remove a component from the action row
|
|
15
16
|
* @param component The component to remove
|
|
16
17
|
*/
|
|
17
|
-
removeComponent(component:
|
|
18
|
+
removeComponent(component: T): void;
|
|
18
19
|
/**
|
|
19
20
|
* Remove all components from the action row
|
|
20
21
|
*/
|
|
21
22
|
removeAllComponents(): void;
|
|
22
|
-
serialize()
|
|
23
|
-
type: number;
|
|
24
|
-
components: import("discord-api-types/v10").APIBaseComponent<import("discord-api-types/v10").ComponentType>[];
|
|
25
|
-
};
|
|
23
|
+
serialize: () => APIActionRowComponent<APIActionRowComponentTypes>;
|
|
26
24
|
}
|
|
27
25
|
//# sourceMappingURL=Row.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Row.d.ts","sourceRoot":"","sources":["../../../src/classes/Row.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAA;AAElE,qBAAa,GAAG;
|
|
1
|
+
{"version":3,"file":"Row.d.ts","sourceRoot":"","sources":["../../../src/classes/Row.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,qBAAqB,EACrB,0BAA0B,EAC1B,MAAM,uBAAuB,CAAA;AAC9B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAA;AAElE,qBAAa,GAAG,CAAC,CAAC,SAAS,aAAa,GAAG,aAAa;IACvD;;OAEG;IACH,UAAU,EAAE,CAAC,EAAE,CAAK;gBAER,UAAU,CAAC,EAAE,CAAC,EAAE;IAI5B;;;OAGG;IACH,YAAY,CAAC,SAAS,EAAE,CAAC;IAIzB;;;OAGG;IACH,eAAe,CAAC,SAAS,EAAE,CAAC;IAM5B;;OAEG;IACH,mBAAmB;IAInB,SAAS,QAAO,qBAAqB,CAAC,0BAA0B,CAAC,CAOhE;CACD"}
|
package/dist/src/classes/Row.js
CHANGED
|
@@ -2,9 +2,10 @@ export class Row {
|
|
|
2
2
|
/**
|
|
3
3
|
* The components in the action row
|
|
4
4
|
*/
|
|
5
|
-
components;
|
|
5
|
+
components = [];
|
|
6
6
|
constructor(components) {
|
|
7
|
-
|
|
7
|
+
if (components)
|
|
8
|
+
this.components = components;
|
|
8
9
|
}
|
|
9
10
|
/**
|
|
10
11
|
* Add a component to the action row
|
|
@@ -29,11 +30,11 @@ export class Row {
|
|
|
29
30
|
removeAllComponents() {
|
|
30
31
|
this.components = [];
|
|
31
32
|
}
|
|
32
|
-
serialize() {
|
|
33
|
+
serialize = () => {
|
|
33
34
|
return {
|
|
34
35
|
type: 1,
|
|
35
36
|
components: this.components.map((component) => component.serialize())
|
|
36
37
|
};
|
|
37
|
-
}
|
|
38
|
+
};
|
|
38
39
|
}
|
|
39
40
|
//# sourceMappingURL=Row.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Row.js","sourceRoot":"","sources":["../../../src/classes/Row.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Row.js","sourceRoot":"","sources":["../../../src/classes/Row.ts"],"names":[],"mappings":"AAMA,MAAM,OAAO,GAAG;IACf;;OAEG;IACH,UAAU,GAAQ,EAAE,CAAA;IAEpB,YAAY,UAAgB;QAC3B,IAAI,UAAU;YAAE,IAAI,CAAC,UAAU,GAAG,UAAU,CAAA;IAC7C,CAAC;IAED;;;OAGG;IACH,YAAY,CAAC,SAAY;QACxB,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,CAAA;IAChC,CAAC;IAED;;;OAGG;IACH,eAAe,CAAC,SAAY;QAC3B,MAAM,KAAK,GAAG,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,SAAS,CAAC,CAAA;QAChD,IAAI,KAAK,KAAK,CAAC,CAAC;YAAE,OAAM;QACxB,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAA;IACjC,CAAC;IAED;;OAEG;IACH,mBAAmB;QAClB,IAAI,CAAC,UAAU,GAAG,EAAE,CAAA;IACrB,CAAC;IAED,SAAS,GAAG,GAAsD,EAAE;QACnE,OAAO;YACN,IAAI,EAAE,CAAC;YACP,UAAU,EAAE,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE,CAC7C,SAAS,CAAC,SAAS,EAAE,CACW;SACjC,CAAA;IACF,CAAC,CAAA;CACD"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { type APITextInputComponent, ComponentType, TextInputStyle } from "discord-api-types/v10";
|
|
2
|
+
import { BaseComponent } from "../abstracts/BaseComponent.js";
|
|
3
|
+
export declare abstract class TextInput extends BaseComponent {
|
|
4
|
+
type: ComponentType;
|
|
5
|
+
/**
|
|
6
|
+
* The custom ID of the text input
|
|
7
|
+
*/
|
|
8
|
+
abstract customId: string;
|
|
9
|
+
/**
|
|
10
|
+
* The label of the text input
|
|
11
|
+
*/
|
|
12
|
+
abstract label: string;
|
|
13
|
+
/**
|
|
14
|
+
* The style of the text input
|
|
15
|
+
* @default TextInputStyle.Short
|
|
16
|
+
*/
|
|
17
|
+
style: TextInputStyle;
|
|
18
|
+
/**
|
|
19
|
+
* The minimum length of the text input
|
|
20
|
+
*/
|
|
21
|
+
minLength?: number;
|
|
22
|
+
/**
|
|
23
|
+
* The maximum length of the text input
|
|
24
|
+
*/
|
|
25
|
+
maxLength?: number;
|
|
26
|
+
/**
|
|
27
|
+
* Whether the text input is required
|
|
28
|
+
*/
|
|
29
|
+
required?: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* The value of the text input
|
|
32
|
+
*/
|
|
33
|
+
value?: string;
|
|
34
|
+
/**
|
|
35
|
+
* The placeholder of the text input
|
|
36
|
+
*/
|
|
37
|
+
placeholder?: string;
|
|
38
|
+
serialize: () => APITextInputComponent;
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=TextInput.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TextInput.d.ts","sourceRoot":"","sources":["../../../src/classes/TextInput.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,KAAK,qBAAqB,EAC1B,aAAa,EACb,cAAc,EACd,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAA;AAE7D,8BAAsB,SAAU,SAAQ,aAAa;IACpD,IAAI,gBAA0B;IAE9B;;OAEG;IACH,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;IAEzB;;OAEG;IACH,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IAEtB;;;OAGG;IACH,KAAK,EAAE,cAAc,CAAuB;IAE5C;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;IAElB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;IAElB;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAA;IAElB;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;IAEd;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAA;IAEpB,SAAS,QAAO,qBAAqB,CAYpC;CACD"}
|