@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/src/index.ts
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
// ----- Abstracts -----
|
|
2
|
-
export * from "./abstracts/AnySelectMenu.js"
|
|
3
|
-
export * from "./abstracts/AnySelectMenuInteraction.js"
|
|
4
|
-
export * from "./abstracts/Base.js"
|
|
5
|
-
export * from "./abstracts/BaseChannel.js"
|
|
6
|
-
export * from "./abstracts/BaseCommand.js"
|
|
7
|
-
export * from "./abstracts/BaseComponent.js"
|
|
8
|
-
export * from "./abstracts/BaseComponentInteraction.js"
|
|
9
|
-
export * from "./abstracts/BaseGuildChannel.js"
|
|
10
|
-
export * from "./abstracts/BaseGuildTextChannel.js"
|
|
11
|
-
export * from "./abstracts/BaseInteraction.js"
|
|
12
|
-
export * from "./abstracts/GuildThreadOnlyChannel.js"
|
|
13
|
-
|
|
14
|
-
// ----- Classes -----
|
|
15
|
-
export * from "./classes/Button.js"
|
|
16
|
-
export * from "./classes/ChannelSelectMenu.js"
|
|
17
|
-
export * from "./classes/Client.js"
|
|
18
|
-
export * from "./classes/Command.js"
|
|
19
|
-
export * from "./classes/CommandWithSubcommandGroups.js"
|
|
20
|
-
export * from "./classes/CommandWithSubcommands.js"
|
|
21
|
-
export * from "./classes/MentionableSelectMenu.js"
|
|
22
|
-
export * from "./classes/RoleSelectMenu.js"
|
|
23
|
-
export * from "./classes/Row.js"
|
|
24
|
-
export * from "./classes/StringSelectMenu.js"
|
|
25
|
-
export * from "./classes/UserSelectMenu.js"
|
|
26
|
-
|
|
27
|
-
// ----- Factories -----
|
|
28
|
-
export * from "./factories/channelFactory.js"
|
|
29
|
-
|
|
30
|
-
// ----- Internals -----
|
|
31
|
-
export * from "./internals/AutocompleteInteraction.js"
|
|
32
|
-
export * from "./internals/ButtonInteraction.js"
|
|
33
|
-
export * from "./internals/ChannelSelectMenuInteraction.js"
|
|
34
|
-
export * from "./internals/CommandHandler.js"
|
|
35
|
-
export * from "./internals/CommandInteraction.js"
|
|
36
|
-
export * from "./internals/ComponentHandler.js"
|
|
37
|
-
export * from "./internals/MentionableSelectMenuInteraction.js"
|
|
38
|
-
export * from "./internals/OptionsHandler.js"
|
|
39
|
-
export * from "./internals/RoleSelectMenuInteraction.js"
|
|
40
|
-
export * from "./internals/StringSelectMenuInteraction.js"
|
|
41
|
-
export * from "./internals/UserSelectMenuInteraction.js"
|
|
42
|
-
|
|
43
|
-
// ----- Structures -----
|
|
44
|
-
export * from "./structures/DmChannel.js"
|
|
45
|
-
export * from "./structures/GroupDmChannel.js"
|
|
46
|
-
export * from "./structures/Guild.js"
|
|
47
|
-
export * from "./structures/GuildAnnouncementChannel.js"
|
|
48
|
-
export * from "./structures/GuildCategoryChannel.js"
|
|
49
|
-
export * from "./structures/GuildForumChannel.js"
|
|
50
|
-
export * from "./structures/GuildMediaChannel.js"
|
|
51
|
-
export * from "./structures/GuildStageOrVoiceChannel.js"
|
|
52
|
-
export * from "./structures/GuildTextChannel.js"
|
|
53
|
-
export * from "./structures/GuildThreadChannel.js"
|
|
54
|
-
export * from "./structures/Message.js"
|
|
55
|
-
export * from "./structures/Role.js"
|
|
56
|
-
export * from "./structures/User.js"
|
|
57
|
-
|
|
58
|
-
// ----- Types -----
|
|
59
|
-
export * from "discord-api-types/v10"
|
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
type APIApplicationCommandAutocompleteInteraction,
|
|
3
|
-
type APIApplicationCommandInteractionDataBasicOption,
|
|
4
|
-
ApplicationCommandOptionType,
|
|
5
|
-
ApplicationCommandType,
|
|
6
|
-
InteractionResponseType,
|
|
7
|
-
InteractionType,
|
|
8
|
-
Routes
|
|
9
|
-
} from "discord-api-types/v10"
|
|
10
|
-
import type { BaseCommand } from "../abstracts/BaseCommand.js"
|
|
11
|
-
import { BaseInteraction } from "../abstracts/BaseInteraction.js"
|
|
12
|
-
import type { Client } from "../classes/Client.js"
|
|
13
|
-
import { Command } from "../classes/Command.js"
|
|
14
|
-
import { OptionsHandler } from "./OptionsHandler.js"
|
|
15
|
-
|
|
16
|
-
export class AutocompleteInteraction extends BaseInteraction<APIApplicationCommandAutocompleteInteraction> {
|
|
17
|
-
/**
|
|
18
|
-
* This is the options of the commands, parsed from the interaction data.
|
|
19
|
-
*/
|
|
20
|
-
options?: AutocompleteOptionsHandler
|
|
21
|
-
constructor(
|
|
22
|
-
client: Client,
|
|
23
|
-
data: APIApplicationCommandAutocompleteInteraction,
|
|
24
|
-
command?: BaseCommand
|
|
25
|
-
) {
|
|
26
|
-
super(client, data)
|
|
27
|
-
if (data.type !== InteractionType.ApplicationCommandAutocomplete) {
|
|
28
|
-
throw new Error("Invalid interaction type was used to create this class")
|
|
29
|
-
}
|
|
30
|
-
if (data.data.type !== ApplicationCommandType.ChatInput) {
|
|
31
|
-
throw new Error("Invalid command type was used to create this class")
|
|
32
|
-
}
|
|
33
|
-
if (
|
|
34
|
-
command instanceof Command &&
|
|
35
|
-
!data.data.options?.find(
|
|
36
|
-
(x) =>
|
|
37
|
-
x.type === ApplicationCommandOptionType.Subcommand ||
|
|
38
|
-
x.type === ApplicationCommandOptionType.SubcommandGroup
|
|
39
|
-
)
|
|
40
|
-
) {
|
|
41
|
-
this.options = new AutocompleteOptionsHandler(
|
|
42
|
-
client,
|
|
43
|
-
(data.data.options ??
|
|
44
|
-
[]) as APIApplicationCommandInteractionDataBasicOption[]
|
|
45
|
-
)
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
override async defer() {
|
|
50
|
-
throw new Error("Defer is not available for autocomplete interactions")
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
override async reply() {
|
|
54
|
-
throw new Error("Reply is not available for autocomplete interactions")
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* Respond with the choices for an autocomplete interaction
|
|
59
|
-
*/
|
|
60
|
-
async respond(
|
|
61
|
-
choices: {
|
|
62
|
-
/**
|
|
63
|
-
* The name of the choice, this is what the user will see
|
|
64
|
-
*/
|
|
65
|
-
name: string
|
|
66
|
-
/**
|
|
67
|
-
* The value of the choice, this is what the bot will receive from Discord as the value
|
|
68
|
-
*/
|
|
69
|
-
value: string
|
|
70
|
-
}[]
|
|
71
|
-
) {
|
|
72
|
-
console.log(choices)
|
|
73
|
-
await this.client.rest.post(
|
|
74
|
-
Routes.interactionCallback(this.rawData.id, this.rawData.token),
|
|
75
|
-
{
|
|
76
|
-
body: {
|
|
77
|
-
type: InteractionResponseType.ApplicationCommandAutocompleteResult,
|
|
78
|
-
data: {
|
|
79
|
-
choices
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
)
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
export class AutocompleteOptionsHandler extends OptionsHandler {
|
|
88
|
-
/**
|
|
89
|
-
* Get the focused option (the one that is being autocompleted)
|
|
90
|
-
*/
|
|
91
|
-
getFocused() {
|
|
92
|
-
const focused = this.raw.find((x) => "focused" in x && x.focused)
|
|
93
|
-
if (!focused) return null
|
|
94
|
-
switch (focused.type) {
|
|
95
|
-
case ApplicationCommandOptionType.String:
|
|
96
|
-
return this.getString(focused.name)
|
|
97
|
-
case ApplicationCommandOptionType.Integer:
|
|
98
|
-
return this.getInteger(focused.name)
|
|
99
|
-
case ApplicationCommandOptionType.Number:
|
|
100
|
-
return this.getNumber(focused.name)
|
|
101
|
-
case ApplicationCommandOptionType.Boolean:
|
|
102
|
-
return this.getBoolean(focused.name)
|
|
103
|
-
default:
|
|
104
|
-
return null
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
type APIMessageButtonInteractionData,
|
|
3
|
-
type APIMessageComponentButtonInteraction,
|
|
4
|
-
ComponentType,
|
|
5
|
-
InteractionType
|
|
6
|
-
} from "discord-api-types/v10"
|
|
7
|
-
import { BaseComponentInteraction } from "../abstracts/BaseComponentInteraction.js"
|
|
8
|
-
import type { Client } from "../classes/Client.js"
|
|
9
|
-
import { splitCustomId } from "../utils.js"
|
|
10
|
-
|
|
11
|
-
export class ButtonInteraction extends BaseComponentInteraction {
|
|
12
|
-
customId: string = splitCustomId(
|
|
13
|
-
(this.rawData.data as APIMessageButtonInteractionData).custom_id
|
|
14
|
-
)[0]
|
|
15
|
-
constructor(client: Client, data: APIMessageComponentButtonInteraction) {
|
|
16
|
-
super(client, data)
|
|
17
|
-
if (!data.data)
|
|
18
|
-
throw new Error("Invalid interaction data was used to create this class")
|
|
19
|
-
if (data.type !== InteractionType.MessageComponent) {
|
|
20
|
-
throw new Error("Invalid interaction type was used to create this class")
|
|
21
|
-
}
|
|
22
|
-
if (data.data.component_type !== ComponentType.Button) {
|
|
23
|
-
throw new Error("Invalid component type was used to create this class")
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
type APIMessageComponentSelectMenuInteraction,
|
|
3
|
-
ComponentType
|
|
4
|
-
} from "discord-api-types/v10"
|
|
5
|
-
import { AnySelectMenuInteraction } from "../abstracts/AnySelectMenuInteraction.js"
|
|
6
|
-
import type { Client } from "../classes/Client.js"
|
|
7
|
-
|
|
8
|
-
export class ChannelSelectMenuInteraction extends AnySelectMenuInteraction {
|
|
9
|
-
constructor(client: Client, data: APIMessageComponentSelectMenuInteraction) {
|
|
10
|
-
super(client, data)
|
|
11
|
-
if (data.data.component_type !== ComponentType.ChannelSelect) {
|
|
12
|
-
throw new Error("Invalid component type was used to create this class")
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
}
|
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
type APIApplicationCommandAutocompleteInteraction,
|
|
3
|
-
type APIApplicationCommandInteraction,
|
|
4
|
-
type APIApplicationCommandSubcommandGroupOption,
|
|
5
|
-
ApplicationCommandOptionType,
|
|
6
|
-
ApplicationCommandType
|
|
7
|
-
} from "discord-api-types/v10"
|
|
8
|
-
import { Base } from "../abstracts/Base.js"
|
|
9
|
-
import { Command } from "../classes/Command.js"
|
|
10
|
-
import { CommandWithSubcommandGroups } from "../classes/CommandWithSubcommandGroups.js"
|
|
11
|
-
import { CommandWithSubcommands } from "../classes/CommandWithSubcommands.js"
|
|
12
|
-
import { AutocompleteInteraction } from "./AutocompleteInteraction.js"
|
|
13
|
-
import { CommandInteraction } from "./CommandInteraction.js"
|
|
14
|
-
|
|
15
|
-
export class CommandHandler extends Base {
|
|
16
|
-
private getCommand(
|
|
17
|
-
rawInteraction:
|
|
18
|
-
| APIApplicationCommandAutocompleteInteraction
|
|
19
|
-
| APIApplicationCommandInteraction
|
|
20
|
-
): Command {
|
|
21
|
-
const command = this.client.commands.find(
|
|
22
|
-
(x) => x.name === rawInteraction.data.name
|
|
23
|
-
)
|
|
24
|
-
if (!command) throw new Error("Command not found")
|
|
25
|
-
|
|
26
|
-
if (command instanceof CommandWithSubcommandGroups) {
|
|
27
|
-
if (rawInteraction.data.type !== ApplicationCommandType.ChatInput) {
|
|
28
|
-
throw new Error("Subcommand groups must be used with ChatInput")
|
|
29
|
-
}
|
|
30
|
-
const data = rawInteraction.data
|
|
31
|
-
const subcommandGroupName = data.options?.find(
|
|
32
|
-
(x) => x.type === ApplicationCommandOptionType.SubcommandGroup
|
|
33
|
-
)?.name
|
|
34
|
-
if (!subcommandGroupName) throw new Error("No subcommand group name")
|
|
35
|
-
|
|
36
|
-
const subcommandGroup = command.subcommandGroups.find(
|
|
37
|
-
(x) => x.name === subcommandGroupName
|
|
38
|
-
)
|
|
39
|
-
|
|
40
|
-
if (!subcommandGroup) throw new Error("Subcommand group not found")
|
|
41
|
-
|
|
42
|
-
const subcommandName = (
|
|
43
|
-
data.options?.find(
|
|
44
|
-
(x) => x.type === ApplicationCommandOptionType.SubcommandGroup
|
|
45
|
-
) as APIApplicationCommandSubcommandGroupOption
|
|
46
|
-
).options?.find(
|
|
47
|
-
(x) => x.type === ApplicationCommandOptionType.Subcommand
|
|
48
|
-
)?.name
|
|
49
|
-
if (!subcommandName) throw new Error("No subcommand name")
|
|
50
|
-
|
|
51
|
-
const subcommand = subcommandGroup.subcommands.find(
|
|
52
|
-
(x) => x.name === subcommandName
|
|
53
|
-
)
|
|
54
|
-
|
|
55
|
-
if (!subcommand) throw new Error("Subcommand not found")
|
|
56
|
-
|
|
57
|
-
return subcommand
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
if (command instanceof CommandWithSubcommands) {
|
|
61
|
-
if (rawInteraction.data.type !== ApplicationCommandType.ChatInput) {
|
|
62
|
-
throw new Error("Subcommands must be used with ChatInput")
|
|
63
|
-
}
|
|
64
|
-
const data = rawInteraction.data
|
|
65
|
-
const subcommand = command.subcommands.find(
|
|
66
|
-
(x) => x.name === data.options?.[0]?.name
|
|
67
|
-
)
|
|
68
|
-
if (!subcommand) throw new Error("Subcommand not found")
|
|
69
|
-
|
|
70
|
-
return subcommand
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
if (command instanceof Command) {
|
|
74
|
-
return command
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
throw new Error("Command is not a valid command type")
|
|
78
|
-
}
|
|
79
|
-
async handleCommandInteraction(
|
|
80
|
-
rawInteraction: APIApplicationCommandInteraction
|
|
81
|
-
) {
|
|
82
|
-
const command = this.getCommand(rawInteraction)
|
|
83
|
-
if (!command) return false
|
|
84
|
-
|
|
85
|
-
const interaction = new CommandInteraction(
|
|
86
|
-
this.client,
|
|
87
|
-
rawInteraction,
|
|
88
|
-
command
|
|
89
|
-
)
|
|
90
|
-
|
|
91
|
-
try {
|
|
92
|
-
const command = this.getCommand(rawInteraction)
|
|
93
|
-
|
|
94
|
-
if (command.defer) {
|
|
95
|
-
await interaction.defer()
|
|
96
|
-
}
|
|
97
|
-
return await command.run(interaction)
|
|
98
|
-
} catch (e: unknown) {
|
|
99
|
-
if (e instanceof Error) console.error(e.message)
|
|
100
|
-
console.error(e)
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
async handleAutocompleteInteraction(
|
|
104
|
-
rawInteraction: APIApplicationCommandAutocompleteInteraction
|
|
105
|
-
) {
|
|
106
|
-
const command = this.getCommand(rawInteraction)
|
|
107
|
-
if (!command) return false
|
|
108
|
-
|
|
109
|
-
const interaction = new AutocompleteInteraction(
|
|
110
|
-
this.client,
|
|
111
|
-
rawInteraction,
|
|
112
|
-
command
|
|
113
|
-
)
|
|
114
|
-
|
|
115
|
-
try {
|
|
116
|
-
const command = this.getCommand(rawInteraction)
|
|
117
|
-
return await command.autocomplete(interaction)
|
|
118
|
-
} catch (e: unknown) {
|
|
119
|
-
if (e instanceof Error) console.error(e.message)
|
|
120
|
-
console.error(e)
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
type APIApplicationCommandInteraction,
|
|
3
|
-
type APIApplicationCommandInteractionDataBasicOption,
|
|
4
|
-
ApplicationCommandOptionType,
|
|
5
|
-
ApplicationCommandType,
|
|
6
|
-
InteractionType
|
|
7
|
-
} from "discord-api-types/v10"
|
|
8
|
-
import type { BaseCommand } from "../abstracts/BaseCommand.js"
|
|
9
|
-
import { BaseInteraction } from "../abstracts/BaseInteraction.js"
|
|
10
|
-
import type { Client } from "../classes/Client.js"
|
|
11
|
-
import { Command } from "../classes/Command.js"
|
|
12
|
-
import { OptionsHandler } from "./OptionsHandler.js"
|
|
13
|
-
// import type { RawOptions } from "./OptionsHandler.js"
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Represents a command interaction
|
|
17
|
-
*/
|
|
18
|
-
export class CommandInteraction extends BaseInteraction<APIApplicationCommandInteraction> {
|
|
19
|
-
/**
|
|
20
|
-
* This is the options of the commands, parsed from the interaction data.
|
|
21
|
-
* It is only available if the command is a {@link Command} class, and the command is a ChatInput command.
|
|
22
|
-
*/
|
|
23
|
-
options?: OptionsHandler
|
|
24
|
-
constructor(
|
|
25
|
-
client: Client,
|
|
26
|
-
data: APIApplicationCommandInteraction,
|
|
27
|
-
command?: BaseCommand
|
|
28
|
-
) {
|
|
29
|
-
super(client, data)
|
|
30
|
-
if (data.type !== InteractionType.ApplicationCommand) {
|
|
31
|
-
throw new Error("Invalid interaction type was used to create this class")
|
|
32
|
-
}
|
|
33
|
-
if (
|
|
34
|
-
command instanceof Command &&
|
|
35
|
-
data.data.type === ApplicationCommandType.ChatInput &&
|
|
36
|
-
!data.data.options?.find(
|
|
37
|
-
(x) =>
|
|
38
|
-
x.type === ApplicationCommandOptionType.Subcommand ||
|
|
39
|
-
x.type === ApplicationCommandOptionType.SubcommandGroup
|
|
40
|
-
)
|
|
41
|
-
) {
|
|
42
|
-
this.options = new OptionsHandler(
|
|
43
|
-
client,
|
|
44
|
-
(data.data.options ??
|
|
45
|
-
[]) as APIApplicationCommandInteractionDataBasicOption[]
|
|
46
|
-
)
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
}
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
APIMessageComponentButtonInteraction,
|
|
3
|
-
APIMessageComponentInteraction,
|
|
4
|
-
APIMessageComponentSelectMenuInteraction
|
|
5
|
-
} from "discord-api-types/v10"
|
|
6
|
-
import { Base } from "../abstracts/Base.js"
|
|
7
|
-
import type { BaseComponent } from "../abstracts/BaseComponent.js"
|
|
8
|
-
import { Button } from "../classes/Button.js"
|
|
9
|
-
import { ChannelSelectMenu } from "../classes/ChannelSelectMenu.js"
|
|
10
|
-
import { MentionableSelectMenu } from "../classes/MentionableSelectMenu.js"
|
|
11
|
-
import { RoleSelectMenu } from "../classes/RoleSelectMenu.js"
|
|
12
|
-
import { StringSelectMenu } from "../classes/StringSelectMenu.js"
|
|
13
|
-
import { UserSelectMenu } from "../classes/UserSelectMenu.js"
|
|
14
|
-
import { ButtonInteraction } from "./ButtonInteraction.js"
|
|
15
|
-
import { ChannelSelectMenuInteraction } from "./ChannelSelectMenuInteraction.js"
|
|
16
|
-
import { MentionableSelectMenuInteraction } from "./MentionableSelectMenuInteraction.js"
|
|
17
|
-
import { RoleSelectMenuInteraction } from "./RoleSelectMenuInteraction.js"
|
|
18
|
-
import { StringSelectMenuInteraction } from "./StringSelectMenuInteraction.js"
|
|
19
|
-
import { UserSelectMenuInteraction } from "./UserSelectMenuInteraction.js"
|
|
20
|
-
|
|
21
|
-
export class ComponentHandler extends Base {
|
|
22
|
-
async handleInteraction(data: APIMessageComponentInteraction) {
|
|
23
|
-
const allComponents = this.client.commands
|
|
24
|
-
.filter((x) => x.components && x.components.length > 0)
|
|
25
|
-
.flatMap((x) => x.components) as BaseComponent[]
|
|
26
|
-
const component = allComponents.find(
|
|
27
|
-
(x) =>
|
|
28
|
-
x.customId === data.data.custom_id &&
|
|
29
|
-
x.type === data.data.component_type
|
|
30
|
-
)
|
|
31
|
-
if (!component) return false
|
|
32
|
-
|
|
33
|
-
if (component instanceof Button) {
|
|
34
|
-
const interaction = new ButtonInteraction(
|
|
35
|
-
this.client,
|
|
36
|
-
data as APIMessageComponentButtonInteraction
|
|
37
|
-
)
|
|
38
|
-
if (component.defer) await interaction.defer()
|
|
39
|
-
await component.run(interaction)
|
|
40
|
-
} else if (component instanceof RoleSelectMenu) {
|
|
41
|
-
const interaction = new RoleSelectMenuInteraction(
|
|
42
|
-
this.client,
|
|
43
|
-
data as APIMessageComponentSelectMenuInteraction
|
|
44
|
-
)
|
|
45
|
-
if (component.defer) await interaction.defer()
|
|
46
|
-
await component.run(interaction)
|
|
47
|
-
} else if (component instanceof ChannelSelectMenu) {
|
|
48
|
-
const interaction = new ChannelSelectMenuInteraction(
|
|
49
|
-
this.client,
|
|
50
|
-
data as APIMessageComponentSelectMenuInteraction
|
|
51
|
-
)
|
|
52
|
-
if (component.defer) await interaction.defer()
|
|
53
|
-
await component.run(interaction)
|
|
54
|
-
} else if (component instanceof MentionableSelectMenu) {
|
|
55
|
-
const interaction = new MentionableSelectMenuInteraction(
|
|
56
|
-
this.client,
|
|
57
|
-
data as APIMessageComponentSelectMenuInteraction
|
|
58
|
-
)
|
|
59
|
-
if (component.defer) await interaction.defer()
|
|
60
|
-
await component.run(interaction)
|
|
61
|
-
} else if (component instanceof StringSelectMenu) {
|
|
62
|
-
const interaction = new StringSelectMenuInteraction(
|
|
63
|
-
this.client,
|
|
64
|
-
data as APIMessageComponentSelectMenuInteraction
|
|
65
|
-
)
|
|
66
|
-
if (component.defer) await interaction.defer()
|
|
67
|
-
await component.run(interaction)
|
|
68
|
-
} else if (component instanceof UserSelectMenu) {
|
|
69
|
-
const interaction = new UserSelectMenuInteraction(
|
|
70
|
-
this.client,
|
|
71
|
-
data as APIMessageComponentSelectMenuInteraction
|
|
72
|
-
)
|
|
73
|
-
if (component.defer) await interaction.defer()
|
|
74
|
-
await component.run(interaction)
|
|
75
|
-
} else {
|
|
76
|
-
throw new Error(
|
|
77
|
-
`Unknown component with type ${data.data.component_type} and custom ID ${data.data.custom_id}`
|
|
78
|
-
)
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
type APIMessageComponentSelectMenuInteraction,
|
|
3
|
-
type APIMessageMentionableSelectInteractionData,
|
|
4
|
-
ComponentType
|
|
5
|
-
} from "discord-api-types/v10"
|
|
6
|
-
import { AnySelectMenuInteraction } from "../abstracts/AnySelectMenuInteraction.js"
|
|
7
|
-
import type { Client } from "../classes/Client.js"
|
|
8
|
-
|
|
9
|
-
export class MentionableSelectMenuInteraction extends AnySelectMenuInteraction {
|
|
10
|
-
constructor(client: Client, data: APIMessageComponentSelectMenuInteraction) {
|
|
11
|
-
super(client, data)
|
|
12
|
-
if (data.data.component_type !== ComponentType.MentionableSelect) {
|
|
13
|
-
throw new Error("Invalid component type was used to create this class")
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
get values(): string[] {
|
|
18
|
-
return (this.rawData.data as APIMessageMentionableSelectInteractionData)
|
|
19
|
-
.values
|
|
20
|
-
}
|
|
21
|
-
}
|
|
@@ -1,148 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
type APIApplicationCommandInteractionDataBasicOption,
|
|
3
|
-
type APIChannel,
|
|
4
|
-
ApplicationCommandOptionType,
|
|
5
|
-
Routes
|
|
6
|
-
} from "discord-api-types/v10"
|
|
7
|
-
import { Base } from "../abstracts/Base.js"
|
|
8
|
-
import { type Client, Role, User, channelFactory } from "../index.js"
|
|
9
|
-
|
|
10
|
-
export type RawOptions = {
|
|
11
|
-
[key: string]:
|
|
12
|
-
| APIApplicationCommandInteractionDataBasicOption["value"]
|
|
13
|
-
| undefined
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* This class is used to parse the options of a command, and provide errors for any missing or invalid options.
|
|
18
|
-
* It is used internally by the Command class.
|
|
19
|
-
*/
|
|
20
|
-
export class OptionsHandler extends Base {
|
|
21
|
-
/**
|
|
22
|
-
* The raw options that were in the interaction data, before they were parsed.
|
|
23
|
-
*/
|
|
24
|
-
readonly raw: APIApplicationCommandInteractionDataBasicOption[]
|
|
25
|
-
/**
|
|
26
|
-
* The errors that were encountered while parsing the options.
|
|
27
|
-
*/
|
|
28
|
-
readonly errors: Array<string> = []
|
|
29
|
-
|
|
30
|
-
constructor(
|
|
31
|
-
client: Client,
|
|
32
|
-
options: APIApplicationCommandInteractionDataBasicOption[]
|
|
33
|
-
) {
|
|
34
|
-
super(client)
|
|
35
|
-
this.raw = options
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* Get the value of a string option.
|
|
40
|
-
* @param key The name of the option to get the value of.
|
|
41
|
-
* @returns The value of the option, or undefined if the option was not provided.
|
|
42
|
-
*/
|
|
43
|
-
public getString(key: string) {
|
|
44
|
-
const value = this.raw.find(
|
|
45
|
-
(x) => x.name === key && x.type === ApplicationCommandOptionType.String
|
|
46
|
-
)?.value
|
|
47
|
-
if (!value || typeof value !== "string") return undefined
|
|
48
|
-
return value
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* Get the value of an integer option.
|
|
53
|
-
* @param key The name of the option to get the value of.
|
|
54
|
-
* @returns The value of the option, or undefined if the option was not provided.
|
|
55
|
-
*/
|
|
56
|
-
public getInteger(key: string) {
|
|
57
|
-
const num = this.raw.find(
|
|
58
|
-
(x) => x.name === key && x.type === ApplicationCommandOptionType.Integer
|
|
59
|
-
)?.value
|
|
60
|
-
if (!num || typeof num !== "number" || !Number.isSafeInteger(num))
|
|
61
|
-
return undefined
|
|
62
|
-
return num
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* Get the value of a number 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
|
-
public getNumber(key: string) {
|
|
71
|
-
const value = this.raw.find(
|
|
72
|
-
(x) => x.name === key && x.type === ApplicationCommandOptionType.Number
|
|
73
|
-
)?.value
|
|
74
|
-
if (!value || typeof value !== "number") return undefined
|
|
75
|
-
return value
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* Get the value of a boolean option.
|
|
80
|
-
* @param key The name of the option to get the value of.
|
|
81
|
-
* @returns The value of the option, or undefined if the option was not provided.
|
|
82
|
-
*/
|
|
83
|
-
public getBoolean(key: string) {
|
|
84
|
-
const value = this.raw.find(
|
|
85
|
-
(x) => x.name === key && x.type === ApplicationCommandOptionType.Boolean
|
|
86
|
-
)?.value
|
|
87
|
-
if (!value || typeof value !== "boolean") return undefined
|
|
88
|
-
return value
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
/**
|
|
92
|
-
* Get the value of a user option.
|
|
93
|
-
* @param key The name of the option to get the value of.
|
|
94
|
-
* @returns The value of the option, or undefined if the option was not provided.
|
|
95
|
-
*/
|
|
96
|
-
public getUser(key: string) {
|
|
97
|
-
const id = this.raw.find(
|
|
98
|
-
(x) => x.name === key && x.type === ApplicationCommandOptionType.User
|
|
99
|
-
)?.value
|
|
100
|
-
if (!id || typeof id !== "string") return undefined
|
|
101
|
-
return new User(this.client, id)
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
/**
|
|
105
|
-
* Get the value of a channel option.
|
|
106
|
-
* @param key The name of the option to get the value of.
|
|
107
|
-
* @returns The value of the option, or undefined if the option was not provided.
|
|
108
|
-
*/
|
|
109
|
-
public async getChannel(key: string) {
|
|
110
|
-
const id = this.raw.find(
|
|
111
|
-
(x) => x.name === key && x.type === ApplicationCommandOptionType.Channel
|
|
112
|
-
)?.value
|
|
113
|
-
if (!id || typeof id !== "string") return undefined
|
|
114
|
-
const data = (await this.client.rest.get(Routes.channel(id))) as APIChannel
|
|
115
|
-
return channelFactory(this.client, data)
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
/**
|
|
119
|
-
* Get the value of a role option.
|
|
120
|
-
* @param key The name of the option to get the value of.
|
|
121
|
-
* @returns The value of the option, or undefined if the option was not provided.
|
|
122
|
-
*/
|
|
123
|
-
public getRole(key: string): Role | undefined {
|
|
124
|
-
const id = this.raw.find(
|
|
125
|
-
(x) => x.name === key && x.type === ApplicationCommandOptionType.Role
|
|
126
|
-
)?.value
|
|
127
|
-
if (!id || typeof id !== "string") return undefined
|
|
128
|
-
return new Role(this.client, id)
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
/**
|
|
132
|
-
* Get the value of a mentionable option.
|
|
133
|
-
* @param key The name of the option to get the value of.
|
|
134
|
-
* @returns The value of the option, or undefined if the option was not provided.
|
|
135
|
-
*/
|
|
136
|
-
public async getMentionable(key: string): Promise<User | Role | undefined> {
|
|
137
|
-
const id = this.raw.find(
|
|
138
|
-
(x) =>
|
|
139
|
-
x.name === key && x.type === ApplicationCommandOptionType.Mentionable
|
|
140
|
-
)?.value
|
|
141
|
-
if (!id || typeof id !== "string") return undefined
|
|
142
|
-
const user = new User(this.client, id)
|
|
143
|
-
await user.fetch().catch(() => {
|
|
144
|
-
return new Role(this.client, id)
|
|
145
|
-
})
|
|
146
|
-
return user
|
|
147
|
-
}
|
|
148
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
type APIMessageComponentSelectMenuInteraction,
|
|
3
|
-
type APIMessageRoleSelectInteractionData,
|
|
4
|
-
ComponentType
|
|
5
|
-
} from "discord-api-types/v10"
|
|
6
|
-
import { AnySelectMenuInteraction } from "../abstracts/AnySelectMenuInteraction.js"
|
|
7
|
-
import type { Client } from "../classes/Client.js"
|
|
8
|
-
|
|
9
|
-
export class RoleSelectMenuInteraction extends AnySelectMenuInteraction {
|
|
10
|
-
constructor(client: Client, data: APIMessageComponentSelectMenuInteraction) {
|
|
11
|
-
super(client, data)
|
|
12
|
-
if (data.data.component_type !== ComponentType.RoleSelect) {
|
|
13
|
-
throw new Error("Invalid component type was used to create this class")
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
get values(): string[] {
|
|
18
|
-
return (this.rawData.data as APIMessageRoleSelectInteractionData).values
|
|
19
|
-
}
|
|
20
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
type APIMessageComponentSelectMenuInteraction,
|
|
3
|
-
type APIMessageStringSelectInteractionData,
|
|
4
|
-
ComponentType
|
|
5
|
-
} from "discord-api-types/v10"
|
|
6
|
-
import { AnySelectMenuInteraction } from "../abstracts/AnySelectMenuInteraction.js"
|
|
7
|
-
import type { Client } from "../classes/Client.js"
|
|
8
|
-
|
|
9
|
-
export class StringSelectMenuInteraction extends AnySelectMenuInteraction {
|
|
10
|
-
constructor(client: Client, data: APIMessageComponentSelectMenuInteraction) {
|
|
11
|
-
super(client, data)
|
|
12
|
-
if (data.data.component_type !== ComponentType.StringSelect) {
|
|
13
|
-
throw new Error("Invalid component type was used to create this class")
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
get values(): string[] {
|
|
18
|
-
return (this.rawData.data as APIMessageStringSelectInteractionData).values
|
|
19
|
-
}
|
|
20
|
-
}
|