seyfert 4.0.1-dev-21084303198.0 → 4.0.1-dev-21272622275.0
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/lib/api/Routes/invites.d.ts +9 -1
- package/lib/api/api.js +9 -15
- package/lib/builders/Attachment.js +1 -1
- package/lib/common/shorters/invites.d.ts +10 -0
- package/lib/common/shorters/invites.js +16 -0
- package/lib/types/rest/channel.d.ts +11 -0
- package/lib/types/rest/invite.d.ts +42 -0
- package/lib/types/rest/invite.js +12 -0
- package/package.json +1 -1
|
@@ -1,8 +1,16 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { MakeRequired } from '../../common';
|
|
2
|
+
import type { RESTDeleteAPIInviteResult, RESTGetAPIInviteQuery, RESTGetAPIInviteResult, RESTGetTargetUsersJobStatusResult, RESTGetTargetUsersResult, RESTPutUpdateTargetUsers, RESTPutUpdateTargetUsersResult } from '../../types';
|
|
2
3
|
import type { RestArguments, RestArgumentsNoBody } from '../api';
|
|
3
4
|
export interface InviteRoutes {
|
|
4
5
|
invites(id: string): {
|
|
5
6
|
get(args?: RestArguments<RESTGetAPIInviteQuery>): Promise<RESTGetAPIInviteResult>;
|
|
6
7
|
delete(args?: RestArgumentsNoBody): Promise<RESTDeleteAPIInviteResult>;
|
|
8
|
+
['target-users']: {
|
|
9
|
+
get(args?: RestArgumentsNoBody): Promise<RESTGetTargetUsersResult>;
|
|
10
|
+
put(args: MakeRequired<RestArguments<RESTPutUpdateTargetUsers>, 'appendToFormData'>): Promise<RESTPutUpdateTargetUsersResult>;
|
|
11
|
+
['job-status']: {
|
|
12
|
+
get(args?: RestArgumentsNoBody): Promise<RESTGetTargetUsersJobStatusResult>;
|
|
13
|
+
};
|
|
14
|
+
};
|
|
7
15
|
};
|
|
8
16
|
}
|
package/lib/api/api.js
CHANGED
|
@@ -324,23 +324,17 @@ class ApiHandler {
|
|
|
324
324
|
if (options.request.query) {
|
|
325
325
|
finalUrl += `?${new URLSearchParams(options.request.query)}`;
|
|
326
326
|
}
|
|
327
|
-
if (options.request.files?.length) {
|
|
327
|
+
if (options.request.files?.length || options.request.appendToFormData) {
|
|
328
328
|
const formData = new FormData();
|
|
329
|
-
for (const [index, file] of options.request.files
|
|
329
|
+
for (const [index, file] of options.request.files?.entries() ?? []) {
|
|
330
330
|
const fileKey = file.key ?? `files[${index}]`;
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
}
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
}
|
|
339
|
-
formData.append(fileKey, new Blob([data], { type: file.contentType }), file.filename);
|
|
340
|
-
}
|
|
341
|
-
else {
|
|
342
|
-
formData.append(fileKey, new Blob([`${file.data}`], { type: file.contentType }), file.filename);
|
|
343
|
-
}
|
|
331
|
+
const blobContent = (0, utils_2.isBufferLike)(file.data)
|
|
332
|
+
? file.data instanceof ArrayBuffer
|
|
333
|
+
? file.data
|
|
334
|
+
: (0, utils_1.toArrayBuffer)(file.data)
|
|
335
|
+
: `${file.data}`;
|
|
336
|
+
const blob = new Blob([blobContent], { type: file.contentType });
|
|
337
|
+
formData.append(fileKey, blob, file.filename);
|
|
344
338
|
}
|
|
345
339
|
if (options.request.body) {
|
|
346
340
|
if (options.request.appendToFormData) {
|
|
@@ -307,6 +307,16 @@ export declare class InvitesShorter extends BaseShorter {
|
|
|
307
307
|
} | undefined;
|
|
308
308
|
type: import("../../types").InviteType;
|
|
309
309
|
}>;
|
|
310
|
+
getTargetUsers(code: string): Promise<string>;
|
|
311
|
+
updateTargetUsers(code: string, targetIds: string[]): Promise<undefined>;
|
|
312
|
+
jobStatus(code: string): Promise<{
|
|
313
|
+
status: import("../../types").TargetUsersJobStatusCode;
|
|
314
|
+
totalUsers: number;
|
|
315
|
+
processedUsers: number;
|
|
316
|
+
createdAt: string;
|
|
317
|
+
completedAt: string | null;
|
|
318
|
+
errorMessage?: string | undefined;
|
|
319
|
+
}>;
|
|
310
320
|
channels: {
|
|
311
321
|
create: ({ channelId, reason, ...body }: CreateInviteFromChannel) => Promise<{
|
|
312
322
|
uses: number;
|
|
@@ -16,6 +16,22 @@ class InvitesShorter extends base_1.BaseShorter {
|
|
|
16
16
|
.delete({ reason })
|
|
17
17
|
.then(x => (0, utils_1.toCamelCase)(x));
|
|
18
18
|
}
|
|
19
|
+
getTargetUsers(code) {
|
|
20
|
+
return this.client.proxy.invites(code)['target-users'].get();
|
|
21
|
+
}
|
|
22
|
+
updateTargetUsers(code, targetIds) {
|
|
23
|
+
return this.client.proxy.invites(code)['target-users'].put({
|
|
24
|
+
body: {
|
|
25
|
+
target_users_file: new Blob([`users\n${targetIds.join('\n')}`], { type: 'text/csv' }),
|
|
26
|
+
},
|
|
27
|
+
appendToFormData: true,
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
jobStatus(code) {
|
|
31
|
+
return this.client.proxy
|
|
32
|
+
.invites(code)['target-users']['job-status'].get()
|
|
33
|
+
.then(x => (0, utils_1.toCamelCase)(x));
|
|
34
|
+
}
|
|
19
35
|
channels = {
|
|
20
36
|
create: ({ channelId, reason, ...body }) => this.client.proxy
|
|
21
37
|
.channels(channelId)
|
|
@@ -499,6 +499,17 @@ export interface RESTPostAPIChannelInviteJSONBody {
|
|
|
499
499
|
* - The application must have the `EMBEDDED` flag
|
|
500
500
|
*/
|
|
501
501
|
target_application_id?: Snowflake | undefined;
|
|
502
|
+
/**
|
|
503
|
+
* A csv file with a single column of user IDs for all the users able to accept this invite
|
|
504
|
+
* - Requires multipart/form-data as the content type with other parameters as form fields in the multipart body.
|
|
505
|
+
* - Requires the MANAGE_GUILD permission.
|
|
506
|
+
* - Uploading a file with invalid user IDs will result in a 400 with the invalid IDs described.
|
|
507
|
+
*/
|
|
508
|
+
target_users_file?: Blob | undefined;
|
|
509
|
+
/**
|
|
510
|
+
* the role ID(s) for roles in the guild given to the users that accept this invite
|
|
511
|
+
*/
|
|
512
|
+
role_ids?: Snowflake[] | undefined;
|
|
502
513
|
}
|
|
503
514
|
/**
|
|
504
515
|
* https://discord.com/developers/docs/resources/channel#create-channel-invite
|
|
@@ -22,3 +22,45 @@ export type RESTGetAPIInviteResult = APIInvite;
|
|
|
22
22
|
* https://discord.com/developers/docs/resources/invite#delete-invite
|
|
23
23
|
*/
|
|
24
24
|
export type RESTDeleteAPIInviteResult = APIInvite;
|
|
25
|
+
/**
|
|
26
|
+
* https://discord.com/developers/docs/resources/invite#get-target-users
|
|
27
|
+
*/
|
|
28
|
+
export type RESTGetTargetUsersResult = string;
|
|
29
|
+
/**
|
|
30
|
+
* https://discord.com/developers/docs/resources/invite#get-target-users
|
|
31
|
+
*
|
|
32
|
+
* Updates the users allowed to see and accept this invite.
|
|
33
|
+
* Uploading a file with invalid user IDs will result in a 400 with the invalid IDs described.
|
|
34
|
+
*/
|
|
35
|
+
export interface RESTPutUpdateTargetUsers {
|
|
36
|
+
/**
|
|
37
|
+
* A csv file with a single column of user IDs for all the users able to accept this invite
|
|
38
|
+
*/
|
|
39
|
+
target_users_file: Blob;
|
|
40
|
+
}
|
|
41
|
+
export type RESTPutUpdateTargetUsersResult = undefined;
|
|
42
|
+
export declare enum TargetUsersJobStatusCode {
|
|
43
|
+
/** The default value. */
|
|
44
|
+
UNSPECIFIED = 0,
|
|
45
|
+
/** The job is still being processed. */
|
|
46
|
+
PROCESSING = 1,
|
|
47
|
+
/** The job has been completed successfully. */
|
|
48
|
+
COMPLETED = 2,
|
|
49
|
+
/** The job has failed, see `error_message` field for more details. */
|
|
50
|
+
FAILED = 3
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* https://discord.com/developers/docs/resources/invite#get-target-users-job-status
|
|
54
|
+
* Processing target users from a CSV when creating or updating an invite is done asynchronously.
|
|
55
|
+
* This endpoint allows you to check the status of that job.
|
|
56
|
+
*/
|
|
57
|
+
export interface RESTGetTargetUsersJobStatus {
|
|
58
|
+
status: TargetUsersJobStatusCode;
|
|
59
|
+
total_users: number;
|
|
60
|
+
processed_users: number;
|
|
61
|
+
created_at: string;
|
|
62
|
+
completed_at: string | null;
|
|
63
|
+
/** The error message if the job has failed. */
|
|
64
|
+
error_message?: string;
|
|
65
|
+
}
|
|
66
|
+
export type RESTGetTargetUsersJobStatusResult = RESTGetTargetUsersJobStatus;
|
package/lib/types/rest/invite.js
CHANGED
|
@@ -1,2 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TargetUsersJobStatusCode = void 0;
|
|
4
|
+
var TargetUsersJobStatusCode;
|
|
5
|
+
(function (TargetUsersJobStatusCode) {
|
|
6
|
+
/** The default value. */
|
|
7
|
+
TargetUsersJobStatusCode[TargetUsersJobStatusCode["UNSPECIFIED"] = 0] = "UNSPECIFIED";
|
|
8
|
+
/** The job is still being processed. */
|
|
9
|
+
TargetUsersJobStatusCode[TargetUsersJobStatusCode["PROCESSING"] = 1] = "PROCESSING";
|
|
10
|
+
/** The job has been completed successfully. */
|
|
11
|
+
TargetUsersJobStatusCode[TargetUsersJobStatusCode["COMPLETED"] = 2] = "COMPLETED";
|
|
12
|
+
/** The job has failed, see `error_message` field for more details. */
|
|
13
|
+
TargetUsersJobStatusCode[TargetUsersJobStatusCode["FAILED"] = 3] = "FAILED";
|
|
14
|
+
})(TargetUsersJobStatusCode || (exports.TargetUsersJobStatusCode = TargetUsersJobStatusCode = {}));
|