seyfert 3.2.7-dev-17041037679.0 → 3.2.7-dev-17350702966.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/builders/Label.d.ts +12 -0
- package/lib/builders/Label.js +35 -0
- package/lib/builders/Modal.d.ts +6 -6
- package/lib/builders/SelectMenu.d.ts +6 -0
- package/lib/builders/SelectMenu.js +9 -0
- package/lib/builders/index.js +3 -0
- package/lib/builders/types.d.ts +6 -5
- package/lib/components/BaseComponent.d.ts +4 -1
- package/lib/components/LabelComponent.d.ts +8 -0
- package/lib/components/LabelComponent.js +20 -0
- package/lib/components/modalcontext.d.ts +2 -1
- package/lib/events/hooks/dispatch.d.ts +2 -1
- package/lib/events/hooks/dispatch.js +5 -1
- package/lib/structures/Interaction.d.ts +4 -3
- package/lib/structures/Interaction.js +4 -5
- package/lib/types/gateway.d.ts +32 -1
- package/lib/types/payloads/_interactions/modalSubmit.d.ts +2 -1
- package/lib/types/payloads/_interactions/responses.d.ts +2 -2
- package/lib/types/payloads/components.d.ts +27 -2
- package/lib/types/payloads/components.js +4 -0
- package/lib/types/utils/index.d.ts +1 -0
- package/lib/types/utils/index.js +1 -0
- package/lib/websocket/discord/shard.js +32 -0
- package/package.json +1 -1
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type APILabelComponent } from '../types';
|
|
2
|
+
import { BaseComponentBuilder } from './Base';
|
|
3
|
+
import type { TextInput } from './Modal';
|
|
4
|
+
import type { StringSelectMenu } from './SelectMenu';
|
|
5
|
+
export declare class Label extends BaseComponentBuilder<APILabelComponent> {
|
|
6
|
+
constructor({ component, ...data }?: Partial<APILabelComponent>);
|
|
7
|
+
component?: TextInput | StringSelectMenu;
|
|
8
|
+
setLabel(label: string): this;
|
|
9
|
+
setDescription(description: string): this;
|
|
10
|
+
setComponent(component: TextInput | StringSelectMenu): this;
|
|
11
|
+
toJSON(): APILabelComponent;
|
|
12
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Label = void 0;
|
|
4
|
+
const types_1 = require("../types");
|
|
5
|
+
const _1 = require(".");
|
|
6
|
+
const Base_1 = require("./Base");
|
|
7
|
+
class Label extends Base_1.BaseComponentBuilder {
|
|
8
|
+
constructor({ component, ...data } = {}) {
|
|
9
|
+
super({ type: types_1.ComponentType.Label, ...data });
|
|
10
|
+
if (component)
|
|
11
|
+
this.component = (0, _1.fromComponent)(component);
|
|
12
|
+
}
|
|
13
|
+
component;
|
|
14
|
+
setLabel(label) {
|
|
15
|
+
this.data.label = label;
|
|
16
|
+
return this;
|
|
17
|
+
}
|
|
18
|
+
setDescription(description) {
|
|
19
|
+
this.data.description = description;
|
|
20
|
+
return this;
|
|
21
|
+
}
|
|
22
|
+
setComponent(component) {
|
|
23
|
+
this.component = component;
|
|
24
|
+
return this;
|
|
25
|
+
}
|
|
26
|
+
toJSON() {
|
|
27
|
+
if (!this.component)
|
|
28
|
+
throw new Error('Cannot convert to JSON without a component.');
|
|
29
|
+
return {
|
|
30
|
+
...this.data,
|
|
31
|
+
component: this.component.toJSON(),
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
exports.Label = Label;
|
package/lib/builders/Modal.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { RestOrArray } from '../common';
|
|
2
2
|
import { type APIModalInteractionResponseCallbackData, type APITextInputComponent, type TextInputStyle } from '../types';
|
|
3
|
-
import type { ActionRow } from './ActionRow';
|
|
4
3
|
import { BaseComponentBuilder, type OptionValuesLength } from './Base';
|
|
5
|
-
import
|
|
4
|
+
import { Label } from './Label';
|
|
5
|
+
import type { ModalSubmitCallback } from './types';
|
|
6
6
|
/**
|
|
7
7
|
* Represents a modal for user interactions.
|
|
8
8
|
* @template T - The type of components allowed in the modal.
|
|
@@ -18,9 +18,9 @@ import type { ModalBuilderComponents, ModalSubmitCallback } from './types';
|
|
|
18
18
|
* });
|
|
19
19
|
* const json = modal.toJSON();
|
|
20
20
|
*/
|
|
21
|
-
export declare class Modal
|
|
21
|
+
export declare class Modal {
|
|
22
22
|
data: Partial<APIModalInteractionResponseCallbackData>;
|
|
23
|
-
components:
|
|
23
|
+
components: Label[];
|
|
24
24
|
/**
|
|
25
25
|
* Creates a new Modal instance.
|
|
26
26
|
* @param data - Optional data for the modal.
|
|
@@ -31,13 +31,13 @@ export declare class Modal<T extends ModalBuilderComponents = TextInput> {
|
|
|
31
31
|
* @param components - Components to be added to the modal.
|
|
32
32
|
* @returns The current Modal instance.
|
|
33
33
|
*/
|
|
34
|
-
addComponents(...components: RestOrArray<
|
|
34
|
+
addComponents(...components: RestOrArray<Label>): this;
|
|
35
35
|
/**
|
|
36
36
|
* Set the components to the modal.
|
|
37
37
|
* @param component - The components to set into the modal.
|
|
38
38
|
* @returns The current Modal instance.
|
|
39
39
|
*/
|
|
40
|
-
setComponents(component:
|
|
40
|
+
setComponents(component: Label[]): this;
|
|
41
41
|
/**
|
|
42
42
|
* Sets the title of the modal.
|
|
43
43
|
* @param title - The title of the modal.
|
|
@@ -163,6 +163,12 @@ export declare class StringSelectMenu extends SelectMenu {
|
|
|
163
163
|
* @returns The current StringSelectMenu instance.
|
|
164
164
|
*/
|
|
165
165
|
setOptions(options: StringSelectOption[]): this;
|
|
166
|
+
/**
|
|
167
|
+
* Sets whether the string select is required to answer in a modal.
|
|
168
|
+
* @param required - Whether the string select is required to answer in a modal.
|
|
169
|
+
* @returns The current StringSelectMenu instance.
|
|
170
|
+
*/
|
|
171
|
+
setRequired(required?: boolean): this;
|
|
166
172
|
toJSON(): APIStringSelectComponent;
|
|
167
173
|
}
|
|
168
174
|
/**
|
|
@@ -236,6 +236,15 @@ class StringSelectMenu extends SelectMenu {
|
|
|
236
236
|
this.data.options = options;
|
|
237
237
|
return this;
|
|
238
238
|
}
|
|
239
|
+
/**
|
|
240
|
+
* Sets whether the string select is required to answer in a modal.
|
|
241
|
+
* @param required - Whether the string select is required to answer in a modal.
|
|
242
|
+
* @returns The current StringSelectMenu instance.
|
|
243
|
+
*/
|
|
244
|
+
setRequired(required = true) {
|
|
245
|
+
this.data.required = required;
|
|
246
|
+
return this;
|
|
247
|
+
}
|
|
239
248
|
toJSON() {
|
|
240
249
|
const { options, ...raw } = this.data;
|
|
241
250
|
return {
|
package/lib/builders/index.js
CHANGED
|
@@ -20,6 +20,7 @@ const ActionRow_1 = require("./ActionRow");
|
|
|
20
20
|
const Button_1 = require("./Button");
|
|
21
21
|
const Container_1 = require("./Container");
|
|
22
22
|
const File_1 = require("./File");
|
|
23
|
+
const Label_1 = require("./Label");
|
|
23
24
|
const MediaGallery_1 = require("./MediaGallery");
|
|
24
25
|
const Modal_1 = require("./Modal");
|
|
25
26
|
const Section_1 = require("./Section");
|
|
@@ -78,5 +79,7 @@ function fromComponent(data) {
|
|
|
78
79
|
return new Separator_1.Separator(data);
|
|
79
80
|
case types_1.ComponentType.File:
|
|
80
81
|
return new File_1.File(data);
|
|
82
|
+
case types_1.ComponentType.Label:
|
|
83
|
+
return new Label_1.Label(data);
|
|
81
84
|
}
|
|
82
85
|
}
|
package/lib/builders/types.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import type { ActionRow } from './ActionRow';
|
|
|
3
3
|
import type { Button } from './Button';
|
|
4
4
|
import type { Container } from './Container';
|
|
5
5
|
import type { File } from './File';
|
|
6
|
+
import { Label } from './Label';
|
|
6
7
|
import type { MediaGallery } from './MediaGallery';
|
|
7
8
|
import type { TextInput } from './Modal';
|
|
8
9
|
import type { Section } from './Section';
|
|
@@ -18,11 +19,11 @@ export type ComponentRefreshCallback = () => any;
|
|
|
18
19
|
export type ModalSubmitCallback<T = ModalSubmitInteraction> = (interaction: T) => any;
|
|
19
20
|
export type ButtonLink = Omit<Button, 'setCustomId'>;
|
|
20
21
|
export type ButtonID = Omit<Button, 'setURL'>;
|
|
21
|
-
export type MessageBuilderComponents =
|
|
22
|
-
export type ModalBuilderComponents =
|
|
23
|
-
export type ActionBuilderComponents =
|
|
24
|
-
export type BuilderComponents = ActionRow |
|
|
25
|
-
export type TopLevelBuilders = Exclude<BuilderComponents, Thumbnail | TextInput>;
|
|
22
|
+
export type MessageBuilderComponents = Exclude<TopLevelBuilders, Label>;
|
|
23
|
+
export type ModalBuilderComponents = Label;
|
|
24
|
+
export type ActionBuilderComponents = Button | BuilderSelectMenus;
|
|
25
|
+
export type BuilderComponents = ActionRow | BuilderSelectMenus | Button | Section<Button | Thumbnail> | Thumbnail | TextDisplay | Container | Separator | MediaGallery | File | TextInput | Label;
|
|
26
|
+
export type TopLevelBuilders = Exclude<BuilderComponents, Thumbnail | TextInput | Button | BuilderSelectMenus>;
|
|
26
27
|
export type FixedComponents<T = Button> = T extends Button ? ButtonLink | ButtonID : T;
|
|
27
28
|
export interface ListenerOptions {
|
|
28
29
|
timeout?: number;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type ActionRow, type Button, type ChannelSelectMenu, type Container, type File, type MediaGallery, type MentionableSelectMenu, type RoleSelectMenu, type Section, type Separator, type StringSelectMenu, type TextDisplay, type TextInput, type Thumbnail, type UserSelectMenu } from '../builders';
|
|
2
|
-
import {
|
|
2
|
+
import { Label } from '../builders/Label';
|
|
3
|
+
import { type APIActionRowComponent, type APIActionRowComponentTypes, type APIButtonComponent, type APIChannelSelectComponent, type APIContainerComponent, type APIFileComponent, type APILabelComponent, type APIMediaGalleryComponent, type APIMentionableSelectComponent, type APIRoleSelectComponent, type APISectionComponent, type APISeparatorComponent, type APIStringSelectComponent, type APITextDisplayComponent, type APITextInputComponent, type APIThumbnailComponent, type APIUserSelectComponent, ComponentType } from '../types';
|
|
3
4
|
export declare class BaseComponent<T extends ComponentType> {
|
|
4
5
|
data: APIComponentsMap[T];
|
|
5
6
|
constructor(data: APIComponentsMap[T]);
|
|
@@ -23,6 +24,7 @@ export interface APIComponentsMap {
|
|
|
23
24
|
[ComponentType.MediaGallery]: APIMediaGalleryComponent;
|
|
24
25
|
[ComponentType.Separator]: APISeparatorComponent;
|
|
25
26
|
[ComponentType.TextDisplay]: APITextDisplayComponent;
|
|
27
|
+
[ComponentType.Label]: APILabelComponent;
|
|
26
28
|
}
|
|
27
29
|
export interface BuilderComponentsMap {
|
|
28
30
|
[ComponentType.ActionRow]: ActionRow;
|
|
@@ -40,4 +42,5 @@ export interface BuilderComponentsMap {
|
|
|
40
42
|
[ComponentType.MediaGallery]: MediaGallery;
|
|
41
43
|
[ComponentType.Separator]: Separator;
|
|
42
44
|
[ComponentType.TextDisplay]: TextDisplay;
|
|
45
|
+
[ComponentType.Label]: Label;
|
|
43
46
|
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { APILabelComponent, ComponentType } from '../types';
|
|
2
|
+
import { BaseComponent } from './BaseComponent';
|
|
3
|
+
export declare class LabelComponent extends BaseComponent<ComponentType.Label> {
|
|
4
|
+
constructor(data: APILabelComponent);
|
|
5
|
+
get label(): string;
|
|
6
|
+
get description(): string | undefined;
|
|
7
|
+
get component(): import(".").AllComponents;
|
|
8
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LabelComponent = void 0;
|
|
4
|
+
const _1 = require(".");
|
|
5
|
+
const BaseComponent_1 = require("./BaseComponent");
|
|
6
|
+
class LabelComponent extends BaseComponent_1.BaseComponent {
|
|
7
|
+
constructor(data) {
|
|
8
|
+
super(data);
|
|
9
|
+
}
|
|
10
|
+
get label() {
|
|
11
|
+
return this.data.label;
|
|
12
|
+
}
|
|
13
|
+
get description() {
|
|
14
|
+
return this.data.description;
|
|
15
|
+
}
|
|
16
|
+
get component() {
|
|
17
|
+
return (0, _1.componentFactory)(this.data.component);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
exports.LabelComponent = LabelComponent;
|
|
@@ -26,7 +26,8 @@ export declare class ModalContext<M extends keyof RegisteredMiddlewares = never>
|
|
|
26
26
|
components: {
|
|
27
27
|
type: import("../types").ComponentType;
|
|
28
28
|
customId: string;
|
|
29
|
-
value
|
|
29
|
+
value?: string | undefined;
|
|
30
|
+
values?: string[] | undefined;
|
|
30
31
|
}[];
|
|
31
32
|
type: import("../types").ComponentType.ActionRow;
|
|
32
33
|
}[];
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { type ClientUserStructure } from '../../client/transformers';
|
|
2
2
|
import type { UsingClient } from '../../commands';
|
|
3
|
-
import type { GatewayDispatchPayload, GatewayReadyDispatchData, GatewayResumedDispatch } from '../../types';
|
|
3
|
+
import type { GatewayDispatchPayload, GatewayRateLimitedDispatchData, GatewayReadyDispatchData, GatewayResumedDispatch } from '../../types';
|
|
4
4
|
export declare const READY: (self: UsingClient, data: GatewayReadyDispatchData) => ClientUserStructure;
|
|
5
5
|
export declare const RESUMED: (_self: UsingClient, _data: GatewayResumedDispatch["d"]) => void;
|
|
6
6
|
export declare const RAW: (_self: UsingClient, data: GatewayDispatchPayload) => GatewayDispatchPayload;
|
|
7
|
+
export declare const RATE_LIMITED: (_self: UsingClient, data: GatewayRateLimitedDispatchData) => GatewayRateLimitedDispatchData;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.RAW = exports.RESUMED = exports.READY = void 0;
|
|
3
|
+
exports.RATE_LIMITED = exports.RAW = exports.RESUMED = exports.READY = void 0;
|
|
4
4
|
const transformers_1 = require("../../client/transformers");
|
|
5
5
|
const READY = (self, data) => {
|
|
6
6
|
return transformers_1.Transformers.ClientUser(self, data.user, data.application);
|
|
@@ -14,3 +14,7 @@ const RAW = (_self, data) => {
|
|
|
14
14
|
return data;
|
|
15
15
|
};
|
|
16
16
|
exports.RAW = RAW;
|
|
17
|
+
const RATE_LIMITED = (_self, data) => {
|
|
18
|
+
return data;
|
|
19
|
+
};
|
|
20
|
+
exports.RATE_LIMITED = RATE_LIMITED;
|
|
@@ -201,12 +201,13 @@ export declare class ModalSubmitInteraction<FromGuild extends boolean = boolean>
|
|
|
201
201
|
components: {
|
|
202
202
|
type: ComponentType;
|
|
203
203
|
customId: string;
|
|
204
|
-
value
|
|
204
|
+
value?: string | undefined;
|
|
205
|
+
values?: string[] | undefined;
|
|
205
206
|
}[];
|
|
206
207
|
type: ComponentType.ActionRow;
|
|
207
208
|
}[];
|
|
208
|
-
getInputValue(customId: string, required: true): string;
|
|
209
|
-
getInputValue(customId: string, required?: false): string | undefined;
|
|
209
|
+
getInputValue(customId: string, required: true): string | string[];
|
|
210
|
+
getInputValue(customId: string, required?: false): string | string[] | undefined;
|
|
210
211
|
isModal(): this is ModalSubmitInteraction;
|
|
211
212
|
}
|
|
212
213
|
export {};
|
|
@@ -8,6 +8,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.ModalSubmitInteraction = exports.MessageCommandInteraction = exports.UserCommandInteraction = exports.ChatInputCommandInteraction = exports.UserSelectMenuInteraction = exports.RoleSelectMenuInteraction = exports.MentionableSelectMenuInteraction = exports.ChannelSelectMenuInteraction = exports.StringSelectMenuInteraction = exports.SelectMenuInteraction = exports.ButtonInteraction = exports.ComponentInteraction = exports.EntryPointInteraction = exports.ApplicationCommandInteraction = exports.Interaction = exports.AutocompleteInteraction = exports.BaseInteraction = void 0;
|
|
10
10
|
const builders_1 = require("../builders");
|
|
11
|
+
const Label_1 = require("../builders/Label");
|
|
11
12
|
const transformers_1 = require("../client/transformers");
|
|
12
13
|
const common_1 = require("../common");
|
|
13
14
|
const mixer_1 = require("../deps/mixer");
|
|
@@ -65,9 +66,7 @@ class BaseInteraction extends DiscordBase_1.DiscordBase {
|
|
|
65
66
|
: {
|
|
66
67
|
...body.data,
|
|
67
68
|
components: body.data?.components
|
|
68
|
-
? body.data.components.map(x => x instanceof
|
|
69
|
-
? x.toJSON()
|
|
70
|
-
: x)
|
|
69
|
+
? body.data.components.map(x => (x instanceof Label_1.Label ? x.toJSON() : x))
|
|
71
70
|
: [],
|
|
72
71
|
},
|
|
73
72
|
};
|
|
@@ -520,11 +519,11 @@ let ModalSubmitInteraction = class ModalSubmitInteraction extends BaseInteractio
|
|
|
520
519
|
for (const { components } of this.components) {
|
|
521
520
|
const get = components.find(x => x.customId === customId);
|
|
522
521
|
if (get) {
|
|
523
|
-
value = get.value;
|
|
522
|
+
value = get.value ?? get.values;
|
|
524
523
|
break;
|
|
525
524
|
}
|
|
526
525
|
}
|
|
527
|
-
if (!value && required)
|
|
526
|
+
if ((!value || value.length === 0) && required)
|
|
528
527
|
throw new Error(`${customId} component doesn't have a value`);
|
|
529
528
|
return value;
|
|
530
529
|
}
|
package/lib/types/gateway.d.ts
CHANGED
|
@@ -18,7 +18,7 @@ export interface GatewayURLQuery {
|
|
|
18
18
|
*/
|
|
19
19
|
export type GatewaySendPayload = GatewayHeartbeat | GatewayIdentify | GatewayRequestGuildMembers | GatewayResume | GatewayUpdatePresence | GatewayVoiceStateUpdate | GatewayRequestSoundboardSounds;
|
|
20
20
|
export type GatewayReceivePayload = GatewayDispatchPayload | GatewayHeartbeatAck | GatewayHeartbeatRequest | GatewayHello | GatewayInvalidSession | GatewayReconnect;
|
|
21
|
-
export type GatewayDispatchPayload = GatewayApplicationCommandPermissionsUpdateDispatch | GatewayAutoModerationActionExecutionDispatch | GatewayAutoModerationRuleCreateDispatch | GatewayAutoModerationRuleDeleteDispatch | GatewayAutoModerationRuleModifyDispatch | GatewayChannelModifyDispatch | GatewayChannelPinsUpdateDispatch | GatewayEntitlementModifyDispatch | GatewayGuildAuditLogEntryCreateDispatch | GatewayGuildBanModifyDispatch | GatewayGuildCreateDispatch | GatewayRawGuildCreateDispatch | GatewayGuildDeleteDispatch | GatewayRawGuildDeleteDispatch | GatewayGuildsReadyDispatch | GatewayGuildEmojisUpdateDispatch | GatewayGuildIntegrationsUpdateDispatch | GatewayGuildMemberAddDispatch | GatewayGuildMemberRemoveDispatch | GatewayGuildMembersChunkDispatch | GatewayGuildMemberUpdateDispatch | GatewayGuildModifyDispatch | GatewayGuildRoleDeleteDispatch | GatewayGuildRoleModifyDispatch | GatewayGuildScheduledEventCreateDispatch | GatewayGuildScheduledEventDeleteDispatch | GatewayGuildScheduledEventUpdateDispatch | GatewayGuildScheduledEventUserAddDispatch | GatewayGuildScheduledEventUserRemoveDispatch | GatewayGuildStickersUpdateDispatch | GatewayIntegrationCreateDispatch | GatewayIntegrationDeleteDispatch | GatewayIntegrationUpdateDispatch | GatewayInteractionCreateDispatch | GatewayInviteCreateDispatch | GatewayInviteDeleteDispatch | GatewayMessageCreateDispatch | GatewayMessageDeleteBulkDispatch | GatewayMessageDeleteDispatch | GatewayMessagePollVoteAddDispatch | GatewayMessagePollVoteRemoveDispatch | GatewayMessageReactionAddDispatch | GatewayMessageReactionRemoveAllDispatch | GatewayMessageReactionRemoveDispatch | GatewayMessageReactionRemoveEmojiDispatch | GatewayMessageUpdateDispatch | GatewayPresenceUpdateDispatch | GatewayReadyDispatch | GatewayResumedDispatch | GatewayStageInstanceCreateDispatch | GatewayStageInstanceDeleteDispatch | GatewayStageInstanceUpdateDispatch | GatewayThreadCreateDispatch | GatewayThreadDeleteDispatch | GatewayThreadListSyncDispatch | GatewayThreadMembersUpdateDispatch | GatewayThreadMemberUpdateDispatch | GatewayThreadUpdateDispatch | GatewayTypingStartDispatch | GatewayUserUpdateDispatch | GatewayVoiceServerUpdateDispatch | GatewayVoiceStateUpdateDispatch | GatewayWebhooksUpdateDispatch | GatewayGuildSoundboardSoundCreateDispatch | GatewayGuildSoundboardSoundDeleteDispatch | GatewayGuildSoundboardSoundUpdateDispatch | GatewayGuildSoundboardSoundsUpdateDispatch | GatewaySoundboardSoundsDispatch;
|
|
21
|
+
export type GatewayDispatchPayload = GatewayApplicationCommandPermissionsUpdateDispatch | GatewayAutoModerationActionExecutionDispatch | GatewayAutoModerationRuleCreateDispatch | GatewayAutoModerationRuleDeleteDispatch | GatewayAutoModerationRuleModifyDispatch | GatewayChannelModifyDispatch | GatewayChannelPinsUpdateDispatch | GatewayEntitlementModifyDispatch | GatewayGuildAuditLogEntryCreateDispatch | GatewayGuildBanModifyDispatch | GatewayGuildCreateDispatch | GatewayRawGuildCreateDispatch | GatewayGuildDeleteDispatch | GatewayRawGuildDeleteDispatch | GatewayGuildsReadyDispatch | GatewayGuildEmojisUpdateDispatch | GatewayGuildIntegrationsUpdateDispatch | GatewayGuildMemberAddDispatch | GatewayGuildMemberRemoveDispatch | GatewayGuildMembersChunkDispatch | GatewayGuildMemberUpdateDispatch | GatewayGuildModifyDispatch | GatewayGuildRoleDeleteDispatch | GatewayGuildRoleModifyDispatch | GatewayGuildScheduledEventCreateDispatch | GatewayGuildScheduledEventDeleteDispatch | GatewayGuildScheduledEventUpdateDispatch | GatewayGuildScheduledEventUserAddDispatch | GatewayGuildScheduledEventUserRemoveDispatch | GatewayGuildStickersUpdateDispatch | GatewayIntegrationCreateDispatch | GatewayIntegrationDeleteDispatch | GatewayIntegrationUpdateDispatch | GatewayInteractionCreateDispatch | GatewayInviteCreateDispatch | GatewayInviteDeleteDispatch | GatewayMessageCreateDispatch | GatewayMessageDeleteBulkDispatch | GatewayMessageDeleteDispatch | GatewayMessagePollVoteAddDispatch | GatewayMessagePollVoteRemoveDispatch | GatewayMessageReactionAddDispatch | GatewayMessageReactionRemoveAllDispatch | GatewayMessageReactionRemoveDispatch | GatewayMessageReactionRemoveEmojiDispatch | GatewayMessageUpdateDispatch | GatewayPresenceUpdateDispatch | GatewayReadyDispatch | GatewayResumedDispatch | GatewayStageInstanceCreateDispatch | GatewayStageInstanceDeleteDispatch | GatewayStageInstanceUpdateDispatch | GatewayThreadCreateDispatch | GatewayThreadDeleteDispatch | GatewayThreadListSyncDispatch | GatewayThreadMembersUpdateDispatch | GatewayThreadMemberUpdateDispatch | GatewayThreadUpdateDispatch | GatewayTypingStartDispatch | GatewayUserUpdateDispatch | GatewayVoiceServerUpdateDispatch | GatewayVoiceStateUpdateDispatch | GatewayWebhooksUpdateDispatch | GatewayGuildSoundboardSoundCreateDispatch | GatewayGuildSoundboardSoundDeleteDispatch | GatewayGuildSoundboardSoundUpdateDispatch | GatewayGuildSoundboardSoundsUpdateDispatch | GatewaySoundboardSoundsDispatch | GatewayRateLimitedDispatch;
|
|
22
22
|
/**
|
|
23
23
|
* https://discord.com/developers/docs/topics/gateway-events#hello
|
|
24
24
|
*/
|
|
@@ -67,6 +67,37 @@ export interface GatewayReconnect extends NonDispatchPayload {
|
|
|
67
67
|
op: GatewayOpcodes.Reconnect;
|
|
68
68
|
d: never;
|
|
69
69
|
}
|
|
70
|
+
/**
|
|
71
|
+
* https://discord.com/developers/docs/events/gateway-events#rate-limited
|
|
72
|
+
*/
|
|
73
|
+
export type GatewayRateLimitedDispatch = DataPayload<GatewayDispatchEvents.RateLimited, GatewayRateLimitedDispatchData>;
|
|
74
|
+
export interface GatewayRateLimitedDispatchData {
|
|
75
|
+
/**
|
|
76
|
+
* Gateway opcode of the event that was rate limited (for now only GuildMembersChunk)
|
|
77
|
+
*/
|
|
78
|
+
opcode: Extract<GatewayOpcodes, GatewayOpcodes.RequestGuildMembers>;
|
|
79
|
+
/**
|
|
80
|
+
* The number of seconds to wait before submitting another request
|
|
81
|
+
*/
|
|
82
|
+
retry_after: number;
|
|
83
|
+
/**
|
|
84
|
+
* Metadata for the event that was rate limited
|
|
85
|
+
*/
|
|
86
|
+
metadata: GatewayRateLimitedMetadata;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* https://discord.com/developers/docs/events/gateway-events#rate-limited-request-guild-member-rate-limit-metadata-structure
|
|
90
|
+
*/
|
|
91
|
+
export interface GatewayRateLimitedMetadata {
|
|
92
|
+
/**
|
|
93
|
+
* ID of the guild to get members for
|
|
94
|
+
*/
|
|
95
|
+
guild_id: Snowflake;
|
|
96
|
+
/**
|
|
97
|
+
* nonce to identify the Guild Members Chunk response
|
|
98
|
+
*/
|
|
99
|
+
nonce?: string;
|
|
100
|
+
}
|
|
70
101
|
/**
|
|
71
102
|
* https://discord.com/developers/docs/topics/gateway-events#ready
|
|
72
103
|
*/
|
|
@@ -2,7 +2,8 @@ import type { APIActionRowComponent, APIBaseInteraction, APIDMInteractionWrapper
|
|
|
2
2
|
export interface ModalSubmitComponent {
|
|
3
3
|
type: ComponentType;
|
|
4
4
|
custom_id: string;
|
|
5
|
-
value
|
|
5
|
+
value?: string;
|
|
6
|
+
values?: string[];
|
|
6
7
|
}
|
|
7
8
|
export interface ModalSubmitActionRowComponent extends Omit<APIActionRowComponent<APIModalActionRowComponent>, 'components'> {
|
|
8
9
|
components: ModalSubmitComponent[];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { MakeRequired } from '../../../common';
|
|
2
2
|
import type { RESTPostAPIWebhookWithTokenJSONBody } from '../../index';
|
|
3
|
-
import type {
|
|
3
|
+
import type { APILabelComponent, MessageFlags } from '../index';
|
|
4
4
|
import type { APIApplicationCommandOptionChoice } from './applicationCommands';
|
|
5
5
|
/**
|
|
6
6
|
* https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object-interaction-type
|
|
@@ -104,7 +104,7 @@ export interface APIModalInteractionResponseCallbackData {
|
|
|
104
104
|
/**
|
|
105
105
|
* Between 1 and 5 (inclusive) components that make up the modal
|
|
106
106
|
*/
|
|
107
|
-
components:
|
|
107
|
+
components: APILabelComponent[];
|
|
108
108
|
}
|
|
109
109
|
/**
|
|
110
110
|
* https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-callback-interaction-callback-object
|
|
@@ -73,7 +73,11 @@ export declare enum ComponentType {
|
|
|
73
73
|
/**
|
|
74
74
|
* Container component
|
|
75
75
|
*/
|
|
76
|
-
Container = 17
|
|
76
|
+
Container = 17,
|
|
77
|
+
/**
|
|
78
|
+
* Label component
|
|
79
|
+
*/
|
|
80
|
+
Label = 18
|
|
77
81
|
}
|
|
78
82
|
/**
|
|
79
83
|
* https://discord.com/developers/docs/interactions/message-components#action-rows
|
|
@@ -201,6 +205,12 @@ export interface APIStringSelectComponent extends APIBaseSelectMenuComponent<Com
|
|
|
201
205
|
* Specified choices in a select menu; max 25
|
|
202
206
|
*/
|
|
203
207
|
options: APISelectMenuOption[];
|
|
208
|
+
/**
|
|
209
|
+
* Whether the string select is required to answer in a modal
|
|
210
|
+
*
|
|
211
|
+
* @default true
|
|
212
|
+
*/
|
|
213
|
+
required?: boolean;
|
|
204
214
|
}
|
|
205
215
|
/**
|
|
206
216
|
* https://discord.com/developers/docs/interactions/message-components#select-menus
|
|
@@ -481,9 +491,24 @@ export interface APIContainerComponent {
|
|
|
481
491
|
/** Whether the container should be a spoiler (or blurred out). Defaults to false. */
|
|
482
492
|
spoiler?: boolean;
|
|
483
493
|
}
|
|
494
|
+
/**
|
|
495
|
+
* https://discord.com/developers/docs/components/reference#label
|
|
496
|
+
*/
|
|
497
|
+
export interface APILabelComponent {
|
|
498
|
+
/** 18 for label */
|
|
499
|
+
type: ComponentType.Label;
|
|
500
|
+
/** Optional identifier for component */
|
|
501
|
+
id?: string;
|
|
502
|
+
/** The label text */
|
|
503
|
+
label: string;
|
|
504
|
+
/** An optional description textfor the label */
|
|
505
|
+
description?: string;
|
|
506
|
+
/** The component within the label */
|
|
507
|
+
component: APITextInputComponent | APIStringSelectComponent;
|
|
508
|
+
}
|
|
484
509
|
/**
|
|
485
510
|
* https://discord.com/developers/docs/components/reference#unfurled-media-item-structure
|
|
486
511
|
*/
|
|
487
512
|
export interface APIUnfurledMediaItem extends Identify<MakeRequired<Partial<Pick<APIAttachment, 'url' | 'proxy_url' | 'height' | 'width' | 'content_type'>>, 'url'>> {
|
|
488
513
|
}
|
|
489
|
-
export type APITopLevelComponent = APIContainerComponent | APIActionRowComponent<APIActionRowComponentTypes> | APIFileComponent | APIMediaGalleryComponent | APISectionComponent | APISeparatorComponent | APITextDisplayComponent;
|
|
514
|
+
export type APITopLevelComponent = APIContainerComponent | APIActionRowComponent<APIActionRowComponentTypes> | APIFileComponent | APIMediaGalleryComponent | APISectionComponent | APISeparatorComponent | APITextDisplayComponent | APILabelComponent;
|
|
@@ -66,6 +66,10 @@ var ComponentType;
|
|
|
66
66
|
* Container component
|
|
67
67
|
*/
|
|
68
68
|
ComponentType[ComponentType["Container"] = 17] = "Container";
|
|
69
|
+
/**
|
|
70
|
+
* Label component
|
|
71
|
+
*/
|
|
72
|
+
ComponentType[ComponentType["Label"] = 18] = "Label";
|
|
69
73
|
})(ComponentType || (exports.ComponentType = ComponentType = {}));
|
|
70
74
|
/**
|
|
71
75
|
* https://discord.com/developers/docs/interactions/message-components#button-object-button-styles
|
|
@@ -345,6 +345,7 @@ export declare enum GatewayDispatchEvents {
|
|
|
345
345
|
SubscriptionDelete = "SUBSCRIPTION_DELETE",
|
|
346
346
|
Ready = "READY",
|
|
347
347
|
Resumed = "RESUMED",
|
|
348
|
+
RateLimited = "RATE_LIMITED",
|
|
348
349
|
ThreadCreate = "THREAD_CREATE",
|
|
349
350
|
ThreadDelete = "THREAD_DELETE",
|
|
350
351
|
ThreadListSync = "THREAD_LIST_SYNC",
|
package/lib/types/utils/index.js
CHANGED
|
@@ -330,6 +330,7 @@ var GatewayDispatchEvents;
|
|
|
330
330
|
GatewayDispatchEvents["SubscriptionDelete"] = "SUBSCRIPTION_DELETE";
|
|
331
331
|
GatewayDispatchEvents["Ready"] = "READY";
|
|
332
332
|
GatewayDispatchEvents["Resumed"] = "RESUMED";
|
|
333
|
+
GatewayDispatchEvents["RateLimited"] = "RATE_LIMITED";
|
|
333
334
|
GatewayDispatchEvents["ThreadCreate"] = "THREAD_CREATE";
|
|
334
335
|
GatewayDispatchEvents["ThreadDelete"] = "THREAD_DELETE";
|
|
335
336
|
GatewayDispatchEvents["ThreadListSync"] = "THREAD_LIST_SYNC";
|
|
@@ -274,6 +274,37 @@ class Shard {
|
|
|
274
274
|
this.options.handlePayload(this.id, packet);
|
|
275
275
|
}
|
|
276
276
|
break;
|
|
277
|
+
case types_1.GatewayDispatchEvents.RateLimited:
|
|
278
|
+
{
|
|
279
|
+
switch (packet.d.opcode) {
|
|
280
|
+
case types_1.GatewayOpcodes.RequestGuildMembers:
|
|
281
|
+
{
|
|
282
|
+
const { retry_after, metadata } = packet.d;
|
|
283
|
+
const nonce = metadata.nonce;
|
|
284
|
+
if (!nonce) {
|
|
285
|
+
this.options.handlePayload(this.id, packet);
|
|
286
|
+
return;
|
|
287
|
+
}
|
|
288
|
+
if (!this.requestGuildMembersChunk.has(nonce)) {
|
|
289
|
+
this.options.handlePayload(this.id, packet);
|
|
290
|
+
return;
|
|
291
|
+
}
|
|
292
|
+
const guildMemberChunk = this.requestGuildMembersChunk.get(nonce);
|
|
293
|
+
void (0, common_1.delay)((retry_after + 0.5) * 1e3).then(() => {
|
|
294
|
+
this.send(false, {
|
|
295
|
+
op: types_1.GatewayOpcodes.RequestGuildMembers,
|
|
296
|
+
d: {
|
|
297
|
+
...guildMemberChunk.options,
|
|
298
|
+
nonce,
|
|
299
|
+
},
|
|
300
|
+
});
|
|
301
|
+
});
|
|
302
|
+
}
|
|
303
|
+
break;
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
this.options.handlePayload(this.id, packet);
|
|
307
|
+
break;
|
|
277
308
|
default:
|
|
278
309
|
this.options.handlePayload(this.id, packet);
|
|
279
310
|
break;
|
|
@@ -299,6 +330,7 @@ class Shard {
|
|
|
299
330
|
presences: [],
|
|
300
331
|
reject,
|
|
301
332
|
resolve,
|
|
333
|
+
options,
|
|
302
334
|
});
|
|
303
335
|
this.send(false, {
|
|
304
336
|
op: types_1.GatewayOpcodes.RequestGuildMembers,
|