fix: dont use ToClass

This commit is contained in:
MARCROCK22 2024-10-27 04:39:31 +00:00
parent c6a2b955b1
commit 537631d488

View File

@ -1,11 +1,10 @@
import type { EmojiResolvable, RestOrArray, ToClass } from '../common'; import type { EmojiResolvable, RestOrArray } from '../common';
import { resolvePartialEmoji } from '../common/it/utils'; import { resolvePartialEmoji } from '../common/it/utils';
import type { import type {
ChannelSelectMenuInteraction, ChannelSelectMenuInteraction,
ComponentInteraction, ComponentInteraction,
MentionableSelectMenuInteraction, MentionableSelectMenuInteraction,
RoleSelectMenuInteraction, RoleSelectMenuInteraction,
StringSelectMenuInteraction,
UserSelectMenuInteraction, UserSelectMenuInteraction,
} from '../structures'; } from '../structures';
import { import {
@ -53,9 +52,6 @@ function mappedDefault<T extends SelectMenuDefaultValueType>(
* const selectMenu = new SelectMenu<APIUserSelectComponent, UserSelectMenuInteraction>(); * const selectMenu = new SelectMenu<APIUserSelectComponent, UserSelectMenuInteraction>();
* selectMenu.setCustomId("user-select-menu"); * selectMenu.setCustomId("user-select-menu");
* selectMenu.setPlaceholder("Select a user"); * selectMenu.setPlaceholder("Select a user");
* selectMenu.run((interaction) => {
* // Handle select menu interaction
* });
*/ */
export class SelectMenu< export class SelectMenu<
Select extends APISelectMenuComponent = APISelectMenuComponent, Select extends APISelectMenuComponent = APISelectMenuComponent,
@ -273,14 +269,12 @@ export class ChannelSelectMenu extends SelectMenu<APIChannelSelectComponent, Cha
* { label: "Option 3", value: "option_3" }, * { label: "Option 3", value: "option_3" },
* ]); * ]);
*/ */
export class StringSelectMenu extends (SelectMenu as unknown as ToClass< export class StringSelectMenu extends SelectMenu {
Omit<SelectMenu<APIStringSelectComponent, StringSelectMenuInteraction>, 'data' | 'toJSON'>, //@ts-expect-error
StringSelectMenu
>) {
declare data: Omit<APIStringSelectComponent, 'options'> & { options: StringSelectOption[] }; declare data: Omit<APIStringSelectComponent, 'options'> & { options: StringSelectOption[] };
constructor(data: Partial<APIStringSelectComponent> = {}) { constructor(data: Partial<APIStringSelectComponent> = {}) {
super({ ...data, type: ComponentType.StringSelect }); super({ ...data, type: ComponentType.StringSelect });
this.data.options = (data.options ?? []).map(x => new StringSelectOption(x)); this.data.options = data.options?.map(x => new StringSelectOption(x)) ?? [];
} }
/** /**
@ -307,7 +301,7 @@ export class StringSelectMenu extends (SelectMenu as unknown as ToClass<
const { options, ...raw } = this.data; const { options, ...raw } = this.data;
return { return {
...raw, ...raw,
options: this.data.options.map(x => x.toJSON()), options: options.map(x => x.toJSON()),
}; };
} }
} }