disgroove 1.3.1 → 1.3.3-dev.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 (267) hide show
  1. package/README.md +1 -1
  2. package/dist/lib/Client.d.ts +234 -0
  3. package/dist/lib/Client.js +256 -0
  4. package/dist/lib/Client.js.map +1 -0
  5. package/dist/lib/constants.d.ts +1084 -0
  6. package/dist/lib/constants.js +1163 -0
  7. package/dist/lib/constants.js.map +1 -0
  8. package/dist/lib/gateway/Shard.d.ts +25 -0
  9. package/dist/lib/gateway/Shard.js +522 -0
  10. package/dist/lib/gateway/Shard.js.map +1 -0
  11. package/dist/lib/gateway/ShardsManager.d.ts +5 -0
  12. package/dist/lib/gateway/ShardsManager.js +13 -0
  13. package/dist/lib/gateway/ShardsManager.js.map +1 -0
  14. package/dist/lib/gateway/index.d.ts +2 -0
  15. package/dist/lib/gateway/index.js +19 -0
  16. package/dist/lib/gateway/index.js.map +1 -0
  17. package/dist/lib/index.d.ts +7 -0
  18. package/dist/lib/index.js +24 -0
  19. package/dist/lib/index.js.map +1 -0
  20. package/dist/lib/rest/CDN.d.ts +21 -0
  21. package/dist/lib/rest/CDN.js +46 -0
  22. package/dist/lib/rest/CDN.js.map +1 -0
  23. package/dist/lib/rest/Endpoints.d.ts +94 -0
  24. package/dist/lib/rest/Endpoints.js +211 -0
  25. package/dist/lib/rest/Endpoints.js.map +1 -0
  26. package/dist/lib/rest/REST.d.ts +22 -0
  27. package/dist/lib/rest/REST.js +35 -0
  28. package/dist/lib/rest/REST.js.map +1 -0
  29. package/dist/lib/rest/RequestsManager.d.ts +17 -0
  30. package/dist/lib/rest/RequestsManager.js +124 -0
  31. package/dist/lib/rest/RequestsManager.js.map +1 -0
  32. package/dist/lib/rest/index.d.ts +4 -0
  33. package/dist/lib/rest/index.js +34 -0
  34. package/dist/lib/rest/index.js.map +1 -0
  35. package/dist/lib/structures/Application.d.ts +174 -0
  36. package/dist/lib/structures/Application.js +328 -0
  37. package/dist/lib/structures/Application.js.map +1 -0
  38. package/dist/lib/structures/ApplicationCommand.d.ts +45 -0
  39. package/dist/lib/structures/ApplicationCommand.js +127 -0
  40. package/dist/lib/structures/ApplicationCommand.js.map +1 -0
  41. package/dist/lib/structures/AuditLog.d.ts +20 -0
  42. package/dist/lib/structures/AuditLog.js +76 -0
  43. package/dist/lib/structures/AuditLog.js.map +1 -0
  44. package/dist/lib/structures/AutoModerationRule.d.ts +34 -0
  45. package/dist/lib/structures/AutoModerationRule.js +96 -0
  46. package/dist/lib/structures/AutoModerationRule.js.map +1 -0
  47. package/dist/lib/structures/Base.d.ts +17 -0
  48. package/dist/lib/structures/Base.js +31 -0
  49. package/dist/lib/structures/Base.js.map +1 -0
  50. package/dist/lib/structures/Channel.d.ts +253 -0
  51. package/dist/lib/structures/Channel.js +591 -0
  52. package/dist/lib/structures/Channel.js.map +1 -0
  53. package/dist/lib/structures/ClientApplication.d.ts +150 -0
  54. package/dist/lib/structures/ClientApplication.js +241 -0
  55. package/dist/lib/structures/ClientApplication.js.map +1 -0
  56. package/dist/lib/structures/Emoji.d.ts +28 -0
  57. package/dist/lib/structures/Emoji.js +79 -0
  58. package/dist/lib/structures/Emoji.js.map +1 -0
  59. package/dist/lib/structures/Entitlement.d.ts +24 -0
  60. package/dist/lib/structures/Entitlement.js +68 -0
  61. package/dist/lib/structures/Entitlement.js.map +1 -0
  62. package/dist/lib/structures/Guild.d.ts +462 -0
  63. package/dist/lib/structures/Guild.js +1095 -0
  64. package/dist/lib/structures/Guild.js.map +1 -0
  65. package/dist/lib/structures/GuildMember.d.ts +50 -0
  66. package/dist/lib/structures/GuildMember.js +149 -0
  67. package/dist/lib/structures/GuildMember.js.map +1 -0
  68. package/dist/lib/structures/GuildScheduledEvent.d.ts +49 -0
  69. package/dist/lib/structures/GuildScheduledEvent.js +118 -0
  70. package/dist/lib/structures/GuildScheduledEvent.js.map +1 -0
  71. package/dist/lib/structures/GuildTemplate.d.ts +32 -0
  72. package/dist/lib/structures/GuildTemplate.js +76 -0
  73. package/dist/lib/structures/GuildTemplate.js.map +1 -0
  74. package/dist/lib/structures/Integration.d.ts +30 -0
  75. package/dist/lib/structures/Integration.js +102 -0
  76. package/dist/lib/structures/Integration.js.map +1 -0
  77. package/dist/lib/structures/Interaction.d.ts +76 -0
  78. package/dist/lib/structures/Interaction.js +345 -0
  79. package/dist/lib/structures/Interaction.js.map +1 -0
  80. package/dist/lib/structures/Invite.d.ts +28 -0
  81. package/dist/lib/structures/Invite.js +86 -0
  82. package/dist/lib/structures/Invite.js.map +1 -0
  83. package/dist/lib/structures/Message.d.ts +84 -0
  84. package/dist/lib/structures/Message.js +300 -0
  85. package/dist/lib/structures/Message.js.map +1 -0
  86. package/dist/lib/structures/Role.d.ts +37 -0
  87. package/dist/lib/structures/Role.js +90 -0
  88. package/dist/lib/structures/Role.js.map +1 -0
  89. package/dist/lib/structures/SKU.d.ts +23 -0
  90. package/dist/lib/structures/SKU.js +63 -0
  91. package/dist/lib/structures/SKU.js.map +1 -0
  92. package/dist/lib/structures/StageInstance.d.ts +24 -0
  93. package/dist/lib/structures/StageInstance.js +57 -0
  94. package/dist/lib/structures/StageInstance.js.map +1 -0
  95. package/dist/lib/structures/Sticker.d.ts +31 -0
  96. package/dist/lib/structures/Sticker.js +86 -0
  97. package/dist/lib/structures/Sticker.js.map +1 -0
  98. package/dist/lib/structures/Team.d.ts +14 -0
  99. package/dist/lib/structures/Team.js +39 -0
  100. package/dist/lib/structures/Team.js.map +1 -0
  101. package/dist/lib/structures/TestEntitlement.d.ts +23 -0
  102. package/dist/lib/structures/TestEntitlement.js +61 -0
  103. package/dist/lib/structures/TestEntitlement.js.map +1 -0
  104. package/dist/lib/structures/UnavailableGuild.d.ts +11 -0
  105. package/dist/lib/structures/UnavailableGuild.js +25 -0
  106. package/dist/lib/structures/UnavailableGuild.js.map +1 -0
  107. package/dist/lib/structures/User.d.ts +63 -0
  108. package/dist/lib/structures/User.js +177 -0
  109. package/dist/lib/structures/User.js.map +1 -0
  110. package/dist/lib/structures/VoiceState.d.ts +26 -0
  111. package/dist/lib/structures/VoiceState.js +70 -0
  112. package/dist/lib/structures/VoiceState.js.map +1 -0
  113. package/dist/lib/structures/Webhook.d.ts +84 -0
  114. package/dist/lib/structures/Webhook.js +239 -0
  115. package/dist/lib/structures/Webhook.js.map +1 -0
  116. package/dist/lib/structures/index.d.ts +27 -0
  117. package/dist/lib/structures/index.js +44 -0
  118. package/dist/lib/structures/index.js.map +1 -0
  119. package/dist/lib/types/application-command.d.ts +102 -0
  120. package/dist/lib/types/application-command.js +3 -0
  121. package/dist/lib/types/application-command.js.map +1 -0
  122. package/dist/lib/types/application-role-connection-metadata.d.ts +18 -0
  123. package/dist/lib/types/application-role-connection-metadata.js +3 -0
  124. package/dist/lib/types/application-role-connection-metadata.js.map +1 -0
  125. package/dist/lib/types/application.d.ts +66 -0
  126. package/dist/lib/types/application.js +3 -0
  127. package/dist/lib/types/application.js.map +1 -0
  128. package/dist/lib/types/audit-log.d.ts +82 -0
  129. package/dist/lib/types/audit-log.js +3 -0
  130. package/dist/lib/types/audit-log.js.map +1 -0
  131. package/dist/lib/types/auto-moderation.d.ts +65 -0
  132. package/dist/lib/types/auto-moderation.js +3 -0
  133. package/dist/lib/types/auto-moderation.js.map +1 -0
  134. package/dist/lib/types/channel.d.ts +456 -0
  135. package/dist/lib/types/channel.js +3 -0
  136. package/dist/lib/types/channel.js.map +1 -0
  137. package/dist/lib/types/emoji.d.ts +22 -0
  138. package/dist/lib/types/emoji.js +3 -0
  139. package/dist/lib/types/emoji.js.map +1 -0
  140. package/dist/lib/types/entitlements.d.ts +32 -0
  141. package/dist/lib/types/entitlements.js +3 -0
  142. package/dist/lib/types/entitlements.js.map +1 -0
  143. package/dist/lib/types/gateway-events.d.ts +805 -0
  144. package/dist/lib/types/gateway-events.js +3 -0
  145. package/dist/lib/types/gateway-events.js.map +1 -0
  146. package/dist/lib/types/guild-scheduled-event.d.ts +57 -0
  147. package/dist/lib/types/guild-scheduled-event.js +3 -0
  148. package/dist/lib/types/guild-scheduled-event.js.map +1 -0
  149. package/dist/lib/types/guild-template.d.ts +28 -0
  150. package/dist/lib/types/guild-template.js +3 -0
  151. package/dist/lib/types/guild-template.js.map +1 -0
  152. package/dist/lib/types/guild.d.ts +333 -0
  153. package/dist/lib/types/guild.js +3 -0
  154. package/dist/lib/types/guild.js.map +1 -0
  155. package/dist/lib/types/index.d.ts +23 -0
  156. package/dist/lib/types/index.js +40 -0
  157. package/dist/lib/types/index.js.map +1 -0
  158. package/dist/lib/types/interaction.d.ts +170 -0
  159. package/dist/lib/types/interaction.js +3 -0
  160. package/dist/lib/types/interaction.js.map +1 -0
  161. package/dist/lib/types/invite.d.ts +59 -0
  162. package/dist/lib/types/invite.js +3 -0
  163. package/dist/lib/types/invite.js.map +1 -0
  164. package/dist/lib/types/message-components.d.ts +100 -0
  165. package/dist/lib/types/message-components.js +3 -0
  166. package/dist/lib/types/message-components.js.map +1 -0
  167. package/dist/lib/types/role.d.ts +47 -0
  168. package/dist/lib/types/role.js +3 -0
  169. package/dist/lib/types/role.js.map +1 -0
  170. package/dist/lib/types/sku.d.ts +30 -0
  171. package/dist/lib/types/sku.js +3 -0
  172. package/dist/lib/types/sku.js.map +1 -0
  173. package/dist/lib/types/stage-instance.d.ts +20 -0
  174. package/dist/lib/types/stage-instance.js +3 -0
  175. package/dist/lib/types/stage-instance.js.map +1 -0
  176. package/dist/lib/types/sticker.d.ts +61 -0
  177. package/dist/lib/types/sticker.js +3 -0
  178. package/dist/lib/types/sticker.js.map +1 -0
  179. package/dist/lib/types/team.d.ts +30 -0
  180. package/dist/lib/types/team.js +3 -0
  181. package/dist/lib/types/team.js.map +1 -0
  182. package/dist/lib/types/user.d.ts +77 -0
  183. package/dist/lib/types/user.js +3 -0
  184. package/dist/lib/types/user.js.map +1 -0
  185. package/dist/lib/types/voice.d.ts +47 -0
  186. package/dist/lib/types/voice.js +3 -0
  187. package/dist/lib/types/voice.js.map +1 -0
  188. package/dist/lib/types/webhook.d.ts +31 -0
  189. package/dist/lib/types/webhook.js +3 -0
  190. package/dist/lib/types/webhook.js.map +1 -0
  191. package/dist/lib/utils/Util.d.ts +15 -0
  192. package/dist/lib/utils/Util.js +543 -0
  193. package/dist/lib/utils/Util.js.map +1 -0
  194. package/dist/lib/utils/errors.d.ts +12 -0
  195. package/dist/lib/utils/errors.js +25 -0
  196. package/dist/lib/utils/errors.js.map +1 -0
  197. package/dist/lib/utils/index.d.ts +2 -0
  198. package/dist/lib/utils/index.js +19 -0
  199. package/dist/lib/utils/index.js.map +1 -0
  200. package/dist/package.json +1 -1
  201. package/lib/Client.ts +616 -0
  202. package/lib/constants.ts +1173 -0
  203. package/lib/gateway/Shard.ts +704 -0
  204. package/lib/gateway/ShardsManager.ts +11 -0
  205. package/lib/gateway/index.ts +2 -0
  206. package/lib/index.ts +7 -0
  207. package/lib/rest/CDN.ts +56 -0
  208. package/lib/rest/Endpoints.ts +241 -0
  209. package/lib/rest/REST.ts +45 -0
  210. package/lib/rest/RequestsManager.ts +134 -0
  211. package/lib/rest/index.ts +4 -0
  212. package/lib/structures/Application.ts +599 -0
  213. package/lib/structures/ApplicationCommand.ts +187 -0
  214. package/lib/structures/AuditLog.ts +112 -0
  215. package/lib/structures/AutoModerationRule.ts +127 -0
  216. package/lib/structures/Base.ts +39 -0
  217. package/lib/structures/Channel.ts +921 -0
  218. package/lib/structures/ClientApplication.ts +515 -0
  219. package/lib/structures/Emoji.ts +95 -0
  220. package/lib/structures/Entitlement.ts +65 -0
  221. package/lib/structures/Guild.ts +1842 -0
  222. package/lib/structures/GuildMember.ts +193 -0
  223. package/lib/structures/GuildScheduledEvent.ts +164 -0
  224. package/lib/structures/GuildTemplate.ts +103 -0
  225. package/lib/structures/Integration.ts +136 -0
  226. package/lib/structures/Interaction.ts +506 -0
  227. package/lib/structures/Invite.ts +108 -0
  228. package/lib/structures/Message.ts +421 -0
  229. package/lib/structures/Role.ts +116 -0
  230. package/lib/structures/SKU.ts +63 -0
  231. package/lib/structures/StageInstance.ts +74 -0
  232. package/lib/structures/Sticker.ts +100 -0
  233. package/lib/structures/Team.ts +41 -0
  234. package/lib/structures/TestEntitlement.ts +78 -0
  235. package/lib/structures/UnavailableGuild.ts +27 -0
  236. package/lib/structures/User.ts +233 -0
  237. package/lib/structures/VoiceState.ts +72 -0
  238. package/lib/structures/Webhook.ts +341 -0
  239. package/lib/structures/index.ts +27 -0
  240. package/lib/types/application-command.ts +118 -0
  241. package/lib/types/application-role-connection-metadata.ts +23 -0
  242. package/lib/types/application.ts +77 -0
  243. package/lib/types/audit-log.ts +105 -0
  244. package/lib/types/auto-moderation.ts +78 -0
  245. package/lib/types/channel.ts +534 -0
  246. package/lib/types/emoji.ts +24 -0
  247. package/lib/types/entitlements.ts +34 -0
  248. package/lib/types/gateway-events.ts +970 -0
  249. package/lib/types/guild-scheduled-event.ts +67 -0
  250. package/lib/types/guild-template.ts +30 -0
  251. package/lib/types/guild.ts +388 -0
  252. package/lib/types/index.ts +23 -0
  253. package/lib/types/interaction.ts +224 -0
  254. package/lib/types/invite.ts +78 -0
  255. package/lib/types/message-components.ts +127 -0
  256. package/lib/types/role.ts +51 -0
  257. package/lib/types/sku.ts +32 -0
  258. package/lib/types/stage-instance.ts +22 -0
  259. package/lib/types/sticker.ts +67 -0
  260. package/lib/types/team.ts +34 -0
  261. package/lib/types/user.ts +93 -0
  262. package/lib/types/voice.ts +51 -0
  263. package/lib/types/webhook.ts +40 -0
  264. package/lib/utils/Util.ts +600 -0
  265. package/lib/utils/errors.ts +23 -0
  266. package/lib/utils/index.ts +2 -0
  267. package/package.json +1 -1
@@ -0,0 +1,341 @@
1
+ import { Base, Channel, Guild, Message, User } from ".";
2
+ import type { Client } from "../Client";
3
+ import { Endpoints, type File } from "../rest";
4
+ import type {
5
+ JSONActionRow,
6
+ JSONAllowedMentions,
7
+ JSONAttachment,
8
+ JSONEmbed,
9
+ JSONWebhook,
10
+ RawMessage,
11
+ RawWebhook,
12
+ } from "../types";
13
+ import type { MessageFlags, WebhookTypes } from "../constants";
14
+
15
+ /** https://discord.com/developers/docs/resources/webhook */
16
+ export class Webhook extends Base {
17
+ protected override raw: RawWebhook;
18
+ type: WebhookTypes;
19
+ guildId?: string | null;
20
+ channelId: string | null;
21
+ user?: User;
22
+ name: string | null;
23
+ avatar: string | null;
24
+ token?: string;
25
+ applicationId: string | null;
26
+ sourceGuild?: Guild;
27
+ sourceChannel?: Channel;
28
+ url?: string;
29
+
30
+ constructor(data: RawWebhook, client: Client) {
31
+ super(data.id, client);
32
+
33
+ this.raw = data;
34
+ this.type = data.type;
35
+ this.channelId = data.channel_id;
36
+ this.name = data.name;
37
+ this.avatar = data.avatar;
38
+ this.applicationId = data.application_id;
39
+
40
+ this.patch(data);
41
+ }
42
+
43
+ protected override patch(data: RawWebhook): void {
44
+ if (data.guild_id !== undefined) this.guildId = data.guild_id;
45
+ if (data.user !== undefined) this.user = new User(data.user, this.client);
46
+ if (data.token !== undefined) this.token = data.token;
47
+ if (data.source_guild !== undefined)
48
+ this.sourceGuild = new Guild(data.source_guild, this.client);
49
+ if (data.source_channel !== undefined)
50
+ this.sourceChannel = new Channel(data.source_channel, this.client);
51
+ if (data.url !== undefined) this.url = data.url;
52
+ }
53
+
54
+ /** https://discord.com/developers/docs/resources/webhook#delete-webhook */
55
+ delete(reason?: string): void {
56
+ this.client.rest.delete(Endpoints.webhook(this.id), {
57
+ reason,
58
+ });
59
+ }
60
+
61
+ /** https://discord.com/developers/docs/resources/webhook#delete-webhook-message */
62
+ deleteMessage(
63
+ messageId: string,
64
+ options?: {
65
+ threadId?: string;
66
+ }
67
+ ): void {
68
+ if (!this.token) throw new Error("[disgroove] Webhook token not found");
69
+
70
+ this.client.rest.delete(
71
+ Endpoints.webhookMessage(this.id, this.token, messageId),
72
+ {
73
+ query: {
74
+ thread_id: options?.threadId,
75
+ },
76
+ }
77
+ );
78
+ }
79
+
80
+ /** https://discord.com/developers/docs/resources/webhook#delete-webhook-with-token */
81
+ deleteWithToken(reason?: string): void {
82
+ if (!this.token) throw new Error("[disgroove] Webhook token not found");
83
+
84
+ this.client.rest.delete(Endpoints.webhook(this.id, this.token), {
85
+ reason,
86
+ authorization: false,
87
+ });
88
+ }
89
+
90
+ /** https://discord.com/developers/docs/resources/webhook#modify-webhook */
91
+ async edit(
92
+ options: {
93
+ name?: string;
94
+ avatar?: string | null;
95
+ channelId?: string;
96
+ },
97
+ reason?: string
98
+ ): Promise<Webhook> {
99
+ return new Webhook(
100
+ await this.client.rest.patch<RawWebhook>(Endpoints.webhook(this.id), {
101
+ json: {
102
+ name: options.name,
103
+ avatar: options.avatar,
104
+ channel_id: options.channelId,
105
+ },
106
+ reason,
107
+ }),
108
+ this.client
109
+ );
110
+ }
111
+
112
+ /** https://discord.com/developers/docs/resources/webhook#edit-webhook-message */
113
+ async editMessage(
114
+ messageId: string,
115
+ options: {
116
+ threadId?: string;
117
+ content?: string | null;
118
+ embeds?: Array<JSONEmbed> | null;
119
+ flags?: MessageFlags | null;
120
+ allowedMentions?: JSONAllowedMentions | null;
121
+ components?: Array<JSONActionRow> | null;
122
+ files?: Array<File> | null;
123
+ attachments?: Array<JSONAttachment> | null;
124
+ }
125
+ ): Promise<Message> {
126
+ if (!this.token) throw new Error("[disgroove] Webhook token not found");
127
+
128
+ return new Message(
129
+ await this.client.rest.patch<RawMessage>(
130
+ Endpoints.webhookMessage(this.id, this.token, messageId),
131
+ {
132
+ json: {
133
+ content: options.content,
134
+ embeds:
135
+ options.embeds !== undefined
136
+ ? options.embeds !== null
137
+ ? this.client.util.embedsToRaw(options.embeds)
138
+ : null
139
+ : undefined,
140
+ allowed_mentions: {
141
+ parse: options.allowedMentions?.parse,
142
+ roles: options.allowedMentions?.roles,
143
+ users: options.allowedMentions?.users,
144
+ replied_user: options.allowedMentions?.repliedUser,
145
+ },
146
+ components:
147
+ options.components !== undefined
148
+ ? options.components !== null
149
+ ? this.client.util.messageComponentsToRaw(options.components)
150
+ : null
151
+ : undefined,
152
+ attachments: options.attachments,
153
+ flags: options.flags,
154
+ },
155
+ files: options.files,
156
+ query: {
157
+ thread_id: options.threadId,
158
+ },
159
+ }
160
+ ),
161
+ this.client
162
+ );
163
+ }
164
+
165
+ /** https://discord.com/developers/docs/resources/webhook#modify-webhook-with-token */
166
+ async editWithToken(
167
+ options: {
168
+ name?: string;
169
+ avatar?: string | null;
170
+ },
171
+ reason?: string
172
+ ): Promise<Webhook> {
173
+ if (!this.token) throw new Error("[disgroove] Webhook token not found");
174
+
175
+ return new Webhook(
176
+ await this.client.rest.patch<RawWebhook>(
177
+ Endpoints.webhook(this.id, this.token),
178
+ {
179
+ json: {
180
+ name: options.name,
181
+ avatar: options.avatar,
182
+ },
183
+ reason,
184
+ authorization: false,
185
+ }
186
+ ),
187
+ this.client
188
+ );
189
+ }
190
+
191
+ /** https://discord.com/developers/docs/resources/webhook#execute-webhook */
192
+ async execute(options: {
193
+ wait?: boolean;
194
+ threadId?: string;
195
+ content?: string | null;
196
+ username?: string;
197
+ avatarURL?: string;
198
+ tts?: boolean;
199
+ embeds?: Array<JSONEmbed> | null;
200
+ allowedMentions?: JSONAllowedMentions | null;
201
+ components?: Array<JSONActionRow> | null;
202
+ files?: Array<File> | null;
203
+ attachments?: Array<JSONAttachment> | null;
204
+ flags?: MessageFlags | null;
205
+ threadName?: string;
206
+ }): Promise<Message | null> {
207
+ if (!this.token) throw new Error("[disgroove] Webhook token not found");
208
+
209
+ return this.client.rest
210
+ .post<RawMessage | null>(Endpoints.webhook(this.id, this.token), {
211
+ json: {
212
+ content: options.content,
213
+ tts: options.tts,
214
+ embeds:
215
+ options.embeds !== undefined
216
+ ? options.embeds !== null
217
+ ? this.client.util.embedsToRaw(options.embeds)
218
+ : null
219
+ : undefined,
220
+ allowed_mentions: {
221
+ parse: options.allowedMentions?.parse,
222
+ roles: options.allowedMentions?.roles,
223
+ users: options.allowedMentions?.users,
224
+ replied_user: options.allowedMentions?.repliedUser,
225
+ },
226
+ components:
227
+ options.components !== undefined
228
+ ? options.components !== null
229
+ ? this.client.util.messageComponentsToRaw(options.components)
230
+ : null
231
+ : undefined,
232
+ attachments: options.attachments,
233
+ flags: options.flags,
234
+ thread_name: options.threadName,
235
+ },
236
+ files: options.files,
237
+ query: {
238
+ wait: options.wait,
239
+ thread_id: options.threadId,
240
+ username: options.username,
241
+ avatarURL: options.avatarURL,
242
+ },
243
+ })
244
+ .then((response) => {
245
+ if (response !== null) {
246
+ return new Message(response, this.client);
247
+ } else return null;
248
+ });
249
+ }
250
+
251
+ /** https://discord.com/developers/docs/resources/webhook#execute-githubcompatible-webhook */
252
+ async executeGitHubCompatible(options: {
253
+ threadId?: string;
254
+ wait?: boolean;
255
+ }): Promise<Message | null> {
256
+ if (!this.token) throw new Error("[disgroove] Webhook token not found");
257
+
258
+ return this.client.rest
259
+ .post<RawMessage | null>(
260
+ Endpoints.webhookPlatform(this.id, this.token, "github"),
261
+ {
262
+ query: {
263
+ thread_id: options.threadId,
264
+ wait: options.wait,
265
+ },
266
+ }
267
+ )
268
+ .then((response) => {
269
+ if (response !== null) {
270
+ return new Message(response, this.client);
271
+ } else return null;
272
+ });
273
+ }
274
+
275
+ /** https://discord.com/developers/docs/resources/webhook#execute-slackcompatible-webhook */
276
+ async executeSlackCompatible(options: {
277
+ threadId?: string;
278
+ wait?: boolean;
279
+ }): Promise<Message | null> {
280
+ if (!this.token) throw new Error("[disgroove] Webhook token not found");
281
+
282
+ return this.client.rest
283
+ .post<RawMessage | null>(
284
+ Endpoints.webhookPlatform(this.id, this.token, "slack"),
285
+ {
286
+ query: {
287
+ thread_id: options.threadId,
288
+ wait: options.wait,
289
+ },
290
+ }
291
+ )
292
+ .then((response) => {
293
+ if (response !== null) {
294
+ return new Message(response, this.client);
295
+ } else return null;
296
+ });
297
+ }
298
+
299
+ /** https://discord.com/developers/docs/resources/webhook#get-webhook-message */
300
+ async getMessage(
301
+ messageId: string,
302
+ options?: {
303
+ threadId?: string;
304
+ }
305
+ ): Promise<Message> {
306
+ if (!this.token) throw new Error("[disgroove] Webhook token not found");
307
+
308
+ return new Message(
309
+ await this.client.rest.get<RawMessage>(
310
+ Endpoints.webhookMessage(this.id, this.token, messageId),
311
+ {
312
+ query: {
313
+ thread_id: options?.threadId,
314
+ },
315
+ }
316
+ ),
317
+ this.client
318
+ );
319
+ }
320
+
321
+ override toRaw(): RawWebhook {
322
+ return this.raw;
323
+ }
324
+
325
+ override toJSON(): JSONWebhook {
326
+ return {
327
+ ...super.toJSON(),
328
+ type: this.type,
329
+ guildId: this.guildId,
330
+ channelId: this.channelId,
331
+ user: this.user?.toJSON(),
332
+ name: this.name,
333
+ avatar: this.avatar,
334
+ token: this.token,
335
+ applicationId: this.applicationId,
336
+ sourceGuild: this.sourceGuild?.toJSON(),
337
+ sourceChannel: this.sourceChannel?.toJSON(),
338
+ url: this.url,
339
+ };
340
+ }
341
+ }
@@ -0,0 +1,27 @@
1
+ export * from "./Base";
2
+ export * from "./Application";
3
+ export * from "./ApplicationCommand";
4
+ export * from "./AuditLog";
5
+ export * from "./AutoModerationRule";
6
+ export * from "./Channel";
7
+ export * from "./ClientApplication";
8
+ export * from "./Emoji";
9
+ export * from "./Entitlement";
10
+ export * from "./Guild";
11
+ export * from "./GuildMember";
12
+ export * from "./GuildScheduledEvent";
13
+ export * from "./GuildTemplate";
14
+ export * from "./Integration";
15
+ export * from "./Interaction";
16
+ export * from "./Invite";
17
+ export * from "./Message";
18
+ export * from "./Role";
19
+ export * from "./SKU";
20
+ export * from "./StageInstance";
21
+ export * from "./Sticker";
22
+ export * from "./Team";
23
+ export * from "./TestEntitlement";
24
+ export * from "./UnavailableGuild";
25
+ export * from "./User";
26
+ export * from "./VoiceState";
27
+ export * from "./Webhook";
@@ -0,0 +1,118 @@
1
+ import type {
2
+ ApplicationCommandTypes,
3
+ ApplicationCommandOptionType,
4
+ ChannelTypes,
5
+ Locale,
6
+ ApplicationCommandPermissionType,
7
+ } from "../constants";
8
+
9
+ /** https://discord.com/developers/docs/interactions/application-commands#application-command-object-application-command-structure */
10
+ export interface RawApplicationCommand {
11
+ id: string;
12
+ type?: ApplicationCommandTypes;
13
+ application_id: string;
14
+ guild_id?: string;
15
+ name: string;
16
+ name_localizations?: Partial<Record<Locale, string>> | null;
17
+ description: string;
18
+ description_localizations?: Partial<Record<Locale, string>> | null;
19
+ options?: Array<RawApplicationCommandOption>;
20
+ default_member_permissions: string | null;
21
+ dm_permission?: boolean;
22
+ default_permission?: boolean | null;
23
+ nsfw?: boolean;
24
+ version: string;
25
+ }
26
+
27
+ /** https://discord.com/developers/docs/interactions/application-commands#application-command-object-application-command-option-structure */
28
+ export interface RawApplicationCommandOption {
29
+ type: ApplicationCommandOptionType;
30
+ name: string;
31
+ name_localizations?: Partial<Record<Locale, string>> | null;
32
+ description: string;
33
+ description_localizations?: Partial<Record<Locale, string>> | null;
34
+ required?: boolean;
35
+ choices?: Array<RawApplicationCommandOptionChoice>;
36
+ options?: Array<RawApplicationCommandOption>;
37
+ channel_types?: Array<ChannelTypes>;
38
+ min_value?: number;
39
+ max_value?: number;
40
+ min_length?: number;
41
+ max_length?: number;
42
+ autocomplete?: boolean;
43
+ }
44
+
45
+ /** https://discord.com/developers/docs/interactions/application-commands#application-command-object-application-command-option-choice-structure */
46
+ export interface RawApplicationCommandOptionChoice {
47
+ name: string;
48
+ name_localizations?: Partial<Record<Locale, string>> | null;
49
+ value: string;
50
+ }
51
+
52
+ /** https://discord.com/developers/docs/interactions/application-commands#application-command-permissions-object-guild-application-command-permissions-structure */
53
+ export interface RawGuildApplicationCommandPermissions {
54
+ id: string;
55
+ application_id: string;
56
+ guild_id: string;
57
+ permissions: Array<RawApplicationCommandPermission>;
58
+ }
59
+
60
+ /** https://discord.com/developers/docs/interactions/application-commands#application-command-permissions-object-application-command-permissions-structure */
61
+ export interface RawApplicationCommandPermission {
62
+ id: string;
63
+ type: ApplicationCommandPermissionType;
64
+ permission: boolean;
65
+ }
66
+
67
+ export interface JSONApplicationCommand {
68
+ id: string;
69
+ type?: ApplicationCommandTypes;
70
+ applicationId: string;
71
+ guildId?: string;
72
+ name: string;
73
+ nameLocalizations?: Partial<Record<Locale, string>> | null;
74
+ description: string;
75
+ descriptionLocalizations?: Partial<Record<Locale, string>> | null;
76
+ options?: Array<JSONApplicationCommandOption>;
77
+ defaultMemberPermissions: string | null;
78
+ dmPermission?: boolean;
79
+ defaultPermission?: boolean | null;
80
+ nsfw?: boolean;
81
+ version: string;
82
+ }
83
+
84
+ export interface JSONApplicationCommandOption {
85
+ type: ApplicationCommandOptionType;
86
+ name: string;
87
+ nameLocalizations?: Partial<Record<Locale, string>> | null;
88
+ description: string;
89
+ descriptionLocalizations?: Partial<Record<Locale, string>> | null;
90
+ required?: boolean;
91
+ choices?: Array<JSONApplicationCommandOptionChoice>;
92
+ options?: Array<JSONApplicationCommandOption>;
93
+ channelTypes?: Array<ChannelTypes>;
94
+ minValue?: number;
95
+ maxValue?: number;
96
+ minLength?: number;
97
+ maxLength?: number;
98
+ autocomplete?: boolean;
99
+ }
100
+
101
+ export interface JSONApplicationCommandOptionChoice {
102
+ name: string;
103
+ nameLocalizations?: Partial<Record<Locale, string>> | null;
104
+ value: string;
105
+ }
106
+
107
+ export interface JSONGuildApplicationCommandPermissions {
108
+ id: string;
109
+ applicationId: string;
110
+ guildId: string;
111
+ permissions: Array<JSONApplicationCommandPermission>;
112
+ }
113
+
114
+ export interface JSONApplicationCommandPermission {
115
+ id: string;
116
+ type: ApplicationCommandPermissionType;
117
+ permission: boolean;
118
+ }
@@ -0,0 +1,23 @@
1
+ import type {
2
+ ApplicationRoleConnectionMetadataType,
3
+ Locale,
4
+ } from "../constants";
5
+
6
+ /** https://discord.com/developers/docs/resources/application-role-connection-metadata#application-role-connection-metadata-object-application-role-connection-metadata-structure */
7
+ export interface RawApplicationRoleConnectionMetadata {
8
+ type: ApplicationRoleConnectionMetadataType;
9
+ key: string;
10
+ name: string;
11
+ name_localizations?: Partial<Record<Locale, string>> | null;
12
+ description: string;
13
+ description_localizations?: Partial<Record<Locale, string>> | null;
14
+ }
15
+
16
+ export interface JSONApplicationRoleConnectionMetadata {
17
+ type: ApplicationRoleConnectionMetadataType;
18
+ key: string;
19
+ name: string;
20
+ nameLocalizations?: Partial<Record<Locale, string>> | null;
21
+ description: string;
22
+ descriptionLocalizations?: Partial<Record<Locale, string>> | null;
23
+ }
@@ -0,0 +1,77 @@
1
+ import type {
2
+ RawUser,
3
+ RawTeam,
4
+ JSONTeam,
5
+ JSONUser,
6
+ RawGuild,
7
+ JSONGuild,
8
+ } from ".";
9
+ import type { ApplicationFlags, OAuth2Scopes } from "../constants";
10
+
11
+ /** https://discord.com/developers/docs/resources/application#application-object-application-structure */
12
+ export interface RawApplication {
13
+ id: string;
14
+ name: string;
15
+ icon: string | null;
16
+ description: string;
17
+ rpc_origins?: Array<string>;
18
+ bot_public: boolean;
19
+ bot_require_code_grant: boolean;
20
+ terms_of_service_url?: string;
21
+ privacy_policy_url?: string;
22
+ owner?: RawUser;
23
+ verify_key: string;
24
+ team: RawTeam | null;
25
+ guild_id?: string;
26
+ guild?: RawGuild;
27
+ primary_sku_id?: string;
28
+ slug?: string;
29
+ cover_image?: string;
30
+ flags?: ApplicationFlags;
31
+ approximate_guild_count?: number;
32
+ redirect_uris?: Array<string>;
33
+ interactions_endpoint_url?: string;
34
+ role_connections_verification_url?: string;
35
+ tags?: Array<string>;
36
+ install_params?: RawInstallParams;
37
+ custom_install_url?: string;
38
+ }
39
+
40
+ /** https://discord.com/developers/docs/resources/application#install-params-object-install-params-structure */
41
+ export interface RawInstallParams {
42
+ scopes: Array<OAuth2Scopes>;
43
+ permissions: string;
44
+ }
45
+
46
+ export interface JSONApplication {
47
+ id: string;
48
+ name: string;
49
+ icon: string | null;
50
+ description: string;
51
+ rpcOrigins?: Array<string>;
52
+ botPublic: boolean;
53
+ botRequireCodeGrant: boolean;
54
+ termsOfServiceURL?: string;
55
+ privacyPolicyURL?: string;
56
+ owner?: JSONUser;
57
+ verifyKey: string;
58
+ team: JSONTeam | null;
59
+ guildId?: string;
60
+ guild?: JSONGuild;
61
+ primarySKUId?: string;
62
+ slug?: string;
63
+ coverImage?: string;
64
+ flags?: ApplicationFlags;
65
+ approximateGuildCount?: number;
66
+ redirectURIs?: Array<string>;
67
+ interactionsEndpointURL?: string;
68
+ roleConnectionsVerificationURL?: string;
69
+ tags?: Array<string>;
70
+ installParams?: JSONInstallParams;
71
+ customInstallURL?: string;
72
+ }
73
+
74
+ export interface JSONInstallParams {
75
+ scopes: Array<OAuth2Scopes>;
76
+ permissions: string;
77
+ }
@@ -0,0 +1,105 @@
1
+ import type {
2
+ RawApplicationCommand,
3
+ RawGuildScheduledEvent,
4
+ RawAutoModerationRule,
5
+ RawIntegration,
6
+ RawChannel,
7
+ RawUser,
8
+ RawWebhook,
9
+ JSONUser,
10
+ JSONApplicationCommand,
11
+ JSONAutoModerationRule,
12
+ JSONGuildScheduledEvent,
13
+ JSONIntegration,
14
+ JSONChannel,
15
+ JSONWebhook,
16
+ } from ".";
17
+ import type { AuditLogEvents } from "../constants";
18
+
19
+ /** https://discord.com/developers/docs/resources/audit-log#audit-log-object-audit-log-structure */
20
+ export interface RawAuditLog {
21
+ application_commands: Array<RawApplicationCommand>;
22
+ audit_log_entries: Array<RawAuditLogEntry>;
23
+ auto_moderation_rules: Array<RawAutoModerationRule>;
24
+ guild_scheduled_events: Array<RawGuildScheduledEvent>;
25
+ integrations: Array<RawIntegration>;
26
+ threads: Array<RawChannel>;
27
+ users: Array<RawUser>;
28
+ webhooks: Array<RawWebhook>;
29
+ }
30
+
31
+ /** https://discord.com/developers/docs/resources/audit-log#audit-log-entry-object-audit-log-entry-structure */
32
+ export interface RawAuditLogEntry {
33
+ target_id: string | null;
34
+ changes?: Array<RawAuditLogChange>;
35
+ user_id: string | null;
36
+ id: string;
37
+ action_type: AuditLogEvents;
38
+ options?: RawOptionalAuditLogEntryInfo;
39
+ reason?: string;
40
+ }
41
+
42
+ /** https://discord.com/developers/docs/resources/audit-log#audit-log-entry-object-optional-audit-entry-info */
43
+ export interface RawOptionalAuditLogEntryInfo {
44
+ application_id: string;
45
+ auto_moderation_rule_name: string;
46
+ auto_moderation_rule_trigger_type: string;
47
+ channel_id: string;
48
+ count: string;
49
+ delete_member_days: string;
50
+ id: string;
51
+ members_removed: string;
52
+ message_id: string;
53
+ role_name: string;
54
+ type: string;
55
+ integration_type: string;
56
+ }
57
+
58
+ /** https://discord.com/developers/docs/resources/audit-log#audit-log-change-object-audit-log-change-structure */
59
+ export interface RawAuditLogChange {
60
+ new_value?: any;
61
+ old_value?: any;
62
+ key: string;
63
+ }
64
+
65
+ export interface JSONAuditLog {
66
+ applicationCommands: Array<JSONApplicationCommand>;
67
+ auditLogEntries: Array<JSONAuditLogEntry>;
68
+ autoModerationRules: Array<JSONAutoModerationRule>;
69
+ guildScheduledEvents: Array<JSONGuildScheduledEvent>;
70
+ integrations: Array<JSONIntegration>;
71
+ threads: Array<JSONChannel>;
72
+ users: Array<JSONUser>;
73
+ webhooks: Array<JSONWebhook>;
74
+ }
75
+
76
+ export interface JSONAuditLogEntry {
77
+ targetId: string | null;
78
+ changes?: Array<JSONAuditLogChange>;
79
+ userId: string | null;
80
+ id: string;
81
+ actionType: AuditLogEvents;
82
+ options?: JSONOptionalAuditLogEntryInfo;
83
+ reason?: string;
84
+ }
85
+
86
+ export interface JSONOptionalAuditLogEntryInfo {
87
+ applicationId: string;
88
+ autoModerationRuleName: string;
89
+ autoModerationRuleTriggerType: string;
90
+ channelId: string;
91
+ count: string;
92
+ deleteMemberDays: string;
93
+ id: string;
94
+ membersRemoved: string;
95
+ messageId: string;
96
+ roleName: string;
97
+ type: string;
98
+ integrationType: string;
99
+ }
100
+
101
+ export interface JSONAuditLogChange {
102
+ newValue?: any;
103
+ oldValue?: any;
104
+ key: string;
105
+ }