seyfert 4.0.1-dev-20556316054.0 → 4.0.1-dev-21085534804.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.
@@ -1,8 +1,16 @@
1
- import type { RESTDeleteAPIInviteResult, RESTGetAPIInviteQuery, RESTGetAPIInviteResult } from '../../types';
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.entries()) {
329
+ for (const [index, file] of options.request.files?.entries() ?? []) {
330
330
  const fileKey = file.key ?? `files[${index}]`;
331
- if ((0, utils_2.isBufferLike)(file.data)) {
332
- let data;
333
- if (Buffer.isBuffer(file.data) || file.data instanceof Uint8Array || file.data instanceof Uint8ClampedArray) {
334
- data = (0, utils_1.toArrayBuffer)(file.data);
335
- }
336
- else {
337
- data = file.data;
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)
@@ -532,7 +532,19 @@ export declare enum GuildFeature {
532
532
  /**
533
533
  * Guild has enabled the welcome screen
534
534
  */
535
- WelcomeScreenEnabled = "WELCOME_SCREEN_ENABLED"
535
+ WelcomeScreenEnabled = "WELCOME_SCREEN_ENABLED",
536
+ /**
537
+ * Guild has access to guest invites.
538
+ */
539
+ GuestsEnabled = "GUESTS_ENABLED",
540
+ /**
541
+ * Guild has access to set guild tags.
542
+ */
543
+ GuildTags = "GUILD_TAGS",
544
+ /**
545
+ * Guild is able to set gradient colors to roles.
546
+ */
547
+ EnhancedRoleColors = "ENHANCED_ROLE_COLORS"
536
548
  }
537
549
  /**
538
550
  * https://discord.com/developers/docs/resources/guild#guild-preview-object
@@ -265,6 +265,18 @@ var GuildFeature;
265
265
  * Guild has enabled the welcome screen
266
266
  */
267
267
  GuildFeature["WelcomeScreenEnabled"] = "WELCOME_SCREEN_ENABLED";
268
+ /**
269
+ * Guild has access to guest invites.
270
+ */
271
+ GuildFeature["GuestsEnabled"] = "GUESTS_ENABLED";
272
+ /**
273
+ * Guild has access to set guild tags.
274
+ */
275
+ GuildFeature["GuildTags"] = "GUILD_TAGS";
276
+ /**
277
+ * Guild is able to set gradient colors to roles.
278
+ */
279
+ GuildFeature["EnhancedRoleColors"] = "ENHANCED_ROLE_COLORS";
268
280
  })(GuildFeature || (exports.GuildFeature = GuildFeature = {}));
269
281
  /**
270
282
  * https://discord.com/developers/docs/resources/guild#integration-object-integration-expire-behaviors
@@ -68,6 +68,8 @@ export interface APIRole {
68
68
  export interface APIRoleColors {
69
69
  /**
70
70
  * The primary color for the role
71
+ *
72
+ * @default 0
71
73
  */
72
74
  primary_color: number;
73
75
  /**
@@ -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
@@ -1,5 +1,5 @@
1
1
  import type { Permissions, Snowflake } from '..';
2
- import type { APIBan, APIChannel, APIDMChannel, APIExtendedInvite, APIGroupDMChannel, APIGuild, APIGuildIntegration, APIGuildMember, APIGuildMembershipScreening, APIGuildOnboarding, APIGuildOnboardingPrompt, APIGuildOnboardingPromptOption, APIGuildPreview, APIGuildWelcomeScreen, APIGuildWidget, APIGuildWidgetSettings, APIRole, APIThreadList, APIVoiceRegion, GuildDefaultMessageNotifications, GuildExplicitContentFilter, GuildFeature, GuildMFALevel, GuildSystemChannelFlags, GuildVerificationLevel, GuildWidgetStyle } from '../payloads';
2
+ import type { APIBan, APIChannel, APIDMChannel, APIExtendedInvite, APIGroupDMChannel, APIGuild, APIGuildIntegration, APIGuildMember, APIGuildMembershipScreening, APIGuildOnboarding, APIGuildOnboardingPrompt, APIGuildOnboardingPromptOption, APIGuildPreview, APIGuildWelcomeScreen, APIGuildWidget, APIGuildWidgetSettings, APIRole, APIRoleColors, APIThreadList, APIVoiceRegion, GuildDefaultMessageNotifications, GuildExplicitContentFilter, GuildFeature, GuildMFALevel, GuildSystemChannelFlags, GuildVerificationLevel, GuildWidgetStyle } from '../payloads';
3
3
  import type { AddUndefinedToPossiblyUndefinedPropertiesOfInterface, DistributiveOmit, DistributivePick, Nullable, StrictPartial } from '../utils';
4
4
  import type { RESTPutAPIChannelPermissionJSONBody } from './channel';
5
5
  export interface APIGuildCreateOverwrite extends RESTPutAPIChannelPermissionJSONBody {
@@ -552,6 +552,10 @@ export interface RESTPostAPIGuildRoleJSONBody {
552
552
  * @default 0
553
553
  */
554
554
  color?: number | null | undefined;
555
+ /**
556
+ * The colors of the role.
557
+ */
558
+ colors?: APIRoleColors;
555
559
  /**
556
560
  * Whether the role should be displayed separately in the sidebar
557
561
  *
@@ -610,6 +614,10 @@ export interface RESTPatchAPIGuildRoleJSONBody {
610
614
  * RGB color value
611
615
  */
612
616
  color?: number | null | undefined;
617
+ /**
618
+ * The colors of the role.
619
+ */
620
+ colors?: APIRoleColors;
613
621
  /**
614
622
  * Whether the role should be displayed separately in the sidebar
615
623
  */
@@ -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;
@@ -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 = {}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "seyfert",
3
- "version": "4.0.1-dev-20556316054.0",
3
+ "version": "4.0.1-dev-21085534804.0",
4
4
  "description": "The most advanced framework for discord bots",
5
5
  "main": "./lib/index.js",
6
6
  "module": "./lib/index.js",