@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,231 +0,0 @@
1
- import type { APIGuildMember, GuildMemberFlags } from "discord-api-types/v10"
2
- import { Base } from "../abstracts/Base.js"
3
- import type { Client } from "../classes/Client.js"
4
- import type { Guild } from "./Guild.js"
5
- import { Role } from "./Role.js"
6
- import { User } from "./User.js"
7
-
8
- export class GuildMember extends Base {
9
- /**
10
- * The guild-specific nickname of the member.
11
- */
12
- nickname?: string | null
13
- /**
14
- * The guild-specific avatar hash of the member.
15
- * You can use {@link GuildMember.avatarUrl} to get the URL of the avatar.
16
- */
17
- avatar?: string | null
18
- /**
19
- * Is this member muted in Voice Channels?
20
- */
21
- mute?: boolean | null
22
- /**
23
- * Is this member deafened in Voice Channels?
24
- */
25
- deaf?: boolean | null
26
- /**
27
- * The date since this member boosted the guild, if applicable.
28
- */
29
- premiumSince?: string | null
30
- /**
31
- * The flags of the member.
32
- * @see https://discord.com/developers/docs/resources/guild#guild-member-object-guild-member-flags
33
- */
34
- flags?: GuildMemberFlags | null
35
- /**
36
- * The roles of the member
37
- */
38
- roles?: Role[] | null
39
- /**
40
- * The joined date of the member
41
- */
42
- joinedAt?: string | null
43
- /**
44
- * The date when the member's communication privileges (timeout) will be reinstated
45
- */
46
- communicationDisabledUntil?: string | null
47
- /**
48
- * Is this member yet to pass the guild's Membership Screening requirements?
49
- */
50
- pending?: boolean | null
51
- /**
52
- * The guild object of the member
53
- */
54
- guild: Guild
55
- /**
56
- * The user object of the member
57
- */
58
- user?: User | null
59
-
60
- private rawData: APIGuildMember | null = null
61
-
62
- constructor(client: Client, rawData: APIGuildMember, guild: Guild) {
63
- super(client)
64
- this.rawData = rawData
65
- this.guild = guild
66
- this.setData(rawData)
67
- }
68
-
69
- private setData(data: typeof this.rawData) {
70
- if (!data) throw new Error("Cannot set data without having data... smh")
71
- this.rawData = data
72
- this.nickname = data.nick
73
- this.avatar = data.avatar
74
- this.mute = data.mute
75
- this.deaf = data.deaf
76
- this.premiumSince = data.premium_since
77
- this.flags = data.flags
78
- this.roles = data.roles?.map((roleId) => new Role(this.client, roleId))
79
- this.joinedAt = data.joined_at
80
- this.communicationDisabledUntil = data.communication_disabled_until
81
- this.pending = data.pending
82
- this.user = data.user ? new User(this.client, data.user) : null
83
- }
84
-
85
- /**
86
- * Set the nickname of the member
87
- */
88
- async setNickname(nickname: string | null): Promise<void> {
89
- await this.client.rest.patch(
90
- `/guilds/${this.guild?.id}/members/${this.user?.id}`,
91
- {
92
- body: {
93
- nick: nickname
94
- }
95
- }
96
- )
97
- this.nickname = nickname
98
- }
99
-
100
- /**
101
- * Add a role to the member
102
- */
103
- async addRole(roleId: string): Promise<void> {
104
- await this.client.rest.put(
105
- `/guilds/${this.guild?.id}/members/${this.user?.id}/roles/${roleId}`,
106
- {}
107
- )
108
- this.roles?.push(new Role(this.client, roleId))
109
- }
110
-
111
- /**
112
- * Remove a role from the member
113
- */
114
- async removeRole(roleId: string): Promise<void> {
115
- await this.client.rest.delete(
116
- `/guilds/${this.guild?.id}/members/${this.user?.id}/roles/${roleId}`
117
- )
118
- this.roles = this.roles?.filter((role) => role.id !== roleId)
119
- }
120
-
121
- /**
122
- * Kick the member from the guild
123
- */
124
- async kick(): Promise<void> {
125
- await this.client.rest.delete(
126
- `/guilds/${this.guild?.id}/members/${this.user?.id}`
127
- )
128
- }
129
-
130
- /**
131
- * Ban the member from the guild
132
- */
133
- async ban(
134
- options: { reason?: string; deleteMessageDays?: number } = {}
135
- ): Promise<void> {
136
- await this.client.rest.put(
137
- `/guilds/${this.guild?.id}/bans/${this.user?.id}`,
138
- {
139
- body: {
140
- reason: options.reason,
141
- delete_message_days: options.deleteMessageDays
142
- }
143
- }
144
- )
145
- }
146
-
147
- /**
148
- * Mute a member in voice channels
149
- */
150
- async muteMember(): Promise<void> {
151
- await this.client.rest.patch(
152
- `/guilds/${this.guild?.id}/members/${this.user?.id}`,
153
- {
154
- body: {
155
- mute: true
156
- }
157
- }
158
- )
159
- this.mute = true
160
- }
161
-
162
- /**
163
- * Unmute a member in voice channels
164
- */
165
- async unmuteMember(): Promise<void> {
166
- await this.client.rest.patch(
167
- `/guilds/${this.guild?.id}/members/${this.user?.id}`,
168
- {
169
- body: {
170
- mute: false
171
- }
172
- }
173
- )
174
- this.mute = false
175
- }
176
-
177
- /**
178
- * Deafen a member in voice channels
179
- */
180
- async deafenMember(): Promise<void> {
181
- await this.client.rest.patch(
182
- `/guilds/${this.guild?.id}/members/${this.user?.id}`,
183
- {
184
- body: {
185
- deaf: true
186
- }
187
- }
188
- )
189
- this.deaf = true
190
- }
191
-
192
- /**
193
- * Undeafen a member in voice channels
194
- */
195
- async undeafenMember(): Promise<void> {
196
- await this.client.rest.patch(
197
- `/guilds/${this.guild?.id}/members/${this.user?.id}`,
198
- {
199
- body: {
200
- deaf: false
201
- }
202
- }
203
- )
204
- this.deaf = false
205
- }
206
-
207
- /**
208
- * Set or remove a timeout for a member in the guild
209
- */
210
- async timeoutMember(communicationDisabledUntil: string): Promise<void> {
211
- await this.client.rest.patch(
212
- `/guilds/${this.guild?.id}/members/${this.user?.id}`,
213
- {
214
- body: {
215
- communication_disabled_until: communicationDisabledUntil
216
- }
217
- }
218
- )
219
- this.communicationDisabledUntil = communicationDisabledUntil
220
- }
221
-
222
- /**
223
- * Get the URL of the member's guild-specific avatar
224
- */
225
- get avatarUrl(): string | null {
226
- if (!this.user) return null
227
- return this.avatar
228
- ? `https://cdn.discordapp.com/guilds/${this.guild.id}/users/${this.user?.id}/${this.avatar}.png`
229
- : null
230
- }
231
- }
@@ -1,46 +0,0 @@
1
- import type {
2
- APIGuildStageVoiceChannel,
3
- APIGuildVoiceChannel,
4
- ChannelType,
5
- VideoQualityMode
6
- } from "discord-api-types/v10"
7
- import { BaseGuildChannel } from "../abstracts/BaseGuildChannel.js"
8
-
9
- export abstract class GuildStageOrVoiceChannel<
10
- Type extends ChannelType.GuildStageVoice | ChannelType.GuildVoice
11
- > extends BaseGuildChannel<Type> {
12
- /**
13
- * The bitrate of the channel.
14
- */
15
- bitrate?: number | null
16
- /**
17
- * The user limit of the channel.
18
- */
19
- userLimit?: number | null
20
- /**
21
- * The RTC region of the channel.
22
- * This is automatic when set to `null`.
23
- */
24
- rtcRegion?: string | null
25
- /**
26
- * The video quality mode of the channel.
27
- * 1 when not present.
28
- */
29
- videoQualityMode?: VideoQualityMode | null
30
-
31
- protected setSpecificData(
32
- data: APIGuildStageVoiceChannel | APIGuildVoiceChannel
33
- ) {
34
- this.bitrate = data.bitrate
35
- this.userLimit = data.user_limit
36
- this.rtcRegion = data.rtc_region
37
- this.videoQualityMode = data.video_quality_mode
38
- }
39
- }
40
-
41
- export class GuildStageChannel extends BaseGuildChannel<ChannelType.GuildStageVoice> {
42
- protected setSpecificData() {}
43
- }
44
- export class GuildVoiceChannel extends BaseGuildChannel<ChannelType.GuildVoice> {
45
- protected setSpecificData() {}
46
- }
@@ -1,21 +0,0 @@
1
- import { type APIGuildTextChannel, ChannelType } from "discord-api-types/v10"
2
- import { BaseGuildTextChannel } from "../abstracts/BaseGuildTextChannel.js"
3
-
4
- export class GuildTextChannel extends BaseGuildTextChannel<ChannelType.GuildText> {
5
- type: ChannelType.GuildText = ChannelType.GuildText
6
- /**
7
- * The default auto archive duration of threads in the channel.
8
- */
9
- defaultAutoArchiveDuration?: number | null
10
- /**
11
- * The default thread rate limit per user of the channel.
12
- */
13
- defaultThreadRateLimitPerUser?: number | null
14
-
15
- protected setMoreSpecificData(
16
- data: APIGuildTextChannel<ChannelType.GuildText>
17
- ) {
18
- this.defaultAutoArchiveDuration = data.default_auto_archive_duration
19
- this.defaultThreadRateLimitPerUser = data.default_thread_rate_limit_per_user
20
- }
21
- }
@@ -1,150 +0,0 @@
1
- import {
2
- type APIThreadChannel,
3
- Routes,
4
- type ThreadChannelType
5
- } from "discord-api-types/v10"
6
- import { BaseGuildChannel } from "../abstracts/BaseGuildChannel.js"
7
-
8
- export class GuildThreadChannel<
9
- Type extends ThreadChannelType
10
- > extends BaseGuildChannel<Type> {
11
- /**
12
- * Whether the thread is archived.
13
- */
14
- archived?: boolean
15
- /**
16
- * The duration until the thread is auto archived.
17
- */
18
- autoArchiveDuration?: number
19
- /**
20
- * The timestamp of when the thread was archived.
21
- */
22
- archiveTimestamp?: string
23
- /**
24
- * Whether the thread is locked.
25
- */
26
- locked?: boolean
27
- /**
28
- * Whether non-moderators can add other non-moderators to a thread; only available on private threads
29
- */
30
- invitable?: boolean
31
- /**
32
- * The timestamp of when the thread was created.
33
- */
34
- createTimestamp?: string
35
- /**
36
- * The number of messages in the thread.
37
- */
38
- messageCount?: number
39
- /**
40
- * The number of members in the thread.
41
- *
42
- * @remarks
43
- * This is only accurate until 50, after that, Discord stops counting.
44
- */
45
- memberCount?: number
46
- /**
47
- * The ID of the owner of the thread.
48
- */
49
- ownerId?: string
50
- /**
51
- * The number of messages sent in the thread.
52
- */
53
- totalMessageSent?: number
54
- /**
55
- * The tags applied to the thread.
56
- */
57
- appliedTags?: string[]
58
-
59
- protected setSpecificData(data: APIThreadChannel) {
60
- this.archived = data.thread_metadata?.archived
61
- this.autoArchiveDuration = data.thread_metadata?.auto_archive_duration
62
- this.archiveTimestamp = data.thread_metadata?.archive_timestamp
63
- this.locked = data.thread_metadata?.locked
64
- this.invitable = data.thread_metadata?.invitable
65
- this.createTimestamp = data.thread_metadata?.create_timestamp
66
- this.messageCount = data.message_count
67
- this.memberCount = data.member_count
68
- this.ownerId = data.owner_id
69
- this.totalMessageSent = data.total_message_sent
70
- this.appliedTags = data.applied_tags
71
- }
72
-
73
- /**
74
- * Join the thread
75
- */
76
- async join() {
77
- await this.addMember("@me")
78
- }
79
-
80
- /**
81
- * Add a member to the thread
82
- */
83
- async addMember(userId: string) {
84
- await this.client.rest.put(Routes.threadMembers(this.id, userId))
85
- }
86
-
87
- /**
88
- * Leave the thread
89
- */
90
- async leave() {
91
- await this.removeMember("@me")
92
- }
93
-
94
- /**
95
- * Get the pinned messages in the thread
96
- */
97
- async removeMember(userId: string) {
98
- await this.client.rest.delete(Routes.threadMembers(this.id, userId))
99
- }
100
-
101
- /**
102
- * Archive the thread
103
- */
104
- async archive() {
105
- await this.client.rest.patch(Routes.channel(this.id), {
106
- body: { archive: true }
107
- })
108
- this.archived = true
109
- }
110
-
111
- /**
112
- * Unarchive the thread
113
- */
114
- async unarchive() {
115
- await this.client.rest.patch(Routes.channel(this.id), {
116
- body: { archive: false }
117
- })
118
- this.archived = false
119
- }
120
-
121
- /**
122
- * Set the auto archive duration of the thread
123
- */
124
- async setAutoArchiveDuration(duration: number) {
125
- await this.client.rest.patch(Routes.channel(this.id), {
126
- body: { auto_archive_duration: duration }
127
- })
128
- this.autoArchiveDuration = duration
129
- }
130
-
131
- /**
132
- * Lock the thread
133
- */
134
- async lock() {
135
- await this.client.rest.put(Routes.channel(this.id), {
136
- body: { locked: true }
137
- })
138
- this.locked = true
139
- }
140
-
141
- /**
142
- * Unlock the thread
143
- */
144
- async unlock() {
145
- await this.client.rest.put(Routes.channel(this.id), {
146
- body: { locked: false }
147
- })
148
- this.locked = false
149
- }
150
- }
@@ -1,124 +0,0 @@
1
- import {
2
- type APIChannel,
3
- type APIMessage,
4
- type APIThreadChannel,
5
- type RESTPostAPIChannelThreadsJSONBody,
6
- Routes
7
- } from "discord-api-types/v10"
8
- import { Base } from "../abstracts/Base.js"
9
- import type { Client } from "../classes/Client.js"
10
- import { channelFactory } from "../factories/channelFactory.js"
11
- import { GuildThreadChannel } from "./GuildThreadChannel.js"
12
- import { User } from "./User.js"
13
-
14
- export class Message extends Base {
15
- /**
16
- * The ID of the message
17
- */
18
- id: string
19
- /**
20
- * The ID of the channel the message is in
21
- */
22
- channelId: string
23
- /**
24
- * Whether the message is a partial message (meaning it does not have all the data).
25
- * If this is true, you should use {@link Message.fetch} to get the full data of the message.
26
- */
27
- partial: boolean
28
-
29
- private rawData: APIMessage | null = null
30
-
31
- constructor(
32
- client: Client,
33
- rawDataOrIds:
34
- | APIMessage
35
- | {
36
- id: string
37
- channel_id: string
38
- }
39
- ) {
40
- super(client)
41
- this.id = rawDataOrIds.id
42
- this.channelId = rawDataOrIds.channel_id
43
- if (Object.keys(rawDataOrIds).length === 2) {
44
- this.partial = true
45
- } else {
46
- this.partial = false
47
- this.setData(rawDataOrIds as APIMessage)
48
- }
49
- }
50
-
51
- private setData(data: typeof this.rawData) {
52
- this.rawData = data
53
- if (!data) throw new Error("Cannot set data without having data... smh")
54
- }
55
-
56
- /**
57
- * Fetch updated data for this message.
58
- * If the message is partial, this will fetch all the data for the message and populate the fields.
59
- * If the message is not partial, all fields will be updated with new values from Discord.
60
- */
61
- async fetch() {
62
- const newData = (await this.client.rest.get(
63
- Routes.channelMessage(this.channelId, this.id)
64
- )) as APIMessage
65
- if (!newData) throw new Error(`Message ${this.id} not found`)
66
-
67
- this.setData(newData)
68
- }
69
-
70
- /**
71
- * Delete this message from Discord
72
- */
73
- async delete() {
74
- return await this.client.rest.delete(
75
- Routes.channelMessage(this.channelId, this.id)
76
- )
77
- }
78
-
79
- get author(): User | null {
80
- if (this.rawData?.webhook_id) return null // TODO: Add webhook user
81
- // Check if we have an additional property on the author object, in which case we have a full user object
82
- if (this.rawData?.author.username)
83
- return new User(this.client, this.rawData.author)
84
- // This means we only have a partial user object
85
- if (this.rawData?.author.id)
86
- return new User(this.client, this.rawData.author.id)
87
- return null
88
- }
89
-
90
- async fetchChannel() {
91
- const data = (await this.client.rest.get(
92
- Routes.channel(this.channelId)
93
- )) as APIChannel
94
- return channelFactory(this.client, data)
95
- }
96
-
97
- /**
98
- * Pin this message
99
- */
100
- async pin() {
101
- await this.client.rest.put(Routes.channelPin(this.channelId, this.id))
102
- }
103
-
104
- /**
105
- * Unpin this message
106
- */
107
- async unpin() {
108
- await this.client.rest.delete(Routes.channelPin(this.channelId, this.id))
109
- }
110
-
111
- /**
112
- * Start a thread with this message as the associated start message.
113
- * If you want to start a thread without a start message, use {@link BaseGuildTextChannel.startThread}
114
- */
115
- async startThread(data: RESTPostAPIChannelThreadsJSONBody) {
116
- const thread = (await this.client.rest.post(
117
- Routes.threads(this.channelId, this.id),
118
- {
119
- body: { ...data }
120
- }
121
- )) as APIThreadChannel
122
- return new GuildThreadChannel(this.client, thread)
123
- }
124
- }