@buape/carbon 0.2.0 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (275) 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 +10 -1
  7. package/dist/src/abstracts/BaseInteraction.d.ts.map +1 -1
  8. package/dist/src/abstracts/BaseInteraction.js +10 -1
  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/classes/Embed.d.ts +60 -0
  14. package/dist/src/classes/Embed.d.ts.map +1 -0
  15. package/dist/src/classes/Embed.js +73 -0
  16. package/dist/src/classes/Embed.js.map +1 -0
  17. package/dist/src/index.d.ts +4 -1
  18. package/dist/src/index.d.ts.map +1 -1
  19. package/dist/src/index.js +4 -1
  20. package/dist/src/index.js.map +1 -1
  21. package/dist/src/internals/AutocompleteInteraction.d.ts +1 -1
  22. package/dist/src/internals/FieldsHandler.d.ts +27 -0
  23. package/dist/src/internals/FieldsHandler.d.ts.map +1 -0
  24. package/dist/src/internals/FieldsHandler.js +37 -0
  25. package/dist/src/internals/FieldsHandler.js.map +1 -0
  26. package/dist/src/internals/ModalInteraction.d.ts +3 -4
  27. package/dist/src/internals/ModalInteraction.d.ts.map +1 -1
  28. package/dist/src/internals/ModalInteraction.js +3 -10
  29. package/dist/src/internals/ModalInteraction.js.map +1 -1
  30. package/dist/src/internals/OptionsHandler.d.ts +33 -17
  31. package/dist/src/internals/OptionsHandler.d.ts.map +1 -1
  32. package/dist/src/internals/OptionsHandler.js +52 -58
  33. package/dist/src/internals/OptionsHandler.js.map +1 -1
  34. package/dist/src/utils.d.ts +3 -0
  35. package/dist/src/utils.d.ts.map +1 -1
  36. package/dist/src/utils.js +54 -0
  37. package/dist/src/utils.js.map +1 -1
  38. package/dist/tsconfig.tsbuildinfo +1 -1
  39. package/package.json +6 -1
  40. package/.turbo/turbo-build.log +0 -5
  41. package/.turbo/turbo-dev.log +0 -8
  42. package/.turbo/turbo-docs.log +0 -12
  43. package/CHANGELOG.md +0 -44
  44. package/dist/src/abstracts/ButtonInteraction.d.ts +0 -8
  45. package/dist/src/abstracts/ButtonInteraction.d.ts.map +0 -1
  46. package/dist/src/abstracts/ButtonInteraction.js +0 -18
  47. package/dist/src/abstracts/ButtonInteraction.js.map +0 -1
  48. package/dist/src/abstracts/ChannelSelectMenuInteraction.d.ts +0 -7
  49. package/dist/src/abstracts/ChannelSelectMenuInteraction.d.ts.map +0 -1
  50. package/dist/src/abstracts/ChannelSelectMenuInteraction.js +0 -11
  51. package/dist/src/abstracts/ChannelSelectMenuInteraction.js.map +0 -1
  52. package/dist/src/abstracts/CommandHandler.d.ts +0 -6
  53. package/dist/src/abstracts/CommandHandler.d.ts.map +0 -1
  54. package/dist/src/abstracts/CommandHandler.js +0 -65
  55. package/dist/src/abstracts/CommandHandler.js.map +0 -1
  56. package/dist/src/abstracts/CommandInteraction.d.ts +0 -15
  57. package/dist/src/abstracts/CommandInteraction.d.ts.map +0 -1
  58. package/dist/src/abstracts/CommandInteraction.js +0 -60
  59. package/dist/src/abstracts/CommandInteraction.js.map +0 -1
  60. package/dist/src/abstracts/ComponentHandler.d.ts +0 -6
  61. package/dist/src/abstracts/ComponentHandler.d.ts.map +0 -1
  62. package/dist/src/abstracts/ComponentHandler.js +0 -64
  63. package/dist/src/abstracts/ComponentHandler.js.map +0 -1
  64. package/dist/src/abstracts/MentionableSelectMenuInteraction.d.ts +0 -8
  65. package/dist/src/abstracts/MentionableSelectMenuInteraction.d.ts.map +0 -1
  66. package/dist/src/abstracts/MentionableSelectMenuInteraction.js +0 -15
  67. package/dist/src/abstracts/MentionableSelectMenuInteraction.js.map +0 -1
  68. package/dist/src/abstracts/RoleSelectMenuInteraction.d.ts +0 -8
  69. package/dist/src/abstracts/RoleSelectMenuInteraction.d.ts.map +0 -1
  70. package/dist/src/abstracts/RoleSelectMenuInteraction.js +0 -14
  71. package/dist/src/abstracts/RoleSelectMenuInteraction.js.map +0 -1
  72. package/dist/src/abstracts/StringSelectMenuInteraction.d.ts +0 -8
  73. package/dist/src/abstracts/StringSelectMenuInteraction.d.ts.map +0 -1
  74. package/dist/src/abstracts/StringSelectMenuInteraction.js +0 -14
  75. package/dist/src/abstracts/StringSelectMenuInteraction.js.map +0 -1
  76. package/dist/src/abstracts/UserSelectMenuInteraction.d.ts +0 -8
  77. package/dist/src/abstracts/UserSelectMenuInteraction.d.ts.map +0 -1
  78. package/dist/src/abstracts/UserSelectMenuInteraction.js +0 -14
  79. package/dist/src/abstracts/UserSelectMenuInteraction.js.map +0 -1
  80. package/dist/src/classes/Paginator.d.ts +0 -3
  81. package/dist/src/classes/Paginator.d.ts.map +0 -1
  82. package/dist/src/classes/Paginator.js +0 -3
  83. package/dist/src/classes/Paginator.js.map +0 -1
  84. package/dist/src/internals/ComponentHandler copy.d.ts +0 -17
  85. package/dist/src/internals/ComponentHandler copy.d.ts.map +0 -1
  86. package/dist/src/internals/ComponentHandler copy.js +0 -75
  87. package/dist/src/internals/ComponentHandler copy.js.map +0 -1
  88. package/dist/src/structures/AnySelectMenu.d.ts +0 -31
  89. package/dist/src/structures/AnySelectMenu.d.ts.map +0 -1
  90. package/dist/src/structures/AnySelectMenu.js +0 -19
  91. package/dist/src/structures/AnySelectMenu.js.map +0 -1
  92. package/dist/src/structures/AnySelectMenuInteraction.d.ts +0 -12
  93. package/dist/src/structures/AnySelectMenuInteraction.d.ts.map +0 -1
  94. package/dist/src/structures/AnySelectMenuInteraction.js +0 -21
  95. package/dist/src/structures/AnySelectMenuInteraction.js.map +0 -1
  96. package/dist/src/structures/Base.d.ts +0 -10
  97. package/dist/src/structures/Base.d.ts.map +0 -1
  98. package/dist/src/structures/Base.js +0 -11
  99. package/dist/src/structures/Base.js.map +0 -1
  100. package/dist/src/structures/BaseCommand.d.ts +0 -64
  101. package/dist/src/structures/BaseCommand.d.ts.map +0 -1
  102. package/dist/src/structures/BaseCommand.js +0 -58
  103. package/dist/src/structures/BaseCommand.js.map +0 -1
  104. package/dist/src/structures/BaseComponent.d.ts +0 -34
  105. package/dist/src/structures/BaseComponent.d.ts.map +0 -1
  106. package/dist/src/structures/BaseComponent.js +0 -30
  107. package/dist/src/structures/BaseComponent.js.map +0 -1
  108. package/dist/src/structures/BaseComponentInteraction.d.ts +0 -9
  109. package/dist/src/structures/BaseComponentInteraction.d.ts.map +0 -1
  110. package/dist/src/structures/BaseComponentInteraction.js +0 -14
  111. package/dist/src/structures/BaseComponentInteraction.js.map +0 -1
  112. package/dist/src/structures/BaseInteraction.d.ts +0 -81
  113. package/dist/src/structures/BaseInteraction.d.ts.map +0 -1
  114. package/dist/src/structures/BaseInteraction.js +0 -99
  115. package/dist/src/structures/BaseInteraction.js.map +0 -1
  116. package/dist/src/structures/ButtonInteraction.d.ts +0 -8
  117. package/dist/src/structures/ButtonInteraction.d.ts.map +0 -1
  118. package/dist/src/structures/ButtonInteraction.js +0 -18
  119. package/dist/src/structures/ButtonInteraction.js.map +0 -1
  120. package/dist/src/structures/ChannelSelectMenuInteraction.d.ts +0 -7
  121. package/dist/src/structures/ChannelSelectMenuInteraction.d.ts.map +0 -1
  122. package/dist/src/structures/ChannelSelectMenuInteraction.js +0 -11
  123. package/dist/src/structures/ChannelSelectMenuInteraction.js.map +0 -1
  124. package/dist/src/structures/CommandHandler.d.ts +0 -6
  125. package/dist/src/structures/CommandHandler.d.ts.map +0 -1
  126. package/dist/src/structures/CommandHandler.js +0 -70
  127. package/dist/src/structures/CommandHandler.js.map +0 -1
  128. package/dist/src/structures/CommandInteraction.d.ts +0 -15
  129. package/dist/src/structures/CommandInteraction.d.ts.map +0 -1
  130. package/dist/src/structures/CommandInteraction.js +0 -60
  131. package/dist/src/structures/CommandInteraction.js.map +0 -1
  132. package/dist/src/structures/ComponentHandler.d.ts +0 -6
  133. package/dist/src/structures/ComponentHandler.d.ts.map +0 -1
  134. package/dist/src/structures/ComponentHandler.js +0 -64
  135. package/dist/src/structures/ComponentHandler.js.map +0 -1
  136. package/dist/src/structures/MentionableSelectMenuInteraction.d.ts +0 -8
  137. package/dist/src/structures/MentionableSelectMenuInteraction.d.ts.map +0 -1
  138. package/dist/src/structures/MentionableSelectMenuInteraction.js +0 -15
  139. package/dist/src/structures/MentionableSelectMenuInteraction.js.map +0 -1
  140. package/dist/src/structures/RoleSelectMenuInteraction.d.ts +0 -8
  141. package/dist/src/structures/RoleSelectMenuInteraction.d.ts.map +0 -1
  142. package/dist/src/structures/RoleSelectMenuInteraction.js +0 -14
  143. package/dist/src/structures/RoleSelectMenuInteraction.js.map +0 -1
  144. package/dist/src/structures/StringSelectMenuInteraction.d.ts +0 -8
  145. package/dist/src/structures/StringSelectMenuInteraction.d.ts.map +0 -1
  146. package/dist/src/structures/StringSelectMenuInteraction.js +0 -14
  147. package/dist/src/structures/StringSelectMenuInteraction.js.map +0 -1
  148. package/dist/src/structures/UserSelectMenuInteraction.d.ts +0 -8
  149. package/dist/src/structures/UserSelectMenuInteraction.d.ts.map +0 -1
  150. package/dist/src/structures/UserSelectMenuInteraction.js +0 -14
  151. package/dist/src/structures/UserSelectMenuInteraction.js.map +0 -1
  152. package/dist/src/types.d.ts +0 -31
  153. package/dist/src/types.d.ts.map +0 -1
  154. package/dist/src/types.js +0 -33
  155. package/dist/src/types.js.map +0 -1
  156. package/docs/classes/AnySelectMenu.mdx +0 -114
  157. package/docs/classes/AnySelectMenuInteraction.mdx +0 -175
  158. package/docs/classes/AutocompleteInteraction.mdx +0 -166
  159. package/docs/classes/AutocompleteOptionsHandler.mdx +0 -243
  160. package/docs/classes/BaseChannel.mdx +0 -97
  161. package/docs/classes/BaseCommand.mdx +0 -61
  162. package/docs/classes/BaseComponent.mdx +0 -55
  163. package/docs/classes/BaseComponentInteraction.mdx +0 -160
  164. package/docs/classes/BaseGuildChannel.mdx +0 -262
  165. package/docs/classes/BaseGuildTextChannel.mdx +0 -360
  166. package/docs/classes/BaseInteraction.mdx +0 -137
  167. package/docs/classes/Button.mdx +0 -99
  168. package/docs/classes/ButtonInteraction.mdx +0 -155
  169. package/docs/classes/ChannelSelectMenu.mdx +0 -122
  170. package/docs/classes/ChannelSelectMenuInteraction.mdx +0 -171
  171. package/docs/classes/Client.mdx +0 -48
  172. package/docs/classes/Command.mdx +0 -111
  173. package/docs/classes/CommandHandler.mdx +0 -65
  174. package/docs/classes/CommandInteraction.mdx +0 -155
  175. package/docs/classes/CommandWithSubcommandGroups.mdx +0 -73
  176. package/docs/classes/CommandWithSubcommands.mdx +0 -76
  177. package/docs/classes/ComponentHandler.mdx +0 -49
  178. package/docs/classes/DmChannel.mdx +0 -118
  179. package/docs/classes/GroupDmChannel.mdx +0 -197
  180. package/docs/classes/Guild.mdx +0 -157
  181. package/docs/classes/GuildAnnouncementChannel.mdx +0 -377
  182. package/docs/classes/GuildCategoryChannel.mdx +0 -272
  183. package/docs/classes/GuildForumChannel.mdx +0 -333
  184. package/docs/classes/GuildMediaChannel.mdx +0 -327
  185. package/docs/classes/GuildStageChannel.mdx +0 -276
  186. package/docs/classes/GuildStageOrVoiceChannel.mdx +0 -292
  187. package/docs/classes/GuildTextChannel.mdx +0 -367
  188. package/docs/classes/GuildThreadChannel.mdx +0 -425
  189. package/docs/classes/GuildThreadOnlyChannel.mdx +0 -333
  190. package/docs/classes/GuildVoiceChannel.mdx +0 -276
  191. package/docs/classes/LinkButton.mdx +0 -84
  192. package/docs/classes/MentionableSelectMenu.mdx +0 -120
  193. package/docs/classes/MentionableSelectMenuInteraction.mdx +0 -171
  194. package/docs/classes/Message.mdx +0 -126
  195. package/docs/classes/OptionsHandler.mdx +0 -203
  196. package/docs/classes/PremiumButton.mdx +0 -84
  197. package/docs/classes/Role.mdx +0 -228
  198. package/docs/classes/RoleSelectMenu.mdx +0 -120
  199. package/docs/classes/RoleSelectMenuInteraction.mdx +0 -171
  200. package/docs/classes/Row.mdx +0 -88
  201. package/docs/classes/StringSelectMenu.mdx +0 -120
  202. package/docs/classes/StringSelectMenuInteraction.mdx +0 -171
  203. package/docs/classes/User.mdx +0 -119
  204. package/docs/classes/UserSelectMenu.mdx +0 -120
  205. package/docs/classes/UserSelectMenuInteraction.mdx +0 -171
  206. package/docs/enumerations/ClientMode.mdx +0 -16
  207. package/docs/functions/channelFactory.mdx +0 -16
  208. package/docs/index.mdx +0 -83
  209. package/docs/type-aliases/AnySelectMenuComponentType.mdx +0 -5
  210. package/docs/type-aliases/ClientOptions.mdx +0 -20
  211. package/docs/type-aliases/CommandOptions.mdx +0 -5
  212. package/docs/type-aliases/ComponentAdditionalData.mdx +0 -9
  213. package/docs/type-aliases/InteractionFileData.mdx +0 -15
  214. package/docs/type-aliases/InteractionReplyData.mdx +0 -14
  215. package/docs/type-aliases/InteractionReplyOptions.mdx +0 -13
  216. package/docs/type-aliases/RawOptions.mdx +0 -9
  217. package/docs/type-aliases/meta.json +0 -3
  218. package/src/README.md +0 -7
  219. package/src/abstracts/AnySelectMenu.ts +0 -63
  220. package/src/abstracts/AnySelectMenuInteraction.ts +0 -29
  221. package/src/abstracts/Base.ts +0 -12
  222. package/src/abstracts/BaseChannel.ts +0 -73
  223. package/src/abstracts/BaseCommand.ts +0 -89
  224. package/src/abstracts/BaseComponent.ts +0 -49
  225. package/src/abstracts/BaseComponentInteraction.ts +0 -19
  226. package/src/abstracts/BaseGuildChannel.ts +0 -152
  227. package/src/abstracts/BaseGuildTextChannel.ts +0 -77
  228. package/src/abstracts/BaseInteraction.ts +0 -209
  229. package/src/abstracts/GuildThreadOnlyChannel.ts +0 -71
  230. package/src/classes/Button.ts +0 -95
  231. package/src/classes/ChannelSelectMenu.ts +0 -21
  232. package/src/classes/Client.ts +0 -277
  233. package/src/classes/Command.ts +0 -53
  234. package/src/classes/CommandWithSubcommandGroups.ts +0 -47
  235. package/src/classes/CommandWithSubcommands.ts +0 -35
  236. package/src/classes/MentionableSelectMenu.ts +0 -19
  237. package/src/classes/Modal.ts +0 -38
  238. package/src/classes/RoleSelectMenu.ts +0 -19
  239. package/src/classes/Row.ts +0 -50
  240. package/src/classes/StringSelectMenu.ts +0 -19
  241. package/src/classes/TextInput.ts +0 -65
  242. package/src/classes/UserSelectMenu.ts +0 -19
  243. package/src/factories/channelFactory.ts +0 -43
  244. package/src/index.ts +0 -62
  245. package/src/internals/AutocompleteInteraction.ts +0 -107
  246. package/src/internals/ButtonInteraction.ts +0 -26
  247. package/src/internals/ChannelSelectMenuInteraction.ts +0 -15
  248. package/src/internals/CommandHandler.ts +0 -127
  249. package/src/internals/CommandInteraction.ts +0 -49
  250. package/src/internals/ComponentHandler.ts +0 -92
  251. package/src/internals/MentionableSelectMenuInteraction.ts +0 -21
  252. package/src/internals/ModalHandler.ts +0 -27
  253. package/src/internals/ModalInteraction.ts +0 -25
  254. package/src/internals/OptionsHandler.ts +0 -148
  255. package/src/internals/RoleSelectMenuInteraction.ts +0 -20
  256. package/src/internals/StringSelectMenuInteraction.ts +0 -20
  257. package/src/internals/UserSelectMenuInteraction.ts +0 -20
  258. package/src/structures/DmChannel.ts +0 -31
  259. package/src/structures/GroupDmChannel.ts +0 -132
  260. package/src/structures/Guild.ts +0 -154
  261. package/src/structures/GuildAnnouncementChannel.ts +0 -20
  262. package/src/structures/GuildCategoryChannel.ts +0 -16
  263. package/src/structures/GuildForumChannel.ts +0 -20
  264. package/src/structures/GuildMediaChannel.ts +0 -13
  265. package/src/structures/GuildMember.ts +0 -231
  266. package/src/structures/GuildStageOrVoiceChannel.ts +0 -46
  267. package/src/structures/GuildTextChannel.ts +0 -21
  268. package/src/structures/GuildThreadChannel.ts +0 -150
  269. package/src/structures/Message.ts +0 -124
  270. package/src/structures/Role.ts +0 -201
  271. package/src/structures/User.ts +0 -153
  272. package/src/utils.ts +0 -13
  273. package/tests/index.test.ts +0 -4
  274. package/tsconfig.json +0 -12
  275. package/typedoc.json +0 -9
@@ -1,89 +0,0 @@
1
- import {
2
- ApplicationCommandType,
3
- type RESTPostAPIApplicationCommandsJSONBody
4
- } from "discord-api-types/v10"
5
- import { ApplicationIntegrationType, InteractionContextType } from "../index.js"
6
-
7
- /**
8
- * Represents the base data of a command that the user creates
9
- */
10
- export abstract class BaseCommand {
11
- /**
12
- * The name of the command (e.g. "ping" for /ping)
13
- */
14
- abstract name: string
15
- /**
16
- * A description of the command
17
- */
18
- abstract description: string
19
- /**
20
- * Whether the command response should be automatically deferred
21
- */
22
- defer = false
23
- /**
24
- * Whether the command response should be ephemeral
25
- */
26
- ephemeral = false
27
- /**
28
- * The type of the command
29
- */
30
- abstract type: ApplicationCommandType
31
- /**
32
- * The places this command can be used in
33
- * @beta API types are not finalized
34
- */
35
- integrationTypes: ApplicationIntegrationType[] = [
36
- ApplicationIntegrationType.GuildInstall,
37
- ApplicationIntegrationType.UserInstall
38
- ]
39
- /**
40
- * The contexts this command can be used in
41
- * @beta API types are not finalized
42
- */
43
- contexts: InteractionContextType[] = [
44
- InteractionContextType.Guild,
45
- InteractionContextType.BotDM,
46
- InteractionContextType.PrivateChannel
47
- ]
48
-
49
- /**
50
- * All the paginators that the command is able to use.
51
- * You mount these here so the handler can access them
52
- */
53
- // paginators?: Paginator[] = []
54
-
55
- /**
56
- * Serializes the command into a JSON object that can be sent to Discord
57
- * @internal
58
- */
59
- serialize() {
60
- // Only chat input commands can have descriptions
61
- if (this.type === ApplicationCommandType.ChatInput) {
62
- const data: RESTPostAPIApplicationCommandsJSONBody = {
63
- name: this.name,
64
- type: this.type,
65
- description: this.description,
66
- options: this.serializeOptions(),
67
- integration_types: this.integrationTypes,
68
- contexts: this.contexts
69
- }
70
-
71
- return data
72
- }
73
- const data: RESTPostAPIApplicationCommandsJSONBody = {
74
- name: this.name,
75
- type: this.type,
76
- options: this.serializeOptions(),
77
- integration_types: this.integrationTypes,
78
- contexts: this.contexts
79
- }
80
-
81
- return data
82
- }
83
-
84
- /**
85
- * Serializes the options of the command into a JSON object that can be sent to Discord
86
- * @internal
87
- */
88
- abstract serializeOptions(): RESTPostAPIApplicationCommandsJSONBody["options"]
89
- }
@@ -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,209 +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 {
9
- Base,
10
- type Client,
11
- Guild,
12
- Message,
13
- type Modal,
14
- type Row,
15
- User,
16
- channelFactory
17
- } from "../index.js"
18
- import { GuildMember } from "../structures/GuildMember.js"
19
-
20
- /**
21
- * The data to reply to an interaction
22
- */
23
- export type InteractionReplyData = {
24
- /**
25
- * The content of the message
26
- */
27
- content?: string
28
- /**
29
- * The components to send in the message, listed in rows
30
- */
31
- components?: Row[]
32
- }
33
-
34
- /**
35
- * Additional options for replying to an interaction
36
- */
37
- export type InteractionReplyOptions = {
38
- /**
39
- * The files to send in the interaction
40
- */
41
- files?: InteractionFileData[]
42
- /**
43
- * Whether the interaction should be ephemeral
44
- */
45
- ephemeral?: boolean
46
- }
47
-
48
- /**
49
- * The data for a file to send in an interaction
50
- */
51
- export type InteractionFileData = {
52
- /**
53
- * The name of the file that will be given to Discord
54
- */
55
- name: string
56
- /**
57
- * The data of the file in a Blob
58
- */
59
- data: Blob
60
- /**
61
- * The alt text of the file, shown for accessibility
62
- * @alpha This isn't implemented yet
63
- */
64
- description?: string
65
- }
66
-
67
- /**
68
- * This is the base type interaction, all interaction types extend from this
69
- */
70
- export abstract class BaseInteraction<T extends APIInteraction> extends Base {
71
- /**
72
- * The type of interaction
73
- */
74
- type: InteractionType
75
- /**
76
- * The raw data of the interaction
77
- */
78
- rawData: T
79
- /**
80
- * The user who sent the interaction
81
- */
82
- userId: string | undefined
83
-
84
- /**
85
- * Whether the interaction is deferred already
86
- * @internal
87
- */
88
- _deferred = false
89
-
90
- private defaultEphemeral = false
91
-
92
- constructor(client: Client, data: T, defaults: { ephemeral?: boolean } = {}) {
93
- super(client)
94
- this.rawData = data
95
- this.type = data.type
96
- this.userId =
97
- this.rawData.user?.id || this.rawData.member?.user.id || undefined
98
- if (defaults.ephemeral) this.defaultEphemeral = defaults.ephemeral
99
- }
100
-
101
- get message(): Message | null {
102
- if (!this.rawData.message) return null
103
- return new Message(this.client, this.rawData.message)
104
- }
105
-
106
- get guild(): Guild | null {
107
- if (!this.rawData.guild_id) return null
108
- return new Guild(this.client, this.rawData.guild_id)
109
- }
110
-
111
- get user(): User | null {
112
- if (this.rawData.user) return new User(this.client, this.rawData.user)
113
- if (this.rawData.member)
114
- return new User(this.client, this.rawData.member.user)
115
- return null
116
- }
117
-
118
- get channel() {
119
- if (!this.rawData.channel) return null
120
- return channelFactory(this.client, this.rawData.channel as APIChannel)
121
- }
122
-
123
- get member() {
124
- if (!this.rawData.member) return null
125
- if (!this.guild) return null
126
- return new GuildMember(this.client, this.rawData.member, this.guild)
127
- }
128
-
129
- /**
130
- * Reply to an interaction.
131
- * If the interaction is deferred, this will edit the original response.
132
- * @param data The response data
133
- */
134
- async reply(
135
- data: InteractionReplyData,
136
- options: InteractionReplyOptions = {}
137
- ) {
138
- data.components?.map((row) => {
139
- row.components.map((component) => {
140
- this.client.componentHandler.registerComponent(component)
141
- })
142
- })
143
- if (this._deferred) {
144
- await this.client.rest.patch(
145
- Routes.webhookMessage(
146
- this.client.options.clientId,
147
- this.rawData.token,
148
- "@original"
149
- ),
150
- {
151
- body: {
152
- ...data,
153
- components: data.components?.map((row) => row.serialize())
154
- },
155
- files: options.files
156
- }
157
- )
158
- } else {
159
- await this.client.rest.post(
160
- Routes.interactionCallback(this.rawData.id, this.rawData.token),
161
- {
162
- body: {
163
- type: InteractionResponseType.ChannelMessageWithSource,
164
- data: {
165
- ...data,
166
- components: data.components?.map((row) => row.serialize()),
167
- ephemeral: options.ephemeral ?? this.defaultEphemeral
168
- }
169
- },
170
- files: options.files
171
- }
172
- )
173
- }
174
- }
175
-
176
- /**
177
- * Defer the interaction response. This is used automatically by commands that are set to defer.
178
- * If the interaction is already deferred, this will do nothing.
179
- * @internal
180
- */
181
- async defer() {
182
- if (this._deferred) return
183
- this._deferred = true
184
- await this.client.rest.post(
185
- Routes.interactionCallback(this.rawData.id, this.rawData.token),
186
- {
187
- body: {
188
- type: InteractionResponseType.DeferredChannelMessageWithSource,
189
- ephemeral: this.defaultEphemeral
190
- }
191
- }
192
- )
193
- }
194
-
195
- async showModal(modal: Modal) {
196
- if (this._deferred)
197
- throw new Error("You cannot defer an interaction that shows a modal")
198
- this.client.modalHandler.registerModal(modal)
199
- await this.client.rest.post(
200
- Routes.interactionCallback(this.rawData.id, this.rawData.token),
201
- {
202
- body: {
203
- type: InteractionResponseType.Modal,
204
- data: modal.serialize()
205
- }
206
- }
207
- )
208
- }
209
- }
@@ -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
- }