@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,148 +0,0 @@
1
- import {
2
- type APIApplicationCommandInteractionDataBasicOption,
3
- type APIChannel,
4
- ApplicationCommandOptionType,
5
- Routes
6
- } from "discord-api-types/v10"
7
- import { Base } from "../abstracts/Base.js"
8
- import { type Client, Role, User, channelFactory } from "../index.js"
9
-
10
- export type RawOptions = {
11
- [key: string]:
12
- | APIApplicationCommandInteractionDataBasicOption["value"]
13
- | undefined
14
- }
15
-
16
- /**
17
- * This class is used to parse the options of a command, and provide errors for any missing or invalid options.
18
- * It is used internally by the Command class.
19
- */
20
- export class OptionsHandler extends Base {
21
- /**
22
- * The raw options that were in the interaction data, before they were parsed.
23
- */
24
- readonly raw: APIApplicationCommandInteractionDataBasicOption[]
25
- /**
26
- * The errors that were encountered while parsing the options.
27
- */
28
- readonly errors: Array<string> = []
29
-
30
- constructor(
31
- client: Client,
32
- options: APIApplicationCommandInteractionDataBasicOption[]
33
- ) {
34
- super(client)
35
- this.raw = options
36
- }
37
-
38
- /**
39
- * Get the value of a string option.
40
- * @param key The name of the option to get the value of.
41
- * @returns The value of the option, or undefined if the option was not provided.
42
- */
43
- public getString(key: string) {
44
- const value = this.raw.find(
45
- (x) => x.name === key && x.type === ApplicationCommandOptionType.String
46
- )?.value
47
- if (!value || typeof value !== "string") return undefined
48
- return value
49
- }
50
-
51
- /**
52
- * Get the value of an integer option.
53
- * @param key The name of the option to get the value of.
54
- * @returns The value of the option, or undefined if the option was not provided.
55
- */
56
- public getInteger(key: string) {
57
- const num = this.raw.find(
58
- (x) => x.name === key && x.type === ApplicationCommandOptionType.Integer
59
- )?.value
60
- if (!num || typeof num !== "number" || !Number.isSafeInteger(num))
61
- return undefined
62
- return num
63
- }
64
-
65
- /**
66
- * Get the value of a number option.
67
- * @param key The name of the option to get the value of.
68
- * @returns The value of the option, or undefined if the option was not provided.
69
- */
70
- public getNumber(key: string) {
71
- const value = this.raw.find(
72
- (x) => x.name === key && x.type === ApplicationCommandOptionType.Number
73
- )?.value
74
- if (!value || typeof value !== "number") return undefined
75
- return value
76
- }
77
-
78
- /**
79
- * Get the value of a boolean option.
80
- * @param key The name of the option to get the value of.
81
- * @returns The value of the option, or undefined if the option was not provided.
82
- */
83
- public getBoolean(key: string) {
84
- const value = this.raw.find(
85
- (x) => x.name === key && x.type === ApplicationCommandOptionType.Boolean
86
- )?.value
87
- if (!value || typeof value !== "boolean") return undefined
88
- return value
89
- }
90
-
91
- /**
92
- * Get the value of a user option.
93
- * @param key The name of the option to get the value of.
94
- * @returns The value of the option, or undefined if the option was not provided.
95
- */
96
- public getUser(key: string) {
97
- const id = this.raw.find(
98
- (x) => x.name === key && x.type === ApplicationCommandOptionType.User
99
- )?.value
100
- if (!id || typeof id !== "string") return undefined
101
- return new User(this.client, id)
102
- }
103
-
104
- /**
105
- * Get the value of a channel option.
106
- * @param key The name of the option to get the value of.
107
- * @returns The value of the option, or undefined if the option was not provided.
108
- */
109
- public async getChannel(key: string) {
110
- const id = this.raw.find(
111
- (x) => x.name === key && x.type === ApplicationCommandOptionType.Channel
112
- )?.value
113
- if (!id || typeof id !== "string") return undefined
114
- const data = (await this.client.rest.get(Routes.channel(id))) as APIChannel
115
- return channelFactory(this.client, data)
116
- }
117
-
118
- /**
119
- * Get the value of a role option.
120
- * @param key The name of the option to get the value of.
121
- * @returns The value of the option, or undefined if the option was not provided.
122
- */
123
- public getRole(key: string): Role | undefined {
124
- const id = this.raw.find(
125
- (x) => x.name === key && x.type === ApplicationCommandOptionType.Role
126
- )?.value
127
- if (!id || typeof id !== "string") return undefined
128
- return new Role(this.client, id)
129
- }
130
-
131
- /**
132
- * Get the value of a mentionable option.
133
- * @param key The name of the option to get the value of.
134
- * @returns The value of the option, or undefined if the option was not provided.
135
- */
136
- public async getMentionable(key: string): Promise<User | Role | undefined> {
137
- const id = this.raw.find(
138
- (x) =>
139
- x.name === key && x.type === ApplicationCommandOptionType.Mentionable
140
- )?.value
141
- if (!id || typeof id !== "string") return undefined
142
- const user = new User(this.client, id)
143
- await user.fetch().catch(() => {
144
- return new Role(this.client, id)
145
- })
146
- return user
147
- }
148
- }
@@ -1,20 +0,0 @@
1
- import {
2
- type APIMessageComponentSelectMenuInteraction,
3
- type APIMessageRoleSelectInteractionData,
4
- ComponentType
5
- } from "discord-api-types/v10"
6
- import { AnySelectMenuInteraction } from "../abstracts/AnySelectMenuInteraction.js"
7
- import type { Client } from "../classes/Client.js"
8
-
9
- export class RoleSelectMenuInteraction extends AnySelectMenuInteraction {
10
- constructor(client: Client, data: APIMessageComponentSelectMenuInteraction) {
11
- super(client, data)
12
- if (data.data.component_type !== ComponentType.RoleSelect) {
13
- throw new Error("Invalid component type was used to create this class")
14
- }
15
- }
16
-
17
- get values(): string[] {
18
- return (this.rawData.data as APIMessageRoleSelectInteractionData).values
19
- }
20
- }
@@ -1,20 +0,0 @@
1
- import {
2
- type APIMessageComponentSelectMenuInteraction,
3
- type APIMessageStringSelectInteractionData,
4
- ComponentType
5
- } from "discord-api-types/v10"
6
- import { AnySelectMenuInteraction } from "../abstracts/AnySelectMenuInteraction.js"
7
- import type { Client } from "../classes/Client.js"
8
-
9
- export class StringSelectMenuInteraction extends AnySelectMenuInteraction {
10
- constructor(client: Client, data: APIMessageComponentSelectMenuInteraction) {
11
- super(client, data)
12
- if (data.data.component_type !== ComponentType.StringSelect) {
13
- throw new Error("Invalid component type was used to create this class")
14
- }
15
- }
16
-
17
- get values(): string[] {
18
- return (this.rawData.data as APIMessageStringSelectInteractionData).values
19
- }
20
- }
@@ -1,20 +0,0 @@
1
- import {
2
- type APIMessageComponentSelectMenuInteraction,
3
- type APIMessageUserSelectInteractionData,
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 UserSelectMenuInteraction extends AnySelectMenuInteraction {
10
- constructor(client: Client, data: APIMessageComponentSelectMenuInteraction) {
11
- super(client, data)
12
- if (data.data.component_type !== ComponentType.UserSelect) {
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 APIMessageUserSelectInteractionData).values
19
- }
20
- }
@@ -1,31 +0,0 @@
1
- import {
2
- type APIDMChannel,
3
- type APIMessage,
4
- ChannelType,
5
- Routes
6
- } from "discord-api-types/v10"
7
- import { BaseChannel } from "../abstracts/BaseChannel.js"
8
-
9
- /**
10
- * Represents a DM between two users.
11
- */
12
- export class DmChannel extends BaseChannel<ChannelType.DM> {
13
- /**
14
- * The name of the channel. This is always null for DM channels.
15
- */
16
- name?: null = null
17
- type: ChannelType.DM = ChannelType.DM
18
-
19
- protected setSpecificData(data: APIDMChannel) {
20
- this.name = data.name
21
- }
22
-
23
- /**
24
- * Send a message to the channel
25
- */
26
- async send(message: APIMessage) {
27
- this.client.rest.post(Routes.channelMessages(this.id), {
28
- body: { ...message }
29
- })
30
- }
31
- }
@@ -1,132 +0,0 @@
1
- import {
2
- type APIGroupDMChannel,
3
- ChannelType,
4
- Routes
5
- } from "discord-api-types/v10"
6
- import { BaseChannel } from "../abstracts/BaseChannel.js"
7
- import { Message } from "./Message.js"
8
- import { User } from "./User.js"
9
-
10
- /**
11
- * Represents a group DM channel.
12
- */
13
- export class GroupDmChannel extends BaseChannel<ChannelType.GroupDM> {
14
- /**
15
- * The name of the channel.
16
- */
17
- name?: string | null
18
- /**
19
- * The recipients of the channel.
20
- */
21
- recipients?: User[]
22
- type: ChannelType.GroupDM = ChannelType.GroupDM
23
- /**
24
- * The ID of the application that created the channel, if it was created by a bot.
25
- */
26
- applicationId?: string | null
27
- /**
28
- * The icon hash of the channel.
29
- */
30
- icon?: string | null
31
- /**
32
- * The ID of the user who created the channel.
33
- */
34
- ownerId?: string | null
35
- /**
36
- * The ID of the last message sent in the channel.
37
- *
38
- * @remarks
39
- * 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.
40
- */
41
- lastMessageId?: string | null
42
- /**
43
- * Whether the channel is managed by an Oauth2 application.
44
- */
45
- managed?: boolean | null
46
-
47
- protected setSpecificData(data: APIGroupDMChannel) {
48
- this.name = data.name
49
- this.recipients = data.recipients?.map((x) => new User(this.client, x))
50
- this.applicationId = data.application_id
51
- this.icon = data.icon
52
- this.ownerId = data.owner_id
53
- this.lastMessageId = data.last_message_id
54
- this.managed = data.managed
55
- }
56
-
57
- /**
58
- * Get the URL of the channel's icon.
59
- */
60
- get iconUrl(): string | null {
61
- return this.icon
62
- ? `https://cdn.discordapp.com/channel-icons/${this.id}/${this.icon}.png`
63
- : null
64
- }
65
-
66
- /**
67
- * Get the owner of the channel.
68
- */
69
- get owner(): User {
70
- if (!this.ownerId) throw new Error("Cannot get owner without owner ID")
71
- return new User(this.client, this.ownerId)
72
- }
73
-
74
- /**
75
- * The last message sent in the channel.
76
- *
77
- * @remarks
78
- * 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.
79
- * This will always return a partial message, so you can use {@link Message.fetch} to get the full message data.
80
- *
81
- */
82
- get lastMessage() {
83
- if (!this.lastMessageId) return null
84
- return new Message(this.client, {
85
- id: this.lastMessageId,
86
- channel_id: this.id
87
- })
88
- }
89
-
90
- /**
91
- * Set the name of the channel
92
- * @param name The new name of the channel
93
- */
94
- async setName(name: string) {
95
- await this.client.rest.patch(Routes.channel(this.id), {
96
- body: {
97
- name
98
- }
99
- })
100
- this.name = name
101
- }
102
-
103
- async addRecipient(user: User | string) {
104
- await this.client.rest.put(
105
- Routes.channelRecipient(
106
- this.id,
107
- typeof user === "string" ? user : user.id
108
- )
109
- )
110
- if (this.recipients)
111
- this.recipients.push(
112
- typeof user === "string" ? new User(this.client, user) : user
113
- )
114
- else
115
- this.recipients = [
116
- typeof user === "string" ? new User(this.client, user) : user
117
- ]
118
- }
119
-
120
- async removeRecipient(user: User | string) {
121
- await this.client.rest.delete(
122
- Routes.channelRecipient(
123
- this.id,
124
- typeof user === "string" ? user : user.id
125
- )
126
- )
127
- if (this.recipients)
128
- this.recipients = this.recipients.filter(
129
- (x) => x.id !== (typeof user === "string" ? user : user.id)
130
- )
131
- }
132
- }
@@ -1,154 +0,0 @@
1
- import {
2
- type APIChannel,
3
- type APIGuild,
4
- type APIGuildMember,
5
- type APIRole,
6
- type RESTPostAPIGuildRoleJSONBody,
7
- Routes
8
- } from "discord-api-types/v10"
9
- import { Base } from "../abstracts/Base.js"
10
- import type { Client } from "../classes/Client.js"
11
- import { channelFactory } from "../factories/channelFactory.js"
12
- import { GuildMember } from "./GuildMember.js"
13
- import { Role } from "./Role.js"
14
-
15
- export class Guild extends Base {
16
- /**
17
- * The ID of the guild
18
- */
19
- id: string
20
- /**
21
- * The name of the guild.
22
- */
23
- name?: string
24
- /**
25
- * The description of the guild.
26
- */
27
- description?: string | null
28
- /**
29
- * The icon hash of the guild.
30
- * You can use {@link Guild.iconUrl} to get the URL of the icon.
31
- */
32
- icon?: string | null
33
- /**
34
- * The splash hash of the guild.
35
- * You can use {@link Guild.splashUrl} to get the URL of the splash.
36
- */
37
- splash?: string | null
38
- /**
39
- * The ID of the owner of the guild.
40
- */
41
- ownerId?: string
42
-
43
- /**
44
- * Whether the guild is a partial guild (meaning it does not have all the data).
45
- * If this is true, you should use {@link Guild.fetch} to get the full data of the guild.
46
- */
47
- partial: boolean
48
-
49
- private rawData: APIGuild | null = null
50
-
51
- constructor(client: Client, rawDataOrId: APIGuild | string) {
52
- super(client)
53
- if (typeof rawDataOrId === "string") {
54
- this.id = rawDataOrId
55
- this.partial = true
56
- } else {
57
- this.rawData = rawDataOrId
58
- this.id = rawDataOrId.id
59
- this.partial = false
60
- this.setData(rawDataOrId)
61
- }
62
- }
63
-
64
- private setData(data: typeof this.rawData) {
65
- if (!data) throw new Error("Cannot set data without having data... smh")
66
- this.rawData = data
67
- this.name = data.name
68
- this.description = data.description
69
- this.icon = data.icon
70
- this.splash = data.splash
71
- this.ownerId = data.owner_id
72
- this.partial = false
73
- }
74
-
75
- /**
76
- * Fetch updated data for this guild.
77
- * If the guild is partial, this will fetch all the data for the guild and populate the fields.
78
- * If the guild is not partial, all fields will be updated with new values from Discord.
79
- */
80
- async fetch() {
81
- const newData = (await this.client.rest.get(
82
- Routes.guild(this.id)
83
- )) as APIGuild
84
- if (!newData) throw new Error(`Guild ${this.id}not found`)
85
-
86
- this.setData(newData)
87
- }
88
-
89
- /**
90
- * Leave the guild
91
- */
92
- async leave() {
93
- return await this.client.rest.delete(Routes.guild(this.id))
94
- }
95
-
96
- /**
97
- * Create a role in the guild
98
- */
99
- async createRole(data: RESTPostAPIGuildRoleJSONBody) {
100
- const role = (await this.client.rest.post(Routes.guildRoles(this.id), {
101
- body: {
102
- ...data
103
- }
104
- })) as APIRole
105
- return new Role(this.client, role)
106
- }
107
-
108
- /**
109
- * Get a member in the guild by ID
110
- */
111
- async fetchMember(memberId: string) {
112
- const member = (await this.client.rest.get(
113
- Routes.guildMember(this.id, memberId)
114
- )) as APIGuildMember
115
- return new GuildMember(this.client, member, this)
116
- }
117
-
118
- /**
119
- * Get the URL of the guild's icon
120
- */
121
- get iconUrl(): string | null {
122
- return this.icon
123
- ? `https://cdn.discordapp.com/icons/${this.id}/${this.icon}.png`
124
- : null
125
- }
126
-
127
- /**
128
- * Get the URL of the guild's splash
129
- */
130
- get splashUrl(): string | null {
131
- return this.splash
132
- ? `https://cdn.discordapp.com/splashes/${this.id}/${this.splash}.png`
133
- : null
134
- }
135
-
136
- /**
137
- * Get all roles in the guild
138
- */
139
- get roles() {
140
- const roles = this.rawData?.roles
141
- if (!roles) throw new Error("Cannot get roles without having data... smh")
142
- return roles.map((role) => new Role(this.client, role))
143
- }
144
-
145
- /**
146
- * Fetch a channel from the guild by ID
147
- */
148
- async fetchChannel(channelId: string) {
149
- const channel = (await this.client.rest.get(
150
- Routes.channel(channelId)
151
- )) as APIChannel
152
- return channelFactory(this.client, channel)
153
- }
154
- }
@@ -1,20 +0,0 @@
1
- import { ChannelType, Routes } from "discord-api-types/v10"
2
- import { BaseGuildTextChannel } from "../abstracts/BaseGuildTextChannel.js"
3
- import type { GuildTextChannel } from "./GuildTextChannel.js"
4
-
5
- /**
6
- * Represents a guild announcement channel.
7
- */
8
- export class GuildAnnouncementChannel extends BaseGuildTextChannel<ChannelType.GuildAnnouncement> {
9
- type: ChannelType.GuildAnnouncement = ChannelType.GuildAnnouncement
10
- protected setMoreSpecificData() {}
11
-
12
- async follow(targetChannel: GuildTextChannel | string) {
13
- await this.client.rest.put(Routes.channelFollowers(this.id), {
14
- body: {
15
- webhook_channel_id:
16
- typeof targetChannel === "string" ? targetChannel : targetChannel.id
17
- }
18
- })
19
- }
20
- }
@@ -1,16 +0,0 @@
1
- import type { ChannelType } from "discord-api-types/v10"
2
- import { BaseGuildChannel } from "../abstracts/BaseGuildChannel.js"
3
-
4
- /**
5
- * Represents a guild category channel.
6
- */
7
- export class GuildCategoryChannel extends BaseGuildChannel<ChannelType.GuildCategory> {
8
- protected setSpecificData() {}
9
-
10
- /**
11
- * You cannot send a message to a category channel, so this method throws an error
12
- */
13
- override async send(): Promise<void> {
14
- throw new Error("Category channels cannot be sent to")
15
- }
16
- }
@@ -1,20 +0,0 @@
1
- import type {
2
- APIGuildForumChannel,
3
- ChannelType,
4
- ForumLayoutType
5
- } from "discord-api-types/v10"
6
- import { GuildThreadOnlyChannel } from "../abstracts/GuildThreadOnlyChannel.js"
7
-
8
- /**
9
- * Represents a guild forum channel.
10
- */
11
- export class GuildForumChannel extends GuildThreadOnlyChannel<ChannelType.GuildForum> {
12
- /**
13
- * The default forum layout of the channel.
14
- */
15
- defaultForumLayout?: ForumLayoutType
16
-
17
- protected setMoreSpecificData(data: APIGuildForumChannel) {
18
- this.defaultForumLayout = data.default_forum_layout
19
- }
20
- }
@@ -1,13 +0,0 @@
1
- import type { ChannelType, ForumLayoutType } from "discord-api-types/v10"
2
- import { GuildThreadOnlyChannel } from "../abstracts/GuildThreadOnlyChannel.js"
3
-
4
- /**
5
- * Represents a guild media channel (a forum channel )
6
- */
7
- export class GuildMediaChannel extends GuildThreadOnlyChannel<ChannelType.GuildMedia> {
8
- /**
9
- * The default forum layout of the channel.
10
- */
11
- defaultForumLayout?: ForumLayoutType
12
- protected setMoreSpecificData() {}
13
- }