Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

types(SelectMenu): allow default values for automatically populated menus #111

Merged
merged 1 commit into from
Sep 25, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,9 @@ declare namespace Dysnomia {
type MessageContent = string | AdvancedMessageContent;
type MFALevel = Constants["MFALevels"][keyof Constants["MFALevels"]];
type PossiblyUncachedMessage = Message | { author?: User | Uncached; channel: TextableChannel | { id: string; guild?: Uncached }; guildID?: string; id: string };
type SelectMenu = BaseSelectMenu | ChannelSelectMenu | StringSelectMenu;
type SelectMenu = BaseSelectMenu | ChannelSelectMenu | StringSelectMenu | UserSelectMenu | RoleSelectMenu | MentionableSelectMenu;
type SelectMenuTypes = Constants["ComponentTypes"][keyof Pick<Constants["ComponentTypes"], "STRING_SELECT" | "USER_SELECT" | "ROLE_SELECT" | "MENTIONABLE_SELECT" | "CHANNEL_SELECT">];
type SelectMenuExtendedTypes = Constants["ComponentTypes"][keyof Pick<Constants["ComponentTypes"], "STRING_SELECT" | "CHANNEL_SELECT">];
type SelectMenuExtendedTypes = Constants["ComponentTypes"][keyof Pick<Constants["ComponentTypes"], "STRING_SELECT" | "CHANNEL_SELECT" | "ROLE_SELECT" | "USER_SELECT" | "MENTIONABLE_SELECT">];


// Permission
Expand Down Expand Up @@ -1364,6 +1364,7 @@ declare namespace Dysnomia {
}
interface ChannelSelectMenu extends SelectMenuBase {
channel_types?: GuildChannelTypes[];
default_values?: SelectMenuDefaultValue<"channel">[];
type: Constants["ComponentTypes"]["CHANNEL_SELECT"];
}
interface CreateStickerOptions extends Required<Pick<EditStickerOptions, "name" | "tags" | "description">> {
Expand All @@ -1380,6 +1381,18 @@ declare namespace Dysnomia {
name?: string;
tags?: string;
}
interface MentionableSelectMenu extends SelectMenuBase {
default_values?: SelectMenuDefaultValue<"any">[];
type: Constants["ComponentTypes"]["MENTIONABLE_SELECT"];
}
interface RoleSelectMenu extends SelectMenuBase {
default_values?: SelectMenuDefaultValue<"role">[];
type: Constants["ComponentTypes"]["ROLE_SELECT"];
}
interface UserSelectMenu extends SelectMenuBase {
default_values?: SelectMenuDefaultValue<"user">[];
type: Constants["ComponentTypes"]["USER_SELECT"];
}
interface BaseSelectMenu extends SelectMenuBase {
type: BaseSelectMenuTypes;
}
Expand All @@ -1395,6 +1408,10 @@ declare namespace Dysnomia {
options: SelectMenuOptions[];
type: Constants["ComponentTypes"]["STRING_SELECT"];
}
interface SelectMenuDefaultValue<Type extends ("any" | "user" | "role" | "channel") = "any"> {
id: string;
type: Type extends "any" ? ("user" | "role" | "channel") : Type;
}
interface SelectMenuOptions {
default?: boolean;
description?: string;
Expand Down