types(Builder.from): fix wrong types (#10071)

* types(Builder.from): fix wrong types

* test: add tests

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
This commit is contained in:
Synbulat Biishev
2024-02-23 14:54:41 +03:00
committed by GitHub
parent c8bbdb70f2
commit bfbd62e3e0
2 changed files with 56 additions and 10 deletions

View File

@@ -777,7 +777,9 @@ export class StringSelectMenuBuilder extends BuilderStringSelectMenuComponent {
public override setOptions(
...options: RestOrArray<BuildersSelectMenuOption | SelectMenuComponentOptionData | APISelectMenuOption>
): this;
public static from(other: JSONEncodable<APISelectMenuComponent> | APISelectMenuComponent): StringSelectMenuBuilder;
public static from(
other: JSONEncodable<APIStringSelectComponent> | APIStringSelectComponent,
): StringSelectMenuBuilder;
}
export {
@@ -789,24 +791,26 @@ export {
export class UserSelectMenuBuilder extends BuilderUserSelectMenuComponent {
public constructor(data?: Partial<UserSelectMenuComponentData | APIUserSelectComponent>);
public static from(other: JSONEncodable<APISelectMenuComponent> | APISelectMenuComponent): UserSelectMenuBuilder;
public static from(other: JSONEncodable<APIUserSelectComponent> | APIUserSelectComponent): UserSelectMenuBuilder;
}
export class RoleSelectMenuBuilder extends BuilderRoleSelectMenuComponent {
public constructor(data?: Partial<RoleSelectMenuComponentData | APIRoleSelectComponent>);
public static from(other: JSONEncodable<APISelectMenuComponent> | APISelectMenuComponent): RoleSelectMenuBuilder;
public static from(other: JSONEncodable<APIRoleSelectComponent> | APIRoleSelectComponent): RoleSelectMenuBuilder;
}
export class MentionableSelectMenuBuilder extends BuilderMentionableSelectMenuComponent {
public constructor(data?: Partial<MentionableSelectMenuComponentData | APIMentionableSelectComponent>);
public static from(
other: JSONEncodable<APISelectMenuComponent> | APISelectMenuComponent,
other: JSONEncodable<APIMentionableSelectComponent> | APIMentionableSelectComponent,
): MentionableSelectMenuBuilder;
}
export class ChannelSelectMenuBuilder extends BuilderChannelSelectMenuComponent {
public constructor(data?: Partial<ChannelSelectMenuComponentData | APIChannelSelectComponent>);
public static from(other: JSONEncodable<APISelectMenuComponent> | APISelectMenuComponent): ChannelSelectMenuBuilder;
public static from(
other: JSONEncodable<APIChannelSelectComponent> | APIChannelSelectComponent,
): ChannelSelectMenuBuilder;
}
export class StringSelectMenuOptionBuilder extends BuildersSelectMenuOption {
@@ -817,7 +821,9 @@ export class StringSelectMenuOptionBuilder extends BuildersSelectMenuOption {
export class ModalBuilder extends BuildersModal {
public constructor(data?: Partial<ModalComponentData> | Partial<APIModalInteractionResponseCallbackData>);
public static from(other: JSONEncodable<APIModalComponent> | APIModalComponent): ModalBuilder;
public static from(
other: JSONEncodable<APIModalInteractionResponseCallbackData> | APIModalInteractionResponseCallbackData,
): ModalBuilder;
}
export class TextInputBuilder extends BuilderTextInputComponent {

View File

@@ -27,6 +27,11 @@ import {
APIActionRowComponent,
APIActionRowComponentTypes,
APIStringSelectComponent,
APIUserSelectComponent,
APIRoleSelectComponent,
APIChannelSelectComponent,
APIMentionableSelectComponent,
APIModalInteractionResponseCallbackData,
} from 'discord-api-types/v10';
import {
ApplicationCommand,
@@ -190,6 +195,14 @@ import {
DirectoryChannel,
Entitlement,
SKU,
UserSelectMenuBuilder,
RoleSelectMenuBuilder,
ChannelSelectMenuBuilder,
MentionableSelectMenuBuilder,
UserSelectMenuComponent,
RoleSelectMenuComponent,
ChannelSelectMenuComponent,
MentionableSelectMenuComponent,
} from '.';
import { expectAssignable, expectNotAssignable, expectNotType, expectType } from 'tsd';
import type { ContextMenuCommandBuilder, SlashCommandBuilder } from '@discordjs/builders';
@@ -2245,11 +2258,35 @@ chatInputInteraction.showModal({
],
});
declare const selectMenuData: APISelectMenuComponent;
StringSelectMenuBuilder.from(selectMenuData);
declare const stringSelectMenuData: APIStringSelectComponent;
StringSelectMenuBuilder.from(stringSelectMenuData);
declare const selectMenuComp: SelectMenuComponent;
StringSelectMenuBuilder.from(selectMenuComp);
declare const userSelectMenuData: APIUserSelectComponent;
UserSelectMenuBuilder.from(userSelectMenuData);
declare const roleSelectMenuData: APIRoleSelectComponent;
RoleSelectMenuBuilder.from(roleSelectMenuData);
declare const channelSelectMenuData: APIChannelSelectComponent;
ChannelSelectMenuBuilder.from(channelSelectMenuData);
declare const mentionableSelectMenuData: APIMentionableSelectComponent;
MentionableSelectMenuBuilder.from(mentionableSelectMenuData);
declare const stringSelectMenuComp: StringSelectMenuComponent;
StringSelectMenuBuilder.from(stringSelectMenuComp);
declare const userSelectMenuComp: UserSelectMenuComponent;
UserSelectMenuBuilder.from(userSelectMenuComp);
declare const roleSelectMenuComp: RoleSelectMenuComponent;
RoleSelectMenuBuilder.from(roleSelectMenuComp);
declare const channelSelectMenuComp: ChannelSelectMenuComponent;
ChannelSelectMenuBuilder.from(channelSelectMenuComp);
declare const mentionableSelectMenuComp: MentionableSelectMenuComponent;
MentionableSelectMenuBuilder.from(mentionableSelectMenuComp);
declare const buttonData: APIButtonComponent;
ButtonBuilder.from(buttonData);
@@ -2257,6 +2294,9 @@ ButtonBuilder.from(buttonData);
declare const buttonComp: ButtonComponent;
ButtonBuilder.from(buttonComp);
declare const modalData: APIModalInteractionResponseCallbackData;
ModalBuilder.from(modalData);
declare const textInputData: APITextInputComponent;
TextInputBuilder.from(textInputData);