@buape/carbon 0.2.0 → 0.3.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/dist/package.json +7 -2
- 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 +10 -1
- package/dist/src/abstracts/BaseInteraction.d.ts.map +1 -1
- package/dist/src/abstracts/BaseInteraction.js +10 -1
- package/dist/src/abstracts/BaseInteraction.js.map +1 -1
- package/dist/src/classes/Client.d.ts.map +1 -1
- package/dist/src/classes/Client.js +21 -11
- package/dist/src/classes/Client.js.map +1 -1
- package/dist/src/classes/Embed.d.ts +60 -0
- package/dist/src/classes/Embed.d.ts.map +1 -0
- package/dist/src/classes/Embed.js +73 -0
- package/dist/src/classes/Embed.js.map +1 -0
- package/dist/src/index.d.ts +4 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +4 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/internals/AutocompleteInteraction.d.ts +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/ModalInteraction.d.ts +3 -4
- package/dist/src/internals/ModalInteraction.d.ts.map +1 -1
- package/dist/src/internals/ModalInteraction.js +3 -10
- package/dist/src/internals/ModalInteraction.js.map +1 -1
- 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 -8
- package/.turbo/turbo-docs.log +0 -12
- package/CHANGELOG.md +0 -44
- 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/internals/ComponentHandler copy.d.ts +0 -17
- package/dist/src/internals/ComponentHandler copy.d.ts.map +0 -1
- package/dist/src/internals/ComponentHandler copy.js +0 -75
- package/dist/src/internals/ComponentHandler copy.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 -89
- 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 -209
- 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 -277
- 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/Modal.ts +0 -38
- package/src/classes/RoleSelectMenu.ts +0 -19
- package/src/classes/Row.ts +0 -50
- package/src/classes/StringSelectMenu.ts +0 -19
- package/src/classes/TextInput.ts +0 -65
- package/src/classes/UserSelectMenu.ts +0 -19
- package/src/factories/channelFactory.ts +0 -43
- package/src/index.ts +0 -62
- 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 -127
- package/src/internals/CommandInteraction.ts +0 -49
- package/src/internals/ComponentHandler.ts +0 -92
- package/src/internals/MentionableSelectMenuInteraction.ts +0 -21
- package/src/internals/ModalHandler.ts +0 -27
- package/src/internals/ModalInteraction.ts +0 -25
- 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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type APIApplicationCommandInteractionDataBasicOption } from "discord-api-types/v10";
|
|
2
2
|
import { Base } from "../abstracts/Base.js";
|
|
3
|
-
import { type Client, Role, User } from "../index.js";
|
|
3
|
+
import { type Client, Role, User, channelFactory } from "../index.js";
|
|
4
4
|
export type RawOptions = {
|
|
5
5
|
[key: string]: APIApplicationCommandInteractionDataBasicOption["value"] | undefined;
|
|
6
6
|
};
|
|
@@ -21,50 +21,66 @@ export declare class OptionsHandler extends Base {
|
|
|
21
21
|
/**
|
|
22
22
|
* Get the value of a string option.
|
|
23
23
|
* @param key The name of the option to get the value of.
|
|
24
|
-
* @
|
|
24
|
+
* @param required Whether the option is required.
|
|
25
|
+
* @returns The value of the option, or undefined if the option was not provided and it is not required.
|
|
25
26
|
*/
|
|
26
|
-
getString(key: string): string | undefined;
|
|
27
|
+
getString(key: string, required?: false): string | undefined;
|
|
28
|
+
getString(key: string, required: true): string;
|
|
27
29
|
/**
|
|
28
30
|
* Get the value of an integer option.
|
|
29
31
|
* @param key The name of the option to get the value of.
|
|
30
|
-
* @
|
|
32
|
+
* @param required Whether the option is required.
|
|
33
|
+
* @returns The value of the option, or undefined if the option was not provided and it is not required.
|
|
31
34
|
*/
|
|
32
|
-
getInteger(key: string): number | undefined;
|
|
35
|
+
getInteger(key: string, required?: false): number | undefined;
|
|
36
|
+
getInteger(key: string, required: true): number;
|
|
33
37
|
/**
|
|
34
38
|
* Get the value of a number option.
|
|
35
39
|
* @param key The name of the option to get the value of.
|
|
36
|
-
* @
|
|
40
|
+
* @param required Whether the option is required.
|
|
41
|
+
* @returns The value of the option, or undefined if the option was not provided and it is not required.
|
|
37
42
|
*/
|
|
38
|
-
getNumber(key: string): number | undefined;
|
|
43
|
+
getNumber(key: string, required?: false): number | undefined;
|
|
44
|
+
getNumber(key: string, required: true): number;
|
|
39
45
|
/**
|
|
40
46
|
* Get the value of a boolean option.
|
|
41
47
|
* @param key The name of the option to get the value of.
|
|
42
|
-
* @
|
|
48
|
+
* @param required Whether the option is required.
|
|
49
|
+
* @returns The value of the option, or undefined if the option was not provided and it is not required.
|
|
43
50
|
*/
|
|
44
|
-
getBoolean(key: string):
|
|
51
|
+
getBoolean(key: string, required?: false): boolean | undefined;
|
|
52
|
+
getBoolean(key: string, required: true): boolean;
|
|
45
53
|
/**
|
|
46
54
|
* Get the value of a user option.
|
|
47
55
|
* @param key The name of the option to get the value of.
|
|
48
|
-
* @
|
|
56
|
+
* @param required Whether the option is required.
|
|
57
|
+
* @returns The value of the option, or undefined if the option was not provided and it is not required.
|
|
49
58
|
*/
|
|
50
|
-
getUser(key: string): User | undefined;
|
|
59
|
+
getUser(key: string, required?: false): User | undefined;
|
|
60
|
+
getUser(key: string, required: true): User;
|
|
51
61
|
/**
|
|
52
62
|
* Get the value of a channel option.
|
|
53
63
|
* @param key The name of the option to get the value of.
|
|
54
|
-
* @
|
|
64
|
+
* @param required Whether the option is required.
|
|
65
|
+
* @returns The value of the option, or undefined if the option was not provided and it is not required.
|
|
55
66
|
*/
|
|
56
|
-
getChannel(key: string): Promise<
|
|
67
|
+
getChannel(key: string, required?: false): Promise<ReturnType<typeof channelFactory> | undefined>;
|
|
68
|
+
getChannel(key: string, required: true): Promise<ReturnType<typeof channelFactory>>;
|
|
57
69
|
/**
|
|
58
70
|
* Get the value of a role option.
|
|
59
71
|
* @param key The name of the option to get the value of.
|
|
60
|
-
* @
|
|
72
|
+
* @param required Whether the option is required.
|
|
73
|
+
* @returns The value of the option, or undefined if the option was not provided and it is not required.
|
|
61
74
|
*/
|
|
62
|
-
getRole(key: string): Role | undefined;
|
|
75
|
+
getRole(key: string, required?: false): Role | undefined;
|
|
76
|
+
getRole(key: string, required: true): Role;
|
|
63
77
|
/**
|
|
64
78
|
* Get the value of a mentionable option.
|
|
65
79
|
* @param key The name of the option to get the value of.
|
|
66
|
-
* @
|
|
80
|
+
* @param required Whether the option is required.
|
|
81
|
+
* @returns The value of the option, or undefined if the option was not provided and it is not required.
|
|
67
82
|
*/
|
|
68
|
-
getMentionable(key: string): Promise<User | Role | undefined>;
|
|
83
|
+
getMentionable(key: string, required?: false): Promise<User | Role | undefined>;
|
|
84
|
+
getMentionable(key: string, required: true): Promise<User | Role>;
|
|
69
85
|
}
|
|
70
86
|
//# sourceMappingURL=OptionsHandler.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OptionsHandler.d.ts","sourceRoot":"","sources":["../../../src/internals/OptionsHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,KAAK,+CAA+C,EAIpD,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAA;AAC3C,OAAO,EAAE,KAAK,MAAM,EAAE,IAAI,EAAE,IAAI,
|
|
1
|
+
{"version":3,"file":"OptionsHandler.d.ts","sourceRoot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EAAE,KAAK,GAAG,OAAO,GAAG,SAAS;IAC9D,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,GAAG,OAAO;IAYvD;;;;;OAKG;IACI,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,KAAK,GAAG,IAAI,GAAG,SAAS;IACxD,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,GAAG,IAAI;IAYjD;;;;;OAKG;IACU,UAAU,CACtB,GAAG,EAAE,MAAM,EACX,QAAQ,CAAC,EAAE,KAAK,GACd,OAAO,CAAC,UAAU,CAAC,OAAO,cAAc,CAAC,GAAG,SAAS,CAAC;IAC5C,UAAU,CACtB,GAAG,EAAE,MAAM,EACX,QAAQ,EAAE,IAAI,GACZ,OAAO,CAAC,UAAU,CAAC,OAAO,cAAc,CAAC,CAAC;IAgB7C;;;;;OAKG;IACI,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,KAAK,GAAG,IAAI,GAAG,SAAS;IACxD,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,GAAG,IAAI;IAYjD;;;;;OAKG;IACU,cAAc,CAC1B,GAAG,EAAE,MAAM,EACX,QAAQ,CAAC,EAAE,KAAK,GACd,OAAO,CAAC,IAAI,GAAG,IAAI,GAAG,SAAS,CAAC;IACtB,cAAc,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC;CAmB9E"}
|
|
@@ -18,92 +18,86 @@ export class OptionsHandler extends Base {
|
|
|
18
18
|
super(client);
|
|
19
19
|
this.raw = options;
|
|
20
20
|
}
|
|
21
|
-
|
|
22
|
-
* Get the value of a string option.
|
|
23
|
-
* @param key The name of the option to get the value of.
|
|
24
|
-
* @returns The value of the option, or undefined if the option was not provided.
|
|
25
|
-
*/
|
|
26
|
-
getString(key) {
|
|
21
|
+
getString(key, required = false) {
|
|
27
22
|
const value = this.raw.find((x) => x.name === key && x.type === ApplicationCommandOptionType.String)?.value;
|
|
28
|
-
if (
|
|
23
|
+
if (required) {
|
|
24
|
+
if (!value || typeof value !== "string")
|
|
25
|
+
throw new Error(`Missing required option: ${key}`);
|
|
26
|
+
}
|
|
27
|
+
else if (!value || typeof value !== "string")
|
|
29
28
|
return undefined;
|
|
30
29
|
return value;
|
|
31
30
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
31
|
+
getInteger(key, required = false) {
|
|
32
|
+
const value = this.raw.find((x) => x.name === key && x.type === ApplicationCommandOptionType.Integer)?.value;
|
|
33
|
+
if (required) {
|
|
34
|
+
if (!value || typeof value !== "number" || !Number.isSafeInteger(value))
|
|
35
|
+
throw new Error(`Missing required option: ${key}`);
|
|
36
|
+
}
|
|
37
|
+
else if (!value ||
|
|
38
|
+
typeof value !== "number" ||
|
|
39
|
+
!Number.isSafeInteger(value))
|
|
40
40
|
return undefined;
|
|
41
|
-
return
|
|
41
|
+
return value;
|
|
42
42
|
}
|
|
43
|
-
|
|
44
|
-
* Get the value of a number option.
|
|
45
|
-
* @param key The name of the option to get the value of.
|
|
46
|
-
* @returns The value of the option, or undefined if the option was not provided.
|
|
47
|
-
*/
|
|
48
|
-
getNumber(key) {
|
|
43
|
+
getNumber(key, required = false) {
|
|
49
44
|
const value = this.raw.find((x) => x.name === key && x.type === ApplicationCommandOptionType.Number)?.value;
|
|
50
|
-
if (
|
|
45
|
+
if (required) {
|
|
46
|
+
if (!value || typeof value !== "number")
|
|
47
|
+
throw new Error(`Missing required option: ${key}`);
|
|
48
|
+
}
|
|
49
|
+
else if (!value || typeof value !== "number")
|
|
51
50
|
return undefined;
|
|
52
51
|
return value;
|
|
53
52
|
}
|
|
54
|
-
|
|
55
|
-
* Get the value of a boolean option.
|
|
56
|
-
* @param key The name of the option to get the value of.
|
|
57
|
-
* @returns The value of the option, or undefined if the option was not provided.
|
|
58
|
-
*/
|
|
59
|
-
getBoolean(key) {
|
|
53
|
+
getBoolean(key, required = false) {
|
|
60
54
|
const value = this.raw.find((x) => x.name === key && x.type === ApplicationCommandOptionType.Boolean)?.value;
|
|
61
|
-
if (
|
|
55
|
+
if (required) {
|
|
56
|
+
if (!value || typeof value !== "boolean")
|
|
57
|
+
throw new Error(`Missing required option: ${key}`);
|
|
58
|
+
}
|
|
59
|
+
else if (!value || typeof value !== "boolean")
|
|
62
60
|
return undefined;
|
|
63
61
|
return value;
|
|
64
62
|
}
|
|
65
|
-
|
|
66
|
-
* Get the value of a user option.
|
|
67
|
-
* @param key The name of the option to get the value of.
|
|
68
|
-
* @returns The value of the option, or undefined if the option was not provided.
|
|
69
|
-
*/
|
|
70
|
-
getUser(key) {
|
|
63
|
+
getUser(key, required = false) {
|
|
71
64
|
const id = this.raw.find((x) => x.name === key && x.type === ApplicationCommandOptionType.User)?.value;
|
|
72
|
-
if (
|
|
65
|
+
if (required) {
|
|
66
|
+
if (!id || typeof id !== "string")
|
|
67
|
+
throw new Error(`Missing required option: ${key}`);
|
|
68
|
+
}
|
|
69
|
+
else if (!id || typeof id !== "string")
|
|
73
70
|
return undefined;
|
|
74
71
|
return new User(this.client, id);
|
|
75
72
|
}
|
|
76
|
-
|
|
77
|
-
* Get the value of a channel option.
|
|
78
|
-
* @param key The name of the option to get the value of.
|
|
79
|
-
* @returns The value of the option, or undefined if the option was not provided.
|
|
80
|
-
*/
|
|
81
|
-
async getChannel(key) {
|
|
73
|
+
async getChannel(key, required = false) {
|
|
82
74
|
const id = this.raw.find((x) => x.name === key && x.type === ApplicationCommandOptionType.Channel)?.value;
|
|
83
|
-
if (
|
|
75
|
+
if (required) {
|
|
76
|
+
if (!id || typeof id !== "string")
|
|
77
|
+
throw new Error(`Missing required option: ${key}`);
|
|
78
|
+
}
|
|
79
|
+
else if (!id || typeof id !== "string")
|
|
84
80
|
return undefined;
|
|
85
81
|
const data = (await this.client.rest.get(Routes.channel(id)));
|
|
86
82
|
return channelFactory(this.client, data);
|
|
87
83
|
}
|
|
88
|
-
|
|
89
|
-
* Get the value of a role option.
|
|
90
|
-
* @param key The name of the option to get the value of.
|
|
91
|
-
* @returns The value of the option, or undefined if the option was not provided.
|
|
92
|
-
*/
|
|
93
|
-
getRole(key) {
|
|
84
|
+
getRole(key, required = false) {
|
|
94
85
|
const id = this.raw.find((x) => x.name === key && x.type === ApplicationCommandOptionType.Role)?.value;
|
|
95
|
-
if (
|
|
86
|
+
if (required) {
|
|
87
|
+
if (!id || typeof id !== "string")
|
|
88
|
+
throw new Error(`Missing required option: ${key}`);
|
|
89
|
+
}
|
|
90
|
+
else if (!id || typeof id !== "string")
|
|
96
91
|
return undefined;
|
|
97
92
|
return new Role(this.client, id);
|
|
98
93
|
}
|
|
99
|
-
|
|
100
|
-
* Get the value of a mentionable option.
|
|
101
|
-
* @param key The name of the option to get the value of.
|
|
102
|
-
* @returns The value of the option, or undefined if the option was not provided.
|
|
103
|
-
*/
|
|
104
|
-
async getMentionable(key) {
|
|
94
|
+
async getMentionable(key, required = false) {
|
|
105
95
|
const id = this.raw.find((x) => x.name === key && x.type === ApplicationCommandOptionType.Mentionable)?.value;
|
|
106
|
-
if (
|
|
96
|
+
if (required) {
|
|
97
|
+
if (!id || typeof id !== "string")
|
|
98
|
+
throw new Error(`Missing required option: ${key}`);
|
|
99
|
+
}
|
|
100
|
+
else if (!id || typeof id !== "string")
|
|
107
101
|
return undefined;
|
|
108
102
|
const user = new User(this.client, id);
|
|
109
103
|
await user.fetch().catch(() => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OptionsHandler.js","sourceRoot":"","sources":["../../../src/internals/OptionsHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EAGN,4BAA4B,EAC5B,MAAM,EACN,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAAE,IAAI,EAAE,MAAM,sBA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W,EACX,QAAQ,GAAG,KAAK;QAEhB,MAAM,EAAE,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CACvB,CAAC,CAAC,EAAE,EAAE,CACL,CAAC,CAAC,IAAI,KAAK,GAAG,IAAI,CAAC,CAAC,IAAI,KAAK,4BAA4B,CAAC,WAAW,CACtE,EAAE,KAAK,CAAA;QACR,IAAI,QAAQ,EAAE,CAAC;YACd,IAAI,CAAC,EAAE,IAAI,OAAO,EAAE,KAAK,QAAQ;gBAChC,MAAM,IAAI,KAAK,CAAC,4BAA4B,GAAG,EAAE,CAAC,CAAA;QACpD,CAAC;aAAM,IAAI,CAAC,EAAE,IAAI,OAAO,EAAE,KAAK,QAAQ;YAAE,OAAO,SAAS,CAAA;QAC1D,MAAM,IAAI,GAAG,IAAI,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE,CAAC,CAAA;QACtC,MAAM,IAAI,CAAC,KAAK,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE;YAC7B,OAAO,IAAI,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE,CAAC,CAAA;QACjC,CAAC,CAAC,CAAA;QACF,OAAO,IAAI,CAAA;IACZ,CAAC;CACD"}
|
package/dist/src/utils.d.ts
CHANGED
|
@@ -1,2 +1,5 @@
|
|
|
1
1
|
export declare const splitCustomId: (customId: string) => [string, Record<string, string>];
|
|
2
|
+
export declare const subtleCrypto: SubtleCrypto;
|
|
3
|
+
export declare function valueToUint8Array(value: Uint8Array | ArrayBuffer | Buffer | string, format?: string): Uint8Array;
|
|
4
|
+
export declare function concatUint8Arrays(arr1: Uint8Array, arr2: Uint8Array): Uint8Array;
|
|
2
5
|
//# sourceMappingURL=utils.d.ts.map
|
package/dist/src/utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,aAAa,aACf,MAAM,KACd,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAUjC,CAAA"}
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,aAAa,aACf,MAAM,KACd,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAUjC,CAAA;AAsBD,eAAO,MAAM,YAAY,cAAoB,CAAA;AAE7C,wBAAgB,iBAAiB,CAChC,KAAK,EAAE,UAAU,GAAG,WAAW,GAAG,MAAM,GAAG,MAAM,EACjD,MAAM,CAAC,EAAE,MAAM,GACb,UAAU,CA8BZ;AAED,wBAAgB,iBAAiB,CAChC,IAAI,EAAE,UAAU,EAChB,IAAI,EAAE,UAAU,GACd,UAAU,CAKZ"}
|
package/dist/src/utils.js
CHANGED
|
@@ -8,4 +8,58 @@ export const splitCustomId = (customId) => {
|
|
|
8
8
|
}));
|
|
9
9
|
return [id, data];
|
|
10
10
|
};
|
|
11
|
+
// Used from https://github.com/discord/discord-interactions-js
|
|
12
|
+
function getSubtleCrypto() {
|
|
13
|
+
if (typeof window !== "undefined" && window.crypto) {
|
|
14
|
+
return window.crypto.subtle;
|
|
15
|
+
}
|
|
16
|
+
if (typeof globalThis !== "undefined" && globalThis.crypto) {
|
|
17
|
+
return globalThis.crypto.subtle;
|
|
18
|
+
}
|
|
19
|
+
if (typeof crypto !== "undefined") {
|
|
20
|
+
return crypto.subtle;
|
|
21
|
+
}
|
|
22
|
+
if (typeof require === "function") {
|
|
23
|
+
const cryptoPackage = "node:crypto";
|
|
24
|
+
const crypto = require(cryptoPackage);
|
|
25
|
+
return crypto.webcrypto.subtle;
|
|
26
|
+
}
|
|
27
|
+
throw new Error("No Web Crypto API implementation found");
|
|
28
|
+
}
|
|
29
|
+
export const subtleCrypto = getSubtleCrypto();
|
|
30
|
+
export function valueToUint8Array(value, format) {
|
|
31
|
+
if (value == null) {
|
|
32
|
+
return new Uint8Array();
|
|
33
|
+
}
|
|
34
|
+
if (typeof value === "string") {
|
|
35
|
+
if (format === "hex") {
|
|
36
|
+
const matches = value.match(/.{1,2}/g);
|
|
37
|
+
if (matches == null) {
|
|
38
|
+
throw new Error("Value is not a valid hex string");
|
|
39
|
+
}
|
|
40
|
+
const hexVal = matches.map((byte) => Number.parseInt(byte, 16));
|
|
41
|
+
return new Uint8Array(hexVal);
|
|
42
|
+
}
|
|
43
|
+
return new TextEncoder().encode(value);
|
|
44
|
+
}
|
|
45
|
+
try {
|
|
46
|
+
if (Buffer.isBuffer(value)) {
|
|
47
|
+
return new Uint8Array(value);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
catch (_) { }
|
|
51
|
+
if (value instanceof ArrayBuffer) {
|
|
52
|
+
return new Uint8Array(value);
|
|
53
|
+
}
|
|
54
|
+
if (value instanceof Uint8Array) {
|
|
55
|
+
return value;
|
|
56
|
+
}
|
|
57
|
+
throw new Error("Unrecognized value type, must be one of: string, Buffer, ArrayBuffer, Uint8Array");
|
|
58
|
+
}
|
|
59
|
+
export function concatUint8Arrays(arr1, arr2) {
|
|
60
|
+
const merged = new Uint8Array(arr1.length + arr2.length);
|
|
61
|
+
merged.set(arr1);
|
|
62
|
+
merged.set(arr2, arr1.length);
|
|
63
|
+
return merged;
|
|
64
|
+
}
|
|
11
65
|
//# sourceMappingURL=utils.js.map
|
package/dist/src/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,aAAa,GAAG,CAC5B,QAAgB,EACmB,EAAE;IACrC,MAAM,CAAC,EAAE,EAAE,GAAG,IAAI,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;IACzC,IAAI,CAAC,EAAE;QAAE,MAAM,IAAI,KAAK,CAAC,gCAAgC,CAAC,CAAA;IAC1D,MAAM,IAAI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