disgroove 1.3.3-dev.2 → 1.3.3-dev.3

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 (277) hide show
  1. package/dist/package.json +1 -1
  2. package/package.json +1 -1
  3. package/dist/lib/Client.d.ts +0 -234
  4. package/dist/lib/Client.js +0 -256
  5. package/dist/lib/Client.js.map +0 -1
  6. package/dist/lib/constants.d.ts +0 -1084
  7. package/dist/lib/constants.js +0 -1163
  8. package/dist/lib/constants.js.map +0 -1
  9. package/dist/lib/gateway/Shard.d.ts +0 -25
  10. package/dist/lib/gateway/Shard.js +0 -522
  11. package/dist/lib/gateway/Shard.js.map +0 -1
  12. package/dist/lib/gateway/ShardsManager.d.ts +0 -5
  13. package/dist/lib/gateway/ShardsManager.js +0 -13
  14. package/dist/lib/gateway/ShardsManager.js.map +0 -1
  15. package/dist/lib/gateway/index.d.ts +0 -2
  16. package/dist/lib/gateway/index.js +0 -19
  17. package/dist/lib/gateway/index.js.map +0 -1
  18. package/dist/lib/index.d.ts +0 -7
  19. package/dist/lib/index.js +0 -24
  20. package/dist/lib/index.js.map +0 -1
  21. package/dist/lib/rest/CDN.d.ts +0 -21
  22. package/dist/lib/rest/CDN.js +0 -46
  23. package/dist/lib/rest/CDN.js.map +0 -1
  24. package/dist/lib/rest/Endpoints.d.ts +0 -94
  25. package/dist/lib/rest/Endpoints.js +0 -211
  26. package/dist/lib/rest/Endpoints.js.map +0 -1
  27. package/dist/lib/rest/REST.d.ts +0 -22
  28. package/dist/lib/rest/REST.js +0 -35
  29. package/dist/lib/rest/REST.js.map +0 -1
  30. package/dist/lib/rest/RequestsManager.d.ts +0 -17
  31. package/dist/lib/rest/RequestsManager.js +0 -124
  32. package/dist/lib/rest/RequestsManager.js.map +0 -1
  33. package/dist/lib/rest/index.d.ts +0 -4
  34. package/dist/lib/rest/index.js +0 -34
  35. package/dist/lib/rest/index.js.map +0 -1
  36. package/dist/lib/structures/Application.d.ts +0 -174
  37. package/dist/lib/structures/Application.js +0 -328
  38. package/dist/lib/structures/Application.js.map +0 -1
  39. package/dist/lib/structures/ApplicationCommand.d.ts +0 -45
  40. package/dist/lib/structures/ApplicationCommand.js +0 -127
  41. package/dist/lib/structures/ApplicationCommand.js.map +0 -1
  42. package/dist/lib/structures/AuditLog.d.ts +0 -20
  43. package/dist/lib/structures/AuditLog.js +0 -76
  44. package/dist/lib/structures/AuditLog.js.map +0 -1
  45. package/dist/lib/structures/AutoModerationRule.d.ts +0 -34
  46. package/dist/lib/structures/AutoModerationRule.js +0 -96
  47. package/dist/lib/structures/AutoModerationRule.js.map +0 -1
  48. package/dist/lib/structures/Base.d.ts +0 -17
  49. package/dist/lib/structures/Base.js +0 -31
  50. package/dist/lib/structures/Base.js.map +0 -1
  51. package/dist/lib/structures/Channel.d.ts +0 -253
  52. package/dist/lib/structures/Channel.js +0 -591
  53. package/dist/lib/structures/Channel.js.map +0 -1
  54. package/dist/lib/structures/ClientApplication.d.ts +0 -150
  55. package/dist/lib/structures/ClientApplication.js +0 -241
  56. package/dist/lib/structures/ClientApplication.js.map +0 -1
  57. package/dist/lib/structures/Emoji.d.ts +0 -28
  58. package/dist/lib/structures/Emoji.js +0 -79
  59. package/dist/lib/structures/Emoji.js.map +0 -1
  60. package/dist/lib/structures/Entitlement.d.ts +0 -24
  61. package/dist/lib/structures/Entitlement.js +0 -68
  62. package/dist/lib/structures/Entitlement.js.map +0 -1
  63. package/dist/lib/structures/Guild.d.ts +0 -462
  64. package/dist/lib/structures/Guild.js +0 -1095
  65. package/dist/lib/structures/Guild.js.map +0 -1
  66. package/dist/lib/structures/GuildMember.d.ts +0 -50
  67. package/dist/lib/structures/GuildMember.js +0 -149
  68. package/dist/lib/structures/GuildMember.js.map +0 -1
  69. package/dist/lib/structures/GuildScheduledEvent.d.ts +0 -49
  70. package/dist/lib/structures/GuildScheduledEvent.js +0 -118
  71. package/dist/lib/structures/GuildScheduledEvent.js.map +0 -1
  72. package/dist/lib/structures/GuildTemplate.d.ts +0 -32
  73. package/dist/lib/structures/GuildTemplate.js +0 -76
  74. package/dist/lib/structures/GuildTemplate.js.map +0 -1
  75. package/dist/lib/structures/Integration.d.ts +0 -30
  76. package/dist/lib/structures/Integration.js +0 -102
  77. package/dist/lib/structures/Integration.js.map +0 -1
  78. package/dist/lib/structures/Interaction.d.ts +0 -76
  79. package/dist/lib/structures/Interaction.js +0 -345
  80. package/dist/lib/structures/Interaction.js.map +0 -1
  81. package/dist/lib/structures/Invite.d.ts +0 -28
  82. package/dist/lib/structures/Invite.js +0 -86
  83. package/dist/lib/structures/Invite.js.map +0 -1
  84. package/dist/lib/structures/Message.d.ts +0 -84
  85. package/dist/lib/structures/Message.js +0 -300
  86. package/dist/lib/structures/Message.js.map +0 -1
  87. package/dist/lib/structures/Role.d.ts +0 -37
  88. package/dist/lib/structures/Role.js +0 -90
  89. package/dist/lib/structures/Role.js.map +0 -1
  90. package/dist/lib/structures/SKU.d.ts +0 -23
  91. package/dist/lib/structures/SKU.js +0 -63
  92. package/dist/lib/structures/SKU.js.map +0 -1
  93. package/dist/lib/structures/StageInstance.d.ts +0 -24
  94. package/dist/lib/structures/StageInstance.js +0 -57
  95. package/dist/lib/structures/StageInstance.js.map +0 -1
  96. package/dist/lib/structures/Sticker.d.ts +0 -31
  97. package/dist/lib/structures/Sticker.js +0 -86
  98. package/dist/lib/structures/Sticker.js.map +0 -1
  99. package/dist/lib/structures/Team.d.ts +0 -14
  100. package/dist/lib/structures/Team.js +0 -39
  101. package/dist/lib/structures/Team.js.map +0 -1
  102. package/dist/lib/structures/TestEntitlement.d.ts +0 -23
  103. package/dist/lib/structures/TestEntitlement.js +0 -61
  104. package/dist/lib/structures/TestEntitlement.js.map +0 -1
  105. package/dist/lib/structures/UnavailableGuild.d.ts +0 -11
  106. package/dist/lib/structures/UnavailableGuild.js +0 -25
  107. package/dist/lib/structures/UnavailableGuild.js.map +0 -1
  108. package/dist/lib/structures/User.d.ts +0 -63
  109. package/dist/lib/structures/User.js +0 -177
  110. package/dist/lib/structures/User.js.map +0 -1
  111. package/dist/lib/structures/VoiceState.d.ts +0 -26
  112. package/dist/lib/structures/VoiceState.js +0 -70
  113. package/dist/lib/structures/VoiceState.js.map +0 -1
  114. package/dist/lib/structures/Webhook.d.ts +0 -84
  115. package/dist/lib/structures/Webhook.js +0 -239
  116. package/dist/lib/structures/Webhook.js.map +0 -1
  117. package/dist/lib/structures/index.d.ts +0 -27
  118. package/dist/lib/structures/index.js +0 -44
  119. package/dist/lib/structures/index.js.map +0 -1
  120. package/dist/lib/types/application-command.d.ts +0 -102
  121. package/dist/lib/types/application-command.js +0 -3
  122. package/dist/lib/types/application-command.js.map +0 -1
  123. package/dist/lib/types/application-role-connection-metadata.d.ts +0 -18
  124. package/dist/lib/types/application-role-connection-metadata.js +0 -3
  125. package/dist/lib/types/application-role-connection-metadata.js.map +0 -1
  126. package/dist/lib/types/application.d.ts +0 -66
  127. package/dist/lib/types/application.js +0 -3
  128. package/dist/lib/types/application.js.map +0 -1
  129. package/dist/lib/types/audit-log.d.ts +0 -82
  130. package/dist/lib/types/audit-log.js +0 -3
  131. package/dist/lib/types/audit-log.js.map +0 -1
  132. package/dist/lib/types/auto-moderation.d.ts +0 -65
  133. package/dist/lib/types/auto-moderation.js +0 -3
  134. package/dist/lib/types/auto-moderation.js.map +0 -1
  135. package/dist/lib/types/channel.d.ts +0 -456
  136. package/dist/lib/types/channel.js +0 -3
  137. package/dist/lib/types/channel.js.map +0 -1
  138. package/dist/lib/types/emoji.d.ts +0 -22
  139. package/dist/lib/types/emoji.js +0 -3
  140. package/dist/lib/types/emoji.js.map +0 -1
  141. package/dist/lib/types/entitlements.d.ts +0 -32
  142. package/dist/lib/types/entitlements.js +0 -3
  143. package/dist/lib/types/entitlements.js.map +0 -1
  144. package/dist/lib/types/gateway-events.d.ts +0 -805
  145. package/dist/lib/types/gateway-events.js +0 -3
  146. package/dist/lib/types/gateway-events.js.map +0 -1
  147. package/dist/lib/types/guild-scheduled-event.d.ts +0 -57
  148. package/dist/lib/types/guild-scheduled-event.js +0 -3
  149. package/dist/lib/types/guild-scheduled-event.js.map +0 -1
  150. package/dist/lib/types/guild-template.d.ts +0 -28
  151. package/dist/lib/types/guild-template.js +0 -3
  152. package/dist/lib/types/guild-template.js.map +0 -1
  153. package/dist/lib/types/guild.d.ts +0 -333
  154. package/dist/lib/types/guild.js +0 -3
  155. package/dist/lib/types/guild.js.map +0 -1
  156. package/dist/lib/types/index.d.ts +0 -23
  157. package/dist/lib/types/index.js +0 -40
  158. package/dist/lib/types/index.js.map +0 -1
  159. package/dist/lib/types/interaction.d.ts +0 -170
  160. package/dist/lib/types/interaction.js +0 -3
  161. package/dist/lib/types/interaction.js.map +0 -1
  162. package/dist/lib/types/invite.d.ts +0 -59
  163. package/dist/lib/types/invite.js +0 -3
  164. package/dist/lib/types/invite.js.map +0 -1
  165. package/dist/lib/types/message-components.d.ts +0 -100
  166. package/dist/lib/types/message-components.js +0 -3
  167. package/dist/lib/types/message-components.js.map +0 -1
  168. package/dist/lib/types/role.d.ts +0 -47
  169. package/dist/lib/types/role.js +0 -3
  170. package/dist/lib/types/role.js.map +0 -1
  171. package/dist/lib/types/sku.d.ts +0 -30
  172. package/dist/lib/types/sku.js +0 -3
  173. package/dist/lib/types/sku.js.map +0 -1
  174. package/dist/lib/types/stage-instance.d.ts +0 -20
  175. package/dist/lib/types/stage-instance.js +0 -3
  176. package/dist/lib/types/stage-instance.js.map +0 -1
  177. package/dist/lib/types/sticker.d.ts +0 -61
  178. package/dist/lib/types/sticker.js +0 -3
  179. package/dist/lib/types/sticker.js.map +0 -1
  180. package/dist/lib/types/team.d.ts +0 -30
  181. package/dist/lib/types/team.js +0 -3
  182. package/dist/lib/types/team.js.map +0 -1
  183. package/dist/lib/types/user.d.ts +0 -77
  184. package/dist/lib/types/user.js +0 -3
  185. package/dist/lib/types/user.js.map +0 -1
  186. package/dist/lib/types/voice.d.ts +0 -47
  187. package/dist/lib/types/voice.js +0 -3
  188. package/dist/lib/types/voice.js.map +0 -1
  189. package/dist/lib/types/webhook.d.ts +0 -31
  190. package/dist/lib/types/webhook.js +0 -3
  191. package/dist/lib/types/webhook.js.map +0 -1
  192. package/dist/lib/utils/Util.d.ts +0 -15
  193. package/dist/lib/utils/Util.js +0 -543
  194. package/dist/lib/utils/Util.js.map +0 -1
  195. package/dist/lib/utils/errors.d.ts +0 -12
  196. package/dist/lib/utils/errors.js +0 -25
  197. package/dist/lib/utils/errors.js.map +0 -1
  198. package/dist/lib/utils/index.d.ts +0 -2
  199. package/dist/lib/utils/index.js +0 -19
  200. package/dist/lib/utils/index.js.map +0 -1
  201. package/examples/applicationCommands.js +0 -43
  202. package/examples/buttons.js +0 -70
  203. package/examples/embeds.js +0 -36
  204. package/examples/ephemeralMessages.js +0 -32
  205. package/examples/files.js +0 -36
  206. package/examples/modalSubmit.js +0 -62
  207. package/examples/permissions.js +0 -41
  208. package/examples/selectMenus.js +0 -160
  209. package/examples/text.txt +0 -1
  210. package/lib/Client.ts +0 -616
  211. package/lib/constants.ts +0 -1173
  212. package/lib/gateway/Shard.ts +0 -704
  213. package/lib/gateway/ShardsManager.ts +0 -11
  214. package/lib/gateway/index.ts +0 -2
  215. package/lib/index.ts +0 -7
  216. package/lib/rest/CDN.ts +0 -56
  217. package/lib/rest/Endpoints.ts +0 -241
  218. package/lib/rest/REST.ts +0 -45
  219. package/lib/rest/RequestsManager.ts +0 -134
  220. package/lib/rest/index.ts +0 -4
  221. package/lib/structures/Application.ts +0 -599
  222. package/lib/structures/ApplicationCommand.ts +0 -187
  223. package/lib/structures/AuditLog.ts +0 -112
  224. package/lib/structures/AutoModerationRule.ts +0 -127
  225. package/lib/structures/Base.ts +0 -39
  226. package/lib/structures/Channel.ts +0 -921
  227. package/lib/structures/ClientApplication.ts +0 -515
  228. package/lib/structures/Emoji.ts +0 -95
  229. package/lib/structures/Entitlement.ts +0 -65
  230. package/lib/structures/Guild.ts +0 -1842
  231. package/lib/structures/GuildMember.ts +0 -193
  232. package/lib/structures/GuildScheduledEvent.ts +0 -164
  233. package/lib/structures/GuildTemplate.ts +0 -103
  234. package/lib/structures/Integration.ts +0 -136
  235. package/lib/structures/Interaction.ts +0 -506
  236. package/lib/structures/Invite.ts +0 -108
  237. package/lib/structures/Message.ts +0 -421
  238. package/lib/structures/Role.ts +0 -116
  239. package/lib/structures/SKU.ts +0 -63
  240. package/lib/structures/StageInstance.ts +0 -74
  241. package/lib/structures/Sticker.ts +0 -100
  242. package/lib/structures/Team.ts +0 -41
  243. package/lib/structures/TestEntitlement.ts +0 -78
  244. package/lib/structures/UnavailableGuild.ts +0 -27
  245. package/lib/structures/User.ts +0 -233
  246. package/lib/structures/VoiceState.ts +0 -72
  247. package/lib/structures/Webhook.ts +0 -341
  248. package/lib/structures/index.ts +0 -27
  249. package/lib/types/application-command.ts +0 -118
  250. package/lib/types/application-role-connection-metadata.ts +0 -23
  251. package/lib/types/application.ts +0 -77
  252. package/lib/types/audit-log.ts +0 -105
  253. package/lib/types/auto-moderation.ts +0 -78
  254. package/lib/types/channel.ts +0 -534
  255. package/lib/types/emoji.ts +0 -24
  256. package/lib/types/entitlements.ts +0 -34
  257. package/lib/types/gateway-events.ts +0 -970
  258. package/lib/types/guild-scheduled-event.ts +0 -67
  259. package/lib/types/guild-template.ts +0 -30
  260. package/lib/types/guild.ts +0 -388
  261. package/lib/types/index.ts +0 -23
  262. package/lib/types/interaction.ts +0 -224
  263. package/lib/types/invite.ts +0 -78
  264. package/lib/types/message-components.ts +0 -127
  265. package/lib/types/role.ts +0 -51
  266. package/lib/types/sku.ts +0 -32
  267. package/lib/types/stage-instance.ts +0 -22
  268. package/lib/types/sticker.ts +0 -67
  269. package/lib/types/team.ts +0 -34
  270. package/lib/types/user.ts +0 -93
  271. package/lib/types/voice.ts +0 -51
  272. package/lib/types/webhook.ts +0 -40
  273. package/lib/utils/Util.ts +0 -600
  274. package/lib/utils/errors.ts +0 -23
  275. package/lib/utils/index.ts +0 -2
  276. package/test/basic.js +0 -8
  277. package/tsconfig.json +0 -107
@@ -1,506 +0,0 @@
1
- import {
2
- Base,
3
- Channel,
4
- Entitlement,
5
- GuildMember,
6
- Message,
7
- Role,
8
- User,
9
- } from ".";
10
- import type { Client } from "../Client";
11
- import { Endpoints, type File } from "../rest";
12
- import type {
13
- JSONActionRow,
14
- JSONAllowedMentions,
15
- JSONApplicationCommandData,
16
- JSONAttachment,
17
- JSONEmbed,
18
- JSONInteraction,
19
- JSONInteractionResponse,
20
- JSONMessageComponentData,
21
- JSONModalSubmitData,
22
- RawInteraction,
23
- RawMessage,
24
- } from "../types";
25
- import {
26
- InteractionCallbackType,
27
- type InteractionType,
28
- type MessageFlags,
29
- } from "../constants";
30
-
31
- /** https://discord.com/developers/docs/interactions/receiving-and-responding */
32
- export class Interaction extends Base {
33
- protected override raw: RawInteraction;
34
- applicationId: string;
35
- type: InteractionType;
36
- data?: JSONApplicationCommandData &
37
- JSONMessageComponentData &
38
- JSONModalSubmitData;
39
- guildId?: string;
40
- channel?: Channel;
41
- channelId?: string;
42
- member?: GuildMember;
43
- user?: User;
44
- token: string;
45
- version: number;
46
- message?: Message;
47
- appPermissions?: string;
48
- locale?: string;
49
- guildLocale?: string;
50
- entitlements: Array<Entitlement>;
51
-
52
- constructor(data: RawInteraction, client: Client) {
53
- super(data.id, client);
54
-
55
- this.raw = data;
56
- this.applicationId = data.application_id;
57
- this.type = data.type;
58
- this.token = data.token;
59
- this.version = data.version;
60
- this.entitlements = data.entitlements.map(
61
- (entitlement) => new Entitlement(entitlement, this.client)
62
- );
63
-
64
- this.patch(data);
65
- }
66
-
67
- protected override patch(data: RawInteraction): void {
68
- if (data.data !== undefined)
69
- this.data = {
70
- id: data.data.id,
71
- name: data.data.name,
72
- type: data.data.type,
73
- resolved: {
74
- users:
75
- data.data.resolved?.users !== undefined
76
- ? new Map(
77
- Object.entries(data.data.resolved.users).map(([id, user]) => [
78
- id,
79
- new User(user, this.client).toJSON(),
80
- ])
81
- )
82
- : undefined,
83
- members:
84
- data.data.resolved?.members !== undefined
85
- ? new Map(
86
- Object.entries(data.data.resolved.members).map(
87
- ([id, member]) => [
88
- id,
89
- new GuildMember(member, this.client).toJSON(),
90
- ]
91
- )
92
- )
93
- : undefined,
94
- roles:
95
- data.data.resolved?.roles !== undefined
96
- ? new Map(
97
- Object.entries(data.data.resolved.roles).map(([id, role]) => [
98
- id,
99
- new Role(role, this.client).toJSON(),
100
- ])
101
- )
102
- : undefined,
103
- channels:
104
- data.data.resolved?.channels !== undefined
105
- ? new Map(
106
- Object.entries(data.data.resolved.channels).map(
107
- ([id, channel]) => [
108
- id,
109
- new Channel(channel, this.client).toJSON(),
110
- ]
111
- )
112
- )
113
- : undefined,
114
- messages:
115
- data.data.resolved?.messages !== undefined
116
- ? new Map(
117
- Object.entries(data.data.resolved.messages).map(
118
- ([id, message]) => [
119
- id,
120
- new Message(message, this.client).toJSON(),
121
- ]
122
- )
123
- )
124
- : undefined,
125
- attachments:
126
- data.data.resolved?.attachments !== undefined
127
- ? new Map(
128
- Object.entries(data.data.resolved.attachments).map(
129
- ([id, attachment]) => [
130
- id,
131
- this.client.util.attachmentToJSON(attachment),
132
- ]
133
- )
134
- )
135
- : undefined,
136
- },
137
- options: data.data.options,
138
- guildId: data.data.guild_id,
139
- targetId: data.data.target_id,
140
- customId: data.data.custom_id,
141
- componentType: data.data.component_type,
142
- values: data.data.values,
143
- components: data.data.components?.map((component) => ({
144
- type: component.type,
145
- components: component.components?.map((c) => ({
146
- type: c.type,
147
- customId: c.custom_id,
148
- style: c.style,
149
- label: c.label,
150
- minLength: c.min_length,
151
- maxLength: c.max_length,
152
- required: c.required,
153
- value: c.value,
154
- placeholder: c.placeholder,
155
- })),
156
- })),
157
- };
158
- if (data.guild_id !== undefined) this.guildId = data.guild_id;
159
- if (data.channel !== undefined)
160
- this.channel = new Channel(data.channel, this.client);
161
- if (data.channel_id !== undefined) this.channelId = data.channel_id;
162
- if (data.member !== undefined)
163
- this.member = new GuildMember(data.member, this.client);
164
- if (data.user !== undefined) this.user = new User(data.user, this.client);
165
- if (data.message !== undefined)
166
- this.message = new Message(data.message, this.client);
167
- if (data.app_permissions !== undefined)
168
- this.appPermissions = data.app_permissions;
169
- if (data.locale !== undefined) this.locale = data.locale;
170
- if (data.guild_locale !== undefined) this.guildLocale = data.guild_locale;
171
- }
172
-
173
- /** https://discord.com/developers/docs/interactions/receiving-and-responding#create-followup-message */
174
- async createFollowupMessage(options: {
175
- content?: string | null;
176
- tts?: boolean;
177
- embeds?: Array<JSONEmbed> | null;
178
- allowedMentions?: JSONAllowedMentions | null;
179
- components?: Array<JSONActionRow> | null;
180
- files?: Array<File> | null;
181
- attachments?: Array<JSONAttachment> | null;
182
- flags?: MessageFlags | null;
183
- threadName?: string;
184
- }): Promise<Message> {
185
- return new Message(
186
- await this.client.rest.post(
187
- Endpoints.webhook(this.applicationId, this.token),
188
- {
189
- json: {
190
- content: options.content,
191
- tts: options.tts,
192
- embeds:
193
- options.embeds !== undefined
194
- ? options.embeds !== null
195
- ? this.client.util.embedsToRaw(options.embeds)
196
- : null
197
- : undefined,
198
- allowed_mentions: {
199
- parse: options.allowedMentions?.parse,
200
- roles: options.allowedMentions?.roles,
201
- users: options.allowedMentions?.users,
202
- replied_user: options.allowedMentions?.repliedUser,
203
- },
204
- components:
205
- options.components !== undefined
206
- ? options.components !== null
207
- ? this.client.util.messageComponentsToRaw(options.components)
208
- : null
209
- : undefined,
210
- attachments: options.attachments,
211
- flags: options.flags,
212
- thread_name: options.threadName,
213
- },
214
- files: options.files,
215
- }
216
- ),
217
- this.client
218
- );
219
- }
220
-
221
- /** https://discord.com/developers/docs/interactions/receiving-and-responding#create-interaction-response */
222
- createResponse(options: JSONInteractionResponse): void {
223
- switch (options.type) {
224
- case InteractionCallbackType.ChannelMessageWithSource:
225
- case InteractionCallbackType.UpdateMessage:
226
- {
227
- this.client.rest.post(
228
- Endpoints.interactionCallback(this.id, this.token),
229
- {
230
- json: {
231
- type: options.type,
232
- data: {
233
- content: options.data?.content,
234
- embeds:
235
- options.data?.embeds !== undefined
236
- ? this.client.util.embedsToRaw(options.data.embeds)
237
- : undefined,
238
- allowed_mentions: {
239
- parse: options.data?.allowedMentions?.parse,
240
- roles: options.data?.allowedMentions?.roles,
241
- users: options.data?.allowedMentions?.users,
242
- replied_user: options.data?.allowedMentions?.repliedUser,
243
- },
244
- flags: options.data?.flags,
245
- components:
246
- options.data?.components !== undefined
247
- ? this.client.util.messageComponentsToRaw(
248
- options.data.components
249
- )
250
- : undefined,
251
- attachments: options.data?.attachments,
252
- },
253
- },
254
- files: options.data?.files,
255
- }
256
- );
257
- }
258
- break;
259
- case InteractionCallbackType.DeferredChannelMessageWithSource:
260
- case InteractionCallbackType.DeferredUpdateMessage:
261
- {
262
- this.client.rest.post(
263
- Endpoints.interactionCallback(this.id, this.token),
264
- {
265
- json: {
266
- type: options.type,
267
- data: {
268
- flags: options.data?.flags,
269
- },
270
- },
271
- }
272
- );
273
- }
274
- break;
275
- case InteractionCallbackType.ApplicationCommandAutocompleteResult:
276
- {
277
- this.client.rest.post(
278
- Endpoints.interactionCallback(this.id, this.token),
279
- {
280
- json: {
281
- type: options.type,
282
- data: {
283
- choices: options.data?.choices?.map((choice) => ({
284
- name: choice.name,
285
- name_localizations: choice.nameLocalizations,
286
- value: choice.value,
287
- })),
288
- },
289
- },
290
- }
291
- );
292
- }
293
- break;
294
- case InteractionCallbackType.Modal:
295
- {
296
- this.client.rest.post(
297
- Endpoints.interactionCallback(this.id, this.token),
298
- {
299
- json: {
300
- type: options.type,
301
- data: {
302
- custom_id: options.data?.customId,
303
- components:
304
- options.data?.components !== undefined
305
- ? this.client.util.messageComponentsToRaw(
306
- options.data.components
307
- )
308
- : undefined,
309
- title: options.data?.title,
310
- },
311
- },
312
- }
313
- );
314
- }
315
- break;
316
- case InteractionCallbackType.PremiumRequired:
317
- {
318
- this.client.rest.post(
319
- Endpoints.interactionCallback(this.id, this.token),
320
- {
321
- json: {
322
- type: options.type,
323
- data: {},
324
- },
325
- }
326
- );
327
- }
328
- break;
329
- }
330
- }
331
-
332
- /** https://discord.com/developers/docs/interactions/receiving-and-responding#delete-followup-message */
333
- deleteFollowupMessage(messageId: string): void {
334
- this.client.rest.delete(
335
- Endpoints.webhookMessage(this.applicationId, this.token, messageId)
336
- );
337
- }
338
-
339
- /** https://discord.com/developers/docs/interactions/receiving-and-responding#delete-original-interaction-response */
340
- deleteResponse(): void {
341
- this.client.rest.delete(
342
- Endpoints.webhookMessage(this.applicationId, this.token)
343
- );
344
- }
345
-
346
- /** https://discord.com/developers/docs/interactions/receiving-and-responding#edit-followup-message */
347
- async editFollowupMessage(
348
- messageId: string,
349
- options: {
350
- threadId?: string;
351
- content?: string | null;
352
- embeds?: Array<JSONEmbed> | null;
353
- flags?: MessageFlags | null;
354
- allowedMentions?: JSONAllowedMentions | null;
355
- components?: Array<JSONActionRow> | null;
356
- files?: Array<File> | null;
357
- attachments?: Array<JSONAttachment> | null;
358
- }
359
- ): Promise<Message> {
360
- return new Message(
361
- await this.client.rest.post<RawMessage>(
362
- Endpoints.webhookMessage(this.applicationId, this.token, messageId),
363
- {
364
- json: {
365
- content: options.content,
366
- embeds:
367
- options.embeds !== undefined
368
- ? options.embeds !== null
369
- ? this.client.util.embedsToRaw(options.embeds)
370
- : null
371
- : undefined,
372
- allowed_mentions: {
373
- parse: options.allowedMentions?.parse,
374
- roles: options.allowedMentions?.roles,
375
- users: options.allowedMentions?.users,
376
- replied_user: options.allowedMentions?.repliedUser,
377
- },
378
- components:
379
- options.components !== undefined
380
- ? options.components !== null
381
- ? this.client.util.messageComponentsToRaw(options.components)
382
- : null
383
- : undefined,
384
- attachments: options.attachments,
385
- flags: options.flags,
386
- },
387
- files: options.files,
388
- query: {
389
- thread_id: options.threadId,
390
- },
391
- }
392
- ),
393
- this.client
394
- );
395
- }
396
-
397
- /** https://discord.com/developers/docs/interactions/receiving-and-responding#edit-original-interaction-response */
398
- async editResponse(options: {
399
- threadId?: string;
400
- content?: string | null;
401
- embeds?: Array<JSONEmbed> | null;
402
- flags?: MessageFlags | null;
403
- allowedMentions?: JSONAllowedMentions | null;
404
- components?: Array<JSONActionRow> | null;
405
- files?: Array<File> | null;
406
- attachments?: Array<JSONAttachment> | null;
407
- }): Promise<Message> {
408
- return new Message(
409
- await this.client.rest.patch<RawMessage>(
410
- Endpoints.webhookMessage(this.applicationId, this.token),
411
- {
412
- json: {
413
- content: options.content,
414
- embeds:
415
- options.embeds !== undefined
416
- ? options.embeds !== null
417
- ? this.client.util.embedsToRaw(options.embeds)
418
- : null
419
- : undefined,
420
- allowed_mentions: {
421
- parse: options.allowedMentions?.parse,
422
- roles: options.allowedMentions?.roles,
423
- users: options.allowedMentions?.users,
424
- replied_user: options.allowedMentions?.repliedUser,
425
- },
426
- components:
427
- options.components !== undefined
428
- ? options.components !== null
429
- ? this.client.util.messageComponentsToRaw(options.components)
430
- : null
431
- : undefined,
432
- attachments: options.attachments,
433
- flags: options.flags,
434
- },
435
- files: options.files,
436
- query: {
437
- thread_id: options.threadId,
438
- },
439
- }
440
- ),
441
- this.client
442
- );
443
- }
444
-
445
- /** https://discord.com/developers/docs/interactions/receiving-and-responding#get-followup-message */
446
- async getFollowupMessage(
447
- messageId: string,
448
- options?: {
449
- threadId?: string;
450
- }
451
- ): Promise<Message> {
452
- return new Message(
453
- await this.client.rest.get<RawMessage>(
454
- Endpoints.webhookMessage(this.applicationId, this.token, messageId),
455
- {
456
- query: {
457
- thread_id: options?.threadId,
458
- },
459
- }
460
- ),
461
- this.client
462
- );
463
- }
464
-
465
- /** https://discord.com/developers/docs/interactions/receiving-and-responding#get-original-interaction-response */
466
- async getResponse(options?: { threadId?: string }): Promise<Message> {
467
- return new Message(
468
- await this.client.rest.get<RawMessage>(
469
- Endpoints.webhookMessage(this.applicationId, this.token),
470
- {
471
- query: {
472
- thread_id: options?.threadId,
473
- },
474
- }
475
- ),
476
- this.client
477
- );
478
- }
479
-
480
- override toRaw(): RawInteraction {
481
- return this.raw;
482
- }
483
-
484
- override toJSON(): JSONInteraction {
485
- return {
486
- ...super.toJSON(),
487
- applicationId: this.applicationId,
488
- type: this.type,
489
- data: this.data,
490
- guildId: this.guildId,
491
- channel: this.channel?.toJSON(),
492
- channelId: this.channelId,
493
- member: this.member?.toJSON(),
494
- user: this.user?.toJSON(),
495
- token: this.token,
496
- version: this.version,
497
- message: this.message?.toJSON(),
498
- appPermissions: this.appPermissions,
499
- locale: this.locale,
500
- guildLocale: this.guildLocale,
501
- entitlements: this.entitlements.map((entitlement) =>
502
- entitlement.toJSON()
503
- ),
504
- };
505
- }
506
- }
@@ -1,108 +0,0 @@
1
- import {
2
- Application,
3
- Channel,
4
- Guild,
5
- GuildMember,
6
- GuildScheduledEvent,
7
- User,
8
- } from ".";
9
- import type { Client } from "../Client";
10
- import { InviteTargetTypes } from "../constants";
11
- import { Endpoints } from "../rest";
12
- import type { JSONInvite, JSONInviteStageInstance, RawInvite } from "../types";
13
-
14
- /** https://discord.com/developers/docs/resources/invite */
15
- export class Invite {
16
- private client: Client;
17
- private raw: RawInvite;
18
- code: string;
19
- guild?: Guild;
20
- channel: Channel;
21
- inviter?: User;
22
- targetType?: InviteTargetTypes;
23
- targetUser?: User;
24
- targetApplication?: Application;
25
- approximatePresenceCount?: number;
26
- approximateMemberCount?: number;
27
- expiresAt?: string | null;
28
- stageInstance?: JSONInviteStageInstance;
29
- guildScheduledEvent?: GuildScheduledEvent;
30
-
31
- constructor(data: RawInvite, client: Client) {
32
- this.client = client;
33
- this.raw = data;
34
- this.code = data.code;
35
- this.channel = new Channel(data.channel, client);
36
-
37
- this.patch(data);
38
- }
39
-
40
- private patch(data: RawInvite): void {
41
- if (data.guild !== undefined)
42
- this.guild = new Guild(data.guild, this.client);
43
- if (data.inviter !== undefined)
44
- this.inviter = new User(data.inviter, this.client);
45
- if (data.target_type !== undefined) this.targetType = data.target_type;
46
- if (data.target_user !== undefined)
47
- this.targetUser = new User(data.target_user, this.client);
48
- if (data.target_application !== undefined)
49
- this.targetApplication = new Application(
50
- data.target_application,
51
- this.client
52
- );
53
- if (data.approximate_presence_count !== undefined)
54
- this.approximatePresenceCount = data.approximate_presence_count;
55
- if (data.approximate_member_count !== undefined)
56
- this.approximateMemberCount = data.approximate_member_count;
57
- if (data.expires_at !== undefined) this.expiresAt = data.expires_at;
58
- if (data.stage_instance !== undefined)
59
- this.stageInstance = {
60
- members: data.stage_instance.members.map((member) =>
61
- new GuildMember(member, this.client).toJSON()
62
- ),
63
- participantCount: data.stage_instance.participant_count,
64
- speakerCount: data.stage_instance.speaker_count,
65
- topic: data.stage_instance.topic,
66
- };
67
- if (data.guild_scheduled_event !== undefined)
68
- this.guildScheduledEvent = new GuildScheduledEvent(
69
- data.guild_scheduled_event,
70
- this.client
71
- );
72
- }
73
-
74
- /** https://discord.com/developers/docs/resources/invite#delete-invite */
75
- async delete(reason?: string): Promise<JSONInvite> {
76
- return new Invite(
77
- await this.client.rest.delete<RawInvite>(Endpoints.invite(this.code), {
78
- reason,
79
- }),
80
- this.client
81
- ).toJSON();
82
- }
83
-
84
- toString(): string {
85
- return `[${this.constructor.name}]`;
86
- }
87
-
88
- toRaw(): RawInvite {
89
- return this.raw;
90
- }
91
-
92
- toJSON(): JSONInvite {
93
- return {
94
- code: this.code,
95
- guild: this.guild?.toJSON(),
96
- channel: this.channel.toJSON(),
97
- inviter: this.inviter?.toJSON(),
98
- targetType: this.targetType,
99
- targetUser: this.targetUser?.toJSON(),
100
- targetApplication: this.targetApplication?.toJSON(),
101
- approximatePresenceCount: this.approximatePresenceCount,
102
- approximateMemberCount: this.approximateMemberCount,
103
- expiresAt: this.expiresAt,
104
- stageInstance: this.stageInstance,
105
- guildScheduledEvent: this.guildScheduledEvent?.toJSON(),
106
- };
107
- }
108
- }