@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/classes/Button.ts
DELETED
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
type APIButtonComponent,
|
|
3
|
-
type APIButtonComponentWithSKUId,
|
|
4
|
-
type APIButtonComponentWithURL,
|
|
5
|
-
ButtonStyle,
|
|
6
|
-
ComponentType
|
|
7
|
-
} from "discord-api-types/v10"
|
|
8
|
-
import { BaseComponent } from "../abstracts/BaseComponent.js"
|
|
9
|
-
import type { ButtonInteraction } from "../internals/ButtonInteraction.js"
|
|
10
|
-
|
|
11
|
-
abstract class BaseButton extends BaseComponent {
|
|
12
|
-
type = ComponentType.Button
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* The label of the button
|
|
16
|
-
*/
|
|
17
|
-
abstract label: string
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* The emoji of the button
|
|
21
|
-
*/
|
|
22
|
-
emoji?: {
|
|
23
|
-
name: string
|
|
24
|
-
id?: string
|
|
25
|
-
animated?: boolean
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* The style of the button
|
|
30
|
-
*/
|
|
31
|
-
style: ButtonStyle = ButtonStyle.Primary
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* The disabled state of the button
|
|
35
|
-
*/
|
|
36
|
-
disabled = false
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export abstract class Button extends BaseButton {
|
|
40
|
-
/**
|
|
41
|
-
* The style of the button
|
|
42
|
-
*/
|
|
43
|
-
abstract style: Exclude<ButtonStyle, ButtonStyle.Link | ButtonStyle.Premium>
|
|
44
|
-
|
|
45
|
-
abstract run(interaction: ButtonInteraction): Promise<void>
|
|
46
|
-
|
|
47
|
-
serialize = (): APIButtonComponent => {
|
|
48
|
-
return {
|
|
49
|
-
type: ComponentType.Button,
|
|
50
|
-
style: this.style,
|
|
51
|
-
label: this.label,
|
|
52
|
-
custom_id: this.customId,
|
|
53
|
-
disabled: this.disabled,
|
|
54
|
-
emoji: this.emoji
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
export abstract class LinkButton extends BaseButton {
|
|
60
|
-
customId = ""
|
|
61
|
-
/**
|
|
62
|
-
* The URL that the button links to
|
|
63
|
-
*/
|
|
64
|
-
abstract url: string
|
|
65
|
-
style: ButtonStyle.Link = ButtonStyle.Link
|
|
66
|
-
|
|
67
|
-
serialize = (): APIButtonComponentWithURL => {
|
|
68
|
-
return {
|
|
69
|
-
type: ComponentType.Button,
|
|
70
|
-
url: this.url,
|
|
71
|
-
style: this.style,
|
|
72
|
-
label: this.label,
|
|
73
|
-
disabled: this.disabled,
|
|
74
|
-
emoji: this.emoji
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
export abstract class PremiumButton extends BaseButton {
|
|
80
|
-
style: ButtonStyle.Premium = ButtonStyle.Premium
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* The SKU ID of the button
|
|
84
|
-
*/
|
|
85
|
-
abstract sku_id: string
|
|
86
|
-
|
|
87
|
-
serialize = (): APIButtonComponentWithSKUId => {
|
|
88
|
-
return {
|
|
89
|
-
style: this.style,
|
|
90
|
-
type: ComponentType.Button,
|
|
91
|
-
disabled: this.disabled,
|
|
92
|
-
sku_id: this.sku_id
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
type APIChannelSelectComponent,
|
|
3
|
-
ComponentType
|
|
4
|
-
} from "discord-api-types/v10"
|
|
5
|
-
import { AnySelectMenu } from "../abstracts/AnySelectMenu.js"
|
|
6
|
-
import type { ChannelSelectMenuInteraction } from "../internals/ChannelSelectMenuInteraction.js"
|
|
7
|
-
|
|
8
|
-
export abstract class ChannelSelectMenu extends AnySelectMenu {
|
|
9
|
-
type: ComponentType.ChannelSelect = ComponentType.ChannelSelect
|
|
10
|
-
channelTypes?: APIChannelSelectComponent["channel_types"]
|
|
11
|
-
defaultValues?: APIChannelSelectComponent["default_values"]
|
|
12
|
-
abstract run(interaction: ChannelSelectMenuInteraction): Promise<void>
|
|
13
|
-
|
|
14
|
-
serializeOptions() {
|
|
15
|
-
return {
|
|
16
|
-
type: this.type,
|
|
17
|
-
default_values: this.defaultValues,
|
|
18
|
-
channel_types: this.channelTypes
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
}
|
package/src/classes/Client.ts
DELETED
|
@@ -1,254 +0,0 @@
|
|
|
1
|
-
import { RequestClient, type RequestClientOptions } from "@buape/carbon-request"
|
|
2
|
-
import {
|
|
3
|
-
type APIInteraction,
|
|
4
|
-
InteractionResponseType,
|
|
5
|
-
InteractionType,
|
|
6
|
-
Routes
|
|
7
|
-
} from "discord-api-types/v10"
|
|
8
|
-
import { PlatformAlgorithm, isValidRequest } from "discord-verify"
|
|
9
|
-
import { AutoRouter, type IRequestStrict, StatusError, json } from "itty-router"
|
|
10
|
-
import type { BaseCommand } from "../abstracts/BaseCommand.js"
|
|
11
|
-
import { CommandHandler } from "../internals/CommandHandler.js"
|
|
12
|
-
import { ComponentHandler } from "../internals/ComponentHandler.js"
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* The mode that the client is running in.
|
|
16
|
-
* Different platforms have different requirements for how processes are handled.
|
|
17
|
-
*/
|
|
18
|
-
export enum ClientMode {
|
|
19
|
-
NodeJS = "node",
|
|
20
|
-
CloudflareWorkers = "cloudflare",
|
|
21
|
-
Bun = "bun",
|
|
22
|
-
Vercel = "vercel",
|
|
23
|
-
Web = "web"
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* The options used for initializing the client
|
|
28
|
-
*/
|
|
29
|
-
export type ClientOptions = {
|
|
30
|
-
/**
|
|
31
|
-
* If you want to have the root route for the interaction handler redirect to a different URL, you can set this.
|
|
32
|
-
*/
|
|
33
|
-
redirectUrl?: string
|
|
34
|
-
/**
|
|
35
|
-
* The client ID of the bot
|
|
36
|
-
*/
|
|
37
|
-
clientId: string
|
|
38
|
-
/**
|
|
39
|
-
* The public key of the bot, used for interaction verification
|
|
40
|
-
*/
|
|
41
|
-
publicKey: string
|
|
42
|
-
/**
|
|
43
|
-
* The token of the bot
|
|
44
|
-
*/
|
|
45
|
-
token: string
|
|
46
|
-
/**
|
|
47
|
-
* The mode of the client, generally where you are hosting the bot. If you have a different mode for your local development, make sure to set it to the local one.
|
|
48
|
-
* @example
|
|
49
|
-
* ```ts
|
|
50
|
-
* import { Client, ClientMode } from "@buape/carbon"
|
|
51
|
-
*
|
|
52
|
-
* const client = new Client({
|
|
53
|
-
* clientId: "12345678901234567890",
|
|
54
|
-
* publicKey: "c1a2f941ae8ce6d776f7704d0bb3d46b863e21fda491cdb2bdba6b8bc5fe7269",
|
|
55
|
-
* token: "MTA4NjEwNTYxMDUxMDE1NTg1Nw.GNt-U8.OSHy-g-5FlfESnu3Z9MEEMJLHiRthXajiXNwiE",
|
|
56
|
-
* mode: process.env.NODE_ENV === "development" ? ClientMode.NodeJS : ClientMode.CloudflareWorkers
|
|
57
|
-
* })
|
|
58
|
-
* ```
|
|
59
|
-
*/
|
|
60
|
-
mode: ClientMode
|
|
61
|
-
/**
|
|
62
|
-
* The route to use for interactions on your server.
|
|
63
|
-
* @default "/interaction"
|
|
64
|
-
*/
|
|
65
|
-
interactionRoute?: string
|
|
66
|
-
/**
|
|
67
|
-
* The options used to initialize the request client, if you want to customize it.
|
|
68
|
-
*/
|
|
69
|
-
requestOptions?: RequestClientOptions
|
|
70
|
-
/**
|
|
71
|
-
* The port to run the server on, if you are using {@link ClientMode.Bun} mode.
|
|
72
|
-
*/
|
|
73
|
-
port?: number
|
|
74
|
-
/**
|
|
75
|
-
* Whether the commands should be deployed to Discord automatically.
|
|
76
|
-
*/
|
|
77
|
-
autoDeploy?: boolean
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
/**
|
|
81
|
-
* The main client used to interact with Discord
|
|
82
|
-
*/
|
|
83
|
-
export class Client {
|
|
84
|
-
/**
|
|
85
|
-
* The options used to initialize the client
|
|
86
|
-
*/
|
|
87
|
-
options: ClientOptions
|
|
88
|
-
/**
|
|
89
|
-
* The commands that the client has registered
|
|
90
|
-
*/
|
|
91
|
-
commands: BaseCommand[]
|
|
92
|
-
/**
|
|
93
|
-
* The router used to handle requests
|
|
94
|
-
*/
|
|
95
|
-
router: ReturnType<typeof AutoRouter<IRequestStrict>>
|
|
96
|
-
/**
|
|
97
|
-
* The rest client used to interact with the Discord API
|
|
98
|
-
*/
|
|
99
|
-
rest: RequestClient
|
|
100
|
-
/**
|
|
101
|
-
* The handler for the component interactions sent from Discord
|
|
102
|
-
*/
|
|
103
|
-
componentHandler: ComponentHandler
|
|
104
|
-
commandHandler: CommandHandler
|
|
105
|
-
|
|
106
|
-
/**
|
|
107
|
-
* Creates a new client
|
|
108
|
-
* @param options The options used to initialize the client
|
|
109
|
-
* @param commands The commands that the client has registered
|
|
110
|
-
*/
|
|
111
|
-
constructor(options: ClientOptions, commands: BaseCommand[]) {
|
|
112
|
-
if (!options.clientId) throw new Error("Missing client ID")
|
|
113
|
-
if (!options.publicKey) throw new Error("Missing public key")
|
|
114
|
-
if (!options.token) throw new Error("Missing token")
|
|
115
|
-
this.options = options
|
|
116
|
-
this.commands = commands
|
|
117
|
-
const routerData =
|
|
118
|
-
this.options.mode === ClientMode.Bun && this.options.port
|
|
119
|
-
? { port: this.options.port }
|
|
120
|
-
: {}
|
|
121
|
-
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
|
|
122
|
-
this.router = AutoRouter<IRequestStrict, any[], Response>(routerData)
|
|
123
|
-
this.rest = new RequestClient(options.token, options.requestOptions)
|
|
124
|
-
this.componentHandler = new ComponentHandler(this)
|
|
125
|
-
this.commandHandler = new CommandHandler(this)
|
|
126
|
-
this.setupRoutes()
|
|
127
|
-
if (this.options.autoDeploy) this.deployCommands()
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
/**
|
|
131
|
-
* Deploy the commands registered to Discord.
|
|
132
|
-
* This is automatically called when running in NodeJS mode.
|
|
133
|
-
*/
|
|
134
|
-
async deployCommands() {
|
|
135
|
-
try {
|
|
136
|
-
const commands = this.commands.map((command) => {
|
|
137
|
-
return command.serialize()
|
|
138
|
-
})
|
|
139
|
-
await this.rest.put(Routes.applicationCommands(this.options.clientId), {
|
|
140
|
-
body: commands
|
|
141
|
-
})
|
|
142
|
-
console.log(`Deployed ${commands.length} commands to Discord`)
|
|
143
|
-
} catch (err) {
|
|
144
|
-
console.error("Failed to deploy commands")
|
|
145
|
-
console.error(err)
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
/**
|
|
150
|
-
* Setup the routes for the client
|
|
151
|
-
*/
|
|
152
|
-
private setupRoutes() {
|
|
153
|
-
this.router.get("/", () => {
|
|
154
|
-
if (this.options.redirectUrl)
|
|
155
|
-
return Response.redirect(this.options.redirectUrl, 302)
|
|
156
|
-
throw new StatusError(404)
|
|
157
|
-
})
|
|
158
|
-
this.router.post(
|
|
159
|
-
this.options.interactionRoute || "/interaction",
|
|
160
|
-
async (req, ctx?: ExecutionContext) => {
|
|
161
|
-
return await this.handle(req, ctx)
|
|
162
|
-
}
|
|
163
|
-
)
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
/**
|
|
167
|
-
* If you want use a custom handler for HTTP requests instead of Carbon's router, you can use this method.
|
|
168
|
-
* @param req The request to handle
|
|
169
|
-
* @param ctx Cloudflare Workers only. The execution context of the request, provided in the fetch handler from CF.
|
|
170
|
-
* @returns A response to send back to the client.
|
|
171
|
-
*/
|
|
172
|
-
public async handle(req: Request, ctx?: ExecutionContext) {
|
|
173
|
-
const isValid = await this.validateInteraction(req)
|
|
174
|
-
if (!isValid) {
|
|
175
|
-
return new Response("Invalid request signature", { status: 401 })
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
const rawInteraction = (await req.json()) as unknown as APIInteraction
|
|
179
|
-
if (rawInteraction.type === InteractionType.Ping) {
|
|
180
|
-
return json({
|
|
181
|
-
type: InteractionResponseType.Pong
|
|
182
|
-
})
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
if (rawInteraction.type === InteractionType.ApplicationCommand) {
|
|
186
|
-
if (ctx?.waitUntil) {
|
|
187
|
-
ctx.waitUntil(
|
|
188
|
-
(async () => {
|
|
189
|
-
await this.commandHandler.handleCommandInteraction(rawInteraction)
|
|
190
|
-
})()
|
|
191
|
-
)
|
|
192
|
-
} else {
|
|
193
|
-
await this.commandHandler.handleCommandInteraction(rawInteraction)
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
if (
|
|
197
|
-
rawInteraction.type === InteractionType.ApplicationCommandAutocomplete
|
|
198
|
-
) {
|
|
199
|
-
if (ctx?.waitUntil) {
|
|
200
|
-
ctx.waitUntil(
|
|
201
|
-
(async () => {
|
|
202
|
-
await this.commandHandler.handleAutocompleteInteraction(
|
|
203
|
-
rawInteraction
|
|
204
|
-
)
|
|
205
|
-
})()
|
|
206
|
-
)
|
|
207
|
-
} else {
|
|
208
|
-
await this.commandHandler.handleAutocompleteInteraction(rawInteraction)
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
if (rawInteraction.type === InteractionType.MessageComponent) {
|
|
212
|
-
if (ctx?.waitUntil) {
|
|
213
|
-
ctx.waitUntil(
|
|
214
|
-
(async () => {
|
|
215
|
-
await this.componentHandler.handleInteraction(rawInteraction)
|
|
216
|
-
})()
|
|
217
|
-
)
|
|
218
|
-
} else {
|
|
219
|
-
await this.componentHandler.handleInteraction(rawInteraction)
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
return new Response(null, { status: 202 })
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
/**
|
|
226
|
-
* Validate the interaction request
|
|
227
|
-
* @param req The request to validate
|
|
228
|
-
*/
|
|
229
|
-
private async validateInteraction(req: Request) {
|
|
230
|
-
if (req.method !== "POST") {
|
|
231
|
-
throw new StatusError(405)
|
|
232
|
-
}
|
|
233
|
-
const isValid = await isValidRequest(
|
|
234
|
-
req,
|
|
235
|
-
this.options.publicKey,
|
|
236
|
-
this.options.mode === ClientMode.CloudflareWorkers
|
|
237
|
-
? PlatformAlgorithm.Cloudflare
|
|
238
|
-
: this.options.mode === ClientMode.Vercel
|
|
239
|
-
? PlatformAlgorithm.VercelProd
|
|
240
|
-
: this.options.mode === ClientMode.Web
|
|
241
|
-
? PlatformAlgorithm.Web
|
|
242
|
-
: PlatformAlgorithm.NewNode
|
|
243
|
-
)
|
|
244
|
-
return isValid
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
/**
|
|
249
|
-
* @hidden
|
|
250
|
-
*/
|
|
251
|
-
export interface ExecutionContext {
|
|
252
|
-
// biome-ignore lint/suspicious/noExplicitAny: true any
|
|
253
|
-
waitUntil(promise: Promise<any>): void
|
|
254
|
-
}
|
package/src/classes/Command.ts
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
type APIApplicationCommandBasicOption,
|
|
3
|
-
ApplicationCommandType
|
|
4
|
-
} from "discord-api-types/v10"
|
|
5
|
-
import {
|
|
6
|
-
type AutocompleteInteraction,
|
|
7
|
-
BaseCommand,
|
|
8
|
-
type CommandInteraction
|
|
9
|
-
} from "../index.js"
|
|
10
|
-
|
|
11
|
-
export type CommandOptions = APIApplicationCommandBasicOption[]
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Represents a standard command that the user creates
|
|
15
|
-
*/
|
|
16
|
-
export abstract class Command extends BaseCommand {
|
|
17
|
-
/**
|
|
18
|
-
* The options that the user passes along with the command in Discord
|
|
19
|
-
*/
|
|
20
|
-
options?: CommandOptions
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* The type of command, either ChatInput, User, or Message. User and Message are context menu commands.
|
|
24
|
-
* @default ChatInput
|
|
25
|
-
*/
|
|
26
|
-
type: ApplicationCommandType = ApplicationCommandType.ChatInput
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* The function that is called when the command is ran
|
|
30
|
-
* @param interaction The interaction that triggered the command
|
|
31
|
-
*/
|
|
32
|
-
abstract run(interaction: CommandInteraction): Promise<void>
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* The function that is called when the command's autocomplete is triggered.
|
|
36
|
-
* @param interaction The interaction that triggered the autocomplete
|
|
37
|
-
* @remarks You are expected to `override` this function to provide your own autocomplete functionality.
|
|
38
|
-
*/
|
|
39
|
-
public async autocomplete(
|
|
40
|
-
interaction: AutocompleteInteraction
|
|
41
|
-
): Promise<void> {
|
|
42
|
-
throw new Error(
|
|
43
|
-
`The ${interaction.rawData.data.name} command does not support autocomplete`
|
|
44
|
-
)
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* @internal
|
|
49
|
-
*/
|
|
50
|
-
serializeOptions() {
|
|
51
|
-
return this.options
|
|
52
|
-
}
|
|
53
|
-
}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
type APIApplicationCommandBasicOption,
|
|
3
|
-
type APIApplicationCommandSubcommandGroupOption,
|
|
4
|
-
type APIApplicationCommandSubcommandOption,
|
|
5
|
-
ApplicationCommandOptionType
|
|
6
|
-
} from "discord-api-types/v10"
|
|
7
|
-
import type { Command } from "./Command.js"
|
|
8
|
-
import { CommandWithSubcommands } from "./CommandWithSubcommands.js"
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Represents a subcommand group command that the user creates.
|
|
12
|
-
* You make this instead of a {@link Command} class when you want to have subcommand groups in your options.
|
|
13
|
-
*/
|
|
14
|
-
export abstract class CommandWithSubcommandGroups extends CommandWithSubcommands {
|
|
15
|
-
/**
|
|
16
|
-
* The subcommands that the user can use
|
|
17
|
-
*/
|
|
18
|
-
subcommands: Command[] = []
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* The subcommands that the user can use
|
|
22
|
-
*/
|
|
23
|
-
abstract subcommandGroups: CommandWithSubcommands[]
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* @internal
|
|
27
|
-
*/
|
|
28
|
-
serializeOptions() {
|
|
29
|
-
const subcommands = this.subcommands.map((subcommand) => ({
|
|
30
|
-
name: subcommand.name,
|
|
31
|
-
description: subcommand.description,
|
|
32
|
-
type: ApplicationCommandOptionType.Subcommand,
|
|
33
|
-
options:
|
|
34
|
-
subcommand.serializeOptions() as APIApplicationCommandBasicOption[]
|
|
35
|
-
})) as APIApplicationCommandSubcommandOption[]
|
|
36
|
-
|
|
37
|
-
const subcommandGroups = this.subcommandGroups.map((subcommandGroup) => ({
|
|
38
|
-
name: subcommandGroup.name,
|
|
39
|
-
description: subcommandGroup.description,
|
|
40
|
-
type: ApplicationCommandOptionType.SubcommandGroup,
|
|
41
|
-
options:
|
|
42
|
-
subcommandGroup.serializeOptions() as APIApplicationCommandSubcommandOption[]
|
|
43
|
-
})) as APIApplicationCommandSubcommandGroupOption[]
|
|
44
|
-
|
|
45
|
-
return [...subcommands, ...subcommandGroups]
|
|
46
|
-
}
|
|
47
|
-
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
type APIApplicationCommandBasicOption,
|
|
3
|
-
type APIApplicationCommandSubcommandOption,
|
|
4
|
-
ApplicationCommandOptionType,
|
|
5
|
-
ApplicationCommandType,
|
|
6
|
-
type RESTPostAPIApplicationCommandsJSONBody
|
|
7
|
-
} from "discord-api-types/v10"
|
|
8
|
-
import { BaseCommand } from "../abstracts/BaseCommand.js"
|
|
9
|
-
import type { Command } from "./Command.js"
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Represents a subcommand command that the user creates.
|
|
13
|
-
* You make this instead of a {@link Command} class when you want to have subcommands in your options.
|
|
14
|
-
*/
|
|
15
|
-
export abstract class CommandWithSubcommands extends BaseCommand {
|
|
16
|
-
type = ApplicationCommandType.ChatInput
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* The subcommands that the user can use
|
|
20
|
-
*/
|
|
21
|
-
abstract subcommands: Command[]
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* @internal
|
|
25
|
-
*/
|
|
26
|
-
serializeOptions(): RESTPostAPIApplicationCommandsJSONBody["options"] {
|
|
27
|
-
return this.subcommands.map((subcommand) => ({
|
|
28
|
-
name: subcommand.name,
|
|
29
|
-
description: subcommand.description,
|
|
30
|
-
type: ApplicationCommandOptionType.Subcommand,
|
|
31
|
-
options:
|
|
32
|
-
subcommand.serializeOptions() as APIApplicationCommandBasicOption[]
|
|
33
|
-
})) as APIApplicationCommandSubcommandOption[]
|
|
34
|
-
}
|
|
35
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
type APIMentionableSelectComponent,
|
|
3
|
-
ComponentType
|
|
4
|
-
} from "discord-api-types/v10"
|
|
5
|
-
import { AnySelectMenu } from "../abstracts/AnySelectMenu.js"
|
|
6
|
-
import type { MentionableSelectMenuInteraction } from "../internals/MentionableSelectMenuInteraction.js"
|
|
7
|
-
|
|
8
|
-
export abstract class MentionableSelectMenu extends AnySelectMenu {
|
|
9
|
-
type: ComponentType.MentionableSelect = ComponentType.MentionableSelect
|
|
10
|
-
defaultValues?: APIMentionableSelectComponent["default_values"]
|
|
11
|
-
abstract run(interaction: MentionableSelectMenuInteraction): Promise<void>
|
|
12
|
-
|
|
13
|
-
serializeOptions() {
|
|
14
|
-
return {
|
|
15
|
-
type: this.type,
|
|
16
|
-
default_values: this.defaultValues
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
type APIRoleSelectComponent,
|
|
3
|
-
ComponentType
|
|
4
|
-
} from "discord-api-types/v10"
|
|
5
|
-
import { AnySelectMenu } from "../abstracts/AnySelectMenu.js"
|
|
6
|
-
import type { RoleSelectMenuInteraction } from "../internals/RoleSelectMenuInteraction.js"
|
|
7
|
-
|
|
8
|
-
export abstract class RoleSelectMenu extends AnySelectMenu {
|
|
9
|
-
type: ComponentType.RoleSelect = ComponentType.RoleSelect
|
|
10
|
-
defaultValues?: APIRoleSelectComponent["default_values"]
|
|
11
|
-
abstract run(interaction: RoleSelectMenuInteraction): Promise<void>
|
|
12
|
-
|
|
13
|
-
serializeOptions() {
|
|
14
|
-
return {
|
|
15
|
-
type: this.type,
|
|
16
|
-
default_values: this.defaultValues
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
}
|
package/src/classes/Row.ts
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import type { BaseComponent } from "../abstracts/BaseComponent.js"
|
|
2
|
-
|
|
3
|
-
export class Row {
|
|
4
|
-
/**
|
|
5
|
-
* The components in the action row
|
|
6
|
-
*/
|
|
7
|
-
components: BaseComponent[]
|
|
8
|
-
|
|
9
|
-
constructor(components: BaseComponent[]) {
|
|
10
|
-
this.components = components
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Add a component to the action row
|
|
15
|
-
* @param component The component to add
|
|
16
|
-
*/
|
|
17
|
-
addComponent(component: BaseComponent) {
|
|
18
|
-
this.components.push(component)
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Remove a component from the action row
|
|
23
|
-
* @param component The component to remove
|
|
24
|
-
*/
|
|
25
|
-
removeComponent(component: BaseComponent) {
|
|
26
|
-
const index = this.components.indexOf(component)
|
|
27
|
-
if (index === -1) return
|
|
28
|
-
this.components.splice(index, 1)
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* Remove all components from the action row
|
|
33
|
-
*/
|
|
34
|
-
removeAllComponents() {
|
|
35
|
-
this.components = []
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
serialize() {
|
|
39
|
-
return {
|
|
40
|
-
type: 1,
|
|
41
|
-
components: this.components.map((component) => component.serialize())
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
type APIStringSelectComponent,
|
|
3
|
-
ComponentType
|
|
4
|
-
} from "discord-api-types/v10"
|
|
5
|
-
import { AnySelectMenu } from "../abstracts/AnySelectMenu.js"
|
|
6
|
-
import type { StringSelectMenuInteraction } from "../internals/StringSelectMenuInteraction.js"
|
|
7
|
-
|
|
8
|
-
export abstract class StringSelectMenu extends AnySelectMenu {
|
|
9
|
-
type: ComponentType.StringSelect = ComponentType.StringSelect
|
|
10
|
-
abstract options: APIStringSelectComponent["options"]
|
|
11
|
-
abstract run(interaction: StringSelectMenuInteraction): Promise<void>
|
|
12
|
-
|
|
13
|
-
serializeOptions() {
|
|
14
|
-
return {
|
|
15
|
-
type: this.type,
|
|
16
|
-
options: this.options
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
type APIUserSelectComponent,
|
|
3
|
-
ComponentType
|
|
4
|
-
} from "discord-api-types/v10"
|
|
5
|
-
import { AnySelectMenu } from "../abstracts/AnySelectMenu.js"
|
|
6
|
-
import type { UserSelectMenuInteraction } from "../internals/UserSelectMenuInteraction.js"
|
|
7
|
-
|
|
8
|
-
export abstract class UserSelectMenu extends AnySelectMenu {
|
|
9
|
-
type: ComponentType.UserSelect = ComponentType.UserSelect
|
|
10
|
-
defaultValues?: APIUserSelectComponent["default_values"]
|
|
11
|
-
abstract run(interaction: UserSelectMenuInteraction): Promise<void>
|
|
12
|
-
|
|
13
|
-
serializeOptions() {
|
|
14
|
-
return {
|
|
15
|
-
type: this.type,
|
|
16
|
-
default_values: this.defaultValues
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { type APIChannel, ChannelType } from "discord-api-types/v10"
|
|
2
|
-
import type { Client } from "../classes/Client.js"
|
|
3
|
-
import { DmChannel } from "../structures/DmChannel.js"
|
|
4
|
-
import { GroupDmChannel } from "../structures/GroupDmChannel.js"
|
|
5
|
-
import { GuildAnnouncementChannel } from "../structures/GuildAnnouncementChannel.js"
|
|
6
|
-
import { GuildCategoryChannel } from "../structures/GuildCategoryChannel.js"
|
|
7
|
-
import { GuildForumChannel } from "../structures/GuildForumChannel.js"
|
|
8
|
-
import { GuildMediaChannel } from "../structures/GuildMediaChannel.js"
|
|
9
|
-
import {
|
|
10
|
-
GuildStageChannel,
|
|
11
|
-
GuildVoiceChannel
|
|
12
|
-
} from "../structures/GuildStageOrVoiceChannel.js"
|
|
13
|
-
import { GuildTextChannel } from "../structures/GuildTextChannel.js"
|
|
14
|
-
import { GuildThreadChannel } from "../structures/GuildThreadChannel.js"
|
|
15
|
-
|
|
16
|
-
export const channelFactory = (client: Client, channelData: APIChannel) => {
|
|
17
|
-
switch (channelData.type) {
|
|
18
|
-
case ChannelType.DM:
|
|
19
|
-
return new DmChannel(client, channelData)
|
|
20
|
-
case ChannelType.GroupDM:
|
|
21
|
-
return new GroupDmChannel(client, channelData)
|
|
22
|
-
case ChannelType.GuildText:
|
|
23
|
-
return new GuildTextChannel(client, channelData)
|
|
24
|
-
case ChannelType.GuildVoice:
|
|
25
|
-
return new GuildVoiceChannel(client, channelData)
|
|
26
|
-
case ChannelType.GuildCategory:
|
|
27
|
-
return new GuildCategoryChannel(client, channelData)
|
|
28
|
-
case ChannelType.GuildAnnouncement:
|
|
29
|
-
return new GuildAnnouncementChannel(client, channelData)
|
|
30
|
-
case ChannelType.AnnouncementThread:
|
|
31
|
-
case ChannelType.PublicThread:
|
|
32
|
-
case ChannelType.PrivateThread:
|
|
33
|
-
return new GuildThreadChannel(client, channelData)
|
|
34
|
-
case ChannelType.GuildStageVoice:
|
|
35
|
-
return new GuildStageChannel(client, channelData)
|
|
36
|
-
case ChannelType.GuildForum:
|
|
37
|
-
return new GuildForumChannel(client, channelData)
|
|
38
|
-
case ChannelType.GuildMedia:
|
|
39
|
-
return new GuildMediaChannel(client, channelData)
|
|
40
|
-
default:
|
|
41
|
-
return null
|
|
42
|
-
}
|
|
43
|
-
}
|