@buape/carbon 0.2.0 → 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.
Files changed (267) hide show
  1. package/dist/package.json +7 -2
  2. package/dist/src/abstracts/BaseComponentInteraction.d.ts +6 -1
  3. package/dist/src/abstracts/BaseComponentInteraction.d.ts.map +1 -1
  4. package/dist/src/abstracts/BaseComponentInteraction.js +12 -0
  5. package/dist/src/abstracts/BaseComponentInteraction.js.map +1 -1
  6. package/dist/src/abstracts/BaseInteraction.d.ts +4 -0
  7. package/dist/src/abstracts/BaseInteraction.d.ts.map +1 -1
  8. package/dist/src/abstracts/BaseInteraction.js +4 -0
  9. package/dist/src/abstracts/BaseInteraction.js.map +1 -1
  10. package/dist/src/classes/Client.d.ts.map +1 -1
  11. package/dist/src/classes/Client.js +21 -11
  12. package/dist/src/classes/Client.js.map +1 -1
  13. package/dist/src/internals/AutocompleteInteraction.d.ts +1 -1
  14. package/dist/src/internals/FieldsHandler.d.ts +27 -0
  15. package/dist/src/internals/FieldsHandler.d.ts.map +1 -0
  16. package/dist/src/internals/FieldsHandler.js +37 -0
  17. package/dist/src/internals/FieldsHandler.js.map +1 -0
  18. package/dist/src/internals/ModalInteraction.d.ts +3 -4
  19. package/dist/src/internals/ModalInteraction.d.ts.map +1 -1
  20. package/dist/src/internals/ModalInteraction.js +3 -10
  21. package/dist/src/internals/ModalInteraction.js.map +1 -1
  22. package/dist/src/internals/OptionsHandler.d.ts +33 -17
  23. package/dist/src/internals/OptionsHandler.d.ts.map +1 -1
  24. package/dist/src/internals/OptionsHandler.js +52 -58
  25. package/dist/src/internals/OptionsHandler.js.map +1 -1
  26. package/dist/src/utils.d.ts +3 -0
  27. package/dist/src/utils.d.ts.map +1 -1
  28. package/dist/src/utils.js +54 -0
  29. package/dist/src/utils.js.map +1 -1
  30. package/dist/tsconfig.tsbuildinfo +1 -1
  31. package/package.json +6 -1
  32. package/.turbo/turbo-build.log +0 -5
  33. package/.turbo/turbo-dev.log +0 -8
  34. package/.turbo/turbo-docs.log +0 -12
  35. package/CHANGELOG.md +0 -44
  36. package/dist/src/abstracts/ButtonInteraction.d.ts +0 -8
  37. package/dist/src/abstracts/ButtonInteraction.d.ts.map +0 -1
  38. package/dist/src/abstracts/ButtonInteraction.js +0 -18
  39. package/dist/src/abstracts/ButtonInteraction.js.map +0 -1
  40. package/dist/src/abstracts/ChannelSelectMenuInteraction.d.ts +0 -7
  41. package/dist/src/abstracts/ChannelSelectMenuInteraction.d.ts.map +0 -1
  42. package/dist/src/abstracts/ChannelSelectMenuInteraction.js +0 -11
  43. package/dist/src/abstracts/ChannelSelectMenuInteraction.js.map +0 -1
  44. package/dist/src/abstracts/CommandHandler.d.ts +0 -6
  45. package/dist/src/abstracts/CommandHandler.d.ts.map +0 -1
  46. package/dist/src/abstracts/CommandHandler.js +0 -65
  47. package/dist/src/abstracts/CommandHandler.js.map +0 -1
  48. package/dist/src/abstracts/CommandInteraction.d.ts +0 -15
  49. package/dist/src/abstracts/CommandInteraction.d.ts.map +0 -1
  50. package/dist/src/abstracts/CommandInteraction.js +0 -60
  51. package/dist/src/abstracts/CommandInteraction.js.map +0 -1
  52. package/dist/src/abstracts/ComponentHandler.d.ts +0 -6
  53. package/dist/src/abstracts/ComponentHandler.d.ts.map +0 -1
  54. package/dist/src/abstracts/ComponentHandler.js +0 -64
  55. package/dist/src/abstracts/ComponentHandler.js.map +0 -1
  56. package/dist/src/abstracts/MentionableSelectMenuInteraction.d.ts +0 -8
  57. package/dist/src/abstracts/MentionableSelectMenuInteraction.d.ts.map +0 -1
  58. package/dist/src/abstracts/MentionableSelectMenuInteraction.js +0 -15
  59. package/dist/src/abstracts/MentionableSelectMenuInteraction.js.map +0 -1
  60. package/dist/src/abstracts/RoleSelectMenuInteraction.d.ts +0 -8
  61. package/dist/src/abstracts/RoleSelectMenuInteraction.d.ts.map +0 -1
  62. package/dist/src/abstracts/RoleSelectMenuInteraction.js +0 -14
  63. package/dist/src/abstracts/RoleSelectMenuInteraction.js.map +0 -1
  64. package/dist/src/abstracts/StringSelectMenuInteraction.d.ts +0 -8
  65. package/dist/src/abstracts/StringSelectMenuInteraction.d.ts.map +0 -1
  66. package/dist/src/abstracts/StringSelectMenuInteraction.js +0 -14
  67. package/dist/src/abstracts/StringSelectMenuInteraction.js.map +0 -1
  68. package/dist/src/abstracts/UserSelectMenuInteraction.d.ts +0 -8
  69. package/dist/src/abstracts/UserSelectMenuInteraction.d.ts.map +0 -1
  70. package/dist/src/abstracts/UserSelectMenuInteraction.js +0 -14
  71. package/dist/src/abstracts/UserSelectMenuInteraction.js.map +0 -1
  72. package/dist/src/classes/Paginator.d.ts +0 -3
  73. package/dist/src/classes/Paginator.d.ts.map +0 -1
  74. package/dist/src/classes/Paginator.js +0 -3
  75. package/dist/src/classes/Paginator.js.map +0 -1
  76. package/dist/src/internals/ComponentHandler copy.d.ts +0 -17
  77. package/dist/src/internals/ComponentHandler copy.d.ts.map +0 -1
  78. package/dist/src/internals/ComponentHandler copy.js +0 -75
  79. package/dist/src/internals/ComponentHandler copy.js.map +0 -1
  80. package/dist/src/structures/AnySelectMenu.d.ts +0 -31
  81. package/dist/src/structures/AnySelectMenu.d.ts.map +0 -1
  82. package/dist/src/structures/AnySelectMenu.js +0 -19
  83. package/dist/src/structures/AnySelectMenu.js.map +0 -1
  84. package/dist/src/structures/AnySelectMenuInteraction.d.ts +0 -12
  85. package/dist/src/structures/AnySelectMenuInteraction.d.ts.map +0 -1
  86. package/dist/src/structures/AnySelectMenuInteraction.js +0 -21
  87. package/dist/src/structures/AnySelectMenuInteraction.js.map +0 -1
  88. package/dist/src/structures/Base.d.ts +0 -10
  89. package/dist/src/structures/Base.d.ts.map +0 -1
  90. package/dist/src/structures/Base.js +0 -11
  91. package/dist/src/structures/Base.js.map +0 -1
  92. package/dist/src/structures/BaseCommand.d.ts +0 -64
  93. package/dist/src/structures/BaseCommand.d.ts.map +0 -1
  94. package/dist/src/structures/BaseCommand.js +0 -58
  95. package/dist/src/structures/BaseCommand.js.map +0 -1
  96. package/dist/src/structures/BaseComponent.d.ts +0 -34
  97. package/dist/src/structures/BaseComponent.d.ts.map +0 -1
  98. package/dist/src/structures/BaseComponent.js +0 -30
  99. package/dist/src/structures/BaseComponent.js.map +0 -1
  100. package/dist/src/structures/BaseComponentInteraction.d.ts +0 -9
  101. package/dist/src/structures/BaseComponentInteraction.d.ts.map +0 -1
  102. package/dist/src/structures/BaseComponentInteraction.js +0 -14
  103. package/dist/src/structures/BaseComponentInteraction.js.map +0 -1
  104. package/dist/src/structures/BaseInteraction.d.ts +0 -81
  105. package/dist/src/structures/BaseInteraction.d.ts.map +0 -1
  106. package/dist/src/structures/BaseInteraction.js +0 -99
  107. package/dist/src/structures/BaseInteraction.js.map +0 -1
  108. package/dist/src/structures/ButtonInteraction.d.ts +0 -8
  109. package/dist/src/structures/ButtonInteraction.d.ts.map +0 -1
  110. package/dist/src/structures/ButtonInteraction.js +0 -18
  111. package/dist/src/structures/ButtonInteraction.js.map +0 -1
  112. package/dist/src/structures/ChannelSelectMenuInteraction.d.ts +0 -7
  113. package/dist/src/structures/ChannelSelectMenuInteraction.d.ts.map +0 -1
  114. package/dist/src/structures/ChannelSelectMenuInteraction.js +0 -11
  115. package/dist/src/structures/ChannelSelectMenuInteraction.js.map +0 -1
  116. package/dist/src/structures/CommandHandler.d.ts +0 -6
  117. package/dist/src/structures/CommandHandler.d.ts.map +0 -1
  118. package/dist/src/structures/CommandHandler.js +0 -70
  119. package/dist/src/structures/CommandHandler.js.map +0 -1
  120. package/dist/src/structures/CommandInteraction.d.ts +0 -15
  121. package/dist/src/structures/CommandInteraction.d.ts.map +0 -1
  122. package/dist/src/structures/CommandInteraction.js +0 -60
  123. package/dist/src/structures/CommandInteraction.js.map +0 -1
  124. package/dist/src/structures/ComponentHandler.d.ts +0 -6
  125. package/dist/src/structures/ComponentHandler.d.ts.map +0 -1
  126. package/dist/src/structures/ComponentHandler.js +0 -64
  127. package/dist/src/structures/ComponentHandler.js.map +0 -1
  128. package/dist/src/structures/MentionableSelectMenuInteraction.d.ts +0 -8
  129. package/dist/src/structures/MentionableSelectMenuInteraction.d.ts.map +0 -1
  130. package/dist/src/structures/MentionableSelectMenuInteraction.js +0 -15
  131. package/dist/src/structures/MentionableSelectMenuInteraction.js.map +0 -1
  132. package/dist/src/structures/RoleSelectMenuInteraction.d.ts +0 -8
  133. package/dist/src/structures/RoleSelectMenuInteraction.d.ts.map +0 -1
  134. package/dist/src/structures/RoleSelectMenuInteraction.js +0 -14
  135. package/dist/src/structures/RoleSelectMenuInteraction.js.map +0 -1
  136. package/dist/src/structures/StringSelectMenuInteraction.d.ts +0 -8
  137. package/dist/src/structures/StringSelectMenuInteraction.d.ts.map +0 -1
  138. package/dist/src/structures/StringSelectMenuInteraction.js +0 -14
  139. package/dist/src/structures/StringSelectMenuInteraction.js.map +0 -1
  140. package/dist/src/structures/UserSelectMenuInteraction.d.ts +0 -8
  141. package/dist/src/structures/UserSelectMenuInteraction.d.ts.map +0 -1
  142. package/dist/src/structures/UserSelectMenuInteraction.js +0 -14
  143. package/dist/src/structures/UserSelectMenuInteraction.js.map +0 -1
  144. package/dist/src/types.d.ts +0 -31
  145. package/dist/src/types.d.ts.map +0 -1
  146. package/dist/src/types.js +0 -33
  147. package/dist/src/types.js.map +0 -1
  148. package/docs/classes/AnySelectMenu.mdx +0 -114
  149. package/docs/classes/AnySelectMenuInteraction.mdx +0 -175
  150. package/docs/classes/AutocompleteInteraction.mdx +0 -166
  151. package/docs/classes/AutocompleteOptionsHandler.mdx +0 -243
  152. package/docs/classes/BaseChannel.mdx +0 -97
  153. package/docs/classes/BaseCommand.mdx +0 -61
  154. package/docs/classes/BaseComponent.mdx +0 -55
  155. package/docs/classes/BaseComponentInteraction.mdx +0 -160
  156. package/docs/classes/BaseGuildChannel.mdx +0 -262
  157. package/docs/classes/BaseGuildTextChannel.mdx +0 -360
  158. package/docs/classes/BaseInteraction.mdx +0 -137
  159. package/docs/classes/Button.mdx +0 -99
  160. package/docs/classes/ButtonInteraction.mdx +0 -155
  161. package/docs/classes/ChannelSelectMenu.mdx +0 -122
  162. package/docs/classes/ChannelSelectMenuInteraction.mdx +0 -171
  163. package/docs/classes/Client.mdx +0 -48
  164. package/docs/classes/Command.mdx +0 -111
  165. package/docs/classes/CommandHandler.mdx +0 -65
  166. package/docs/classes/CommandInteraction.mdx +0 -155
  167. package/docs/classes/CommandWithSubcommandGroups.mdx +0 -73
  168. package/docs/classes/CommandWithSubcommands.mdx +0 -76
  169. package/docs/classes/ComponentHandler.mdx +0 -49
  170. package/docs/classes/DmChannel.mdx +0 -118
  171. package/docs/classes/GroupDmChannel.mdx +0 -197
  172. package/docs/classes/Guild.mdx +0 -157
  173. package/docs/classes/GuildAnnouncementChannel.mdx +0 -377
  174. package/docs/classes/GuildCategoryChannel.mdx +0 -272
  175. package/docs/classes/GuildForumChannel.mdx +0 -333
  176. package/docs/classes/GuildMediaChannel.mdx +0 -327
  177. package/docs/classes/GuildStageChannel.mdx +0 -276
  178. package/docs/classes/GuildStageOrVoiceChannel.mdx +0 -292
  179. package/docs/classes/GuildTextChannel.mdx +0 -367
  180. package/docs/classes/GuildThreadChannel.mdx +0 -425
  181. package/docs/classes/GuildThreadOnlyChannel.mdx +0 -333
  182. package/docs/classes/GuildVoiceChannel.mdx +0 -276
  183. package/docs/classes/LinkButton.mdx +0 -84
  184. package/docs/classes/MentionableSelectMenu.mdx +0 -120
  185. package/docs/classes/MentionableSelectMenuInteraction.mdx +0 -171
  186. package/docs/classes/Message.mdx +0 -126
  187. package/docs/classes/OptionsHandler.mdx +0 -203
  188. package/docs/classes/PremiumButton.mdx +0 -84
  189. package/docs/classes/Role.mdx +0 -228
  190. package/docs/classes/RoleSelectMenu.mdx +0 -120
  191. package/docs/classes/RoleSelectMenuInteraction.mdx +0 -171
  192. package/docs/classes/Row.mdx +0 -88
  193. package/docs/classes/StringSelectMenu.mdx +0 -120
  194. package/docs/classes/StringSelectMenuInteraction.mdx +0 -171
  195. package/docs/classes/User.mdx +0 -119
  196. package/docs/classes/UserSelectMenu.mdx +0 -120
  197. package/docs/classes/UserSelectMenuInteraction.mdx +0 -171
  198. package/docs/enumerations/ClientMode.mdx +0 -16
  199. package/docs/functions/channelFactory.mdx +0 -16
  200. package/docs/index.mdx +0 -83
  201. package/docs/type-aliases/AnySelectMenuComponentType.mdx +0 -5
  202. package/docs/type-aliases/ClientOptions.mdx +0 -20
  203. package/docs/type-aliases/CommandOptions.mdx +0 -5
  204. package/docs/type-aliases/ComponentAdditionalData.mdx +0 -9
  205. package/docs/type-aliases/InteractionFileData.mdx +0 -15
  206. package/docs/type-aliases/InteractionReplyData.mdx +0 -14
  207. package/docs/type-aliases/InteractionReplyOptions.mdx +0 -13
  208. package/docs/type-aliases/RawOptions.mdx +0 -9
  209. package/docs/type-aliases/meta.json +0 -3
  210. package/src/README.md +0 -7
  211. package/src/abstracts/AnySelectMenu.ts +0 -63
  212. package/src/abstracts/AnySelectMenuInteraction.ts +0 -29
  213. package/src/abstracts/Base.ts +0 -12
  214. package/src/abstracts/BaseChannel.ts +0 -73
  215. package/src/abstracts/BaseCommand.ts +0 -89
  216. package/src/abstracts/BaseComponent.ts +0 -49
  217. package/src/abstracts/BaseComponentInteraction.ts +0 -19
  218. package/src/abstracts/BaseGuildChannel.ts +0 -152
  219. package/src/abstracts/BaseGuildTextChannel.ts +0 -77
  220. package/src/abstracts/BaseInteraction.ts +0 -209
  221. package/src/abstracts/GuildThreadOnlyChannel.ts +0 -71
  222. package/src/classes/Button.ts +0 -95
  223. package/src/classes/ChannelSelectMenu.ts +0 -21
  224. package/src/classes/Client.ts +0 -277
  225. package/src/classes/Command.ts +0 -53
  226. package/src/classes/CommandWithSubcommandGroups.ts +0 -47
  227. package/src/classes/CommandWithSubcommands.ts +0 -35
  228. package/src/classes/MentionableSelectMenu.ts +0 -19
  229. package/src/classes/Modal.ts +0 -38
  230. package/src/classes/RoleSelectMenu.ts +0 -19
  231. package/src/classes/Row.ts +0 -50
  232. package/src/classes/StringSelectMenu.ts +0 -19
  233. package/src/classes/TextInput.ts +0 -65
  234. package/src/classes/UserSelectMenu.ts +0 -19
  235. package/src/factories/channelFactory.ts +0 -43
  236. package/src/index.ts +0 -62
  237. package/src/internals/AutocompleteInteraction.ts +0 -107
  238. package/src/internals/ButtonInteraction.ts +0 -26
  239. package/src/internals/ChannelSelectMenuInteraction.ts +0 -15
  240. package/src/internals/CommandHandler.ts +0 -127
  241. package/src/internals/CommandInteraction.ts +0 -49
  242. package/src/internals/ComponentHandler.ts +0 -92
  243. package/src/internals/MentionableSelectMenuInteraction.ts +0 -21
  244. package/src/internals/ModalHandler.ts +0 -27
  245. package/src/internals/ModalInteraction.ts +0 -25
  246. package/src/internals/OptionsHandler.ts +0 -148
  247. package/src/internals/RoleSelectMenuInteraction.ts +0 -20
  248. package/src/internals/StringSelectMenuInteraction.ts +0 -20
  249. package/src/internals/UserSelectMenuInteraction.ts +0 -20
  250. package/src/structures/DmChannel.ts +0 -31
  251. package/src/structures/GroupDmChannel.ts +0 -132
  252. package/src/structures/Guild.ts +0 -154
  253. package/src/structures/GuildAnnouncementChannel.ts +0 -20
  254. package/src/structures/GuildCategoryChannel.ts +0 -16
  255. package/src/structures/GuildForumChannel.ts +0 -20
  256. package/src/structures/GuildMediaChannel.ts +0 -13
  257. package/src/structures/GuildMember.ts +0 -231
  258. package/src/structures/GuildStageOrVoiceChannel.ts +0 -46
  259. package/src/structures/GuildTextChannel.ts +0 -21
  260. package/src/structures/GuildThreadChannel.ts +0 -150
  261. package/src/structures/Message.ts +0 -124
  262. package/src/structures/Role.ts +0 -201
  263. package/src/structures/User.ts +0 -153
  264. package/src/utils.ts +0 -13
  265. package/tests/index.test.ts +0 -4
  266. package/tsconfig.json +0 -12
  267. package/typedoc.json +0 -9
@@ -1,65 +0,0 @@
1
- import {
2
- type APITextInputComponent,
3
- ComponentType,
4
- TextInputStyle
5
- } from "discord-api-types/v10"
6
- import { BaseComponent } from "../abstracts/BaseComponent.js"
7
-
8
- export abstract class TextInput extends BaseComponent {
9
- type = ComponentType.TextInput
10
-
11
- /**
12
- * The custom ID of the text input
13
- */
14
- abstract customId: string
15
-
16
- /**
17
- * The label of the text input
18
- */
19
- abstract label: string
20
-
21
- /**
22
- * The style of the text input
23
- * @default TextInputStyle.Short
24
- */
25
- style: TextInputStyle = TextInputStyle.Short
26
-
27
- /**
28
- * The minimum length of the text input
29
- */
30
- minLength?: number
31
-
32
- /**
33
- * The maximum length of the text input
34
- */
35
- maxLength?: number
36
-
37
- /**
38
- * Whether the text input is required
39
- */
40
- required?: boolean
41
-
42
- /**
43
- * The value of the text input
44
- */
45
- value?: string
46
-
47
- /**
48
- * The placeholder of the text input
49
- */
50
- placeholder?: string
51
-
52
- serialize = (): APITextInputComponent => {
53
- return {
54
- type: ComponentType.TextInput,
55
- custom_id: this.customId,
56
- style: this.style,
57
- label: this.label,
58
- min_length: this.minLength,
59
- max_length: this.maxLength,
60
- required: this.required,
61
- value: this.value,
62
- placeholder: this.placeholder
63
- }
64
- }
65
- }
@@ -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
- }
package/src/index.ts DELETED
@@ -1,62 +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/Modal.js"
23
- export * from "./classes/RoleSelectMenu.js"
24
- export * from "./classes/Row.js"
25
- export * from "./classes/TextInput.js"
26
- export * from "./classes/StringSelectMenu.js"
27
- export * from "./classes/UserSelectMenu.js"
28
-
29
- // ----- Factories -----
30
- export * from "./factories/channelFactory.js"
31
-
32
- // ----- Internals -----
33
- export * from "./internals/AutocompleteInteraction.js"
34
- export * from "./internals/ButtonInteraction.js"
35
- export * from "./internals/ChannelSelectMenuInteraction.js"
36
- export * from "./internals/CommandHandler.js"
37
- export * from "./internals/CommandInteraction.js"
38
- export * from "./internals/ComponentHandler.js"
39
- export * from "./internals/MentionableSelectMenuInteraction.js"
40
- export * from "./internals/ModalInteraction.js"
41
- export * from "./internals/OptionsHandler.js"
42
- export * from "./internals/RoleSelectMenuInteraction.js"
43
- export * from "./internals/StringSelectMenuInteraction.js"
44
- export * from "./internals/UserSelectMenuInteraction.js"
45
-
46
- // ----- Structures -----
47
- export * from "./structures/DmChannel.js"
48
- export * from "./structures/GroupDmChannel.js"
49
- export * from "./structures/Guild.js"
50
- export * from "./structures/GuildAnnouncementChannel.js"
51
- export * from "./structures/GuildCategoryChannel.js"
52
- export * from "./structures/GuildForumChannel.js"
53
- export * from "./structures/GuildMediaChannel.js"
54
- export * from "./structures/GuildStageOrVoiceChannel.js"
55
- export * from "./structures/GuildTextChannel.js"
56
- export * from "./structures/GuildThreadChannel.js"
57
- export * from "./structures/Message.js"
58
- export * from "./structures/Role.js"
59
- export * from "./structures/User.js"
60
-
61
- // ----- Types -----
62
- 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,127 +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
- /**
80
- * Handle a command interaction
81
- * @internal
82
- */
83
- async handleCommandInteraction(
84
- rawInteraction: APIApplicationCommandInteraction
85
- ) {
86
- const command = this.getCommand(rawInteraction)
87
- if (!command) return false
88
-
89
- const interaction = new CommandInteraction(
90
- this.client,
91
- rawInteraction,
92
- command
93
- )
94
-
95
- try {
96
- const command = this.getCommand(rawInteraction)
97
-
98
- if (command.defer) {
99
- await interaction.defer()
100
- }
101
- return await command.run(interaction)
102
- } catch (e: unknown) {
103
- if (e instanceof Error) console.error(e.message)
104
- console.error(e)
105
- }
106
- }
107
- async handleAutocompleteInteraction(
108
- rawInteraction: APIApplicationCommandAutocompleteInteraction
109
- ) {
110
- const command = this.getCommand(rawInteraction)
111
- if (!command) return false
112
-
113
- const interaction = new AutocompleteInteraction(
114
- this.client,
115
- rawInteraction,
116
- command
117
- )
118
-
119
- try {
120
- const command = this.getCommand(rawInteraction)
121
- return await command.autocomplete(interaction)
122
- } catch (e: unknown) {
123
- if (e instanceof Error) console.error(e.message)
124
- console.error(e)
125
- }
126
- }
127
- }
@@ -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,92 +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
- components: BaseComponent[] = []
23
- /**
24
- * Register a component with the handler
25
- * @internal
26
- */
27
- registerComponent(component: BaseComponent) {
28
- if (!this.components.find((x) => x.customId === component.customId)) {
29
- this.components.push(component)
30
- }
31
- }
32
- /**
33
- * Handle an interaction
34
- * @internal
35
- */
36
- async handleInteraction(data: APIMessageComponentInteraction) {
37
- const component = this.components.find(
38
- (x) =>
39
- x.customId === data.data.custom_id &&
40
- x.type === data.data.component_type
41
- )
42
- if (!component) return false
43
-
44
- if (component instanceof Button) {
45
- const interaction = new ButtonInteraction(
46
- this.client,
47
- data as APIMessageComponentButtonInteraction
48
- )
49
- if (component.defer) await interaction.defer()
50
- await component.run(interaction)
51
- } else if (component instanceof RoleSelectMenu) {
52
- const interaction = new RoleSelectMenuInteraction(
53
- this.client,
54
- data as APIMessageComponentSelectMenuInteraction
55
- )
56
- if (component.defer) await interaction.defer()
57
- await component.run(interaction)
58
- } else if (component instanceof ChannelSelectMenu) {
59
- const interaction = new ChannelSelectMenuInteraction(
60
- this.client,
61
- data as APIMessageComponentSelectMenuInteraction
62
- )
63
- if (component.defer) await interaction.defer()
64
- await component.run(interaction)
65
- } else if (component instanceof MentionableSelectMenu) {
66
- const interaction = new MentionableSelectMenuInteraction(
67
- this.client,
68
- data as APIMessageComponentSelectMenuInteraction
69
- )
70
- if (component.defer) await interaction.defer()
71
- await component.run(interaction)
72
- } else if (component instanceof StringSelectMenu) {
73
- const interaction = new StringSelectMenuInteraction(
74
- this.client,
75
- data as APIMessageComponentSelectMenuInteraction
76
- )
77
- if (component.defer) await interaction.defer()
78
- await component.run(interaction)
79
- } else if (component instanceof UserSelectMenu) {
80
- const interaction = new UserSelectMenuInteraction(
81
- this.client,
82
- data as APIMessageComponentSelectMenuInteraction
83
- )
84
- if (component.defer) await interaction.defer()
85
- await component.run(interaction)
86
- } else {
87
- throw new Error(
88
- `Unknown component with type ${data.data.component_type} and custom ID ${data.data.custom_id}`
89
- )
90
- }
91
- }
92
- }
@@ -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,27 +0,0 @@
1
- import type { APIModalSubmitInteraction } from "discord-api-types/v10"
2
- import { Base } from "../abstracts/Base.js"
3
- import type { Modal } from "../classes/Modal.js"
4
- import { ModalInteraction } from "./ModalInteraction.js"
5
-
6
- export class ModalHandler extends Base {
7
- modals: Modal[] = []
8
- /**
9
- * Register a modal with the handler
10
- * @internal
11
- */
12
- registerModal(modal: Modal) {
13
- if (!this.modals.find((x) => x.customId === modal.customId)) {
14
- this.modals.push(modal)
15
- }
16
- }
17
- /**
18
- * Handle an interaction
19
- * @internal
20
- */
21
- async handleInteraction(data: APIModalSubmitInteraction) {
22
- const modal = this.modals.find((x) => x.customId === data.data.custom_id)
23
- if (!modal) return false
24
-
25
- modal.run(new ModalInteraction(this.client, data))
26
- }
27
- }
@@ -1,25 +0,0 @@
1
- import {
2
- type APIModalSubmitInteraction,
3
- ComponentType
4
- } from "discord-api-types/v10"
5
- import { BaseInteraction } from "../abstracts/BaseInteraction.js"
6
- import type { Client } from "../index.js"
7
-
8
- export class ModalInteraction extends BaseInteraction<APIModalSubmitInteraction> {
9
- customId: string
10
- values: { [key: string]: string }
11
-
12
- constructor(client: Client, data: APIModalSubmitInteraction) {
13
- super(client, data)
14
-
15
- this.customId = data.data.custom_id
16
- this.values = {}
17
- data.data.components.map((row) => {
18
- row.components.map((component) => {
19
- if (component.type === ComponentType.TextInput) {
20
- this.values[component.custom_id] = component.value
21
- }
22
- })
23
- })
24
- }
25
- }