seyfert 2.0.0 → 2.1.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.
Files changed (81) hide show
  1. package/lib/api/Routes/interactions.d.ts +8 -2
  2. package/lib/api/Routes/skus.d.ts +11 -0
  3. package/lib/api/Routes/skus.js +2 -0
  4. package/lib/api/api.d.ts +1 -1
  5. package/lib/api/api.js +14 -12
  6. package/lib/api/shared.d.ts +1 -1
  7. package/lib/api/utils/constants.d.ts +1 -1
  8. package/lib/api/utils/constants.js +1 -1
  9. package/lib/builders/Attachment.d.ts +1 -1
  10. package/lib/builders/Attachment.js +12 -12
  11. package/lib/cache/index.d.ts +4 -1
  12. package/lib/cache/index.js +11 -3
  13. package/lib/client/base.d.ts +3 -3
  14. package/lib/client/base.js +8 -3
  15. package/lib/client/client.d.ts +4 -0
  16. package/lib/client/client.js +30 -14
  17. package/lib/client/httpclient.js +2 -2
  18. package/lib/client/workerclient.d.ts +3 -2
  19. package/lib/client/workerclient.js +23 -11
  20. package/lib/commands/applications/entryPoint.d.ts +46 -0
  21. package/lib/commands/applications/entryPoint.js +56 -0
  22. package/lib/commands/applications/entrycontext.d.ts +40 -0
  23. package/lib/commands/applications/entrycontext.js +85 -0
  24. package/lib/commands/applications/options.d.ts +3 -2
  25. package/lib/commands/decorators.d.ts +11 -17
  26. package/lib/commands/decorators.js +3 -0
  27. package/lib/commands/handle.d.ts +6 -5
  28. package/lib/commands/handle.js +42 -0
  29. package/lib/commands/handler.d.ts +6 -4
  30. package/lib/commands/handler.js +6 -1
  31. package/lib/commands/index.d.ts +2 -0
  32. package/lib/commands/index.js +2 -0
  33. package/lib/commands/optionresolver.js +1 -1
  34. package/lib/common/bot/watcher.d.ts +1 -1
  35. package/lib/common/it/utils.d.ts +10 -3
  36. package/lib/common/it/utils.js +10 -0
  37. package/lib/common/shorters/interaction.d.ts +1 -1
  38. package/lib/common/types/util.d.ts +1 -1
  39. package/lib/common/types/write.d.ts +2 -2
  40. package/lib/deps/mixer.js +6 -1
  41. package/lib/events/handler.js +3 -3
  42. package/lib/events/hooks/custom.d.ts +1 -0
  43. package/lib/events/hooks/custom.js +5 -1
  44. package/lib/events/hooks/subscriptions.d.ts +35 -0
  45. package/lib/events/hooks/subscriptions.js +16 -0
  46. package/lib/structures/Interaction.d.ts +24 -4
  47. package/lib/structures/Interaction.js +54 -5
  48. package/lib/structures/Message.d.ts +0 -3
  49. package/lib/structures/Message.js +0 -3
  50. package/lib/structures/channels.js +2 -2
  51. package/lib/structures/extra/BaseGuild.d.ts +11 -1
  52. package/lib/structures/extra/BaseGuild.js +27 -0
  53. package/lib/types/gateway.d.ts +19 -2
  54. package/lib/types/payloads/_interactions/_applicationCommands/chatInput.d.ts +6 -1
  55. package/lib/types/payloads/_interactions/applicationCommands.d.ts +41 -6
  56. package/lib/types/payloads/_interactions/applicationCommands.js +28 -1
  57. package/lib/types/payloads/_interactions/responses.d.ts +74 -2
  58. package/lib/types/payloads/_interactions/responses.js +4 -0
  59. package/lib/types/payloads/channel.d.ts +44 -4
  60. package/lib/types/payloads/channel.js +5 -1
  61. package/lib/types/payloads/monetization.d.ts +29 -1
  62. package/lib/types/payloads/monetization.js +10 -1
  63. package/lib/types/rest/channel.d.ts +4 -17
  64. package/lib/types/rest/interactions.d.ts +30 -8
  65. package/lib/types/rest/monetization.d.ts +22 -1
  66. package/lib/types/rest/webhook.d.ts +2 -2
  67. package/lib/types/utils/index.d.ts +16 -5
  68. package/lib/types/utils/index.js +15 -4
  69. package/lib/websocket/SharedTypes.d.ts +9 -3
  70. package/lib/websocket/constants/index.d.ts +3 -2
  71. package/lib/websocket/constants/index.js +11 -1
  72. package/lib/websocket/discord/shard.d.ts +3 -2
  73. package/lib/websocket/discord/shard.js +25 -11
  74. package/lib/websocket/discord/sharder.js +59 -1
  75. package/lib/websocket/discord/shared.d.ts +21 -1
  76. package/lib/websocket/discord/socket/custom.d.ts +1 -1
  77. package/lib/websocket/discord/socket/custom.js +51 -34
  78. package/lib/websocket/discord/worker.d.ts +2 -1
  79. package/lib/websocket/discord/workermanager.d.ts +2 -1
  80. package/lib/websocket/discord/workermanager.js +30 -13
  81. package/package.json +8 -3
@@ -692,7 +692,7 @@ export interface APIMessageSnapshot {
692
692
  */
693
693
  guild_id?: Snowflake;
694
694
  }
695
- export type APIMessageSnapshotFields = Pick<APIMessage, 'attachments' | 'content' | 'edited_timestamp' | 'embeds' | 'flags' | 'mention_roles' | 'mentions' | 'timestamp' | 'type'>;
695
+ export type APIMessageSnapshotFields = Pick<APIMessage, 'attachments' | 'content' | 'edited_timestamp' | 'embeds' | 'flags' | 'mention_roles' | 'mentions' | 'timestamp' | 'type' | 'sticker_items' | 'components' | 'stickers'>;
696
696
  /**
697
697
  * https://discord.com/developers/docs/resources/channel#message-object-message-activity-types
698
698
  */
@@ -990,8 +990,6 @@ export interface APIEmbed {
990
990
  /**
991
991
  * Type of embed (always "rich" for webhook embeds)
992
992
  *
993
- * @deprecated *Embed types should be considered deprecated and might be removed in a future API version*
994
- *
995
993
  * See https://discord.com/developers/docs/resources/channel#embed-object-embed-types
996
994
  */
997
995
  type?: EmbedType;
@@ -1058,10 +1056,47 @@ export interface APIEmbed {
1058
1056
  */
1059
1057
  fields?: APIEmbedField[];
1060
1058
  }
1059
+ /**
1060
+ * https://discord.com/developers/docs/resources/message#embed-fields-by-embed-type-poll-result-embed-fields
1061
+ */
1062
+ export interface PollResultEmbedField<T extends string, V extends string = string> {
1063
+ name: T;
1064
+ value: V;
1065
+ inline: false;
1066
+ }
1067
+ /**
1068
+ * https://discord.com/developers/docs/resources/message#embed-fields-by-embed-type-poll-result-embed-fields
1069
+ */
1070
+ export type PollResultEmbedFields = [
1071
+ /** question text from the original poll */
1072
+ PollResultEmbedField<'poll_question_text'>,
1073
+ /** number of votes for the answer(s) with the most votes */
1074
+ PollResultEmbedField<'victor_answer_votes', `${number}`>,
1075
+ /** total number of votes in the poll */
1076
+ PollResultEmbedField<'total_votes', `${number}`>,
1077
+ /** id for the winning answer */
1078
+ PollResultEmbedField<'victor_answer_id', `${number}`> | undefined,
1079
+ /** text for the winning answer */
1080
+ PollResultEmbedField<'victor_answer_text'> | undefined,
1081
+ /** id for an emoji associated with the winning answer */
1082
+ PollResultEmbedField<'victor_answer_emoji_id'> | undefined,
1083
+ /** name for an emoji associated with the winning answer */
1084
+ PollResultEmbedField<'victor_answer_emoji_name'> | undefined,
1085
+ /** if an emoji associated with the winning answer is animated */
1086
+ PollResultEmbedField<'victor_answer_emoji_animated', `${boolean}`> | undefined
1087
+ ];
1088
+ export type APIEmbedPollResult = {
1089
+ type: EmbedType.PollResult;
1090
+ fields: PollResultEmbedFields;
1091
+ /**
1092
+ * @unstable This field is not officially documented by Discord.
1093
+ * Current observations indicate a consistent value of 0 for all embeds.
1094
+ */
1095
+ content_scan_version: number;
1096
+ };
1061
1097
  /**
1062
1098
  * https://discord.com/developers/docs/resources/channel#embed-object-embed-types
1063
1099
  *
1064
- * @deprecated *Embed types should be considered deprecated and might be removed in a future API version*
1065
1100
  */
1066
1101
  export declare enum EmbedType {
1067
1102
  /**
@@ -1088,6 +1123,11 @@ export declare enum EmbedType {
1088
1123
  * Link embed
1089
1124
  */
1090
1125
  Link = "link",
1126
+ /**
1127
+ * Poll result embed
1128
+ * https://discord.com/developers/docs/resources/message#embed-fields-by-embed-type-poll-result-embed-fields
1129
+ */
1130
+ PollResult = "poll_result",
1091
1131
  /**
1092
1132
  * Auto moderation alert embed
1093
1133
  *
@@ -190,7 +190,6 @@ var ThreadMemberFlags;
190
190
  /**
191
191
  * https://discord.com/developers/docs/resources/channel#embed-object-embed-types
192
192
  *
193
- * @deprecated *Embed types should be considered deprecated and might be removed in a future API version*
194
193
  */
195
194
  var EmbedType;
196
195
  (function (EmbedType) {
@@ -218,6 +217,11 @@ var EmbedType;
218
217
  * Link embed
219
218
  */
220
219
  EmbedType["Link"] = "link";
220
+ /**
221
+ * Poll result embed
222
+ * https://discord.com/developers/docs/resources/message#embed-fields-by-embed-type-poll-result-embed-fields
223
+ */
224
+ EmbedType["PollResult"] = "poll_result";
221
225
  /**
222
226
  * Auto moderation alert embed
223
227
  *
@@ -38,7 +38,7 @@ export interface APIEntitlement {
38
38
  /**
39
39
  * Date at which the entitlement is no longer valid. Not present when using test entitlements.
40
40
  */
41
- ends_at?: string;
41
+ ends_at?: string | null;
42
42
  /**
43
43
  * For consumable items, whether or not the entitlement has been consumed
44
44
  */
@@ -148,3 +148,31 @@ export declare enum SKUType {
148
148
  */
149
149
  SubscriptionGroup = 6
150
150
  }
151
+ export interface APISubscription {
152
+ /** ID of the subscription */
153
+ id: string;
154
+ /** ID of the user who is subscribed */
155
+ user_id: string;
156
+ /** List of SKUs subscribed to */
157
+ sku_ids: string[];
158
+ /** List of entitlements granted for this subscription */
159
+ entitlements_ids: string[];
160
+ /** Start of the current subscription period */
161
+ current_period_start: string;
162
+ /** End of the current subscription period */
163
+ current_period_end: string;
164
+ /** Current status of the subscription */
165
+ status: SubscriptionStatus;
166
+ /** When the subscription was canceled */
167
+ canceled_at: string | null;
168
+ /** ISO3166-1 alpha-2 country code of the payment source used to purchase the subscription. Missing unless queried with a private OAuth scope. */
169
+ country?: string;
170
+ }
171
+ export declare enum SubscriptionStatus {
172
+ /** Subscription is active and scheduled to renew. */
173
+ Active = 0,
174
+ /** Subscription is active but will not renew. */
175
+ Ending = 1,
176
+ /** Subscription is inactive and not being charged. */
177
+ Inactive = 2
178
+ }
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SKUType = exports.SKUFlags = exports.EntitlementType = void 0;
3
+ exports.SubscriptionStatus = exports.SKUType = exports.SKUFlags = exports.EntitlementType = void 0;
4
4
  /**
5
5
  * https://discord.com/developers/docs/monetization/entitlements#entitlement-object-entitlement-types
6
6
  */
@@ -77,3 +77,12 @@ var SKUType;
77
77
  */
78
78
  SKUType[SKUType["SubscriptionGroup"] = 6] = "SubscriptionGroup";
79
79
  })(SKUType || (exports.SKUType = SKUType = {}));
80
+ var SubscriptionStatus;
81
+ (function (SubscriptionStatus) {
82
+ /** Subscription is active and scheduled to renew. */
83
+ SubscriptionStatus[SubscriptionStatus["Active"] = 0] = "Active";
84
+ /** Subscription is active but will not renew. */
85
+ SubscriptionStatus[SubscriptionStatus["Ending"] = 1] = "Ending";
86
+ /** Subscription is inactive and not being charged. */
87
+ SubscriptionStatus[SubscriptionStatus["Inactive"] = 2] = "Inactive";
88
+ })(SubscriptionStatus || (exports.SubscriptionStatus = SubscriptionStatus = {}));
@@ -1,5 +1,5 @@
1
1
  import type { Snowflake, ChannelType, VideoQualityMode, OverwriteType, Permissions } from '..';
2
- import type { APIChannel, ThreadAutoArchiveDuration, ChannelFlags, APIGuildForumTag, APIGuildForumDefaultReactionEmoji, SortOrderType, ForumLayoutType, APIMessage, APIMessageReference, APIEmbed, APIAllowedMentions, APIActionRowComponent, APIMessageActionRowComponent, MessageFlags, APIUser, APIExtendedInvite, InviteTargetType, APIFollowedChannel, ThreadChannelType, APIThreadMember, APIThreadList } from '../payloads';
2
+ import type { APIChannel, ThreadAutoArchiveDuration, ChannelFlags, APIGuildForumTag, APIGuildForumDefaultReactionEmoji, SortOrderType, ForumLayoutType, APIMessage, APIMessageReference, APIEmbed, APIAllowedMentions, APIActionRowComponent, APIMessageActionRowComponent, MessageFlags, APIUser, APIExtendedInvite, InviteTargetType, APIFollowedChannel, ThreadChannelType, APIThreadMember, APIThreadList, APIAttachment } from '../payloads';
3
3
  import type { AddUndefinedToPossiblyUndefinedPropertiesOfInterface, StrictPartial } from '../utils';
4
4
  import type { RESTAPIPollCreate } from './poll';
5
5
  export interface APIChannelPatchOverwrite extends RESTPutAPIChannelPermissionJSONBody {
@@ -211,22 +211,9 @@ export type APIMessageReferenceSend = AddUndefinedToPossiblyUndefinedPropertiesO
211
211
  fail_if_not_exists?: boolean | undefined;
212
212
  };
213
213
  /**
214
- * https://discord.com/developers/docs/resources/channel#attachment-object
214
+ * https://discord.com/developers/docs/resources/message#attachment-object
215
215
  */
216
- export interface RESTAPIAttachment {
217
- /**
218
- * Attachment id or a number that matches `n` in `files[n]`
219
- */
220
- id: Snowflake | number;
221
- /**
222
- * Name of the file
223
- */
224
- filename?: string | undefined;
225
- /**
226
- * Description of the file
227
- */
228
- description?: string | undefined;
229
- }
216
+ export type RESTAPIAttachment = Partial<Pick<APIAttachment, 'description' | 'duration_secs' | 'filename' | 'title' | 'waveform'>>;
230
217
  /**
231
218
  * https://discord.com/developers/docs/resources/channel#create-message
232
219
  */
@@ -392,7 +379,7 @@ export interface RESTPatchAPIChannelMessageJSONBody {
392
379
  *
393
380
  * Starting with API v10, the `attachments` array must contain all attachments that should be present after edit, including **retained and new** attachments provided in the request body.
394
381
  *
395
- * See https://discord.com/developers/docs/resources/channel#attachment-object
382
+ * See https://discord.com/developers/docs/resources/message#attachment-object
396
383
  */
397
384
  attachments?: RESTAPIAttachment[] | undefined;
398
385
  /**
@@ -1,4 +1,4 @@
1
- import type { APIApplicationCommand, APIApplicationCommandPermission, APIGuildApplicationCommandPermissions, APIInteractionResponse, APIInteractionResponseCallbackData, ApplicationCommandType } from '../payloads';
1
+ import type { APIApplicationCommand, APIApplicationCommandPermission, APIGuildApplicationCommandPermissions, APIInteractionCallbackLaunchActivity, APIInteractionCallbackMessage, APIInteractionResponse, APIInteractionResponseCallbackData, ApplicationCommandType, EntryPointCommandHandlerType } from '../payloads';
2
2
  import type { AddUndefinedToPossiblyUndefinedPropertiesOfInterface, NonNullableFields, StrictPartial } from '../utils';
3
3
  import type { RESTDeleteAPIWebhookWithTokenMessageResult, RESTGetAPIWebhookWithTokenMessageResult, RESTPatchAPIWebhookWithTokenMessageFormDataBody, RESTPatchAPIWebhookWithTokenMessageJSONBody, RESTPatchAPIWebhookWithTokenMessageResult, RESTPostAPIWebhookWithTokenWaitResult } from './webhook';
4
4
  /**
@@ -21,7 +21,7 @@ export type RESTGetAPIApplicationCommandsResult = APIApplicationCommand[];
21
21
  * https://discord.com/developers/docs/interactions/application-commands#get-global-application-command
22
22
  */
23
23
  export type RESTGetAPIApplicationCommandResult = APIApplicationCommand;
24
- type RESTPostAPIBaseApplicationCommandsJSONBody = AddUndefinedToPossiblyUndefinedPropertiesOfInterface<Omit<APIApplicationCommand, 'application_id' | 'contexts' | 'default_member_permissions' | 'description_localized' | 'description' | 'guild_id' | 'id' | 'integration_types' | 'name_localized' | 'type' | 'version'> & Partial<NonNullableFields<Pick<APIApplicationCommand, 'contexts'>> & Pick<APIApplicationCommand, 'default_member_permissions' | 'integration_types'>>>;
24
+ type RESTPostAPIBaseApplicationCommandsJSONBody = AddUndefinedToPossiblyUndefinedPropertiesOfInterface<Omit<APIApplicationCommand, 'application_id' | 'contexts' | 'default_member_permissions' | 'description_localized' | 'description' | 'guild_id' | 'id' | 'integration_types' | 'name_localized' | 'type' | 'version' | 'handler'> & Partial<NonNullableFields<Pick<APIApplicationCommand, 'contexts'>> & Pick<APIApplicationCommand, 'default_member_permissions' | 'integration_types'>>>;
25
25
  /**
26
26
  * https://discord.com/developers/docs/interactions/application-commands#create-global-application-command
27
27
  */
@@ -38,7 +38,15 @@ export interface RESTPostAPIContextMenuApplicationCommandsJSONBody extends RESTP
38
38
  /**
39
39
  * https://discord.com/developers/docs/interactions/application-commands#create-global-application-command
40
40
  */
41
- export type RESTPostAPIApplicationCommandsJSONBody = RESTPostAPIChatInputApplicationCommandsJSONBody | RESTPostAPIContextMenuApplicationCommandsJSONBody;
41
+ export interface RESTPostAPIEntryPointApplicationCommandsJSONBody extends RESTPostAPIBaseApplicationCommandsJSONBody {
42
+ type: ApplicationCommandType.PrimaryEntryPoint;
43
+ description: string;
44
+ handler: EntryPointCommandHandlerType;
45
+ }
46
+ /**
47
+ * https://discord.com/developers/docs/interactions/application-commands#create-global-application-command
48
+ */
49
+ export type RESTPostAPIApplicationCommandsJSONBody = RESTPostAPIChatInputApplicationCommandsJSONBody | RESTPostAPIContextMenuApplicationCommandsJSONBody | RESTPostAPIEntryPointApplicationCommandsJSONBody;
42
50
  /**
43
51
  * https://discord.com/developers/docs/interactions/application-commands#create-global-application-command
44
52
  */
@@ -63,14 +71,15 @@ export type RESTPutAPIApplicationCommandsResult = APIApplicationCommand[];
63
71
  * https://discord.com/developers/docs/interactions/application-commands#get-guild-application-commands
64
72
  */
65
73
  export type RESTGetAPIApplicationGuildCommandsQuery = RESTGetAPIApplicationCommandsQuery;
74
+ export type RESTAPIApplicationGuildCommand = Omit<APIApplicationCommand, 'dm_permission' | 'handler'>;
66
75
  /**
67
76
  * https://discord.com/developers/docs/interactions/application-commands#get-guild-application-commands
68
77
  */
69
- export type RESTGetAPIApplicationGuildCommandsResult = Omit<APIApplicationCommand, 'dm_permission'>[];
78
+ export type RESTGetAPIApplicationGuildCommandsResult = RESTAPIApplicationGuildCommand[];
70
79
  /**
71
80
  * https://discord.com/developers/docs/interactions/application-commands#get-guild-application-commands
72
81
  */
73
- export type RESTGetAPIApplicationGuildCommandResult = Omit<APIApplicationCommand, 'dm_permission'>;
82
+ export type RESTGetAPIApplicationGuildCommandResult = RESTAPIApplicationGuildCommand;
74
83
  /**
75
84
  * https://discord.com/developers/docs/interactions/application-commands#create-guild-application-command
76
85
  */
@@ -78,7 +87,7 @@ export type RESTPostAPIApplicationGuildCommandsJSONBody = Omit<RESTPostAPIChatIn
78
87
  /**
79
88
  * https://discord.com/developers/docs/interactions/application-commands#create-guild-application-command
80
89
  */
81
- export type RESTPostAPIApplicationGuildCommandsResult = Omit<APIApplicationCommand, 'dm_permission'>;
90
+ export type RESTPostAPIApplicationGuildCommandsResult = RESTAPIApplicationGuildCommand;
82
91
  /**
83
92
  * https://discord.com/developers/docs/interactions/application-commands#edit-guild-application-command
84
93
  */
@@ -86,7 +95,7 @@ export type RESTPatchAPIApplicationGuildCommandJSONBody = StrictPartial<Omit<RES
86
95
  /**
87
96
  * https://discord.com/developers/docs/interactions/application-commands#edit-guild-application-command
88
97
  */
89
- export type RESTPatchAPIApplicationGuildCommandResult = Omit<APIApplicationCommand, 'dm_permission'>;
98
+ export type RESTPatchAPIApplicationGuildCommandResult = RESTAPIApplicationGuildCommand;
90
99
  /**
91
100
  * https://discord.com/developers/docs/interactions/application-commands#bulk-overwrite-guild-application-commands
92
101
  */
@@ -94,11 +103,24 @@ export type RESTPutAPIApplicationGuildCommandsJSONBody = ((Omit<RESTPostAPIChatI
94
103
  /**
95
104
  * https://discord.com/developers/docs/interactions/application-commands#bulk-overwrite-guild-application-commands
96
105
  */
97
- export type RESTPutAPIApplicationGuildCommandsResult = Omit<APIApplicationCommand, 'dm_permission'>[];
106
+ export type RESTPutAPIApplicationGuildCommandsResult = RESTAPIApplicationGuildCommand[];
98
107
  /**
99
108
  * https://discord.com/developers/docs/interactions/receiving-and-responding#create-interaction-response
100
109
  */
101
110
  export type RESTPostAPIInteractionCallbackJSONBody = APIInteractionResponse;
111
+ /**
112
+ * https://discord.com/developers/docs/interactions/receiving-and-responding#create-interaction-response-query-string-params
113
+ */
114
+ export type RESTPostAPIInteractionCallbackQuery = {
115
+ /**
116
+ * Whether to include a RESTPostAPIInteractionCallbackResult as the response instead of a 204.
117
+ */
118
+ with_response?: boolean;
119
+ };
120
+ /**
121
+ * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-callback
122
+ */
123
+ export type RESTPostAPIInteractionCallbackResult = APIInteractionCallbackLaunchActivity | APIInteractionCallbackMessage;
102
124
  /**
103
125
  * https://discord.com/developers/docs/interactions/receiving-and-responding#create-interaction-response
104
126
  */
@@ -1,5 +1,5 @@
1
1
  import type { Snowflake } from '..';
2
- import type { APIEntitlement, APISKU } from '../payloads';
2
+ import type { APIEntitlement, APISKU, APISubscription } from '../payloads';
3
3
  /**
4
4
  * https://discord.com/developers/docs/monetization/entitlements#list-entitlements
5
5
  */
@@ -80,3 +80,24 @@ export type RESTGetAPISKUsResult = APISKU[];
80
80
  * https://discord.com/developers/docs/monetization/entitlements#consume-an-entitlement
81
81
  */
82
82
  export type RESTPostAPIEntitlementConsumeResult = never;
83
+ /**
84
+ * https://canary.discord.com/developers/docs/resources/subscription#query-string-params
85
+ */
86
+ export interface RESTGetAPISKUSubscriptionsQuery {
87
+ /** List subscriptions before this ID */
88
+ before?: string;
89
+ /** List subscriptions after this ID */
90
+ after?: string;
91
+ /** Number of results to return (1-100) */
92
+ limit?: number;
93
+ /** User ID for which to return subscriptions. Required except for OAuth queries. */
94
+ user_id?: string;
95
+ }
96
+ /**
97
+ * https://canary.discord.com/developers/docs/resources/subscription#list-sku-subscriptions
98
+ */
99
+ export type RESTGetAPISKUSubscriptionsResult = APISubscription[];
100
+ /**
101
+ * https://canary.discord.com/developers/docs/resources/subscription#get-sku-subscription
102
+ */
103
+ export type RESTGetAPISKUSubscriptionResult = APISubscription;
@@ -221,13 +221,13 @@ export interface RESTGetAPIWebhookWithTokenMessageQuery {
221
221
  /**
222
222
  * https://discord.com/developers/docs/resources/webhook#edit-webhook-message
223
223
  */
224
- export type RESTPatchAPIWebhookWithTokenMessageJSONBody = AddUndefinedToPossiblyUndefinedPropertiesOfInterface<Nullable<Pick<RESTPostAPIWebhookWithTokenJSONBody, 'allowed_mentions' | 'components' | 'content' | 'embeds'>>> & {
224
+ export type RESTPatchAPIWebhookWithTokenMessageJSONBody = AddUndefinedToPossiblyUndefinedPropertiesOfInterface<Nullable<Pick<RESTPostAPIWebhookWithTokenJSONBody, 'allowed_mentions' | 'components' | 'content' | 'embeds' | 'poll'>>> & {
225
225
  /**
226
226
  * Attached files to keep
227
227
  *
228
228
  * Starting with API v10, the `attachments` array must contain all attachments that should be present after edit, including **retained and new** attachments provided in the request body.
229
229
  *
230
- * See https://discord.com/developers/docs/resources/channel#attachment-object
230
+ * See https://discord.com/developers/docs/resources/message#attachment-object
231
231
  */
232
232
  attachments?: RESTAPIAttachment[] | undefined;
233
233
  };
@@ -323,6 +323,9 @@ export declare enum GatewayDispatchEvents {
323
323
  StageInstanceCreate = "STAGE_INSTANCE_CREATE",
324
324
  StageInstanceDelete = "STAGE_INSTANCE_DELETE",
325
325
  StageInstanceUpdate = "STAGE_INSTANCE_UPDATE",
326
+ SubscriptionCreate = "SUBSCRIPTION_CREATE",
327
+ SubscriptionUpdate = "SUBSCRIPTION_UPDATE",
328
+ SubscriptionDelete = "SUBSCRIPTION_DELETE",
326
329
  Ready = "READY",
327
330
  Resumed = "RESUMED",
328
331
  ThreadCreate = "THREAD_CREATE",
@@ -765,21 +768,29 @@ export declare enum GuildMemberFlags {
765
768
  */
766
769
  StartedOnboarding = 8,
767
770
  /**
768
- * @unstable This guild member flag is currently not documented by Discord but has a known value which we will try to keep up to date.
771
+ * Member is a guest and can only access the voice channel they were invited to
772
+ */
773
+ IsGuest = 16,
774
+ /**
775
+ * This guild member flag is currently not documented by Discord but has a known value which we will try to keep up to date.
769
776
  */
770
777
  StartedHomeActions = 32,
771
778
  /**
772
- * @unstable This guild member flag is currently not documented by Discord but has a known value which we will try to keep up to date.
779
+ * This guild member flag is currently not documented by Discord but has a known value which we will try to keep up to date.
773
780
  */
774
781
  CompletedHomeActions = 64,
775
782
  /**
776
- * @unstable This guild member flag is currently not documented by Discord but has a known value which we will try to keep up to date.
783
+ * This guild member flag is currently not documented by Discord but has a known value which we will try to keep up to date.
777
784
  */
778
785
  AutomodQuarantinedUsernameOrGuildNickname = 128,
779
786
  /**
780
- * @unstable This guild member flag is currently not documented by Discord but has a known value which we will try to keep up to date.
787
+ * @deprecated This guild member flag is currently not documented by Discord but has a known value which we will try to keep up to date.
788
+ */
789
+ AutomodQuarantinedBio = 256,
790
+ /**
791
+ * Member has dismissed the DM settings upsell
781
792
  */
782
- AutomodQuarantinedBio = 256
793
+ DmSettingsUpsellAcknowledged = 512
783
794
  }
784
795
  export declare enum OverwriteType {
785
796
  Role = 0,
@@ -312,6 +312,9 @@ var GatewayDispatchEvents;
312
312
  GatewayDispatchEvents["StageInstanceCreate"] = "STAGE_INSTANCE_CREATE";
313
313
  GatewayDispatchEvents["StageInstanceDelete"] = "STAGE_INSTANCE_DELETE";
314
314
  GatewayDispatchEvents["StageInstanceUpdate"] = "STAGE_INSTANCE_UPDATE";
315
+ GatewayDispatchEvents["SubscriptionCreate"] = "SUBSCRIPTION_CREATE";
316
+ GatewayDispatchEvents["SubscriptionUpdate"] = "SUBSCRIPTION_UPDATE";
317
+ GatewayDispatchEvents["SubscriptionDelete"] = "SUBSCRIPTION_DELETE";
315
318
  GatewayDispatchEvents["Ready"] = "READY";
316
319
  GatewayDispatchEvents["Resumed"] = "RESUMED";
317
320
  GatewayDispatchEvents["ThreadCreate"] = "THREAD_CREATE";
@@ -766,21 +769,29 @@ var GuildMemberFlags;
766
769
  */
767
770
  GuildMemberFlags[GuildMemberFlags["StartedOnboarding"] = 8] = "StartedOnboarding";
768
771
  /**
769
- * @unstable This guild member flag is currently not documented by Discord but has a known value which we will try to keep up to date.
772
+ * Member is a guest and can only access the voice channel they were invited to
773
+ */
774
+ GuildMemberFlags[GuildMemberFlags["IsGuest"] = 16] = "IsGuest";
775
+ /**
776
+ * This guild member flag is currently not documented by Discord but has a known value which we will try to keep up to date.
770
777
  */
771
778
  GuildMemberFlags[GuildMemberFlags["StartedHomeActions"] = 32] = "StartedHomeActions";
772
779
  /**
773
- * @unstable This guild member flag is currently not documented by Discord but has a known value which we will try to keep up to date.
780
+ * This guild member flag is currently not documented by Discord but has a known value which we will try to keep up to date.
774
781
  */
775
782
  GuildMemberFlags[GuildMemberFlags["CompletedHomeActions"] = 64] = "CompletedHomeActions";
776
783
  /**
777
- * @unstable This guild member flag is currently not documented by Discord but has a known value which we will try to keep up to date.
784
+ * This guild member flag is currently not documented by Discord but has a known value which we will try to keep up to date.
778
785
  */
779
786
  GuildMemberFlags[GuildMemberFlags["AutomodQuarantinedUsernameOrGuildNickname"] = 128] = "AutomodQuarantinedUsernameOrGuildNickname";
780
787
  /**
781
- * @unstable This guild member flag is currently not documented by Discord but has a known value which we will try to keep up to date.
788
+ * @deprecated This guild member flag is currently not documented by Discord but has a known value which we will try to keep up to date.
782
789
  */
783
790
  GuildMemberFlags[GuildMemberFlags["AutomodQuarantinedBio"] = 256] = "AutomodQuarantinedBio";
791
+ /**
792
+ * Member has dismissed the DM settings upsell
793
+ */
794
+ GuildMemberFlags[GuildMemberFlags["DmSettingsUpsellAcknowledged"] = 512] = "DmSettingsUpsellAcknowledged";
784
795
  })(GuildMemberFlags || (exports.GuildMemberFlags = GuildMemberFlags = {}));
785
796
  var OverwriteType;
786
797
  (function (OverwriteType) {
@@ -1,5 +1,5 @@
1
1
  import type { RestToKeys } from '../common';
2
- import type { GatewayActivity, PresenceUpdateStatus, GatewayPresenceUpdateData, GatewayRequestGuildMembersDataWithQuery, GatewayRequestGuildMembersDataWithUserIds, APIGuildMember, APIUser, GatewayReadyDispatchData, GatewayChannelUpdateDispatchData, GatewayAutoModerationActionExecutionDispatchData, GatewayThreadCreateDispatchData, GatewayThreadDeleteDispatchData, GatewayThreadListSyncDispatchData, GatewayThreadMemberUpdateDispatchData, GatewayThreadMembersUpdateDispatchData, GatewayChannelPinsUpdateDispatchData, GatewayGuildCreateDispatchData, APIGuild, GatewayGuildDeleteDispatchData, APIAuditLogEntry, GatewayGuildBanAddDispatchData, GatewayGuildBanRemoveDispatchData, GatewayGuildEmojisUpdateDispatchData, GatewayGuildStickersUpdateDispatchData, GatewayGuildIntegrationsUpdateDispatchData, GatewayGuildMemberAddDispatchData, GatewayGuildMemberRemoveDispatchData, GatewayGuildMemberUpdateDispatchData, GatewayGuildMembersChunkDispatchData, GatewayGuildRoleCreateDispatchData, GatewayGuildRoleUpdateDispatchData, GatewayGuildRoleDeleteDispatchData, GatewayIntegrationDeleteDispatchData, GatewayInviteCreateDispatchData, GatewayInviteDeleteDispatchData, GatewayMessageCreateDispatchData, GatewayMessageUpdateDispatchData, GatewayMessageDeleteDispatchData, GatewayMessageDeleteBulkDispatchData, GatewayMessageReactionAddDispatchData, GatewayMessageReactionRemoveDispatchData, GatewayMessageReactionRemoveAllDispatchData, GatewayMessageReactionRemoveEmojiDispatchData, GatewayPresenceUpdateDispatchData, GatewayTypingStartDispatchData, GatewayUserUpdateDispatchData, GatewayVoiceStateUpdateData, GatewayVoiceServerUpdateDispatchData, GatewayWebhooksUpdateDispatchData, GatewayInteractionCreateDispatchData, APIStageInstance, GatewayMessagePollVoteDispatchData, GatewayIntegrationCreateDispatchData, GatewayGuildScheduledEventUserRemoveDispatchData, APIGuildScheduledEvent, APIChannel, APIAutoModerationRule, APIEntitlement, GatewayVoiceChannelEffectSendDispachData } from '../types';
2
+ import type { GatewayActivity, PresenceUpdateStatus, GatewayPresenceUpdateData, GatewayRequestGuildMembersDataWithQuery, GatewayRequestGuildMembersDataWithUserIds, APIGuildMember, APIUser, GatewayReadyDispatchData, GatewayChannelUpdateDispatchData, GatewayAutoModerationActionExecutionDispatchData, GatewayThreadCreateDispatchData, GatewayThreadDeleteDispatchData, GatewayThreadListSyncDispatchData, GatewayThreadMemberUpdateDispatchData, GatewayThreadMembersUpdateDispatchData, GatewayChannelPinsUpdateDispatchData, GatewayGuildCreateDispatchData, APIGuild, GatewayGuildDeleteDispatchData, APIAuditLogEntry, GatewayGuildBanAddDispatchData, GatewayGuildBanRemoveDispatchData, GatewayGuildEmojisUpdateDispatchData, GatewayGuildStickersUpdateDispatchData, GatewayGuildIntegrationsUpdateDispatchData, GatewayGuildMemberAddDispatchData, GatewayGuildMemberRemoveDispatchData, GatewayGuildMemberUpdateDispatchData, GatewayGuildMembersChunkDispatchData, GatewayGuildRoleCreateDispatchData, GatewayGuildRoleUpdateDispatchData, GatewayGuildRoleDeleteDispatchData, GatewayIntegrationDeleteDispatchData, GatewayInviteCreateDispatchData, GatewayInviteDeleteDispatchData, GatewayMessageCreateDispatchData, GatewayMessageUpdateDispatchData, GatewayMessageDeleteDispatchData, GatewayMessageDeleteBulkDispatchData, GatewayMessageReactionAddDispatchData, GatewayMessageReactionRemoveDispatchData, GatewayMessageReactionRemoveAllDispatchData, GatewayMessageReactionRemoveEmojiDispatchData, GatewayPresenceUpdateDispatchData, GatewayTypingStartDispatchData, GatewayUserUpdateDispatchData, GatewayVoiceStateUpdateData, GatewayVoiceServerUpdateDispatchData, GatewayWebhooksUpdateDispatchData, GatewayInteractionCreateDispatchData, APIStageInstance, GatewayMessagePollVoteDispatchData, GatewayIntegrationCreateDispatchData, GatewayGuildScheduledEventUserRemoveDispatchData, APIGuildScheduledEvent, APIChannel, APIAutoModerationRule, APIEntitlement, GatewayVoiceChannelEffectSendDispachData, APISubscription, GatewayEntitlementCreateDispatchData } from '../types';
3
3
  import { GatewayDispatchEvents } from '../types';
4
4
  /** https://discord.com/developers/docs/topics/gateway-events#update-presence */
5
5
  export interface StatusUpdate {
@@ -81,6 +81,7 @@ export interface Events {
81
81
  [GatewayDispatchEvents.VoiceServerUpdate]: GatewayVoiceServerUpdateDispatchData;
82
82
  [GatewayDispatchEvents.WebhooksUpdate]: GatewayWebhooksUpdateDispatchData;
83
83
  [GatewayDispatchEvents.InteractionCreate]: GatewayInteractionCreateDispatchData;
84
+ [GatewayDispatchEvents.EntitlementCreate]: GatewayEntitlementCreateDispatchData;
84
85
  }
85
86
  export type StageSameEvents = RestToKeys<[
86
87
  APIStageInstance,
@@ -123,11 +124,16 @@ export type AutoModetaractionRuleEvents = RestToKeys<[
123
124
  ]>;
124
125
  export type EntitlementEvents = RestToKeys<[
125
126
  APIEntitlement,
126
- GatewayDispatchEvents.EntitlementCreate,
127
127
  GatewayDispatchEvents.EntitlementDelete,
128
128
  GatewayDispatchEvents.EntitlementUpdate
129
129
  ]>;
130
- export type NormalizeEvents = Events & AutoModetaractionRuleEvents & ChannelSameEvents & GuildScheduledSameEvents & GuildScheduledUserSameEvents & IntegrationSameEvents & EntitlementEvents & PollVoteSameEvents & StageSameEvents & {
130
+ export type SubscriptionEvents = RestToKeys<[
131
+ APISubscription,
132
+ GatewayDispatchEvents.SubscriptionCreate,
133
+ GatewayDispatchEvents.SubscriptionDelete,
134
+ GatewayDispatchEvents.SubscriptionUpdate
135
+ ]>;
136
+ export type NormalizeEvents = Events & AutoModetaractionRuleEvents & ChannelSameEvents & GuildScheduledSameEvents & GuildScheduledUserSameEvents & IntegrationSameEvents & EntitlementEvents & PollVoteSameEvents & StageSameEvents & SubscriptionEvents & {
131
137
  RAW: GatewayDispatchEvents;
132
138
  };
133
139
  export type GatewayEvents = {
@@ -1,3 +1,4 @@
1
+ import type { DeepPartial } from '../../common';
1
2
  import type { ShardManagerOptions, WorkerManagerOptions } from '../discord';
2
3
  declare const COMPRESS = false;
3
4
  declare const properties: {
@@ -5,8 +6,8 @@ declare const properties: {
5
6
  browser: string;
6
7
  device: string;
7
8
  };
8
- declare const ShardManagerDefaults: Partial<ShardManagerOptions>;
9
- declare const WorkerManagerDefaults: Partial<WorkerManagerOptions>;
9
+ declare const ShardManagerDefaults: DeepPartial<ShardManagerOptions>;
10
+ declare const WorkerManagerDefaults: DeepPartial<WorkerManagerOptions>;
10
11
  export interface IdentifyProperties {
11
12
  /**
12
13
  * Operating system the shard runs on.
@@ -20,11 +20,21 @@ const ShardManagerDefaults = {
20
20
  handlePayload: (shardId, packet) => {
21
21
  console.info(`Packet ${packet.t} on shard ${shardId}`);
22
22
  },
23
+ resharding: {
24
+ interval: 8 * 60 * 60 * 1e3, // 8h
25
+ percentage: 80,
26
+ reloadGuilds() {
27
+ throw new Error('Unexpected to run <reloadGuilds>');
28
+ },
29
+ onGuild() {
30
+ throw new Error('Unexpected to run <onGuild>');
31
+ },
32
+ },
23
33
  };
24
34
  exports.ShardManagerDefaults = ShardManagerDefaults;
25
35
  const WorkerManagerDefaults = {
26
36
  ...ShardManagerDefaults,
27
- shardsPerWorker: 32,
37
+ shardsPerWorker: 16,
28
38
  handlePayload: (_shardId, _workerId, _packet) => { },
29
39
  };
30
40
  exports.WorkerManagerDefaults = WorkerManagerDefaults;
@@ -1,4 +1,4 @@
1
- import { type MakeRequired, type Logger } from '../../common';
1
+ import { Logger, type MakeRequired } from '../../common';
2
2
  import { DynamicBucket } from '../structures';
3
3
  import { ConnectTimeout } from '../structures/timeout';
4
4
  import { BaseSocket } from './basesocket';
@@ -13,6 +13,7 @@ export interface ShardHeart {
13
13
  }
14
14
  export declare class Shard {
15
15
  id: number;
16
+ logger: Logger;
16
17
  debugger?: Logger;
17
18
  data: Partial<ShardData> | ShardData;
18
19
  websocket: BaseSocket | null;
@@ -42,7 +43,7 @@ export declare class Shard {
42
43
  reason: string;
43
44
  }): Promise<void>;
44
45
  close(code: number, reason: string): Promise<void>;
45
- protected handleMessage(data: string | Buffer): Promise<void>;
46
+ protected handleMessage(data: string | Buffer): Promise<void> | undefined;
46
47
  checkOffline(force: boolean): Promise<unknown>;
47
48
  calculateSafeRequests(): number;
48
49
  }
@@ -11,6 +11,7 @@ const shared_1 = require("./shared");
11
11
  const types_1 = require("../../types");
12
12
  class Shard {
13
13
  id;
14
+ logger;
14
15
  debugger;
15
16
  data = {
16
17
  resume_seq: null,
@@ -33,6 +34,10 @@ class Shard {
33
34
  maxRequestsPerRateLimitTick: 120,
34
35
  },
35
36
  });
37
+ this.logger = new common_1.Logger({
38
+ name: `[Shard #${id}]`,
39
+ logLevel: common_1.LogLevels.Info,
40
+ });
36
41
  if (options.debugger)
37
42
  this.debugger = options.debugger;
38
43
  const safe = this.calculateSafeRequests();
@@ -66,7 +71,7 @@ class Shard {
66
71
  async connect() {
67
72
  await this.connectTimeout.wait();
68
73
  if (this.isOpen) {
69
- this.debugger?.debug(`[Shard #${this.id}] attempted to connect while open`);
74
+ this.debugger?.debug(`[Shard #${this.id}] Attempted to connect while open`);
70
75
  return;
71
76
  }
72
77
  clearTimeout(this.heart.nodeInterval);
@@ -78,7 +83,7 @@ class Shard {
78
83
  this.handleMessage(data);
79
84
  };
80
85
  this.websocket.onclose = (event) => this.handleClosed(event);
81
- this.websocket.onerror = (event) => this.debugger?.error(event);
86
+ this.websocket.onerror = (event) => this.logger.error(event);
82
87
  this.websocket.onopen = () => {
83
88
  this.heart.ack = true;
84
89
  };
@@ -178,7 +183,7 @@ class Shard {
178
183
  case types_1.GatewayOpcodes.InvalidSession:
179
184
  if (packet.d) {
180
185
  if (!this.resumable) {
181
- return this.debugger?.fatal(`[Shard #${this.id}] This is a completely unexpected error message.`);
186
+ return this.logger.fatal('This is a completely unexpected error message.');
182
187
  }
183
188
  await this.resume();
184
189
  }
@@ -212,7 +217,7 @@ class Shard {
212
217
  }
213
218
  async handleClosed(close) {
214
219
  clearInterval(this.heart.nodeInterval);
215
- this.debugger?.warn(`[Shard #${this.id}] ${shared_1.ShardSocketCloseCodes[close.code] ?? types_1.GatewayCloseCodes[close.code] ?? close.code} (${close.code})`, close.reason);
220
+ this.logger.warn(`${shared_1.ShardSocketCloseCodes[close.code] ?? types_1.GatewayCloseCodes[close.code] ?? close.code} (${close.code})`, close.reason);
216
221
  switch (close.code) {
217
222
  case shared_1.ShardSocketCloseCodes.Shutdown:
218
223
  //Force disconnect, ignore
@@ -234,7 +239,7 @@ class Shard {
234
239
  case types_1.GatewayCloseCodes.NotAuthenticated:
235
240
  case types_1.GatewayCloseCodes.AlreadyAuthenticated:
236
241
  case types_1.GatewayCloseCodes.RateLimited:
237
- this.debugger?.info(`[Shard #${this.id}] Trying to reconnect`);
242
+ this.logger.info('Trying to reconnect');
238
243
  await this.reconnect();
239
244
  break;
240
245
  case types_1.GatewayCloseCodes.AuthenticationFailed:
@@ -243,26 +248,35 @@ class Shard {
243
248
  case types_1.GatewayCloseCodes.InvalidIntents:
244
249
  case types_1.GatewayCloseCodes.InvalidShard:
245
250
  case types_1.GatewayCloseCodes.ShardingRequired:
246
- this.debugger?.fatal(`[Shard #${this.id}] cannot reconnect`);
251
+ this.logger.fatal('Cannot reconnect');
247
252
  break;
248
253
  default:
249
- this.debugger?.warn(`[Shard #${this.id}] Unknown close code, trying to reconnect anyways`);
254
+ this.logger.warn('Unknown close code, trying to reconnect anyways');
250
255
  await this.reconnect();
251
256
  break;
252
257
  }
253
258
  }
254
259
  async close(code, reason) {
260
+ clearInterval(this.heart.nodeInterval);
255
261
  if (!this.isOpen) {
256
262
  return this.debugger?.warn(`[Shard #${this.id}] Is not open`);
257
263
  }
258
- this.debugger?.warn(`[Shard #${this.id}] Called close`);
264
+ this.debugger?.debug(`[Shard #${this.id}] Called close`);
259
265
  this.websocket?.close(code, reason);
260
266
  }
261
267
  handleMessage(data) {
262
- if (data instanceof Buffer) {
263
- data = (0, node_zlib_1.inflateSync)(data);
268
+ let packet;
269
+ try {
270
+ if (data instanceof Buffer) {
271
+ data = (0, node_zlib_1.inflateSync)(data);
272
+ }
273
+ packet = JSON.parse(data);
274
+ }
275
+ catch (e) {
276
+ this.logger.error(e);
277
+ return;
264
278
  }
265
- return this.onpacket(JSON.parse(data));
279
+ return this.onpacket(packet);
266
280
  }
267
281
  checkOffline(force) {
268
282
  if (!this.isOpen) {