@buape/carbon 0.0.0-beta-20241008010229

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 (245) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +52 -0
  3. package/dist/package.json +34 -0
  4. package/dist/src/abstracts/AnySelectMenu.d.ts +31 -0
  5. package/dist/src/abstracts/AnySelectMenu.d.ts.map +1 -0
  6. package/dist/src/abstracts/AnySelectMenu.js +19 -0
  7. package/dist/src/abstracts/AnySelectMenu.js.map +1 -0
  8. package/dist/src/abstracts/AnySelectMenuInteraction.d.ts +13 -0
  9. package/dist/src/abstracts/AnySelectMenuInteraction.d.ts.map +1 -0
  10. package/dist/src/abstracts/AnySelectMenuInteraction.js +21 -0
  11. package/dist/src/abstracts/AnySelectMenuInteraction.js.map +1 -0
  12. package/dist/src/abstracts/Base.d.ts +10 -0
  13. package/dist/src/abstracts/Base.d.ts.map +1 -0
  14. package/dist/src/abstracts/Base.js +11 -0
  15. package/dist/src/abstracts/Base.js.map +1 -0
  16. package/dist/src/abstracts/BaseChannel.d.ts +45 -0
  17. package/dist/src/abstracts/BaseChannel.d.ts.map +1 -0
  18. package/dist/src/abstracts/BaseChannel.js +68 -0
  19. package/dist/src/abstracts/BaseChannel.js.map +1 -0
  20. package/dist/src/abstracts/BaseCommand.d.ts +58 -0
  21. package/dist/src/abstracts/BaseCommand.d.ts.map +1 -0
  22. package/dist/src/abstracts/BaseCommand.js +72 -0
  23. package/dist/src/abstracts/BaseCommand.js.map +1 -0
  24. package/dist/src/abstracts/BaseComponent.d.ts +34 -0
  25. package/dist/src/abstracts/BaseComponent.d.ts.map +1 -0
  26. package/dist/src/abstracts/BaseComponent.js +30 -0
  27. package/dist/src/abstracts/BaseComponent.js.map +1 -0
  28. package/dist/src/abstracts/BaseComponentInteraction.d.ts +19 -0
  29. package/dist/src/abstracts/BaseComponentInteraction.d.ts.map +1 -0
  30. package/dist/src/abstracts/BaseComponentInteraction.js +42 -0
  31. package/dist/src/abstracts/BaseComponentInteraction.js.map +1 -0
  32. package/dist/src/abstracts/BaseGuildChannel.d.ts +70 -0
  33. package/dist/src/abstracts/BaseGuildChannel.d.ts.map +1 -0
  34. package/dist/src/abstracts/BaseGuildChannel.js +143 -0
  35. package/dist/src/abstracts/BaseGuildChannel.js.map +1 -0
  36. package/dist/src/abstracts/BaseGuildTextChannel.d.ts +46 -0
  37. package/dist/src/abstracts/BaseGuildTextChannel.d.ts.map +1 -0
  38. package/dist/src/abstracts/BaseGuildTextChannel.js +77 -0
  39. package/dist/src/abstracts/BaseGuildTextChannel.js.map +1 -0
  40. package/dist/src/abstracts/BaseInteraction.d.ts +92 -0
  41. package/dist/src/abstracts/BaseInteraction.d.ts.map +1 -0
  42. package/dist/src/abstracts/BaseInteraction.js +152 -0
  43. package/dist/src/abstracts/BaseInteraction.js.map +1 -0
  44. package/dist/src/abstracts/GuildThreadOnlyChannel.d.ts +43 -0
  45. package/dist/src/abstracts/GuildThreadOnlyChannel.d.ts.map +1 -0
  46. package/dist/src/abstracts/GuildThreadOnlyChannel.js +69 -0
  47. package/dist/src/abstracts/GuildThreadOnlyChannel.js.map +1 -0
  48. package/dist/src/classes/Button.d.ts +49 -0
  49. package/dist/src/classes/Button.d.ts.map +1 -0
  50. package/dist/src/classes/Button.js +61 -0
  51. package/dist/src/classes/Button.js.map +1 -0
  52. package/dist/src/classes/ChannelSelectMenu.d.ts +15 -0
  53. package/dist/src/classes/ChannelSelectMenu.d.ts.map +1 -0
  54. package/dist/src/classes/ChannelSelectMenu.js +15 -0
  55. package/dist/src/classes/ChannelSelectMenu.js.map +1 -0
  56. package/dist/src/classes/Client.d.ts +180 -0
  57. package/dist/src/classes/Client.d.ts.map +1 -0
  58. package/dist/src/classes/Client.js +263 -0
  59. package/dist/src/classes/Client.js.map +1 -0
  60. package/dist/src/classes/Command.d.ts +33 -0
  61. package/dist/src/classes/Command.d.ts.map +1 -0
  62. package/dist/src/classes/Command.js +31 -0
  63. package/dist/src/classes/Command.js.map +1 -0
  64. package/dist/src/classes/CommandWithSubcommandGroups.d.ts +22 -0
  65. package/dist/src/classes/CommandWithSubcommandGroups.d.ts.map +1 -0
  66. package/dist/src/classes/CommandWithSubcommandGroups.js +31 -0
  67. package/dist/src/classes/CommandWithSubcommandGroups.js.map +1 -0
  68. package/dist/src/classes/CommandWithSubcommands.d.ts +19 -0
  69. package/dist/src/classes/CommandWithSubcommands.d.ts.map +1 -0
  70. package/dist/src/classes/CommandWithSubcommands.js +21 -0
  71. package/dist/src/classes/CommandWithSubcommands.js.map +1 -0
  72. package/dist/src/classes/Embed.d.ts +61 -0
  73. package/dist/src/classes/Embed.d.ts.map +1 -0
  74. package/dist/src/classes/Embed.js +75 -0
  75. package/dist/src/classes/Embed.js.map +1 -0
  76. package/dist/src/classes/MentionableSelectMenu.d.ts +13 -0
  77. package/dist/src/classes/MentionableSelectMenu.d.ts.map +1 -0
  78. package/dist/src/classes/MentionableSelectMenu.js +13 -0
  79. package/dist/src/classes/MentionableSelectMenu.js.map +1 -0
  80. package/dist/src/classes/Modal.d.ts +21 -0
  81. package/dist/src/classes/Modal.d.ts.map +1 -0
  82. package/dist/src/classes/Modal.js +14 -0
  83. package/dist/src/classes/Modal.js.map +1 -0
  84. package/dist/src/classes/RoleSelectMenu.d.ts +13 -0
  85. package/dist/src/classes/RoleSelectMenu.d.ts.map +1 -0
  86. package/dist/src/classes/RoleSelectMenu.js +13 -0
  87. package/dist/src/classes/RoleSelectMenu.js.map +1 -0
  88. package/dist/src/classes/Row.d.ts +25 -0
  89. package/dist/src/classes/Row.d.ts.map +1 -0
  90. package/dist/src/classes/Row.js +40 -0
  91. package/dist/src/classes/Row.js.map +1 -0
  92. package/dist/src/classes/StringSelectMenu.d.ts +13 -0
  93. package/dist/src/classes/StringSelectMenu.d.ts.map +1 -0
  94. package/dist/src/classes/StringSelectMenu.js +12 -0
  95. package/dist/src/classes/StringSelectMenu.js.map +1 -0
  96. package/dist/src/classes/TextInput.d.ts +40 -0
  97. package/dist/src/classes/TextInput.d.ts.map +1 -0
  98. package/dist/src/classes/TextInput.js +44 -0
  99. package/dist/src/classes/TextInput.js.map +1 -0
  100. package/dist/src/classes/UserSelectMenu.d.ts +13 -0
  101. package/dist/src/classes/UserSelectMenu.d.ts.map +1 -0
  102. package/dist/src/classes/UserSelectMenu.js +13 -0
  103. package/dist/src/classes/UserSelectMenu.js.map +1 -0
  104. package/dist/src/factories/channelFactory.d.ts +13 -0
  105. package/dist/src/factories/channelFactory.d.ts.map +1 -0
  106. package/dist/src/factories/channelFactory.js +39 -0
  107. package/dist/src/factories/channelFactory.js.map +1 -0
  108. package/dist/src/index.d.ts +55 -0
  109. package/dist/src/index.d.ts.map +1 -0
  110. package/dist/src/index.js +61 -0
  111. package/dist/src/index.js.map +1 -0
  112. package/dist/src/internals/AutocompleteInteraction.d.ts +33 -0
  113. package/dist/src/internals/AutocompleteInteraction.d.ts.map +1 -0
  114. package/dist/src/internals/AutocompleteInteraction.js +61 -0
  115. package/dist/src/internals/AutocompleteInteraction.js.map +1 -0
  116. package/dist/src/internals/ButtonInteraction.d.ts +9 -0
  117. package/dist/src/internals/ButtonInteraction.d.ts.map +1 -0
  118. package/dist/src/internals/ButtonInteraction.js +18 -0
  119. package/dist/src/internals/ButtonInteraction.js.map +1 -0
  120. package/dist/src/internals/ChannelSelectMenuInteraction.d.ts +8 -0
  121. package/dist/src/internals/ChannelSelectMenuInteraction.d.ts.map +1 -0
  122. package/dist/src/internals/ChannelSelectMenuInteraction.js +11 -0
  123. package/dist/src/internals/ChannelSelectMenuInteraction.js.map +1 -0
  124. package/dist/src/internals/CommandHandler.d.ts +12 -0
  125. package/dist/src/internals/CommandHandler.d.ts.map +1 -0
  126. package/dist/src/internals/CommandHandler.js +89 -0
  127. package/dist/src/internals/CommandHandler.js.map +1 -0
  128. package/dist/src/internals/CommandInteraction.d.ts +16 -0
  129. package/dist/src/internals/CommandInteraction.d.ts.map +1 -0
  130. package/dist/src/internals/CommandInteraction.js +23 -0
  131. package/dist/src/internals/CommandInteraction.js.map +1 -0
  132. package/dist/src/internals/ComponentHandler.d.ts +17 -0
  133. package/dist/src/internals/ComponentHandler.d.ts.map +1 -0
  134. package/dist/src/internals/ComponentHandler.js +75 -0
  135. package/dist/src/internals/ComponentHandler.js.map +1 -0
  136. package/dist/src/internals/FieldsHandler.d.ts +27 -0
  137. package/dist/src/internals/FieldsHandler.d.ts.map +1 -0
  138. package/dist/src/internals/FieldsHandler.js +37 -0
  139. package/dist/src/internals/FieldsHandler.js.map +1 -0
  140. package/dist/src/internals/MentionableSelectMenuInteraction.d.ts +9 -0
  141. package/dist/src/internals/MentionableSelectMenuInteraction.d.ts.map +1 -0
  142. package/dist/src/internals/MentionableSelectMenuInteraction.js +15 -0
  143. package/dist/src/internals/MentionableSelectMenuInteraction.js.map +1 -0
  144. package/dist/src/internals/ModalHandler.d.ts +17 -0
  145. package/dist/src/internals/ModalHandler.d.ts.map +1 -0
  146. package/dist/src/internals/ModalHandler.js +25 -0
  147. package/dist/src/internals/ModalHandler.js.map +1 -0
  148. package/dist/src/internals/ModalInteraction.d.ts +22 -0
  149. package/dist/src/internals/ModalInteraction.d.ts.map +1 -0
  150. package/dist/src/internals/ModalInteraction.js +42 -0
  151. package/dist/src/internals/ModalInteraction.js.map +1 -0
  152. package/dist/src/internals/OptionsHandler.d.ts +82 -0
  153. package/dist/src/internals/OptionsHandler.d.ts.map +1 -0
  154. package/dist/src/internals/OptionsHandler.js +127 -0
  155. package/dist/src/internals/OptionsHandler.js.map +1 -0
  156. package/dist/src/internals/RoleSelectMenuInteraction.d.ts +9 -0
  157. package/dist/src/internals/RoleSelectMenuInteraction.d.ts.map +1 -0
  158. package/dist/src/internals/RoleSelectMenuInteraction.js +14 -0
  159. package/dist/src/internals/RoleSelectMenuInteraction.js.map +1 -0
  160. package/dist/src/internals/StringSelectMenuInteraction.d.ts +9 -0
  161. package/dist/src/internals/StringSelectMenuInteraction.d.ts.map +1 -0
  162. package/dist/src/internals/StringSelectMenuInteraction.js +14 -0
  163. package/dist/src/internals/StringSelectMenuInteraction.js.map +1 -0
  164. package/dist/src/internals/UserSelectMenuInteraction.d.ts +9 -0
  165. package/dist/src/internals/UserSelectMenuInteraction.d.ts.map +1 -0
  166. package/dist/src/internals/UserSelectMenuInteraction.js +14 -0
  167. package/dist/src/internals/UserSelectMenuInteraction.js.map +1 -0
  168. package/dist/src/plugins/linked-roles/LinkedRoles.d.ts +49 -0
  169. package/dist/src/plugins/linked-roles/LinkedRoles.d.ts.map +1 -0
  170. package/dist/src/plugins/linked-roles/LinkedRoles.js +164 -0
  171. package/dist/src/plugins/linked-roles/LinkedRoles.js.map +1 -0
  172. package/dist/src/plugins/linked-roles/index.d.ts +3 -0
  173. package/dist/src/plugins/linked-roles/index.d.ts.map +1 -0
  174. package/dist/src/plugins/linked-roles/index.js +3 -0
  175. package/dist/src/plugins/linked-roles/index.js.map +1 -0
  176. package/dist/src/plugins/linked-roles/types.d.ts +88 -0
  177. package/dist/src/plugins/linked-roles/types.d.ts.map +1 -0
  178. package/dist/src/plugins/linked-roles/types.js +39 -0
  179. package/dist/src/plugins/linked-roles/types.js.map +1 -0
  180. package/dist/src/structures/DmChannel.d.ts +19 -0
  181. package/dist/src/structures/DmChannel.d.ts.map +1 -0
  182. package/dist/src/structures/DmChannel.js +25 -0
  183. package/dist/src/structures/DmChannel.js.map +1 -0
  184. package/dist/src/structures/GroupDmChannel.d.ts +65 -0
  185. package/dist/src/structures/GroupDmChannel.d.ts.map +1 -0
  186. package/dist/src/structures/GroupDmChannel.js +116 -0
  187. package/dist/src/structures/GroupDmChannel.js.map +1 -0
  188. package/dist/src/structures/Guild.d.ts +77 -0
  189. package/dist/src/structures/Guild.d.ts.map +1 -0
  190. package/dist/src/structures/Guild.js +156 -0
  191. package/dist/src/structures/Guild.js.map +1 -0
  192. package/dist/src/structures/GuildAnnouncementChannel.d.ts +11 -0
  193. package/dist/src/structures/GuildAnnouncementChannel.d.ts.map +1 -0
  194. package/dist/src/structures/GuildAnnouncementChannel.js +15 -0
  195. package/dist/src/structures/GuildAnnouncementChannel.js.map +1 -0
  196. package/dist/src/structures/GuildCategoryChannel.d.ts +13 -0
  197. package/dist/src/structures/GuildCategoryChannel.d.ts.map +1 -0
  198. package/dist/src/structures/GuildCategoryChannel.js +13 -0
  199. package/dist/src/structures/GuildCategoryChannel.js.map +1 -0
  200. package/dist/src/structures/GuildForumChannel.d.ts +14 -0
  201. package/dist/src/structures/GuildForumChannel.d.ts.map +1 -0
  202. package/dist/src/structures/GuildForumChannel.js +15 -0
  203. package/dist/src/structures/GuildForumChannel.js.map +1 -0
  204. package/dist/src/structures/GuildMediaChannel.d.ts +9 -0
  205. package/dist/src/structures/GuildMediaChannel.d.ts.map +1 -0
  206. package/dist/src/structures/GuildMediaChannel.js +7 -0
  207. package/dist/src/structures/GuildMediaChannel.js.map +1 -0
  208. package/dist/src/structures/GuildMember.d.ts +111 -0
  209. package/dist/src/structures/GuildMember.d.ts.map +1 -0
  210. package/dist/src/structures/GuildMember.js +224 -0
  211. package/dist/src/structures/GuildMember.js.map +1 -0
  212. package/dist/src/structures/GuildStageOrVoiceChannel.d.ts +31 -0
  213. package/dist/src/structures/GuildStageOrVoiceChannel.d.ts.map +1 -0
  214. package/dist/src/structures/GuildStageOrVoiceChannel.js +43 -0
  215. package/dist/src/structures/GuildStageOrVoiceChannel.js.map +1 -0
  216. package/dist/src/structures/GuildTextChannel.d.ts +15 -0
  217. package/dist/src/structures/GuildTextChannel.d.ts.map +1 -0
  218. package/dist/src/structures/GuildTextChannel.js +20 -0
  219. package/dist/src/structures/GuildTextChannel.js.map +1 -0
  220. package/dist/src/structures/GuildThreadChannel.d.ts +90 -0
  221. package/dist/src/structures/GuildThreadChannel.d.ts.map +1 -0
  222. package/dist/src/structures/GuildThreadChannel.js +165 -0
  223. package/dist/src/structures/GuildThreadChannel.js.map +1 -0
  224. package/dist/src/structures/Message.d.ts +153 -0
  225. package/dist/src/structures/Message.d.ts.map +1 -0
  226. package/dist/src/structures/Message.js +296 -0
  227. package/dist/src/structures/Message.js.map +1 -0
  228. package/dist/src/structures/Role.d.ts +108 -0
  229. package/dist/src/structures/Role.d.ts.map +1 -0
  230. package/dist/src/structures/Role.js +220 -0
  231. package/dist/src/structures/Role.js.map +1 -0
  232. package/dist/src/structures/User.d.ts +82 -0
  233. package/dist/src/structures/User.d.ts.map +1 -0
  234. package/dist/src/structures/User.js +166 -0
  235. package/dist/src/structures/User.js.map +1 -0
  236. package/dist/src/types.d.ts +37 -0
  237. package/dist/src/types.d.ts.map +1 -0
  238. package/dist/src/types.js +2 -0
  239. package/dist/src/types.js.map +1 -0
  240. package/dist/src/utils.d.ts +22 -0
  241. package/dist/src/utils.d.ts.map +1 -0
  242. package/dist/src/utils.js +79 -0
  243. package/dist/src/utils.js.map +1 -0
  244. package/dist/tsconfig.tsbuildinfo +1 -0
  245. package/package.json +34 -0
@@ -0,0 +1,296 @@
1
+ import { Routes } from "discord-api-types/v10";
2
+ import { Base } from "../abstracts/Base.js";
3
+ import { Embed } from "../classes/Embed.js";
4
+ import { channelFactory } from "../factories/channelFactory.js";
5
+ import { GuildThreadChannel } from "./GuildThreadChannel.js";
6
+ import { Role } from "./Role.js";
7
+ import { User } from "./User.js";
8
+ export class Message extends Base {
9
+ constructor(client, rawDataOrIds) {
10
+ super(client);
11
+ if (Object.keys(rawDataOrIds).length === 2) {
12
+ this.id = rawDataOrIds.id;
13
+ this.channelId = rawDataOrIds["channelId"];
14
+ }
15
+ else {
16
+ const data = rawDataOrIds;
17
+ this.id = data.id;
18
+ this.channelId = data.channel_id;
19
+ this.setData(data);
20
+ }
21
+ }
22
+ rawData = null;
23
+ setData(data) {
24
+ this.rawData = data;
25
+ if (!data)
26
+ throw new Error("Cannot set data without having data... smh");
27
+ }
28
+ // private setField(key: keyof APIMessage, value: unknown) {
29
+ // if (!this.rawData)
30
+ // throw new Error("Cannot set field without having data... smh")
31
+ // Reflect.set(this.rawData, key, value)
32
+ // }
33
+ /**
34
+ * The ID of the message
35
+ */
36
+ id;
37
+ /**
38
+ * The ID of the channel the message is in
39
+ */
40
+ channelId;
41
+ /**
42
+ * Whether the message is a partial message (meaning it does not have all the data).
43
+ * If this is true, you should use {@link Message.fetch} to get the full data of the message.
44
+ */
45
+ get partial() {
46
+ return (this.rawData === null);
47
+ }
48
+ /**
49
+ * If this message is a response to an interaction, this is the ID of the interaction's application
50
+ */
51
+ get applicationId() {
52
+ if (!this.rawData)
53
+ return undefined;
54
+ return this.rawData.application_id;
55
+ }
56
+ /**
57
+ * The attachments of the message
58
+ */
59
+ get attachments() {
60
+ if (!this.rawData)
61
+ return undefined;
62
+ return this.rawData.attachments ?? [];
63
+ }
64
+ /**
65
+ * The components of the message
66
+ */
67
+ get components() {
68
+ if (!this.rawData)
69
+ return undefined;
70
+ return this.rawData.components ?? [];
71
+ }
72
+ /**
73
+ * The content of the message
74
+ */
75
+ get content() {
76
+ if (!this.rawData)
77
+ return undefined;
78
+ return this.rawData.content ?? "";
79
+ }
80
+ get embeds() {
81
+ if (!this.rawData)
82
+ return undefined;
83
+ if (!this.rawData?.embeds)
84
+ return [];
85
+ return this.rawData.embeds.map((embed) => new Embed(embed));
86
+ }
87
+ /**
88
+ * If this message was edited, this is the timestamp of the edit
89
+ */
90
+ get editedTimestamp() {
91
+ if (!this.rawData)
92
+ return undefined;
93
+ return this.rawData.edited_timestamp;
94
+ }
95
+ /**
96
+ * The flags of the message
97
+ */
98
+ get flags() {
99
+ if (!this.rawData)
100
+ return undefined;
101
+ return this.rawData.flags;
102
+ }
103
+ /**
104
+ * The interaction metadata of the message
105
+ */
106
+ get interactionMetadata() {
107
+ if (!this.rawData)
108
+ return undefined;
109
+ return this.rawData.interaction_metadata;
110
+ }
111
+ /**
112
+ * Whether the message mentions everyone
113
+ */
114
+ get mentionedEveryone() {
115
+ if (!this.rawData)
116
+ return undefined;
117
+ return this.rawData.mention_everyone;
118
+ }
119
+ /**
120
+ * The users mentioned in the message
121
+ */
122
+ get mentionedUsers() {
123
+ if (!this.rawData)
124
+ return undefined;
125
+ if (!this.rawData?.mentions)
126
+ return [];
127
+ return this.rawData.mentions.map((mention) => new User(this.client, mention));
128
+ }
129
+ /**
130
+ * The roles mentioned in the message
131
+ */
132
+ get mentionedRoles() {
133
+ if (!this.rawData)
134
+ return undefined;
135
+ if (!this.rawData?.mention_roles)
136
+ return [];
137
+ return this.rawData.mention_roles.map((mention) => new Role(this.client, mention));
138
+ }
139
+ /**
140
+ * The data about the referenced message. You can use {@link Message.referencedMessage} to get the referenced message itself.
141
+ */
142
+ get messageReference() {
143
+ if (!this.rawData)
144
+ return undefined;
145
+ return this.rawData.message_reference;
146
+ }
147
+ /**
148
+ * The referenced message itself
149
+ */
150
+ get referencedMessage() {
151
+ if (!this.rawData?.referenced_message)
152
+ return null;
153
+ return new Message(this.client, this.rawData?.referenced_message);
154
+ }
155
+ /**
156
+ * Whether the message is pinned
157
+ */
158
+ get pinned() {
159
+ if (!this.rawData)
160
+ return undefined;
161
+ return this.rawData.pinned;
162
+ }
163
+ /**
164
+ * The poll contained in the message
165
+ */
166
+ get poll() {
167
+ if (!this.rawData)
168
+ return undefined;
169
+ return this.rawData.poll;
170
+ }
171
+ /**
172
+ * The approximate position of the message in the channel
173
+ */
174
+ get position() {
175
+ if (!this.rawData)
176
+ return undefined;
177
+ return this.rawData.position;
178
+ }
179
+ /**
180
+ * The reactions on the message
181
+ */
182
+ get reactions() {
183
+ if (!this.rawData)
184
+ return undefined;
185
+ return this.rawData.reactions ?? [];
186
+ }
187
+ /**
188
+ * The stickers in the message
189
+ */
190
+ get stickers() {
191
+ if (!this.rawData)
192
+ return undefined;
193
+ return this.rawData.sticker_items ?? [];
194
+ }
195
+ /**
196
+ * The timestamp of the original message
197
+ */
198
+ get timestamp() {
199
+ if (!this.rawData)
200
+ return undefined;
201
+ return this.rawData.timestamp;
202
+ }
203
+ /**
204
+ * Whether the message is a TTS message
205
+ */
206
+ get tts() {
207
+ if (!this.rawData)
208
+ return undefined;
209
+ return this.rawData.tts;
210
+ }
211
+ /**
212
+ * The type of the message
213
+ */
214
+ get type() {
215
+ if (!this.rawData)
216
+ return undefined;
217
+ return this.rawData.type;
218
+ }
219
+ /**
220
+ * Get the author of the message
221
+ */
222
+ get author() {
223
+ if (!this.rawData)
224
+ return null;
225
+ if (this.rawData?.webhook_id)
226
+ return null; // TODO: Add webhook user
227
+ return new User(this.client, this.rawData.author);
228
+ }
229
+ /**
230
+ * Get the thread associated with this message, if there is one
231
+ */
232
+ get thread() {
233
+ if (!this.rawData)
234
+ return null;
235
+ if (!this.rawData?.thread)
236
+ return null;
237
+ return channelFactory(this.client, this.rawData?.thread);
238
+ }
239
+ /**
240
+ * Fetch updated data for this message.
241
+ * If the message is partial, this will fetch all the data for the message and populate the fields.
242
+ * If the message is not partial, all fields will be updated with new values from Discord.
243
+ */
244
+ async fetch() {
245
+ const newData = (await this.client.rest.get(Routes.channelMessage(this.channelId, this.id)));
246
+ if (!newData)
247
+ throw new Error(`Message ${this.id} not found`);
248
+ this.setData(newData);
249
+ }
250
+ /**
251
+ * Delete this message from Discord
252
+ */
253
+ async delete() {
254
+ return await this.client.rest.delete(Routes.channelMessage(this.channelId, this.id));
255
+ }
256
+ /**
257
+ * Get the channel the message was sent in
258
+ */
259
+ async fetchChannel() {
260
+ const data = (await this.client.rest.get(Routes.channel(this.channelId)));
261
+ return channelFactory(this.client, data);
262
+ }
263
+ /**
264
+ * Pin this message
265
+ */
266
+ async pin() {
267
+ await this.client.rest.put(Routes.channelPin(this.channelId, this.id));
268
+ }
269
+ /**
270
+ * Unpin this message
271
+ */
272
+ async unpin() {
273
+ await this.client.rest.delete(Routes.channelPin(this.channelId, this.id));
274
+ }
275
+ /**
276
+ * Start a thread with this message as the associated start message.
277
+ * If you want to start a thread without a start message, use {@link BaseGuildTextChannel.startThread}
278
+ */
279
+ async startThread(data) {
280
+ const thread = (await this.client.rest.post(Routes.threads(this.channelId, this.id), {
281
+ body: { ...data }
282
+ }));
283
+ return new GuildThreadChannel(this.client, thread);
284
+ }
285
+ async edit(data) {
286
+ await this.client.rest.patch(Routes.channelMessage(this.channelId, this.id), {
287
+ body: {
288
+ ...data,
289
+ embeds: data.embeds?.map((embed) => embed.serialize()),
290
+ components: data.components?.map((row) => row.serialize()),
291
+ allowed_mentions: data.allowedMentions
292
+ }
293
+ });
294
+ }
295
+ }
296
+ //# sourceMappingURL=Message.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Message.js","sourceRoot":"","sources":["../../../src/structures/Message.ts"],"names":[],"mappings":"AAAA,OAAO,EAeN,MAAM,EACN,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAA;AAE3C,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAE3C,OAAO,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAA;AAE/D,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAC5D,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAChC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAEhC,MAAM,OAAO,OAA2C,SAAQ,IAAI;IACnE,YACC,MAAc,EACd,YAEa;QAEb,KAAK,CAAC,MAAM,CAAC,CAAA;QACb,IAAI,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC5C,IAAI,CAAC,EAAE,GAAG,YAAY,CAAC,EAAE,CAAA;YACzB,IAAI,CAAC,SAAS,GAAG,YAAY,CAAC,WAAoB,CAAC,CAAA;QACpD,CAAC;aAAM,CAAC;YACP,MAAM,IAAI,GAAG,YAA0B,CAAA;YACvC,IAAI,CAAC,EAAE,GAAG,IAAI,CAAC,EAAE,CAAA;YACjB,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,UAAU,CAAA;YAChC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,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IAAI,CAC1C,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,EAAE,CAAC,EACvC;YACC,IAAI,EAAE,EAAE,GAAG,IAAI,EAAE;SACjB,CACD,CAAqB,CAAA;QACtB,OAAO,IAAI,kBAAkB,CAAC,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IACnD,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,IAKV;QACA,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAC3B,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,EAAE,CAAC,EAC9C;YACC,IAAI,EAAE;gBACL,GAAG,IAAI;gBACP,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,SAAS,EAAE,CAAC;gBACtD,UAAU,EAAE,IAAI,CAAC,UAAU,EAAE,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,SAAS,EAAE,CAAC;gBAC1D,gBAAgB,EAAE,IAAI,CAAC,eAAe;aACtC;SACD,CACD,CAAA;IACF,CAAC;CACD"}
@@ -0,0 +1,108 @@
1
+ import { type APIRole, type APIRoleTags, type RoleFlags } from "discord-api-types/v10";
2
+ import { Base } from "../abstracts/Base.js";
3
+ import type { Client } from "../classes/Client.js";
4
+ import type { IfPartial } from "../utils.js";
5
+ export declare class Role<IsPartial extends boolean = false> extends Base {
6
+ constructor(client: Client, rawDataOrId: IsPartial extends true ? string : APIRole);
7
+ private rawData;
8
+ private setData;
9
+ private setField;
10
+ /**
11
+ * The ID of the role.
12
+ */
13
+ readonly id: string;
14
+ /**
15
+ * Whether the role is a partial role (meaning it does not have all the data).
16
+ * If this is true, you should use {@link Role.fetch} to get the full data of the role.
17
+ */
18
+ get partial(): IsPartial;
19
+ /**
20
+ * The name of the role.
21
+ */
22
+ get name(): IfPartial<IsPartial, string>;
23
+ /**
24
+ * The color of the role.
25
+ */
26
+ get color(): IfPartial<IsPartial, number>;
27
+ /**
28
+ * The icon hash of the role.
29
+ * You can use {@link Role.iconUrl} to get the URL of the icon.
30
+ */
31
+ get icon(): IfPartial<IsPartial, string | null>;
32
+ /**
33
+ * Get the URL of the role's icon
34
+ */
35
+ get iconUrl(): IfPartial<IsPartial, string | null>;
36
+ /**
37
+ * If this role is mentionable.
38
+ */
39
+ get mentionable(): IfPartial<IsPartial, boolean>;
40
+ /**
41
+ * If this role is hoisted.
42
+ */
43
+ get hoisted(): IfPartial<IsPartial, boolean>;
44
+ /**
45
+ * The position of the role.
46
+ */
47
+ get position(): IfPartial<IsPartial, number>;
48
+ /**
49
+ * The permissions of the role.
50
+ */
51
+ get permissions(): IfPartial<IsPartial, string>;
52
+ /**
53
+ * If this role is managed by an integration.
54
+ */
55
+ get managed(): IfPartial<IsPartial, boolean>;
56
+ /**
57
+ * The unicode emoji for the role.
58
+ */
59
+ get unicodeEmoji(): IfPartial<IsPartial, string | null>;
60
+ /**
61
+ * The flags of this role.
62
+ * @see https://discord.com/developers/docs/topics/permissions#role-object-role-flags
63
+ */
64
+ get flags(): IfPartial<IsPartial, RoleFlags>;
65
+ /**
66
+ * The tags of this role.
67
+ * @see https://discord.com/developers/docs/topics/permissions#role-object-role-tags-structure
68
+ */
69
+ get tags(): IfPartial<IsPartial, APIRoleTags | undefined>;
70
+ /**
71
+ * Fetch updated data for this role.
72
+ * If the role is partial, this will fetch all the data for the role and populate the fields.
73
+ * If the role is not partial, all fields will be updated with new values from Discord.
74
+ */
75
+ fetch(guildId: string): Promise<void>;
76
+ /**
77
+ * Set the name of the role
78
+ */
79
+ setName(guildId: string, name: string): Promise<void>;
80
+ /**
81
+ * Set the color of the role
82
+ */
83
+ setColor(guildId: string, color: number): Promise<void>;
84
+ /**
85
+ * Set the icon of the role
86
+ * @param icon The unicode emoji or icon URL to set
87
+ */
88
+ setIcon(guildId: string, icon: string): Promise<void>;
89
+ /**
90
+ * Set the mentionable status of the role
91
+ */
92
+ setMentionable(guildId: string, mentionable: boolean): Promise<void>;
93
+ /**
94
+ * Set the hoisted status of the role
95
+ */
96
+ setHoisted(guildId: string, hoisted: boolean): Promise<void>;
97
+ /**
98
+ * Set the position of the role
99
+ */
100
+ setPosition(guildId: string, position: number): Promise<void>;
101
+ /**
102
+ * Set the permissions of the role
103
+ * @param permissions The permissions to set as a BitField string, until a better permission structure is implemented
104
+ */
105
+ setPermissions(guildId: string, permissions: string): Promise<void>;
106
+ delete(guildId: string): Promise<void>;
107
+ }
108
+ //# sourceMappingURL=Role.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Role.d.ts","sourceRoot":"","sources":["../../../src/structures/Role.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,KAAK,OAAO,EACZ,KAAK,WAAW,EAChB,KAAK,SAAS,EAEd,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAA;AAC3C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAA;AAClD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAE5C,qBAAa,IAAI,CAAC,SAAS,SAAS,OAAO,GAAG,KAAK,CAAE,SAAQ,IAAI;gBAE/D,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,SAAS,SAAS,IAAI,GAAG,MAAM,GAAG,OAAO;IAYvD,OAAO,CAAC,OAAO,CAAuB;IACtC,OAAO,CAAC,OAAO;IAIf,OAAO,CAAC,QAAQ;IAMhB;;OAEG;IACH,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;IAEnB;;;OAGG;IACH,IAAI,OAAO,IAAI,SAAS,CAEvB;IAED;;OAEG;IACH,IAAI,IAAI,IAAI,SAAS,CAAC,SAAS,EAAE,MAAM,CAAC,CAGvC;IAED;;OAEG;IACH,IAAI,KAAK,IAAI,SAAS,CAAC,SAAS,EAAE,MAAM,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AAE,MAAM,EAAE,OAAO,EAAE,OAAO;IAOlD;;OAEG;IACG,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM;IAOnD;;;OAGG;IACG,cAAc,CAAC,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM;IAOnD,MAAM,CAAC,OAAO,EAAE,MAAM;CAG5B"}
@@ -0,0 +1,220 @@
1
+ import { Routes } from "discord-api-types/v10";
2
+ import { Base } from "../abstracts/Base.js";
3
+ export class Role extends Base {
4
+ constructor(client, rawDataOrId) {
5
+ super(client);
6
+ if (typeof rawDataOrId === "string") {
7
+ this.id = rawDataOrId;
8
+ }
9
+ else {
10
+ this.rawData = rawDataOrId;
11
+ this.id = rawDataOrId.id;
12
+ this.setData(rawDataOrId);
13
+ }
14
+ }
15
+ rawData = null;
16
+ setData(data) {
17
+ if (!data)
18
+ throw new Error("Cannot set data without having data... smh");
19
+ this.rawData = data;
20
+ }
21
+ setField(key, value) {
22
+ if (!this.rawData)
23
+ throw new Error("Cannot set field without having data... smh");
24
+ Reflect.set(this.rawData, key, value);
25
+ }
26
+ /**
27
+ * The ID of the role.
28
+ */
29
+ id;
30
+ /**
31
+ * Whether the role is a partial role (meaning it does not have all the data).
32
+ * If this is true, you should use {@link Role.fetch} to get the full data of the role.
33
+ */
34
+ get partial() {
35
+ return (this.rawData === null);
36
+ }
37
+ /**
38
+ * The name of the role.
39
+ */
40
+ get name() {
41
+ if (!this.rawData)
42
+ return undefined;
43
+ return this.rawData.name;
44
+ }
45
+ /**
46
+ * The color of the role.
47
+ */
48
+ get color() {
49
+ if (!this.rawData)
50
+ return undefined;
51
+ return this.rawData.color;
52
+ }
53
+ /**
54
+ * The icon hash of the role.
55
+ * You can use {@link Role.iconUrl} to get the URL of the icon.
56
+ */
57
+ get icon() {
58
+ if (!this.rawData)
59
+ return undefined;
60
+ return this.rawData.icon ?? null;
61
+ }
62
+ /**
63
+ * Get the URL of the role's icon
64
+ */
65
+ get iconUrl() {
66
+ if (!this.rawData)
67
+ return undefined;
68
+ if (!this.icon)
69
+ return null;
70
+ return `https://cdn.discordapp.com/role-icons/${this.id}/${this.icon}.png`;
71
+ }
72
+ /**
73
+ * If this role is mentionable.
74
+ */
75
+ get mentionable() {
76
+ if (!this.rawData)
77
+ return undefined;
78
+ return this.rawData.mentionable;
79
+ }
80
+ /**
81
+ * If this role is hoisted.
82
+ */
83
+ get hoisted() {
84
+ if (!this.rawData)
85
+ return undefined;
86
+ return this.rawData.hoist;
87
+ }
88
+ /**
89
+ * The position of the role.
90
+ */
91
+ get position() {
92
+ if (!this.rawData)
93
+ return undefined;
94
+ return this.rawData.position;
95
+ }
96
+ /**
97
+ * The permissions of the role.
98
+ */
99
+ get permissions() {
100
+ if (!this.rawData)
101
+ return undefined;
102
+ return this.rawData.permissions;
103
+ }
104
+ /**
105
+ * If this role is managed by an integration.
106
+ */
107
+ get managed() {
108
+ if (!this.rawData)
109
+ return undefined;
110
+ return this.rawData.managed;
111
+ }
112
+ /**
113
+ * The unicode emoji for the role.
114
+ */
115
+ get unicodeEmoji() {
116
+ if (!this.rawData)
117
+ return undefined;
118
+ return this.rawData.unicode_emoji ?? null;
119
+ }
120
+ /**
121
+ * The flags of this role.
122
+ * @see https://discord.com/developers/docs/topics/permissions#role-object-role-flags
123
+ */
124
+ get flags() {
125
+ if (!this.rawData)
126
+ return undefined;
127
+ return this.rawData.flags;
128
+ }
129
+ /**
130
+ * The tags of this role.
131
+ * @see https://discord.com/developers/docs/topics/permissions#role-object-role-tags-structure
132
+ */
133
+ get tags() {
134
+ if (!this.rawData)
135
+ return undefined;
136
+ return this.rawData.tags;
137
+ }
138
+ /**
139
+ * Fetch updated data for this role.
140
+ * If the role is partial, this will fetch all the data for the role and populate the fields.
141
+ * If the role is not partial, all fields will be updated with new values from Discord.
142
+ */
143
+ async fetch(guildId) {
144
+ const newData = (await this.client.rest.get(Routes.guildRole(guildId, this.id)));
145
+ if (!newData)
146
+ throw new Error(`Role ${this.id} not found`);
147
+ this.setData(newData);
148
+ }
149
+ /**
150
+ * Set the name of the role
151
+ */
152
+ async setName(guildId, name) {
153
+ await this.client.rest.patch(Routes.guildRole(guildId, this.id), {
154
+ body: {
155
+ name
156
+ }
157
+ });
158
+ this.setField("name", name);
159
+ }
160
+ /**
161
+ * Set the color of the role
162
+ */
163
+ async setColor(guildId, color) {
164
+ await this.client.rest.patch(Routes.guildRole(guildId, this.id), {
165
+ body: { color }
166
+ });
167
+ this.setField("color", color);
168
+ }
169
+ /**
170
+ * Set the icon of the role
171
+ * @param icon The unicode emoji or icon URL to set
172
+ */
173
+ async setIcon(guildId, icon) {
174
+ await this.client.rest.patch(Routes.guildRole(guildId, this.id), {
175
+ body: { icon }
176
+ });
177
+ this.setField("icon", icon);
178
+ }
179
+ /**
180
+ * Set the mentionable status of the role
181
+ */
182
+ async setMentionable(guildId, mentionable) {
183
+ await this.client.rest.patch(Routes.guildRole(guildId, this.id), {
184
+ body: { mentionable }
185
+ });
186
+ this.setField("mentionable", mentionable);
187
+ }
188
+ /**
189
+ * Set the hoisted status of the role
190
+ */
191
+ async setHoisted(guildId, hoisted) {
192
+ await this.client.rest.patch(Routes.guildRole(guildId, this.id), {
193
+ body: { hoist: hoisted }
194
+ });
195
+ this.setField("hoist", hoisted);
196
+ }
197
+ /**
198
+ * Set the position of the role
199
+ */
200
+ async setPosition(guildId, position) {
201
+ await this.client.rest.patch(Routes.guildRole(guildId, this.id), {
202
+ body: { position }
203
+ });
204
+ this.setField("position", position);
205
+ }
206
+ /**
207
+ * Set the permissions of the role
208
+ * @param permissions The permissions to set as a BitField string, until a better permission structure is implemented
209
+ */
210
+ async setPermissions(guildId, permissions) {
211
+ await this.client.rest.patch(Routes.guildRole(guildId, this.id), {
212
+ body: { permissions }
213
+ });
214
+ this.setField("permissions", permissions);
215
+ }
216
+ async delete(guildId) {
217
+ await this.client.rest.delete(Routes.guildRole(guildId, this.id));
218
+ }
219
+ }
220
+ //# sourceMappingURL=Role.js.map
@@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