snowtransfer 0.17.7 → 0.18.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.
- package/CHANGELOG.md +60 -0
- package/LICENSE.md +1 -1
- package/README.md +4 -5
- package/dist/Constants.d.ts +59 -0
- package/dist/Constants.js +123 -0
- package/dist/Endpoints.d.ts +120 -0
- package/dist/Endpoints.js +121 -0
- package/dist/RequestHandler.d.ts +258 -0
- package/dist/RequestHandler.js +629 -0
- package/dist/SnowTransfer.d.ts +70 -0
- package/dist/SnowTransfer.js +105 -0
- package/dist/StateMachine.d.ts +89 -0
- package/dist/StateMachine.js +208 -0
- package/dist/StateMachineGraph.d.ts +3 -0
- package/dist/StateMachineGraph.js +23 -0
- package/dist/Types.d.ts +76 -0
- package/dist/Types.js +2 -0
- package/dist/index.d.ts +25 -4102
- package/dist/index.js +63 -46
- package/dist/methods/Assets.d.ts +290 -0
- package/dist/methods/Assets.js +326 -0
- package/dist/methods/AuditLog.d.ts +40 -0
- package/dist/methods/AuditLog.js +44 -0
- package/dist/methods/AutoModeration.d.ts +122 -0
- package/dist/methods/AutoModeration.js +135 -0
- package/dist/methods/Bot.d.ts +65 -0
- package/dist/methods/Bot.js +75 -0
- package/dist/methods/Channel.d.ts +866 -0
- package/dist/methods/Channel.js +982 -0
- package/dist/methods/Entitlements.d.ts +87 -0
- package/dist/methods/Entitlements.js +99 -0
- package/dist/methods/Guild.d.ts +722 -0
- package/dist/methods/Guild.js +785 -0
- package/dist/methods/GuildScheduledEvent.d.ts +138 -0
- package/dist/methods/GuildScheduledEvent.js +155 -0
- package/dist/methods/GuildTemplate.d.ts +110 -0
- package/dist/methods/GuildTemplate.js +124 -0
- package/dist/methods/Interaction.d.ts +339 -0
- package/dist/methods/Interaction.js +359 -0
- package/dist/methods/Invite.d.ts +81 -0
- package/dist/methods/Invite.js +107 -0
- package/dist/methods/Sku.d.ts +58 -0
- package/dist/methods/Sku.js +66 -0
- package/dist/methods/StageInstance.d.ts +86 -0
- package/dist/methods/StageInstance.js +97 -0
- package/dist/methods/User.d.ts +167 -0
- package/dist/methods/User.js +184 -0
- package/dist/methods/Voice.d.ts +44 -0
- package/dist/methods/Voice.js +52 -0
- package/dist/methods/Webhook.d.ts +265 -0
- package/dist/methods/Webhook.js +256 -0
- package/dist/tokenless.d.ts +19 -0
- package/dist/tokenless.js +31 -0
- package/package.json +16 -11
- package/dist/index.js.map +0 -1
|
@@ -0,0 +1,359 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const Endpoints = require("../Endpoints");
|
|
3
|
+
const Constants = require("../Constants");
|
|
4
|
+
const v10_1 = require("discord-api-types/v10");
|
|
5
|
+
/**
|
|
6
|
+
* Methods for interacting with slash command specific endpoints
|
|
7
|
+
* @since 0.3.0
|
|
8
|
+
*/
|
|
9
|
+
class InteractionMethods {
|
|
10
|
+
requestHandler;
|
|
11
|
+
webhooks;
|
|
12
|
+
options;
|
|
13
|
+
/**
|
|
14
|
+
* Create a new Interaction Method Handler
|
|
15
|
+
*
|
|
16
|
+
* Usually SnowTransfer creates a method handler for you, this is here for completion
|
|
17
|
+
*
|
|
18
|
+
* You can access the methods listed via `client.interaction.method`, where `client` is an initialized SnowTransfer instance
|
|
19
|
+
* @param requestHandler request handler that calls the rest api
|
|
20
|
+
* @param webhooks WebhookMethods class that handles webhook related stuff
|
|
21
|
+
*/
|
|
22
|
+
constructor(requestHandler, webhooks, options) {
|
|
23
|
+
this.requestHandler = requestHandler;
|
|
24
|
+
this.webhooks = webhooks;
|
|
25
|
+
this.options = options;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Fetch all global commands for your application
|
|
29
|
+
* @since 0.3.0
|
|
30
|
+
* @param appId The Id of the application
|
|
31
|
+
* @param withLocalizations Whether or not to include localizations
|
|
32
|
+
* @returns An Array of [application command](https://discord.com/developers/docs/interactions/application-commands#application-command-object-application-command-structure) objects
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* const client = new SnowTransfer("TOKEN")
|
|
36
|
+
* const commands = await client.interaction.getApplicationCommands("appId")
|
|
37
|
+
*/
|
|
38
|
+
async getApplicationCommands(appId, withLocalizations) {
|
|
39
|
+
return this.requestHandler.request(Endpoints.APPLICATION_COMMANDS(appId), { with_localizations: withLocalizations }, "get", "json");
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Create a new global command. New global commands will be available in all guilds after 1 hour
|
|
43
|
+
* @since 0.3.0
|
|
44
|
+
* @param appId The Id of the application
|
|
45
|
+
* @param data The command data
|
|
46
|
+
* @returns An [application command](https://discord.com/developers/docs/interactions/application-commands#application-command-object-application-command-structure) object
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* const client = new SnowTransfer("TOKEN")
|
|
50
|
+
* const command = await client.interaction.createApplicationCommand("appId", { name: "test", description: "testing 1, 2, 3" })
|
|
51
|
+
*/
|
|
52
|
+
async createApplicationCommand(appId, data) {
|
|
53
|
+
return this.requestHandler.request(Endpoints.APPLICATION_COMMANDS(appId), {}, "post", "json", data);
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Fetch a global command for your application
|
|
57
|
+
* @since 0.3.0
|
|
58
|
+
* @param appId The Id of the application
|
|
59
|
+
* @param cmdId The Id of the command
|
|
60
|
+
* @returns An [application command](https://discord.com/developers/docs/interactions/application-commands#application-command-object-application-command-structure) object
|
|
61
|
+
*
|
|
62
|
+
* @example
|
|
63
|
+
* const client = new SnowTransfer("TOKEN")
|
|
64
|
+
* const command = await client.interaction.getApplicationCommand("appId", "cmdId")
|
|
65
|
+
*/
|
|
66
|
+
async getApplicationCommand(appId, cmdId) {
|
|
67
|
+
return this.requestHandler.request(Endpoints.APPLICATION_COMMAND(appId, cmdId), {}, "get", "json");
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Edit a global command. Updates will be available in all guilds after 1 hour
|
|
71
|
+
* @since 0.3.0
|
|
72
|
+
* @param appId The Id of the application
|
|
73
|
+
* @param cmdId The Id of the command
|
|
74
|
+
* @param data The command data
|
|
75
|
+
* @returns An [application command](https://discord.com/developers/docs/interactions/application-commands#application-command-object-application-command-structure) object
|
|
76
|
+
*
|
|
77
|
+
* @example
|
|
78
|
+
* const client = new SnowTransfer("TOKEN")
|
|
79
|
+
* const command = await client.interaction.editApplicationCommand("appId", "cmdId", { name: "cool", description: "tells you how cool you are" })
|
|
80
|
+
*/
|
|
81
|
+
async editApplicationCommand(appId, cmdId, data) {
|
|
82
|
+
return this.requestHandler.request(Endpoints.APPLICATION_COMMAND(appId, cmdId), {}, "patch", "json", data);
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Deletes a global command
|
|
86
|
+
* @since 0.3.0
|
|
87
|
+
* @param appId The Id of the application
|
|
88
|
+
* @param cmdId The Id of the command
|
|
89
|
+
* @returns Resolves the Promise on successful execution
|
|
90
|
+
*
|
|
91
|
+
* @example
|
|
92
|
+
* const client = new SnowTransfer("TOKEN")
|
|
93
|
+
* client.interaction.deleteApplicationCommand("appId", "cmdId")
|
|
94
|
+
*/
|
|
95
|
+
async deleteApplicationCommand(appId, cmdId) {
|
|
96
|
+
return this.requestHandler.request(Endpoints.APPLICATION_COMMAND(appId, cmdId), {}, "delete", "json");
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Takes a list of application commands, overwriting existing commands that are registered globally for this application.
|
|
100
|
+
* Updates will be available in all guilds after 1 hour
|
|
101
|
+
* @since 0.18.0
|
|
102
|
+
* @param appId The Id of the application
|
|
103
|
+
* @param data Array of commands
|
|
104
|
+
* @returns An Array of [application command](https://discord.com/developers/docs/interactions/application-commands#application-command-object-application-command-structure) objects
|
|
105
|
+
*
|
|
106
|
+
* @example
|
|
107
|
+
* const client = new SnowTransfer("TOKEN")
|
|
108
|
+
* const commands = await client.interaction.editApplicationCommands("appId", [{ name: "test", description: "testing 1, 2, 3" }])
|
|
109
|
+
*/
|
|
110
|
+
async editApplicationCommands(appId, data) {
|
|
111
|
+
return this.requestHandler.request(Endpoints.APPLICATION_COMMANDS(appId), {}, "put", "json", data);
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Fetch all of the guild commands for your application for a specific guild.
|
|
115
|
+
* @since 0.3.0
|
|
116
|
+
* @param appId The Id of the application
|
|
117
|
+
* @param guildId The Id of the guild
|
|
118
|
+
* @param withLocalizations Whether or not to include localizations
|
|
119
|
+
* @returns An Array of [application command](https://discord.com/developers/docs/interactions/application-commands#application-command-object-application-command-structure) objects
|
|
120
|
+
*
|
|
121
|
+
* @example
|
|
122
|
+
* const client = new SnowTransfer("TOKEN")
|
|
123
|
+
* const commands = await client.interaction.getGuildCommands("appId", "guildId", true)
|
|
124
|
+
*/
|
|
125
|
+
async getGuildApplicationCommands(appId, guildId, withLocalizations) {
|
|
126
|
+
return this.requestHandler.request(Endpoints.APPLICATION_GUILD_COMMANDS(appId, guildId), { with_localizations: withLocalizations }, "get", "json");
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Create a new guild command. New guild commands will be available in the guild immediately.
|
|
130
|
+
* @since 0.3.0
|
|
131
|
+
* @param appId The Id of the application
|
|
132
|
+
* @param guildId The Id of the guild
|
|
133
|
+
* @param data Command data
|
|
134
|
+
* @returns An [application command](https://discord.com/developers/docs/interactions/application-commands#application-command-object-application-command-structure) object
|
|
135
|
+
*
|
|
136
|
+
* @example
|
|
137
|
+
* const client = new SnowTransfer("TOKEN")
|
|
138
|
+
* const command = await client.interaction.createGuildApplicationCommand("appId", "guildId", { name: "test", description: "testing 1, 2, 3" })
|
|
139
|
+
*/
|
|
140
|
+
async createGuildApplicationCommand(appId, guildId, data) {
|
|
141
|
+
return this.requestHandler.request(Endpoints.APPLICATION_GUILD_COMMANDS(appId, guildId), {}, "post", "json", data);
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Fetch a guild command for your application
|
|
145
|
+
* @since 0.3.0
|
|
146
|
+
* @param appId The Id of the application
|
|
147
|
+
* @param guildId The Id of the guild
|
|
148
|
+
* @param cmdId The Id of the command
|
|
149
|
+
* @returns An [application command](https://discord.com/developers/docs/interactions/application-commands#application-command-object-application-command-structure) object
|
|
150
|
+
*
|
|
151
|
+
* @example
|
|
152
|
+
* const client = new SnowTransfer("TOKEN")
|
|
153
|
+
* const command = await client.interaction.getGuildApplicationCommand("appId", "guildId", "cmdId")
|
|
154
|
+
*/
|
|
155
|
+
async getGuildApplicationCommand(appId, guildId, cmdId) {
|
|
156
|
+
return this.requestHandler.request(Endpoints.APPLICATION_GUILD_COMMAND(appId, guildId, cmdId), {}, "get", "json");
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Edit a guild command. Updates for guild commands will be available immediately.
|
|
160
|
+
* @since 0.3.0
|
|
161
|
+
* @param appId The Id of the application
|
|
162
|
+
* @param guildId The Id of the guild
|
|
163
|
+
* @param cmdId The Id of the command
|
|
164
|
+
* @param data New command data
|
|
165
|
+
* @returns An [application command](https://discord.com/developers/docs/interactions/application-commands#application-command-object-application-command-structure) object
|
|
166
|
+
*
|
|
167
|
+
* @example
|
|
168
|
+
* const client = new SnowTransfer("TOKEN")
|
|
169
|
+
* const command = await client.interaction.editGuildApplicationCommand("appId", "guildId", "cmdId", { name: "coolest", description: "tells you that you are the coolest" })
|
|
170
|
+
*/
|
|
171
|
+
async editGuildApplicationCommand(appId, guildId, cmdId, data) {
|
|
172
|
+
return this.requestHandler.request(Endpoints.APPLICATION_GUILD_COMMAND(appId, guildId, cmdId), {}, "patch", "json", data);
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Delete a guild command
|
|
176
|
+
* @since 0.3.0
|
|
177
|
+
* @param appId The Id of the application
|
|
178
|
+
* @param guildId The Id of the guild
|
|
179
|
+
* @param cmdId The Id of the command
|
|
180
|
+
* @returns Resolves the Promise on successful execution
|
|
181
|
+
*
|
|
182
|
+
* @example
|
|
183
|
+
* const client = new SnowTransfer("TOKEN")
|
|
184
|
+
* client.interaction.deleteGuildApplicationCommand("appId", "guildId", "cmdId")
|
|
185
|
+
*/
|
|
186
|
+
async deleteGuildApplicationCommand(appId, guildId, cmdId) {
|
|
187
|
+
return this.requestHandler.request(Endpoints.APPLICATION_GUILD_COMMAND(appId, guildId, cmdId), {}, "delete", "json");
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Takes a list of application commands, overwriting existing commands for the guild
|
|
191
|
+
* @since 0.18.0
|
|
192
|
+
* @param appId The Id of the application
|
|
193
|
+
* @param guildId The Id of the guild
|
|
194
|
+
* @param data Array of commands
|
|
195
|
+
* @returns An Array of [application command](https://discord.com/developers/docs/interactions/application-commands#application-command-object-application-command-structure) objects
|
|
196
|
+
*
|
|
197
|
+
* @example
|
|
198
|
+
* const client = new SnowTransfer("TOKEN")
|
|
199
|
+
* const commands = await client.interaction.editGuildApplicationCommands("appId", "guildId", [{ name: "test", description: "testing 1, 2, 3" }])
|
|
200
|
+
*/
|
|
201
|
+
async editGuildApplicationCommands(appId, guildId, data) {
|
|
202
|
+
return this.requestHandler.request(Endpoints.APPLICATION_GUILD_COMMANDS(appId, guildId), {}, "put", "json", data);
|
|
203
|
+
}
|
|
204
|
+
async getGuildApplicationCommandPermissions(appId, guildId, cmdId) {
|
|
205
|
+
if (cmdId)
|
|
206
|
+
return this.requestHandler.request(Endpoints.APPLICATION_GUILD_COMMAND_PERMISSIONS(appId, guildId, cmdId), {}, "get", "json");
|
|
207
|
+
return this.requestHandler.request(Endpoints.APPLICATION_GUILD_COMMANDS_PERMISSIONS(appId, guildId), {}, "get", "json");
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* Edits command permissions for a specific command for your application in a guild. You can only add up to 10 permission overwrites for a command.
|
|
211
|
+
* @since 0.5.0
|
|
212
|
+
* @param appId The Id of the application
|
|
213
|
+
* @param guildId The Id of the guild
|
|
214
|
+
* @param cmdId The Id of the command
|
|
215
|
+
* @param permissions New application command permissions data
|
|
216
|
+
* @returns A [guild application command permission](https://discord.com/developers/docs/interactions/application-commands#application-command-permissions-object-guild-application-command-permissions-structure) object
|
|
217
|
+
*
|
|
218
|
+
* @example
|
|
219
|
+
* const client = new SnowTransfer("TOKEN")
|
|
220
|
+
* const permissions = await client.interaction.editGuildApplicationCommandPermissions("appId", "guildId", "cmdId", [{ type: 2, id: "userId", permission: true }])
|
|
221
|
+
*/
|
|
222
|
+
async editGuildApplicationCommandPermissions(appId, guildId, cmdId, permissions) {
|
|
223
|
+
const payload = { permissions: permissions };
|
|
224
|
+
return this.requestHandler.request(Endpoints.APPLICATION_GUILD_COMMAND_PERMISSIONS(appId, guildId, cmdId), {}, "put", "json", payload);
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* Create a response to an Interaction
|
|
228
|
+
*
|
|
229
|
+
* When uploading attachments to respond to message interactions, you must provide the top level files property
|
|
230
|
+
* which needs to match attachments array length and each element needs to match the same indexes as where their filename is defined (the top level files property gets deleted before it's appended to payload_json).
|
|
231
|
+
* Should you have a more elegant solution, possibly rewriting the interface with the request handler, please submit a PR/issue.
|
|
232
|
+
* @since 0.3.0
|
|
233
|
+
* @param interactionId The Id of the interaction
|
|
234
|
+
* @param token The token of the interaction
|
|
235
|
+
* @param data Response data
|
|
236
|
+
* @returns Resolves the Promise on successful execution
|
|
237
|
+
*
|
|
238
|
+
* @example
|
|
239
|
+
* // Respond to a message interaction
|
|
240
|
+
* const client = new SnowTransfer() // This endpoint does not require a Bot token. The interaction token alone will suffice
|
|
241
|
+
* client.interaction.createInteractionResponse("interactionId", "token", { type: 4, data: { content: "Hello World" } })
|
|
242
|
+
*/
|
|
243
|
+
async createInteractionResponse(interactionId, token, data) {
|
|
244
|
+
const payload = Constants.cloneUserInput(data);
|
|
245
|
+
if ((payload.type === v10_1.InteractionResponseType.ChannelMessageWithSource ||
|
|
246
|
+
payload.type === v10_1.InteractionResponseType.UpdateMessage) && payload.data)
|
|
247
|
+
payload.data.allowed_mentions ??= this.options.allowed_mentions;
|
|
248
|
+
if (payload.files)
|
|
249
|
+
return this.requestHandler.request(Endpoints.INTERACTION_CALLBACK(interactionId, token), {}, "post", "multipart", await Constants.standardMultipartHandler(payload));
|
|
250
|
+
else
|
|
251
|
+
return this.requestHandler.request(Endpoints.INTERACTION_CALLBACK(interactionId, token), {}, "post", "json", payload);
|
|
252
|
+
}
|
|
253
|
+
/**
|
|
254
|
+
* Returns the initial Interaction response
|
|
255
|
+
* @since 0.3.0
|
|
256
|
+
* @param appId The Id of the application
|
|
257
|
+
* @param token The token of the interaction
|
|
258
|
+
* @returns A [message](https://discord.com/developers/docs/resources/channel#message-object) object
|
|
259
|
+
*
|
|
260
|
+
* @example
|
|
261
|
+
* const client = new SnowTransfer() // This endpoint does not require a Bot token. The interaction token alone will suffice
|
|
262
|
+
* const message = await client.interaction.getOriginalInteractionResponse("appId", "token")
|
|
263
|
+
*/
|
|
264
|
+
async getOriginalInteractionResponse(appId, token) {
|
|
265
|
+
return this.webhooks.getWebhookMessage(appId, token, "@original");
|
|
266
|
+
}
|
|
267
|
+
/**
|
|
268
|
+
* Edits the initial Interaction response
|
|
269
|
+
* @since 0.3.0
|
|
270
|
+
* @param appId The Id of the application
|
|
271
|
+
* @param token The token of the interaction
|
|
272
|
+
* @param data New response data
|
|
273
|
+
* @returns A [message](https://discord.com/developers/docs/resources/channel#message-object) object
|
|
274
|
+
*
|
|
275
|
+
* @example
|
|
276
|
+
* const client = new SnowTransfer() // This endpoint does not require a Bot token. The interaction token alone will suffice
|
|
277
|
+
* const message = await client.interaction.editOriginalInteractionResponse("appId", "token", { content: "The world said hello back" })
|
|
278
|
+
*/
|
|
279
|
+
async editOriginalInteractionResponse(appId, token, data) {
|
|
280
|
+
return this.webhooks.editWebhookMessage(appId, token, "@original", data);
|
|
281
|
+
}
|
|
282
|
+
/**
|
|
283
|
+
* Deletes the initial Interaction response
|
|
284
|
+
* @since 0.3.0
|
|
285
|
+
* @param appId The Id of the application
|
|
286
|
+
* @param token The token of the interaction
|
|
287
|
+
* @returns Resolves the Promise on successful execution
|
|
288
|
+
*
|
|
289
|
+
* @example
|
|
290
|
+
* const client = new SnowTransfer() // This endpoint does not require a Bot token. The interaction token alone will suffice
|
|
291
|
+
* client.interaction.deleteOriginalInteractionResponse("appId", "token")
|
|
292
|
+
*/
|
|
293
|
+
async deleteOriginalInteractionResponse(appId, token) {
|
|
294
|
+
return this.webhooks.deleteWebhookMessage(appId, token, "@original");
|
|
295
|
+
}
|
|
296
|
+
/**
|
|
297
|
+
* Create a followup message for an Interaction
|
|
298
|
+
* @since 0.3.0
|
|
299
|
+
* @param appId The Id of the application
|
|
300
|
+
* @param token The token of the interaction
|
|
301
|
+
* @param data Message data
|
|
302
|
+
* @returns A [message](https://discord.com/developers/docs/resources/channel#message-object) object
|
|
303
|
+
*
|
|
304
|
+
* @example
|
|
305
|
+
* const client = new SnowTransfer() // This endpoint does not require a Bot token. The interaction token alone will suffice
|
|
306
|
+
* const message = await client.interaction.createFollowupMessage("appId", "token", { content: "The pacer gram fitness test-" })
|
|
307
|
+
*/
|
|
308
|
+
async createFollowupMessage(appId, token, data) {
|
|
309
|
+
// wait is always true for interactions and should not be supplied as it will throw an error if the query string is present
|
|
310
|
+
return this.webhooks.executeWebhook(appId, token, data);
|
|
311
|
+
}
|
|
312
|
+
/**
|
|
313
|
+
* Get a followup message for an Interaction
|
|
314
|
+
* @since 0.3.0
|
|
315
|
+
* @param appId The Id of the application
|
|
316
|
+
* @param token The token of the interaction
|
|
317
|
+
* @param messageId The Id of the message
|
|
318
|
+
* @returns A [message](https://discord.com/developers/docs/resources/channel#message-object) object
|
|
319
|
+
*
|
|
320
|
+
* @example
|
|
321
|
+
* const client = new SnowTransfer() // This endpoint does not require a Bot token. The interaction token alone will suffice
|
|
322
|
+
* const message = await client.interaction.getFollowupMessage("appId", "token", "messageId")
|
|
323
|
+
*/
|
|
324
|
+
async getFollowupMessage(appId, token, messageId) {
|
|
325
|
+
return this.webhooks.getWebhookMessage(appId, token, messageId);
|
|
326
|
+
}
|
|
327
|
+
/**
|
|
328
|
+
* Edits a followup message for an Interaction
|
|
329
|
+
* @since 0.3.0
|
|
330
|
+
* @param appId The Id of the application
|
|
331
|
+
* @param token The token of the interaction
|
|
332
|
+
* @param messageId The Id of the message
|
|
333
|
+
* @param data The new message data
|
|
334
|
+
* @returns A [message](https://discord.com/developers/docs/resources/channel#message-object) object
|
|
335
|
+
*
|
|
336
|
+
* @example
|
|
337
|
+
* const client = new SnowTransfer() // This endpoint does not require a Bot token. The interaction token alone will suffice
|
|
338
|
+
* const message = await client.interaction.editFollowupMessage("appId", "token", "messageId", { content: "-is a multistage aerobic capacity test" })
|
|
339
|
+
*/
|
|
340
|
+
async editFollowupMessage(appId, token, messageId, data) {
|
|
341
|
+
return this.webhooks.editWebhookMessage(appId, token, messageId, data);
|
|
342
|
+
}
|
|
343
|
+
/**
|
|
344
|
+
* Deletes a followup message for an Interaction
|
|
345
|
+
* @since 0.3.0
|
|
346
|
+
* @param appId The Id of the application
|
|
347
|
+
* @param token The token of the interaction
|
|
348
|
+
* @param messageId The Id of the message
|
|
349
|
+
* @returns Resolves the Promise on successful execution
|
|
350
|
+
*
|
|
351
|
+
* @example
|
|
352
|
+
* const client = new SnowTransfer() // This endpoint does not require a Bot token. The interaction token alone will suffice
|
|
353
|
+
* client.interaction.deleteFollowupMessage("appId", "token", "messageId")
|
|
354
|
+
*/
|
|
355
|
+
async deleteFollowupMessage(appId, token, messageId) {
|
|
356
|
+
return this.webhooks.deleteWebhookMessage(appId, token, messageId);
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
module.exports = InteractionMethods;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import type { RequestHandler } from "../RequestHandler";
|
|
2
|
+
import type { RESTDeleteAPIInviteResult, RESTGetAPIInviteQuery, RESTGetAPIInviteResult, RESTGetAPIInviteTargetUsersJobStatusResult, RESTPutAPIInviteTargetUsersResult } from "discord-api-types/v10";
|
|
3
|
+
/**
|
|
4
|
+
* Methods for interacting with invites
|
|
5
|
+
* @since 0.1.0
|
|
6
|
+
*/
|
|
7
|
+
declare class InviteMethods {
|
|
8
|
+
readonly requestHandler: RequestHandler;
|
|
9
|
+
/**
|
|
10
|
+
* Create a new Invite Method Handler
|
|
11
|
+
*
|
|
12
|
+
* Usually SnowTransfer creates a method handler for you, this is here for completion
|
|
13
|
+
*
|
|
14
|
+
* You can access the methods listed via `client.invite.method`, where `client` is an initialized SnowTransfer instance
|
|
15
|
+
* @param requestHandler request handler that calls the rest api
|
|
16
|
+
*/
|
|
17
|
+
constructor(requestHandler: RequestHandler);
|
|
18
|
+
/**
|
|
19
|
+
* Get the invite data on an invite id
|
|
20
|
+
* @since 0.1.0
|
|
21
|
+
* @param inviteId Id of the invite
|
|
22
|
+
* @param options Query params for additional metadata fields
|
|
23
|
+
* @returns [Invite Object](https://discord.com/developers/docs/resources/invite#invite-object)
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* // Gets an invite with approximate_member_count and approximate_presence_count
|
|
27
|
+
* const client = new SnowTransfer("TOKEN")
|
|
28
|
+
* const invite = await client.invite.getInvite("inviteId", { with_counts: true })
|
|
29
|
+
*/
|
|
30
|
+
getInvite(inviteId: string, options?: RESTGetAPIInviteQuery): Promise<RESTGetAPIInviteResult>;
|
|
31
|
+
/**
|
|
32
|
+
* Delete an invite
|
|
33
|
+
* @since 0.1.0
|
|
34
|
+
* @param inviteId Id of the invite
|
|
35
|
+
* @param reason Reason for deleting the invite
|
|
36
|
+
* @returns [Invite Object](https://discord.com/developers/docs/resources/invite#invite-object)
|
|
37
|
+
*
|
|
38
|
+
* | Permissions needed | Condition |
|
|
39
|
+
* |--------------------|-----------------------------------------------|
|
|
40
|
+
* | MANAGE_CHANNELS | for invite that belongs to a specific channel |
|
|
41
|
+
* | MANAGE_GUILD | delete any invite guild wide |
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* const client = new SnowTransfer("TOKEN")
|
|
45
|
+
* const invite = await client.invite.deleteInvite("inviteId")
|
|
46
|
+
*/
|
|
47
|
+
deleteInvite(inviteId: string, reason?: string): Promise<RESTDeleteAPIInviteResult>;
|
|
48
|
+
/**
|
|
49
|
+
* Gets the users allowed to see and accept an invite
|
|
50
|
+
* @since 0.17.0
|
|
51
|
+
* @param inviteId Id of the invite
|
|
52
|
+
* @returns An Array of user IDs
|
|
53
|
+
*
|
|
54
|
+
* @example
|
|
55
|
+
* const client = new SnowTransfer("TOKEN")
|
|
56
|
+
* const userIds = await client.invite.getInviteTargetUsers("inviteId")
|
|
57
|
+
*/
|
|
58
|
+
getInviteTargetUsers(inviteId: string): Promise<Array<string>>;
|
|
59
|
+
/**
|
|
60
|
+
* Updates the users allowed to see and accept an invite
|
|
61
|
+
* @since 0.18.0
|
|
62
|
+
* @param inviteId Id of the invite
|
|
63
|
+
* @returns Resolves the Promise on successful execution
|
|
64
|
+
*
|
|
65
|
+
* @example
|
|
66
|
+
* const client = new SnowTransfer("TOKEN")
|
|
67
|
+
* await client.invite.editInviteTargetUsers("inviteId", someUserArray)
|
|
68
|
+
*/
|
|
69
|
+
editInviteTargetUsers(inviteId: string, userIds: Array<string>): Promise<RESTPutAPIInviteTargetUsersResult>;
|
|
70
|
+
/**
|
|
71
|
+
* Gets the job status on setting target users to an invite
|
|
72
|
+
* @param inviteId Id of the invite
|
|
73
|
+
* @returns [Target Users Job Status Object](https://discord.com/developers/docs/resources/invite#get-target-users-job-status-example-response)
|
|
74
|
+
*
|
|
75
|
+
* @example
|
|
76
|
+
* const client = new SnowTransfer("TOKEN")
|
|
77
|
+
* const jobStatus = await client.invite.getInviteTargetUsersJobStatus("inviteId")
|
|
78
|
+
*/
|
|
79
|
+
getInviteTargetUsersJobStatus(inviteId: string): Promise<RESTGetAPIInviteTargetUsersJobStatusResult>;
|
|
80
|
+
}
|
|
81
|
+
export = InviteMethods;
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const Endpoints = require("../Endpoints");
|
|
3
|
+
const Constants = require("../Constants");
|
|
4
|
+
/**
|
|
5
|
+
* Methods for interacting with invites
|
|
6
|
+
* @since 0.1.0
|
|
7
|
+
*/
|
|
8
|
+
class InviteMethods {
|
|
9
|
+
requestHandler;
|
|
10
|
+
/**
|
|
11
|
+
* Create a new Invite Method Handler
|
|
12
|
+
*
|
|
13
|
+
* Usually SnowTransfer creates a method handler for you, this is here for completion
|
|
14
|
+
*
|
|
15
|
+
* You can access the methods listed via `client.invite.method`, where `client` is an initialized SnowTransfer instance
|
|
16
|
+
* @param requestHandler request handler that calls the rest api
|
|
17
|
+
*/
|
|
18
|
+
constructor(requestHandler) {
|
|
19
|
+
this.requestHandler = requestHandler;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Get the invite data on an invite id
|
|
23
|
+
* @since 0.1.0
|
|
24
|
+
* @param inviteId Id of the invite
|
|
25
|
+
* @param options Query params for additional metadata fields
|
|
26
|
+
* @returns [Invite Object](https://discord.com/developers/docs/resources/invite#invite-object)
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* // Gets an invite with approximate_member_count and approximate_presence_count
|
|
30
|
+
* const client = new SnowTransfer("TOKEN")
|
|
31
|
+
* const invite = await client.invite.getInvite("inviteId", { with_counts: true })
|
|
32
|
+
*/
|
|
33
|
+
async getInvite(inviteId, options) {
|
|
34
|
+
return this.requestHandler.request(Endpoints.INVITES(inviteId), options, "get", "json");
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Delete an invite
|
|
38
|
+
* @since 0.1.0
|
|
39
|
+
* @param inviteId Id of the invite
|
|
40
|
+
* @param reason Reason for deleting the invite
|
|
41
|
+
* @returns [Invite Object](https://discord.com/developers/docs/resources/invite#invite-object)
|
|
42
|
+
*
|
|
43
|
+
* | Permissions needed | Condition |
|
|
44
|
+
* |--------------------|-----------------------------------------------|
|
|
45
|
+
* | MANAGE_CHANNELS | for invite that belongs to a specific channel |
|
|
46
|
+
* | MANAGE_GUILD | delete any invite guild wide |
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* const client = new SnowTransfer("TOKEN")
|
|
50
|
+
* const invite = await client.invite.deleteInvite("inviteId")
|
|
51
|
+
*/
|
|
52
|
+
async deleteInvite(inviteId, reason) {
|
|
53
|
+
return this.requestHandler.request(Endpoints.INVITES(inviteId), {}, "delete", "json", undefined, Constants.reasonHeader(reason));
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Gets the users allowed to see and accept an invite
|
|
57
|
+
* @since 0.17.0
|
|
58
|
+
* @param inviteId Id of the invite
|
|
59
|
+
* @returns An Array of user IDs
|
|
60
|
+
*
|
|
61
|
+
* @example
|
|
62
|
+
* const client = new SnowTransfer("TOKEN")
|
|
63
|
+
* const userIds = await client.invite.getInviteTargetUsers("inviteId")
|
|
64
|
+
*/
|
|
65
|
+
async getInviteTargetUsers(inviteId) {
|
|
66
|
+
const response = await this.requestHandler.request(Endpoints.INVITE_TARGET_USERS(inviteId), {}, "get", "json", undefined, undefined, this.requestHandler.options.retryLimit, true);
|
|
67
|
+
let b;
|
|
68
|
+
try {
|
|
69
|
+
b = await response.text();
|
|
70
|
+
}
|
|
71
|
+
catch {
|
|
72
|
+
b = "";
|
|
73
|
+
}
|
|
74
|
+
if (!b.length)
|
|
75
|
+
return [];
|
|
76
|
+
return b.split("\n").slice(1).map(l => l.replace(",", "").trim()); // first line is the table column names, but only Users exists
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Updates the users allowed to see and accept an invite
|
|
80
|
+
* @since 0.18.0
|
|
81
|
+
* @param inviteId Id of the invite
|
|
82
|
+
* @returns Resolves the Promise on successful execution
|
|
83
|
+
*
|
|
84
|
+
* @example
|
|
85
|
+
* const client = new SnowTransfer("TOKEN")
|
|
86
|
+
* await client.invite.editInviteTargetUsers("inviteId", someUserArray)
|
|
87
|
+
*/
|
|
88
|
+
async editInviteTargetUsers(inviteId, userIds) {
|
|
89
|
+
const csv = `Users\n${userIds.join(",\n")},`;
|
|
90
|
+
const form = new FormData();
|
|
91
|
+
await Constants.standardAddToFormHandler(form, "target_users_file", csv, "target_users_file.csv");
|
|
92
|
+
return this.requestHandler.request(Endpoints.INVITE_TARGET_USERS(inviteId), { target_users_file: "target_users_file.csv" }, "put", "multipart", form);
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Gets the job status on setting target users to an invite
|
|
96
|
+
* @param inviteId Id of the invite
|
|
97
|
+
* @returns [Target Users Job Status Object](https://discord.com/developers/docs/resources/invite#get-target-users-job-status-example-response)
|
|
98
|
+
*
|
|
99
|
+
* @example
|
|
100
|
+
* const client = new SnowTransfer("TOKEN")
|
|
101
|
+
* const jobStatus = await client.invite.getInviteTargetUsersJobStatus("inviteId")
|
|
102
|
+
*/
|
|
103
|
+
async getInviteTargetUsersJobStatus(inviteId) {
|
|
104
|
+
return this.requestHandler.request(Endpoints.INVITE_TARGET_USERS_JOB_STATUS(inviteId), {}, "get", "json");
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
module.exports = InviteMethods;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import type { RequestHandler } from "../RequestHandler";
|
|
2
|
+
import type { RESTGetAPISKUsResult, RESTGetAPISKUSubscriptionsQuery, RESTGetAPISKUSubscriptionsResult, RESTGetAPISKUSubscriptionResult } from "discord-api-types/v10";
|
|
3
|
+
/**
|
|
4
|
+
* Methods for interacting with SKUs
|
|
5
|
+
* @since 0.13.0
|
|
6
|
+
*/
|
|
7
|
+
declare class SkuMethods {
|
|
8
|
+
readonly requestHandler: RequestHandler;
|
|
9
|
+
/**
|
|
10
|
+
* Create a new SKU Method handler
|
|
11
|
+
*
|
|
12
|
+
* Usually SnowTransfer creates a method handler for you, this is here for completion
|
|
13
|
+
*
|
|
14
|
+
* You can access the methods listed via `client.subscription.method` where `client` is an initialized SnowTransfer instance
|
|
15
|
+
* @param requestHandler request handler that calls the rest api
|
|
16
|
+
*/
|
|
17
|
+
constructor(requestHandler: RequestHandler);
|
|
18
|
+
/**
|
|
19
|
+
* Returns all SKUs for a given application.
|
|
20
|
+
* @since 0.18.0
|
|
21
|
+
* @param appId Id of the app
|
|
22
|
+
* @returns Array of [SKU objects](https://discord.com/developers/docs/resources/sku#sku-object)
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* // Get all SKUs for an app
|
|
26
|
+
* const client = new SnowTransfer("TOKEN")
|
|
27
|
+
* const skus = await client.sku.getSkus("app id")
|
|
28
|
+
*/
|
|
29
|
+
getSkus(appId: string): Promise<RESTGetAPISKUsResult>;
|
|
30
|
+
/**
|
|
31
|
+
* Returns all subscriptions containing the SKU, filtered by user.
|
|
32
|
+
* @since 0.13.0
|
|
33
|
+
* @param skuId Id of the SKU
|
|
34
|
+
* @param options Query data (required with at least `user_id` unless using an OAuth token)
|
|
35
|
+
* @returns Array of [subscription objects](https://discord.com/developers/docs/resources/subscription#subscription-object)
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* // Get all subscriptions for a user
|
|
39
|
+
* const client = new SnowTransfer("TOKEN")
|
|
40
|
+
* const filter = { user_id: "user id" }
|
|
41
|
+
* const subscriptions = await client.sku.getSubscriptions("sku id", filter)
|
|
42
|
+
*/
|
|
43
|
+
getSubscriptions(skuId: string, options?: RESTGetAPISKUSubscriptionsQuery): Promise<RESTGetAPISKUSubscriptionsResult>;
|
|
44
|
+
/**
|
|
45
|
+
* Get a subscription by its ID.
|
|
46
|
+
* @since 0.13.0
|
|
47
|
+
* @param skuId Id of the SKU
|
|
48
|
+
* @param subscriptionId Id of the subscription
|
|
49
|
+
* @returns A [subscription object](https://discord.com/developers/docs/resources/subscription#subscription-object)
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* // Get a subscription for a SKU by Id
|
|
53
|
+
* const client = new SnowTransfer("TOKEN")
|
|
54
|
+
* const subscription = await client.sku.getSubscription("sku id", "subscription id")
|
|
55
|
+
*/
|
|
56
|
+
getSubscription(skuId: string, subscriptionId: string): Promise<RESTGetAPISKUSubscriptionResult>;
|
|
57
|
+
}
|
|
58
|
+
export = SkuMethods;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const Endpoints = require("../Endpoints");
|
|
3
|
+
/**
|
|
4
|
+
* Methods for interacting with SKUs
|
|
5
|
+
* @since 0.13.0
|
|
6
|
+
*/
|
|
7
|
+
class SkuMethods {
|
|
8
|
+
requestHandler;
|
|
9
|
+
/**
|
|
10
|
+
* Create a new SKU Method handler
|
|
11
|
+
*
|
|
12
|
+
* Usually SnowTransfer creates a method handler for you, this is here for completion
|
|
13
|
+
*
|
|
14
|
+
* You can access the methods listed via `client.subscription.method` where `client` is an initialized SnowTransfer instance
|
|
15
|
+
* @param requestHandler request handler that calls the rest api
|
|
16
|
+
*/
|
|
17
|
+
constructor(requestHandler) {
|
|
18
|
+
this.requestHandler = requestHandler;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Returns all SKUs for a given application.
|
|
22
|
+
* @since 0.18.0
|
|
23
|
+
* @param appId Id of the app
|
|
24
|
+
* @returns Array of [SKU objects](https://discord.com/developers/docs/resources/sku#sku-object)
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* // Get all SKUs for an app
|
|
28
|
+
* const client = new SnowTransfer("TOKEN")
|
|
29
|
+
* const skus = await client.sku.getSkus("app id")
|
|
30
|
+
*/
|
|
31
|
+
async getSkus(appId) {
|
|
32
|
+
return this.requestHandler.request(Endpoints.APPLICATION_SKUS(appId), {}, "get", "json");
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Returns all subscriptions containing the SKU, filtered by user.
|
|
36
|
+
* @since 0.13.0
|
|
37
|
+
* @param skuId Id of the SKU
|
|
38
|
+
* @param options Query data (required with at least `user_id` unless using an OAuth token)
|
|
39
|
+
* @returns Array of [subscription objects](https://discord.com/developers/docs/resources/subscription#subscription-object)
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* // Get all subscriptions for a user
|
|
43
|
+
* const client = new SnowTransfer("TOKEN")
|
|
44
|
+
* const filter = { user_id: "user id" }
|
|
45
|
+
* const subscriptions = await client.sku.getSubscriptions("sku id", filter)
|
|
46
|
+
*/
|
|
47
|
+
async getSubscriptions(skuId, options = {}) {
|
|
48
|
+
return this.requestHandler.request(Endpoints.SKU_SUBSCRIPTIONS(skuId), options, "get", "json");
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Get a subscription by its ID.
|
|
52
|
+
* @since 0.13.0
|
|
53
|
+
* @param skuId Id of the SKU
|
|
54
|
+
* @param subscriptionId Id of the subscription
|
|
55
|
+
* @returns A [subscription object](https://discord.com/developers/docs/resources/subscription#subscription-object)
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* // Get a subscription for a SKU by Id
|
|
59
|
+
* const client = new SnowTransfer("TOKEN")
|
|
60
|
+
* const subscription = await client.sku.getSubscription("sku id", "subscription id")
|
|
61
|
+
*/
|
|
62
|
+
async getSubscription(skuId, subscriptionId) {
|
|
63
|
+
return this.requestHandler.request(Endpoints.SKU_SUBSCRIPTION(skuId, subscriptionId), {}, "get", "json");
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
module.exports = SkuMethods;
|