@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.
Files changed (292) hide show
  1. package/dist/package.json +7 -2
  2. package/dist/src/abstracts/BaseCommand.d.ts +1 -6
  3. package/dist/src/abstracts/BaseCommand.d.ts.map +1 -1
  4. package/dist/src/abstracts/BaseCommand.js +0 -5
  5. package/dist/src/abstracts/BaseCommand.js.map +1 -1
  6. package/dist/src/abstracts/BaseComponentInteraction.d.ts +6 -1
  7. package/dist/src/abstracts/BaseComponentInteraction.d.ts.map +1 -1
  8. package/dist/src/abstracts/BaseComponentInteraction.js +12 -0
  9. package/dist/src/abstracts/BaseComponentInteraction.js.map +1 -1
  10. package/dist/src/abstracts/BaseInteraction.d.ts +14 -7
  11. package/dist/src/abstracts/BaseInteraction.d.ts.map +1 -1
  12. package/dist/src/abstracts/BaseInteraction.js +29 -8
  13. package/dist/src/abstracts/BaseInteraction.js.map +1 -1
  14. package/dist/src/classes/Client.d.ts +11 -0
  15. package/dist/src/classes/Client.d.ts.map +1 -1
  16. package/dist/src/classes/Client.js +43 -11
  17. package/dist/src/classes/Client.js.map +1 -1
  18. package/dist/src/classes/Modal.d.ts +21 -0
  19. package/dist/src/classes/Modal.d.ts.map +1 -0
  20. package/dist/src/classes/Modal.js +14 -0
  21. package/dist/src/classes/Modal.js.map +1 -0
  22. package/dist/src/classes/Row.d.ts +7 -9
  23. package/dist/src/classes/Row.d.ts.map +1 -1
  24. package/dist/src/classes/Row.js +5 -4
  25. package/dist/src/classes/Row.js.map +1 -1
  26. package/dist/src/classes/TextInput.d.ts +40 -0
  27. package/dist/src/classes/TextInput.d.ts.map +1 -0
  28. package/dist/src/classes/TextInput.js +44 -0
  29. package/dist/src/classes/TextInput.js.map +1 -0
  30. package/dist/src/index.d.ts +3 -0
  31. package/dist/src/index.d.ts.map +1 -1
  32. package/dist/src/index.js +3 -0
  33. package/dist/src/index.js.map +1 -1
  34. package/dist/src/internals/AutocompleteInteraction.d.ts +1 -1
  35. package/dist/src/internals/CommandHandler.d.ts +4 -0
  36. package/dist/src/internals/CommandHandler.d.ts.map +1 -1
  37. package/dist/src/internals/CommandHandler.js +4 -0
  38. package/dist/src/internals/CommandHandler.js.map +1 -1
  39. package/dist/src/internals/ComponentHandler.d.ts +11 -0
  40. package/dist/src/internals/ComponentHandler.d.ts.map +1 -1
  41. package/dist/src/internals/ComponentHandler.js +15 -4
  42. package/dist/src/internals/ComponentHandler.js.map +1 -1
  43. package/dist/src/internals/FieldsHandler.d.ts +27 -0
  44. package/dist/src/internals/FieldsHandler.d.ts.map +1 -0
  45. package/dist/src/internals/FieldsHandler.js +37 -0
  46. package/dist/src/internals/FieldsHandler.js.map +1 -0
  47. package/dist/src/internals/ModalHandler.d.ts +17 -0
  48. package/dist/src/internals/ModalHandler.d.ts.map +1 -0
  49. package/dist/src/internals/ModalHandler.js +25 -0
  50. package/dist/src/internals/ModalHandler.js.map +1 -0
  51. package/dist/src/internals/ModalInteraction.d.ts +10 -0
  52. package/dist/src/internals/ModalInteraction.d.ts.map +1 -0
  53. package/dist/src/internals/ModalInteraction.js +12 -0
  54. package/dist/src/internals/ModalInteraction.js.map +1 -0
  55. package/dist/src/internals/OptionsHandler.d.ts +33 -17
  56. package/dist/src/internals/OptionsHandler.d.ts.map +1 -1
  57. package/dist/src/internals/OptionsHandler.js +52 -58
  58. package/dist/src/internals/OptionsHandler.js.map +1 -1
  59. package/dist/src/utils.d.ts +3 -0
  60. package/dist/src/utils.d.ts.map +1 -1
  61. package/dist/src/utils.js +54 -0
  62. package/dist/src/utils.js.map +1 -1
  63. package/dist/tsconfig.tsbuildinfo +1 -1
  64. package/package.json +6 -1
  65. package/.turbo/turbo-build.log +0 -5
  66. package/.turbo/turbo-dev.log +0 -175
  67. package/.turbo/turbo-docs.log +0 -12
  68. package/CHANGELOG.md +0 -34
  69. package/dist/src/abstracts/ButtonInteraction.d.ts +0 -8
  70. package/dist/src/abstracts/ButtonInteraction.d.ts.map +0 -1
  71. package/dist/src/abstracts/ButtonInteraction.js +0 -18
  72. package/dist/src/abstracts/ButtonInteraction.js.map +0 -1
  73. package/dist/src/abstracts/ChannelSelectMenuInteraction.d.ts +0 -7
  74. package/dist/src/abstracts/ChannelSelectMenuInteraction.d.ts.map +0 -1
  75. package/dist/src/abstracts/ChannelSelectMenuInteraction.js +0 -11
  76. package/dist/src/abstracts/ChannelSelectMenuInteraction.js.map +0 -1
  77. package/dist/src/abstracts/CommandHandler.d.ts +0 -6
  78. package/dist/src/abstracts/CommandHandler.d.ts.map +0 -1
  79. package/dist/src/abstracts/CommandHandler.js +0 -65
  80. package/dist/src/abstracts/CommandHandler.js.map +0 -1
  81. package/dist/src/abstracts/CommandInteraction.d.ts +0 -15
  82. package/dist/src/abstracts/CommandInteraction.d.ts.map +0 -1
  83. package/dist/src/abstracts/CommandInteraction.js +0 -60
  84. package/dist/src/abstracts/CommandInteraction.js.map +0 -1
  85. package/dist/src/abstracts/ComponentHandler.d.ts +0 -6
  86. package/dist/src/abstracts/ComponentHandler.d.ts.map +0 -1
  87. package/dist/src/abstracts/ComponentHandler.js +0 -64
  88. package/dist/src/abstracts/ComponentHandler.js.map +0 -1
  89. package/dist/src/abstracts/MentionableSelectMenuInteraction.d.ts +0 -8
  90. package/dist/src/abstracts/MentionableSelectMenuInteraction.d.ts.map +0 -1
  91. package/dist/src/abstracts/MentionableSelectMenuInteraction.js +0 -15
  92. package/dist/src/abstracts/MentionableSelectMenuInteraction.js.map +0 -1
  93. package/dist/src/abstracts/RoleSelectMenuInteraction.d.ts +0 -8
  94. package/dist/src/abstracts/RoleSelectMenuInteraction.d.ts.map +0 -1
  95. package/dist/src/abstracts/RoleSelectMenuInteraction.js +0 -14
  96. package/dist/src/abstracts/RoleSelectMenuInteraction.js.map +0 -1
  97. package/dist/src/abstracts/StringSelectMenuInteraction.d.ts +0 -8
  98. package/dist/src/abstracts/StringSelectMenuInteraction.d.ts.map +0 -1
  99. package/dist/src/abstracts/StringSelectMenuInteraction.js +0 -14
  100. package/dist/src/abstracts/StringSelectMenuInteraction.js.map +0 -1
  101. package/dist/src/abstracts/UserSelectMenuInteraction.d.ts +0 -8
  102. package/dist/src/abstracts/UserSelectMenuInteraction.d.ts.map +0 -1
  103. package/dist/src/abstracts/UserSelectMenuInteraction.js +0 -14
  104. package/dist/src/abstracts/UserSelectMenuInteraction.js.map +0 -1
  105. package/dist/src/classes/Paginator.d.ts +0 -3
  106. package/dist/src/classes/Paginator.d.ts.map +0 -1
  107. package/dist/src/classes/Paginator.js +0 -3
  108. package/dist/src/classes/Paginator.js.map +0 -1
  109. package/dist/src/structures/AnySelectMenu.d.ts +0 -31
  110. package/dist/src/structures/AnySelectMenu.d.ts.map +0 -1
  111. package/dist/src/structures/AnySelectMenu.js +0 -19
  112. package/dist/src/structures/AnySelectMenu.js.map +0 -1
  113. package/dist/src/structures/AnySelectMenuInteraction.d.ts +0 -12
  114. package/dist/src/structures/AnySelectMenuInteraction.d.ts.map +0 -1
  115. package/dist/src/structures/AnySelectMenuInteraction.js +0 -21
  116. package/dist/src/structures/AnySelectMenuInteraction.js.map +0 -1
  117. package/dist/src/structures/Base.d.ts +0 -10
  118. package/dist/src/structures/Base.d.ts.map +0 -1
  119. package/dist/src/structures/Base.js +0 -11
  120. package/dist/src/structures/Base.js.map +0 -1
  121. package/dist/src/structures/BaseCommand.d.ts +0 -64
  122. package/dist/src/structures/BaseCommand.d.ts.map +0 -1
  123. package/dist/src/structures/BaseCommand.js +0 -58
  124. package/dist/src/structures/BaseCommand.js.map +0 -1
  125. package/dist/src/structures/BaseComponent.d.ts +0 -34
  126. package/dist/src/structures/BaseComponent.d.ts.map +0 -1
  127. package/dist/src/structures/BaseComponent.js +0 -30
  128. package/dist/src/structures/BaseComponent.js.map +0 -1
  129. package/dist/src/structures/BaseComponentInteraction.d.ts +0 -9
  130. package/dist/src/structures/BaseComponentInteraction.d.ts.map +0 -1
  131. package/dist/src/structures/BaseComponentInteraction.js +0 -14
  132. package/dist/src/structures/BaseComponentInteraction.js.map +0 -1
  133. package/dist/src/structures/BaseInteraction.d.ts +0 -81
  134. package/dist/src/structures/BaseInteraction.d.ts.map +0 -1
  135. package/dist/src/structures/BaseInteraction.js +0 -99
  136. package/dist/src/structures/BaseInteraction.js.map +0 -1
  137. package/dist/src/structures/ButtonInteraction.d.ts +0 -8
  138. package/dist/src/structures/ButtonInteraction.d.ts.map +0 -1
  139. package/dist/src/structures/ButtonInteraction.js +0 -18
  140. package/dist/src/structures/ButtonInteraction.js.map +0 -1
  141. package/dist/src/structures/ChannelSelectMenuInteraction.d.ts +0 -7
  142. package/dist/src/structures/ChannelSelectMenuInteraction.d.ts.map +0 -1
  143. package/dist/src/structures/ChannelSelectMenuInteraction.js +0 -11
  144. package/dist/src/structures/ChannelSelectMenuInteraction.js.map +0 -1
  145. package/dist/src/structures/CommandHandler.d.ts +0 -6
  146. package/dist/src/structures/CommandHandler.d.ts.map +0 -1
  147. package/dist/src/structures/CommandHandler.js +0 -70
  148. package/dist/src/structures/CommandHandler.js.map +0 -1
  149. package/dist/src/structures/CommandInteraction.d.ts +0 -15
  150. package/dist/src/structures/CommandInteraction.d.ts.map +0 -1
  151. package/dist/src/structures/CommandInteraction.js +0 -60
  152. package/dist/src/structures/CommandInteraction.js.map +0 -1
  153. package/dist/src/structures/ComponentHandler.d.ts +0 -6
  154. package/dist/src/structures/ComponentHandler.d.ts.map +0 -1
  155. package/dist/src/structures/ComponentHandler.js +0 -64
  156. package/dist/src/structures/ComponentHandler.js.map +0 -1
  157. package/dist/src/structures/MentionableSelectMenuInteraction.d.ts +0 -8
  158. package/dist/src/structures/MentionableSelectMenuInteraction.d.ts.map +0 -1
  159. package/dist/src/structures/MentionableSelectMenuInteraction.js +0 -15
  160. package/dist/src/structures/MentionableSelectMenuInteraction.js.map +0 -1
  161. package/dist/src/structures/RoleSelectMenuInteraction.d.ts +0 -8
  162. package/dist/src/structures/RoleSelectMenuInteraction.d.ts.map +0 -1
  163. package/dist/src/structures/RoleSelectMenuInteraction.js +0 -14
  164. package/dist/src/structures/RoleSelectMenuInteraction.js.map +0 -1
  165. package/dist/src/structures/StringSelectMenuInteraction.d.ts +0 -8
  166. package/dist/src/structures/StringSelectMenuInteraction.d.ts.map +0 -1
  167. package/dist/src/structures/StringSelectMenuInteraction.js +0 -14
  168. package/dist/src/structures/StringSelectMenuInteraction.js.map +0 -1
  169. package/dist/src/structures/UserSelectMenuInteraction.d.ts +0 -8
  170. package/dist/src/structures/UserSelectMenuInteraction.d.ts.map +0 -1
  171. package/dist/src/structures/UserSelectMenuInteraction.js +0 -14
  172. package/dist/src/structures/UserSelectMenuInteraction.js.map +0 -1
  173. package/dist/src/types.d.ts +0 -31
  174. package/dist/src/types.d.ts.map +0 -1
  175. package/dist/src/types.js +0 -33
  176. package/dist/src/types.js.map +0 -1
  177. package/docs/classes/AnySelectMenu.mdx +0 -114
  178. package/docs/classes/AnySelectMenuInteraction.mdx +0 -175
  179. package/docs/classes/AutocompleteInteraction.mdx +0 -166
  180. package/docs/classes/AutocompleteOptionsHandler.mdx +0 -243
  181. package/docs/classes/BaseChannel.mdx +0 -97
  182. package/docs/classes/BaseCommand.mdx +0 -61
  183. package/docs/classes/BaseComponent.mdx +0 -55
  184. package/docs/classes/BaseComponentInteraction.mdx +0 -160
  185. package/docs/classes/BaseGuildChannel.mdx +0 -262
  186. package/docs/classes/BaseGuildTextChannel.mdx +0 -360
  187. package/docs/classes/BaseInteraction.mdx +0 -137
  188. package/docs/classes/Button.mdx +0 -99
  189. package/docs/classes/ButtonInteraction.mdx +0 -155
  190. package/docs/classes/ChannelSelectMenu.mdx +0 -122
  191. package/docs/classes/ChannelSelectMenuInteraction.mdx +0 -171
  192. package/docs/classes/Client.mdx +0 -48
  193. package/docs/classes/Command.mdx +0 -111
  194. package/docs/classes/CommandHandler.mdx +0 -65
  195. package/docs/classes/CommandInteraction.mdx +0 -155
  196. package/docs/classes/CommandWithSubcommandGroups.mdx +0 -73
  197. package/docs/classes/CommandWithSubcommands.mdx +0 -76
  198. package/docs/classes/ComponentHandler.mdx +0 -49
  199. package/docs/classes/DmChannel.mdx +0 -118
  200. package/docs/classes/GroupDmChannel.mdx +0 -197
  201. package/docs/classes/Guild.mdx +0 -157
  202. package/docs/classes/GuildAnnouncementChannel.mdx +0 -377
  203. package/docs/classes/GuildCategoryChannel.mdx +0 -272
  204. package/docs/classes/GuildForumChannel.mdx +0 -333
  205. package/docs/classes/GuildMediaChannel.mdx +0 -327
  206. package/docs/classes/GuildStageChannel.mdx +0 -276
  207. package/docs/classes/GuildStageOrVoiceChannel.mdx +0 -292
  208. package/docs/classes/GuildTextChannel.mdx +0 -367
  209. package/docs/classes/GuildThreadChannel.mdx +0 -425
  210. package/docs/classes/GuildThreadOnlyChannel.mdx +0 -333
  211. package/docs/classes/GuildVoiceChannel.mdx +0 -276
  212. package/docs/classes/LinkButton.mdx +0 -84
  213. package/docs/classes/MentionableSelectMenu.mdx +0 -120
  214. package/docs/classes/MentionableSelectMenuInteraction.mdx +0 -171
  215. package/docs/classes/Message.mdx +0 -126
  216. package/docs/classes/OptionsHandler.mdx +0 -203
  217. package/docs/classes/PremiumButton.mdx +0 -84
  218. package/docs/classes/Role.mdx +0 -228
  219. package/docs/classes/RoleSelectMenu.mdx +0 -120
  220. package/docs/classes/RoleSelectMenuInteraction.mdx +0 -171
  221. package/docs/classes/Row.mdx +0 -88
  222. package/docs/classes/StringSelectMenu.mdx +0 -120
  223. package/docs/classes/StringSelectMenuInteraction.mdx +0 -171
  224. package/docs/classes/User.mdx +0 -119
  225. package/docs/classes/UserSelectMenu.mdx +0 -120
  226. package/docs/classes/UserSelectMenuInteraction.mdx +0 -171
  227. package/docs/enumerations/ClientMode.mdx +0 -16
  228. package/docs/functions/channelFactory.mdx +0 -16
  229. package/docs/index.mdx +0 -83
  230. package/docs/type-aliases/AnySelectMenuComponentType.mdx +0 -5
  231. package/docs/type-aliases/ClientOptions.mdx +0 -20
  232. package/docs/type-aliases/CommandOptions.mdx +0 -5
  233. package/docs/type-aliases/ComponentAdditionalData.mdx +0 -9
  234. package/docs/type-aliases/InteractionFileData.mdx +0 -15
  235. package/docs/type-aliases/InteractionReplyData.mdx +0 -14
  236. package/docs/type-aliases/InteractionReplyOptions.mdx +0 -13
  237. package/docs/type-aliases/RawOptions.mdx +0 -9
  238. package/docs/type-aliases/meta.json +0 -3
  239. package/src/README.md +0 -7
  240. package/src/abstracts/AnySelectMenu.ts +0 -63
  241. package/src/abstracts/AnySelectMenuInteraction.ts +0 -29
  242. package/src/abstracts/Base.ts +0 -12
  243. package/src/abstracts/BaseChannel.ts +0 -73
  244. package/src/abstracts/BaseCommand.ts +0 -99
  245. package/src/abstracts/BaseComponent.ts +0 -49
  246. package/src/abstracts/BaseComponentInteraction.ts +0 -19
  247. package/src/abstracts/BaseGuildChannel.ts +0 -152
  248. package/src/abstracts/BaseGuildTextChannel.ts +0 -77
  249. package/src/abstracts/BaseInteraction.ts +0 -177
  250. package/src/abstracts/GuildThreadOnlyChannel.ts +0 -71
  251. package/src/classes/Button.ts +0 -95
  252. package/src/classes/ChannelSelectMenu.ts +0 -21
  253. package/src/classes/Client.ts +0 -254
  254. package/src/classes/Command.ts +0 -53
  255. package/src/classes/CommandWithSubcommandGroups.ts +0 -47
  256. package/src/classes/CommandWithSubcommands.ts +0 -35
  257. package/src/classes/MentionableSelectMenu.ts +0 -19
  258. package/src/classes/RoleSelectMenu.ts +0 -19
  259. package/src/classes/Row.ts +0 -44
  260. package/src/classes/StringSelectMenu.ts +0 -19
  261. package/src/classes/UserSelectMenu.ts +0 -19
  262. package/src/factories/channelFactory.ts +0 -43
  263. package/src/index.ts +0 -59
  264. package/src/internals/AutocompleteInteraction.ts +0 -107
  265. package/src/internals/ButtonInteraction.ts +0 -26
  266. package/src/internals/ChannelSelectMenuInteraction.ts +0 -15
  267. package/src/internals/CommandHandler.ts +0 -123
  268. package/src/internals/CommandInteraction.ts +0 -49
  269. package/src/internals/ComponentHandler.ts +0 -81
  270. package/src/internals/MentionableSelectMenuInteraction.ts +0 -21
  271. package/src/internals/OptionsHandler.ts +0 -148
  272. package/src/internals/RoleSelectMenuInteraction.ts +0 -20
  273. package/src/internals/StringSelectMenuInteraction.ts +0 -20
  274. package/src/internals/UserSelectMenuInteraction.ts +0 -20
  275. package/src/structures/DmChannel.ts +0 -31
  276. package/src/structures/GroupDmChannel.ts +0 -132
  277. package/src/structures/Guild.ts +0 -154
  278. package/src/structures/GuildAnnouncementChannel.ts +0 -20
  279. package/src/structures/GuildCategoryChannel.ts +0 -16
  280. package/src/structures/GuildForumChannel.ts +0 -20
  281. package/src/structures/GuildMediaChannel.ts +0 -13
  282. package/src/structures/GuildMember.ts +0 -231
  283. package/src/structures/GuildStageOrVoiceChannel.ts +0 -46
  284. package/src/structures/GuildTextChannel.ts +0 -21
  285. package/src/structures/GuildThreadChannel.ts +0 -150
  286. package/src/structures/Message.ts +0 -124
  287. package/src/structures/Role.ts +0 -201
  288. package/src/structures/User.ts +0 -153
  289. package/src/utils.ts +0 -13
  290. package/tests/index.test.ts +0 -4
  291. package/tsconfig.json +0 -12
  292. package/typedoc.json +0 -9
@@ -1,99 +0,0 @@
1
- import {
2
- ApplicationCommandType,
3
- type RESTPostAPIApplicationCommandsJSONBody
4
- } from "discord-api-types/v10"
5
- import {
6
- ApplicationIntegrationType,
7
- type BaseComponent,
8
- InteractionContextType
9
- } from "../index.js"
10
-
11
- /**
12
- * Represents the base data of a command that the user creates
13
- */
14
- export abstract class BaseCommand {
15
- /**
16
- * The name of the command (e.g. "ping" for /ping)
17
- */
18
- abstract name: string
19
- /**
20
- * A description of the command
21
- */
22
- abstract description: string
23
- /**
24
- * Whether the command response should be automatically deferred
25
- */
26
- defer = false
27
- /**
28
- * Whether the command response should be ephemeral
29
- */
30
- ephemeral = false
31
- /**
32
- * The type of the command
33
- */
34
- abstract type: ApplicationCommandType
35
- /**
36
- * The places this command can be used in
37
- * @beta API types are not finalized
38
- */
39
- integrationTypes: ApplicationIntegrationType[] = [
40
- ApplicationIntegrationType.GuildInstall,
41
- ApplicationIntegrationType.UserInstall
42
- ]
43
- /**
44
- * The contexts this command can be used in
45
- * @beta API types are not finalized
46
- */
47
- contexts: InteractionContextType[] = [
48
- InteractionContextType.Guild,
49
- InteractionContextType.BotDM,
50
- InteractionContextType.PrivateChannel
51
- ]
52
-
53
- /**
54
- * All the components that the command is able to use.
55
- * You mount these here so the handler can access them
56
- */
57
- components?: BaseComponent[] = []
58
-
59
- /**
60
- * All the paginators that the command is able to use.
61
- * You mount these here so the handler can access them
62
- */
63
- // paginators?: Paginator[] = []
64
-
65
- /**
66
- * Serializes the command into a JSON object that can be sent to Discord
67
- * @internal
68
- */
69
- serialize() {
70
- // Only chat input commands can have descriptions
71
- if (this.type === ApplicationCommandType.ChatInput) {
72
- const data: RESTPostAPIApplicationCommandsJSONBody = {
73
- name: this.name,
74
- type: this.type,
75
- description: this.description,
76
- options: this.serializeOptions(),
77
- integration_types: this.integrationTypes,
78
- contexts: this.contexts
79
- }
80
-
81
- return data
82
- }
83
- const data: RESTPostAPIApplicationCommandsJSONBody = {
84
- name: this.name,
85
- type: this.type,
86
- options: this.serializeOptions(),
87
- integration_types: this.integrationTypes,
88
- contexts: this.contexts
89
- }
90
-
91
- return data
92
- }
93
-
94
- /**
95
- * Serializes the options of the command into a JSON object that can be sent to Discord
96
- * @internal
97
- */
98
- abstract serializeOptions(): RESTPostAPIApplicationCommandsJSONBody["options"]
99
- }
@@ -1,49 +0,0 @@
1
- import type { APIBaseComponent, ComponentType } from "discord-api-types/v10"
2
-
3
- export type ComponentAdditionalData = {
4
- [key: string]: string | number | boolean
5
- }
6
-
7
- export abstract class BaseComponent {
8
- constructor(data?: {
9
- additionalData?: ComponentAdditionalData
10
- }) {
11
- if (data?.additionalData) this.additionalData = data.additionalData
12
- }
13
-
14
- /**
15
- * Whether the component response should be automatically deferred
16
- */
17
- defer = false
18
- /**
19
- * Whether the component response should be ephemeral
20
- */
21
- ephemeral = false
22
-
23
- /**
24
- * The type of the component
25
- */
26
- abstract type: ComponentType
27
- /**
28
- * The custom ID of the component
29
- */
30
- abstract customId: string
31
-
32
- additionalData: ComponentAdditionalData | null = null
33
-
34
- /**
35
- * Create a custom ID to use for this component that embeds additional data that you want to be handed
36
- * @param additionalData The additional data that you want to be passed in this component's custom ID
37
- * @returns The custom ID to use
38
- */
39
- public createId = (additionalData: typeof this.additionalData) => {
40
- if (!additionalData) return this.customId
41
- // id:arg1=1;arg2=2
42
- const id = `${this.customId}:${Object.entries(additionalData)
43
- .map(([key, value]) => `${key}=${value}`)
44
- .join(";")}`
45
- return id
46
- }
47
-
48
- abstract serialize: () => APIBaseComponent<typeof this.type>
49
- }
@@ -1,19 +0,0 @@
1
- import type {
2
- APIMessageComponentInteraction,
3
- ComponentType
4
- } from "discord-api-types/v10"
5
- import type { Client } from "../classes/Client.js"
6
- import { splitCustomId } from "../utils.js"
7
- import { BaseInteraction } from "./BaseInteraction.js"
8
-
9
- export class BaseComponentInteraction extends BaseInteraction<APIMessageComponentInteraction> {
10
- customId: string
11
- componentType: ComponentType
12
- constructor(client: Client, data: APIMessageComponentInteraction) {
13
- super(client, data)
14
- if (!data.data)
15
- throw new Error("Invalid interaction data was used to create this class")
16
- this.customId = splitCustomId(data.data.custom_id)[0]
17
- this.componentType = data.data.component_type
18
- }
19
- }
@@ -1,152 +0,0 @@
1
- import {
2
- type APIChannel,
3
- type APIGuildChannel,
4
- type APIMessage,
5
- type GuildChannelType,
6
- type RESTGetAPIGuildInvitesResult,
7
- type RESTPostAPIChannelInviteJSONBody,
8
- type RESTPostAPIChannelInviteResult,
9
- Routes
10
- } from "discord-api-types/v10"
11
- import { Guild } from "../structures/Guild.js"
12
- import type { GuildCategoryChannel } from "../structures/GuildCategoryChannel.js"
13
- import { BaseChannel } from "./BaseChannel.js"
14
-
15
- export abstract class BaseGuildChannel<
16
- Type extends GuildChannelType
17
- > extends BaseChannel<Type> {
18
- /**
19
- * The name of the channel.
20
- */
21
- name?: string
22
- /**
23
- * The ID of the guild this channel is in
24
- */
25
- guildId?: string
26
- /**
27
- * The position of the channel in the channel list.
28
- */
29
- position?: number
30
- /**
31
- * The ID of the parent category for the channel.
32
- */
33
- parentId?: string | null
34
- /**
35
- * Whether the channel is marked as nsfw.
36
- */
37
- nsfw?: boolean
38
-
39
- /**
40
- * The guild this channel is in
41
- */
42
- get guild() {
43
- if (!this.guildId) throw new Error("Cannot get guild without guild ID")
44
- return new Guild(this.client, this.guildId)
45
- }
46
-
47
- protected override setData(data: APIGuildChannel<Type>): void {
48
- this.rawData = data as Extract<APIChannel, { type: Type }> | null
49
- this.partial = false
50
- this.name = data.name
51
- this.guildId = data.guild_id
52
- this.position = data.position
53
- this.parentId = data.parent_id
54
- this.nsfw = data.nsfw
55
- this.setSpecificData(data as Extract<APIChannel, { type: Type }>)
56
- }
57
-
58
- /**
59
- * Set the name of the channel
60
- * @param name The new name of the channel
61
- */
62
- async setName(name: string) {
63
- await this.client.rest.patch(Routes.channel(this.id), {
64
- body: {
65
- name
66
- }
67
- })
68
- this.name = name
69
- }
70
-
71
- /**
72
- * Set the position of the channel
73
- * @param position The new position of the channel
74
- */
75
- async setPosition(position: number) {
76
- await this.client.rest.patch(Routes.channel(this.id), {
77
- body: {
78
- position
79
- }
80
- })
81
- this.position = position
82
- }
83
-
84
- /**
85
- * Set the parent ID of the channel
86
- * @param parent The new category channel or ID to set
87
- */
88
- async setParent(parent: GuildCategoryChannel | string) {
89
- if (typeof parent === "string") {
90
- await this.client.rest.patch(Routes.channel(this.id), {
91
- body: {
92
- parent_id: parent
93
- }
94
- })
95
- this.parentId = parent
96
- } else {
97
- await this.client.rest.patch(Routes.channel(this.id), {
98
- body: {
99
- parent_id: parent.id
100
- }
101
- })
102
- this.parentId = parent.id
103
- }
104
- }
105
-
106
- /**
107
- * Set whether the channel is nsfw
108
- * @param nsfw The new nsfw status of the channel
109
- */
110
- async setNsfw(nsfw: boolean) {
111
- await this.client.rest.patch(Routes.channel(this.id), {
112
- body: {
113
- nsfw
114
- }
115
- })
116
- this.nsfw = nsfw
117
- }
118
-
119
- /**
120
- * Send a message to the channel
121
- */
122
- async send(message: APIMessage) {
123
- this.client.rest.post(Routes.channelMessages(this.id), {
124
- body: { ...message }
125
- })
126
- }
127
-
128
- /**
129
- * Get the invites for the channel
130
- */
131
- async getInvites() {
132
- return (await this.client.rest.get(
133
- Routes.channelInvites(this.id)
134
- )) as RESTGetAPIGuildInvitesResult
135
- }
136
-
137
- /**
138
- * Create an invite for the channel
139
- */
140
- async createInvite(options?: RESTPostAPIChannelInviteJSONBody) {
141
- return (await this.client.rest.post(Routes.channelInvites(this.id), {
142
- body: { ...options }
143
- })) as RESTPostAPIChannelInviteResult
144
- }
145
-
146
- /**
147
- * Trigger a typing indicator in the channel (this will expire after 10 seconds)
148
- */
149
- async triggerTyping() {
150
- await this.client.rest.post(Routes.channelTyping(this.id))
151
- }
152
- }
@@ -1,77 +0,0 @@
1
- import {
2
- type APIGuildTextChannel,
3
- type APIThreadChannel,
4
- type GuildTextChannelType,
5
- type RESTGetAPIChannelPinsResult,
6
- type RESTPostAPIChannelThreadsJSONBody,
7
- Routes
8
- } from "discord-api-types/v10"
9
- import { GuildThreadChannel } from "../structures/GuildThreadChannel.js"
10
- import { Message } from "../structures/Message.js"
11
- import { BaseGuildChannel } from "./BaseGuildChannel.js"
12
-
13
- export abstract class BaseGuildTextChannel<
14
- Type extends GuildTextChannelType
15
- > extends BaseGuildChannel<Type> {
16
- /**
17
- * The ID of the last message sent in the channel.
18
- *
19
- * @remarks
20
- * This might not always resolve to a message. The ID still stays a part of the channel's data, even if the message is deleted.
21
- */
22
- lastMessageId?: string | null
23
- /**
24
- * The timestamp of the last pin in the channel.
25
- */
26
- lastPinTimestamp?: string | null
27
- /**
28
- * The rate limit per user for the channel, in seconds.
29
- */
30
- rateLimitPerUser?: number | null
31
-
32
- protected setSpecificData(data: APIGuildTextChannel<Type>): void {
33
- this.lastMessageId = data.last_message_id
34
- this.lastPinTimestamp = data.last_pin_timestamp
35
- this.rateLimitPerUser = data.rate_limit_per_user
36
- this.setMoreSpecificData(data)
37
- }
38
-
39
- protected abstract setMoreSpecificData(data: APIGuildTextChannel<Type>): void
40
-
41
- /**
42
- * The last message sent in the channel.
43
- *
44
- * @remarks
45
- * This might not always resolve to a message. The ID still stays a part of the channel's data, even if the message is deleted.
46
- * This will always return a partial message, so you can use {@link Message.fetch} to get the full message data.
47
- *
48
- */
49
- get lastMessage() {
50
- if (!this.lastMessageId) return null
51
- return new Message(this.client, {
52
- id: this.lastMessageId,
53
- channel_id: this.id
54
- })
55
- }
56
-
57
- /**
58
- * Get the pinned messages in the channel
59
- */
60
- async getPinnedMessages() {
61
- const msgs = (await this.client.rest.get(
62
- Routes.channelPins(this.id)
63
- )) as RESTGetAPIChannelPinsResult
64
- return msgs.map((x) => new Message(this.client, x))
65
- }
66
-
67
- /**
68
- * Start a thread without an associated start message.
69
- * If you want to start a thread with a start message, use {@link Message.startThread}
70
- */
71
- async startThread(data: RESTPostAPIChannelThreadsJSONBody) {
72
- const thread = (await this.client.rest.post(Routes.threads(this.id), {
73
- body: { ...data }
74
- })) as APIThreadChannel
75
- return new GuildThreadChannel(this.client, thread)
76
- }
77
- }
@@ -1,177 +0,0 @@
1
- import {
2
- type APIChannel,
3
- type APIInteraction,
4
- InteractionResponseType,
5
- type InteractionType,
6
- Routes
7
- } from "discord-api-types/v10"
8
- import type { Client } from "../classes/Client.js"
9
- import type { Row } from "../classes/Row.js"
10
- import { channelFactory } from "../factories/channelFactory.js"
11
- import { Guild } from "../structures/Guild.js"
12
- import { GuildMember } from "../structures/GuildMember.js"
13
- import { Message } from "../structures/Message.js"
14
- import { User } from "../structures/User.js"
15
- import { Base } from "./Base.js"
16
-
17
- /**
18
- * The data to reply to an interaction
19
- */
20
- export type InteractionReplyData = {
21
- /**
22
- * The content of the message
23
- */
24
- content?: string
25
- /**
26
- * The components to send in the message, listed in rows
27
- */
28
- components?: Row[]
29
- }
30
-
31
- /**
32
- * Additional options for replying to an interaction
33
- */
34
- export type InteractionReplyOptions = {
35
- /**
36
- * The files to send in the interaction
37
- */
38
- files?: InteractionFileData[]
39
- }
40
-
41
- /**
42
- * The data for a file to send in an interaction
43
- */
44
- export type InteractionFileData = {
45
- /**
46
- * The name of the file that will be given to Discord
47
- */
48
- name: string
49
- /**
50
- * The data of the file in a Blob
51
- */
52
- data: Blob
53
- /**
54
- * The alt text of the file, shown for accessibility
55
- * @alpha This isn't implemented yet
56
- */
57
- description?: string
58
- }
59
-
60
- /**
61
- * This is the base type interaction, all interaction types extend from this
62
- */
63
- export abstract class BaseInteraction<T extends APIInteraction> extends Base {
64
- /**
65
- * The type of interaction
66
- */
67
- type: InteractionType
68
- /**
69
- * The raw data of the interaction
70
- */
71
- rawData: T
72
- /**
73
- * The user who sent the interaction
74
- */
75
- userId: string | undefined
76
-
77
- /**
78
- * Whether the interaction is deferred already
79
- * @internal
80
- */
81
- _deferred = false
82
-
83
- constructor(client: Client, data: T) {
84
- super(client)
85
- this.rawData = data
86
- this.type = data.type
87
- this.userId =
88
- this.rawData.user?.id || this.rawData.member?.user.id || undefined
89
- }
90
-
91
- get message(): Message | null {
92
- if (!this.rawData.message) return null
93
- return new Message(this.client, this.rawData.message)
94
- }
95
-
96
- get guild(): Guild | null {
97
- if (!this.rawData.guild_id) return null
98
- return new Guild(this.client, this.rawData.guild_id)
99
- }
100
-
101
- get user(): User | null {
102
- if (this.rawData.user) return new User(this.client, this.rawData.user)
103
- if (this.rawData.member)
104
- return new User(this.client, this.rawData.member.user)
105
- return null
106
- }
107
-
108
- get channel() {
109
- if (!this.rawData.channel) return null
110
- return channelFactory(this.client, this.rawData.channel as APIChannel)
111
- }
112
-
113
- get member() {
114
- if (!this.rawData.member) return null
115
- if (!this.guild) return null
116
- return new GuildMember(this.client, this.rawData.member, this.guild)
117
- }
118
-
119
- /**
120
- * Reply to an interaction.
121
- * If the interaction is deferred, this will edit the original response.
122
- * @param data The response data
123
- */
124
- async reply(
125
- data: InteractionReplyData,
126
- options: InteractionReplyOptions = {}
127
- ) {
128
- if (this._deferred) {
129
- await this.client.rest.patch(
130
- Routes.webhookMessage(
131
- this.client.options.clientId,
132
- this.rawData.token,
133
- "@original"
134
- ),
135
- {
136
- body: {
137
- ...data,
138
- components: data.components?.map((row) => row.serialize())
139
- },
140
- files: options.files
141
- }
142
- )
143
- } else {
144
- await this.client.rest.post(
145
- Routes.interactionCallback(this.rawData.id, this.rawData.token),
146
- {
147
- body: {
148
- type: InteractionResponseType.ChannelMessageWithSource,
149
- data: {
150
- ...data,
151
- components: data.components?.map((row) => row.serialize())
152
- }
153
- },
154
- files: options.files
155
- }
156
- )
157
- }
158
- }
159
-
160
- /**
161
- * Defer the interaction response. This is used automatically by commands that are set to defer.
162
- * If the interaction is already deferred, this will do nothing.
163
- * @internal
164
- */
165
- async defer() {
166
- if (this._deferred) return
167
- this._deferred = true
168
- await this.client.rest.post(
169
- Routes.interactionCallback(this.rawData.id, this.rawData.token),
170
- {
171
- body: {
172
- type: InteractionResponseType.DeferredChannelMessageWithSource
173
- }
174
- }
175
- )
176
- }
177
- }
@@ -1,71 +0,0 @@
1
- import type {
2
- APIGuildForumDefaultReactionEmoji,
3
- APIGuildForumTag,
4
- APIMessage,
5
- APIThreadOnlyChannel,
6
- ChannelType,
7
- SortOrderType
8
- } from "discord-api-types/v10"
9
- import { GuildThreadChannel } from "../structures/GuildThreadChannel.js"
10
- import { BaseGuildChannel } from "./BaseGuildChannel.js"
11
-
12
- export abstract class GuildThreadOnlyChannel<
13
- Type extends ChannelType.GuildForum | ChannelType.GuildMedia
14
- > extends BaseGuildChannel<Type> {
15
- /**
16
- * The topic of the channel.
17
- */
18
- topic?: string | null
19
- /**
20
- * The default auto archive duration of the channel.
21
- */
22
- defaultAutoArchiveDuration?: number | null
23
- /**
24
- * The available tags to set on posts in the channel.
25
- */
26
- availableTags?: APIGuildForumTag[]
27
- /**
28
- * The default thread rate limit per user for the channel.
29
- */
30
- defaultThreadRateLimitPerUser?: number | null
31
- /**
32
- * The default reaction emoji for the channel.
33
- */
34
- defaultReactionEmoji?: APIGuildForumDefaultReactionEmoji | null
35
- /**
36
- * The default sort order for the channel, by latest activity or by creation date.
37
- */
38
- defaultSortOrder?: SortOrderType | null
39
-
40
- protected setSpecificData(data: APIThreadOnlyChannel<Type>): void {
41
- this.topic = data.topic
42
- this.defaultAutoArchiveDuration = data.default_auto_archive_duration
43
- this.availableTags = data.available_tags
44
- this.defaultThreadRateLimitPerUser = data.default_thread_rate_limit_per_user
45
- this.defaultReactionEmoji = data.default_reaction_emoji
46
- this.defaultSortOrder = data.default_sort_order
47
- this.setMoreSpecificData(data)
48
- }
49
-
50
- protected abstract setMoreSpecificData(data: APIThreadOnlyChannel<Type>): void
51
-
52
- /**
53
- * You cannot send a message directly to a forum or media channel, so this method throws an error.
54
- * Use {@link GuildThreadChannel.send} instead, or the alias {@link GuildThreadOnlyChannel.sendToPost} instead, to send a message to the channel's posts.
55
- */
56
- override async send(): Promise<void> {
57
- throw new Error(
58
- "You cannot send a message directly to a forum or media channel. Use GuildThreadChannel.send instead, or the alias GuildThreadOnlyChannel.sendToPost instead, to send a message to the channel's posts."
59
- )
60
- }
61
-
62
- /**
63
- * Send a message to a post in the channel
64
- * @remarks
65
- * This is an alias for {@link GuildThreadChannel.send} that will fetch the channel, but if you already have the channel, you can use {@link GuildThreadChannel.send} instead.
66
- */
67
- async sendToPost(message: APIMessage, postId: string): Promise<void> {
68
- const channel = new GuildThreadChannel(this.client, postId)
69
- await channel.send(message)
70
- }
71
- }