@impulsedev/chameleon 3.3.0 → 3.6.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/README.md +1 -1
- package/dist/{builders-WHD6LQWX.js → builders-X4JJZ6M2.js} +1 -1
- package/dist/{chunk-G4SUOXGV.js → chunk-SEC6DGVP.js} +13 -1
- package/dist/index.d.ts +574 -151
- package/dist/index.js +953 -281
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -608,6 +608,18 @@ declare const ComponentType: {
|
|
|
608
608
|
readonly ROLE_SELECT: 6;
|
|
609
609
|
readonly MENTIONABLE_SELECT: 7;
|
|
610
610
|
readonly CHANNEL_SELECT: 8;
|
|
611
|
+
readonly SECTION: 9;
|
|
612
|
+
readonly TEXT_DISPLAY: 10;
|
|
613
|
+
readonly THUMBNAIL: 11;
|
|
614
|
+
readonly MEDIA_GALLERY: 12;
|
|
615
|
+
readonly FILE: 13;
|
|
616
|
+
readonly SEPARATOR: 14;
|
|
617
|
+
readonly CONTAINER: 17;
|
|
618
|
+
readonly LABEL: 18;
|
|
619
|
+
readonly FILE_UPLOAD: 19;
|
|
620
|
+
readonly RADIO_GROUP: 21;
|
|
621
|
+
readonly CHECKBOX_GROUP: 22;
|
|
622
|
+
readonly CHECKBOX: 23;
|
|
611
623
|
};
|
|
612
624
|
declare const ButtonStyle: {
|
|
613
625
|
readonly PRIMARY: 1;
|
|
@@ -639,6 +651,15 @@ interface MessageComponent {
|
|
|
639
651
|
components?: MessageComponent[];
|
|
640
652
|
skuId?: string;
|
|
641
653
|
channelTypes?: number[];
|
|
654
|
+
content?: string;
|
|
655
|
+
media?: {
|
|
656
|
+
url: string;
|
|
657
|
+
};
|
|
658
|
+
accessory?: MessageComponent;
|
|
659
|
+
description?: string;
|
|
660
|
+
spoiler?: boolean;
|
|
661
|
+
spacing?: number;
|
|
662
|
+
divider?: boolean;
|
|
642
663
|
}
|
|
643
664
|
|
|
644
665
|
declare const EntitlementType: {
|
|
@@ -1669,6 +1690,7 @@ type ChameleonAPIResult<T> = {
|
|
|
1669
1690
|
ok: false;
|
|
1670
1691
|
status: number;
|
|
1671
1692
|
code?: number;
|
|
1693
|
+
error: string;
|
|
1672
1694
|
message: string;
|
|
1673
1695
|
raw?: unknown;
|
|
1674
1696
|
};
|
|
@@ -1814,48 +1836,46 @@ declare class ChameleonGateway {
|
|
|
1814
1836
|
private clearReconnectTimer;
|
|
1815
1837
|
}
|
|
1816
1838
|
|
|
1817
|
-
type OptionType = 'string' | 'integer' | 'boolean' | 'user' | 'channel' | 'role' | 'number';
|
|
1839
|
+
type OptionType = 'string' | 'integer' | 'boolean' | 'user' | 'channel' | 'role' | 'mentionable' | 'number' | 'attachment';
|
|
1840
|
+
type ChoiceValue = string | number;
|
|
1841
|
+
interface ChoiceDef<V extends ChoiceValue = ChoiceValue> {
|
|
1842
|
+
name: string;
|
|
1843
|
+
value: V;
|
|
1844
|
+
}
|
|
1818
1845
|
interface OptionDef<T extends OptionType, R extends boolean> {
|
|
1819
1846
|
type: T;
|
|
1820
1847
|
description: string;
|
|
1821
1848
|
required: R;
|
|
1822
1849
|
min?: number;
|
|
1823
1850
|
max?: number;
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1851
|
+
minLength?: number;
|
|
1852
|
+
maxLength?: number;
|
|
1853
|
+
choices?: readonly ChoiceDef[];
|
|
1854
|
+
channelTypes?: number[];
|
|
1828
1855
|
}
|
|
1829
|
-
type ResolveOptionType<T extends OptionType> = T extends 'string' ? string : T extends 'integer' | 'number' ? number : T extends 'boolean' ? boolean : T extends 'user' ? User : T extends 'channel' ? Channel : T extends 'role' ? Role : never;
|
|
1856
|
+
type ResolveOptionType<T extends OptionType> = T extends 'string' ? string : T extends 'integer' | 'number' ? number : T extends 'boolean' ? boolean : T extends 'user' ? User : T extends 'channel' ? Channel : T extends 'role' ? Role : T extends 'mentionable' ? User | Role : T extends 'attachment' ? Attachment : never;
|
|
1830
1857
|
type ResolveOption<O extends OptionDef<OptionType, boolean>> = O['required'] extends true ? ResolveOptionType<O['type']> : ResolveOptionType<O['type']> | undefined;
|
|
1831
1858
|
type ResolveOptions<O extends Record<string, OptionDef<OptionType, boolean>>> = {
|
|
1832
1859
|
[K in keyof O]: ResolveOption<O[K]>;
|
|
1833
1860
|
};
|
|
1861
|
+
declare function choice<V extends ChoiceValue>(name: string, value: V): ChoiceDef<V>;
|
|
1862
|
+
declare function choices<const T extends readonly ChoiceDef[]>(...items: T): T;
|
|
1834
1863
|
declare const opt: {
|
|
1835
1864
|
string: <R extends boolean = false>(description: string, options?: {
|
|
1836
1865
|
required?: R;
|
|
1837
|
-
choices?:
|
|
1838
|
-
name: string;
|
|
1839
|
-
value: string;
|
|
1840
|
-
}[];
|
|
1866
|
+
choices?: readonly ChoiceDef<string>[];
|
|
1841
1867
|
minLength?: number;
|
|
1842
1868
|
maxLength?: number;
|
|
1843
1869
|
}) => OptionDef<"string", R>;
|
|
1844
1870
|
integer: <R extends boolean = false>(description: string, options?: {
|
|
1845
1871
|
required?: R;
|
|
1846
|
-
choices?:
|
|
1847
|
-
name: string;
|
|
1848
|
-
value: number;
|
|
1849
|
-
}[];
|
|
1872
|
+
choices?: readonly ChoiceDef<number>[];
|
|
1850
1873
|
min?: number;
|
|
1851
1874
|
max?: number;
|
|
1852
1875
|
}) => OptionDef<"integer", R>;
|
|
1853
1876
|
number: <R extends boolean = false>(description: string, options?: {
|
|
1854
1877
|
required?: R;
|
|
1855
|
-
choices?:
|
|
1856
|
-
name: string;
|
|
1857
|
-
value: number;
|
|
1858
|
-
}[];
|
|
1878
|
+
choices?: readonly ChoiceDef<number>[];
|
|
1859
1879
|
min?: number;
|
|
1860
1880
|
max?: number;
|
|
1861
1881
|
}) => OptionDef<"number", R>;
|
|
@@ -1867,80 +1887,36 @@ declare const opt: {
|
|
|
1867
1887
|
}) => OptionDef<"user", R>;
|
|
1868
1888
|
channel: <R extends boolean = false>(description: string, options?: {
|
|
1869
1889
|
required?: R;
|
|
1890
|
+
channelTypes?: number[];
|
|
1870
1891
|
}) => OptionDef<"channel", R>;
|
|
1871
1892
|
role: <R extends boolean = false>(description: string, options?: {
|
|
1872
1893
|
required?: R;
|
|
1873
1894
|
}) => OptionDef<"role", R>;
|
|
1895
|
+
mentionable: <R extends boolean = false>(description: string, options?: {
|
|
1896
|
+
required?: R;
|
|
1897
|
+
}) => OptionDef<"mentionable", R>;
|
|
1898
|
+
attachment: <R extends boolean = false>(description: string, options?: {
|
|
1899
|
+
required?: R;
|
|
1900
|
+
}) => OptionDef<"attachment", R>;
|
|
1874
1901
|
};
|
|
1875
1902
|
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
components?: (MessageComponent | {
|
|
1882
|
-
build?(): MessageComponent;
|
|
1883
|
-
} | {
|
|
1884
|
-
toJSON(): Record<string, unknown>;
|
|
1885
|
-
} | Record<string, unknown>)[];
|
|
1886
|
-
ephemeral?: boolean;
|
|
1887
|
-
};
|
|
1888
|
-
declare class BaseInteractionContext {
|
|
1889
|
-
user: User;
|
|
1890
|
-
guild?: Guild | {
|
|
1891
|
-
id: string;
|
|
1892
|
-
} | undefined;
|
|
1893
|
-
channel?: Channel | {
|
|
1894
|
-
id: string;
|
|
1895
|
-
} | undefined;
|
|
1896
|
-
interactionId: string;
|
|
1897
|
-
interactionToken: string;
|
|
1898
|
-
protected _client: Client;
|
|
1899
|
-
protected _deferred: boolean;
|
|
1900
|
-
protected _replied: boolean;
|
|
1903
|
+
declare class ComponentContext<Values = unknown, Fields = unknown> extends BaseInteractionContext {
|
|
1904
|
+
customId: string;
|
|
1905
|
+
message?: Record<string, unknown>;
|
|
1906
|
+
values: Values;
|
|
1907
|
+
fields: Fields;
|
|
1901
1908
|
constructor(client: Client, raw: Record<string, unknown>, user: User, guild?: Guild | {
|
|
1902
1909
|
id: string;
|
|
1903
1910
|
}, channel?: Channel | {
|
|
1904
1911
|
id: string;
|
|
1905
1912
|
});
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
protected _resolvePayload(payload: InteractionReplyOptions): Record<string, unknown>;
|
|
1909
|
-
reply(payload: InteractionReplyOptions): Promise<void>;
|
|
1910
|
-
defer(options?: {
|
|
1911
|
-
ephemeral?: boolean;
|
|
1912
|
-
}): Promise<void>;
|
|
1913
|
-
followUp(payload: InteractionReplyOptions): Promise<void>;
|
|
1914
|
-
showModal(modal: Record<string, unknown>): Promise<void>;
|
|
1915
|
-
}
|
|
1916
|
-
declare class CommandContext<Options = Record<string, unknown>> extends BaseInteractionContext {
|
|
1917
|
-
options: Options;
|
|
1918
|
-
constructor(client: Client, rawInteraction: Record<string, unknown>, parsedOptions: Options, user: User, guild?: Guild | {
|
|
1919
|
-
id: string;
|
|
1920
|
-
}, channel?: Channel | {
|
|
1921
|
-
id: string;
|
|
1922
|
-
});
|
|
1923
|
-
}
|
|
1924
|
-
|
|
1925
|
-
type ExecuteFunction<O extends Record<string, OptionDef<OptionType, boolean>>> = (ctx: CommandContext<ResolveOptions<O>>) => void | Promise<void>;
|
|
1926
|
-
interface Subcommand<O extends Record<string, OptionDef<OptionType, boolean>> = Record<string, never>> {
|
|
1927
|
-
description: string;
|
|
1928
|
-
options?: O;
|
|
1929
|
-
execute: ExecuteFunction<O>;
|
|
1913
|
+
deferUpdate(): Promise<void>;
|
|
1914
|
+
update(payload: InteractionReplyOptions): Promise<void>;
|
|
1930
1915
|
}
|
|
1931
|
-
declare function defineSubcommand<O extends Record<string, OptionDef<OptionType, boolean>>>(def: Subcommand<O>): Subcommand<O>;
|
|
1932
|
-
type CommandDef<O extends Record<string, OptionDef<OptionType, boolean>> = Record<string, never>, S extends Record<string, Subcommand<Record<string, OptionDef<OptionType, boolean>>>> = Record<string, never>> = {
|
|
1933
|
-
name: string;
|
|
1934
|
-
description: string;
|
|
1935
|
-
options?: O;
|
|
1936
|
-
subcommands?: S;
|
|
1937
|
-
execute?: ExecuteFunction<O>;
|
|
1938
|
-
};
|
|
1939
|
-
type AnyCommandDef = CommandDef<Record<string, OptionDef<OptionType, boolean>>, Record<string, Subcommand<Record<string, OptionDef<OptionType, boolean>>>>>;
|
|
1940
|
-
declare function defineCommand<O extends Record<string, OptionDef<OptionType, boolean>>, S extends Record<string, Subcommand<Record<string, OptionDef<OptionType, boolean>>>>>(def: CommandDef<O, S>): CommandDef<O, S>;
|
|
1941
1916
|
|
|
1942
|
-
declare class ModalContext extends BaseInteractionContext {
|
|
1917
|
+
declare class ModalContext<Fields = Record<string, unknown>> extends BaseInteractionContext {
|
|
1943
1918
|
customId: string;
|
|
1919
|
+
attachments: Record<string, Attachment[]>;
|
|
1944
1920
|
private _fields;
|
|
1945
1921
|
constructor(client: Client, raw: Record<string, unknown>, user: User, guild?: Guild | {
|
|
1946
1922
|
id: string;
|
|
@@ -1948,48 +1924,7 @@ declare class ModalContext extends BaseInteractionContext {
|
|
|
1948
1924
|
id: string;
|
|
1949
1925
|
});
|
|
1950
1926
|
get values(): string[];
|
|
1951
|
-
get fields():
|
|
1952
|
-
}
|
|
1953
|
-
|
|
1954
|
-
declare class ComponentContext<Values = unknown, Fields = unknown> extends BaseInteractionContext {
|
|
1955
|
-
customId: string;
|
|
1956
|
-
message?: Record<string, unknown>;
|
|
1957
|
-
values: Values;
|
|
1958
|
-
fields: Fields;
|
|
1959
|
-
constructor(client: Client, raw: Record<string, unknown>, user: User, guild?: Guild | {
|
|
1960
|
-
id: string;
|
|
1961
|
-
}, channel?: Channel | {
|
|
1962
|
-
id: string;
|
|
1963
|
-
});
|
|
1964
|
-
deferUpdate(): Promise<void>;
|
|
1965
|
-
update(payload: InteractionReplyOptions): Promise<void>;
|
|
1966
|
-
}
|
|
1967
|
-
|
|
1968
|
-
interface ComponentHandler {
|
|
1969
|
-
type?: string;
|
|
1970
|
-
customId?: string | RegExp;
|
|
1971
|
-
execute?: (ctx: ComponentContext) => unknown | Promise<unknown>;
|
|
1972
|
-
}
|
|
1973
|
-
interface ModalHandler {
|
|
1974
|
-
customId: string | RegExp;
|
|
1975
|
-
execute: (ctx: ModalContext) => unknown | Promise<unknown>;
|
|
1976
|
-
}
|
|
1977
|
-
declare class CommandManager {
|
|
1978
|
-
private _commands;
|
|
1979
|
-
private _components;
|
|
1980
|
-
private _modals;
|
|
1981
|
-
private _client;
|
|
1982
|
-
constructor(client: Client);
|
|
1983
|
-
register(...commands: AnyCommandDef[]): void;
|
|
1984
|
-
registerGuild(guildId: string, ...commands: AnyCommandDef[]): void;
|
|
1985
|
-
registerComponent(handler: ComponentHandler): void;
|
|
1986
|
-
registerModal(handler: ModalHandler): void;
|
|
1987
|
-
load(directory: string): Promise<void>;
|
|
1988
|
-
private _deployCommands;
|
|
1989
|
-
private _transformCommand;
|
|
1990
|
-
handleInteraction(raw: Record<string, unknown>): Promise<void>;
|
|
1991
|
-
private _handleComponentInteraction;
|
|
1992
|
-
private _handleModalInteraction;
|
|
1927
|
+
get fields(): Fields;
|
|
1993
1928
|
}
|
|
1994
1929
|
|
|
1995
1930
|
declare enum COMPONENT_TYPES {
|
|
@@ -2000,7 +1935,19 @@ declare enum COMPONENT_TYPES {
|
|
|
2000
1935
|
USER_SELECT = 5,
|
|
2001
1936
|
ROLE_SELECT = 6,
|
|
2002
1937
|
MENTIONABLE_SELECT = 7,
|
|
2003
|
-
CHANNEL_SELECT = 8
|
|
1938
|
+
CHANNEL_SELECT = 8,
|
|
1939
|
+
SECTION = 9,
|
|
1940
|
+
TEXT_DISPLAY = 10,
|
|
1941
|
+
THUMBNAIL = 11,
|
|
1942
|
+
MEDIA_GALLERY = 12,
|
|
1943
|
+
FILE = 13,
|
|
1944
|
+
SEPARATOR = 14,
|
|
1945
|
+
CONTAINER = 17,
|
|
1946
|
+
LABEL = 18,
|
|
1947
|
+
FILE_UPLOAD = 19,
|
|
1948
|
+
RADIO_GROUP = 21,
|
|
1949
|
+
CHECKBOX_GROUP = 22,
|
|
1950
|
+
CHECKBOX = 23
|
|
2004
1951
|
}
|
|
2005
1952
|
declare enum TEXT_INPUT_STYLES {
|
|
2006
1953
|
SHORT = 1,
|
|
@@ -2009,19 +1956,67 @@ declare enum TEXT_INPUT_STYLES {
|
|
|
2009
1956
|
|
|
2010
1957
|
type ButtonStyleString = 'primary' | 'secondary' | 'success' | 'danger' | 'link' | 'premium';
|
|
2011
1958
|
interface ButtonDef {
|
|
1959
|
+
/** Custom ID returned in the interaction payload for non-link buttons */
|
|
2012
1960
|
customId?: string;
|
|
1961
|
+
/** External URL opened by a link button */
|
|
2013
1962
|
url?: string;
|
|
1963
|
+
/** Visible text rendered on the button */
|
|
2014
1964
|
label?: string;
|
|
1965
|
+
/** Discord button style as either a readable string or raw numeric value */
|
|
2015
1966
|
style: ButtonStyleString | number;
|
|
1967
|
+
/** Whether the button should be rendered as disabled */
|
|
2016
1968
|
disabled?: boolean;
|
|
1969
|
+
/** Optional emoji rendered next to the label */
|
|
2017
1970
|
emoji?: Partial<Emoji>;
|
|
1971
|
+
/** Premium SKU ID used by Discord premium buttons */
|
|
2018
1972
|
skuId?: string;
|
|
1973
|
+
/** Optional handler executed when the component interaction is received */
|
|
2019
1974
|
execute?: (ctx: ComponentContext) => void | Promise<void>;
|
|
2020
1975
|
}
|
|
1976
|
+
/**
|
|
1977
|
+
* Normalize a human-readable button style into the numeric Discord API value
|
|
1978
|
+
* Accepts either a style name such as `'primary'` or a raw numeric style
|
|
1979
|
+
*/
|
|
2021
1980
|
declare function resolveButtonStyle(style: string | number): number;
|
|
1981
|
+
/**
|
|
1982
|
+
* Define a reusable button component handler
|
|
1983
|
+
* The returned object can be used in `ActionRow.of(...)` or in higher-level builders that accept button definitions
|
|
1984
|
+
*
|
|
1985
|
+
* @param def Button configuration including label, style, IDs and optional execute handler
|
|
1986
|
+
*/
|
|
2022
1987
|
declare function defineButton(def: ButtonDef): ButtonDef & {
|
|
2023
1988
|
type: 'button';
|
|
2024
1989
|
};
|
|
1990
|
+
declare const Button: {
|
|
1991
|
+
/** Build a reusable button definition that can be used in both V1 action rows and V2 accessories */
|
|
1992
|
+
of: (def: ButtonDef) => ButtonDef & {
|
|
1993
|
+
type: "button";
|
|
1994
|
+
};
|
|
1995
|
+
/** @param customId Component custom ID sent back in the interaction payload @param label Visible button text */
|
|
1996
|
+
primary: (customId: string, label: string) => ButtonDef & {
|
|
1997
|
+
type: "button";
|
|
1998
|
+
};
|
|
1999
|
+
/** @param customId Component custom ID sent back in the interaction payload @param label Visible button text */
|
|
2000
|
+
secondary: (customId: string, label: string) => ButtonDef & {
|
|
2001
|
+
type: "button";
|
|
2002
|
+
};
|
|
2003
|
+
/** @param customId Component custom ID sent back in the interaction payload @param label Visible button text */
|
|
2004
|
+
success: (customId: string, label: string) => ButtonDef & {
|
|
2005
|
+
type: "button";
|
|
2006
|
+
};
|
|
2007
|
+
/** @param customId Component custom ID sent back in the interaction payload @param label Visible button text */
|
|
2008
|
+
danger: (customId: string, label: string) => ButtonDef & {
|
|
2009
|
+
type: "button";
|
|
2010
|
+
};
|
|
2011
|
+
/** @param url Destination URL opened by the button @param label Visible button text */
|
|
2012
|
+
link: (url: string, label: string) => ButtonDef & {
|
|
2013
|
+
type: "button";
|
|
2014
|
+
};
|
|
2015
|
+
/** @param skuId Premium SKU ID used by Discord premium buttons @param label Visible button text */
|
|
2016
|
+
premium: (skuId: string, label: string) => ButtonDef & {
|
|
2017
|
+
type: "button";
|
|
2018
|
+
};
|
|
2019
|
+
};
|
|
2025
2020
|
interface StringSelectDef {
|
|
2026
2021
|
customId: string;
|
|
2027
2022
|
options: SelectOption[];
|
|
@@ -2079,48 +2074,420 @@ interface MentionableSelectDef {
|
|
|
2079
2074
|
declare function defineMentionableSelect(def: MentionableSelectDef): MentionableSelectDef & {
|
|
2080
2075
|
type: 'mentionable_select';
|
|
2081
2076
|
};
|
|
2082
|
-
|
|
2077
|
+
type ModalFieldType = TEXT_INPUT_STYLES | 19 | 21 | 22 | 23;
|
|
2078
|
+
interface ModalFieldDef<Required extends boolean = true, T extends ModalFieldType = ModalFieldType> {
|
|
2083
2079
|
id: string;
|
|
2084
|
-
type:
|
|
2085
|
-
label
|
|
2080
|
+
type: T;
|
|
2081
|
+
label?: string;
|
|
2086
2082
|
required?: Required;
|
|
2087
2083
|
minLength?: number;
|
|
2088
2084
|
maxLength?: number;
|
|
2089
2085
|
placeholder?: string;
|
|
2090
|
-
value?: string;
|
|
2086
|
+
value?: string | boolean | string[];
|
|
2087
|
+
options?: SelectOption[];
|
|
2088
|
+
[key: string]: any;
|
|
2091
2089
|
}
|
|
2092
2090
|
declare const field: {
|
|
2091
|
+
/**
|
|
2092
|
+
* Create a single-line text input field for a modal
|
|
2093
|
+
* @param id Field ID used as the key inside `ctx.fields`
|
|
2094
|
+
* @param label Visible field label shown in the modal
|
|
2095
|
+
* @param options Extra validation and UX settings for the text input
|
|
2096
|
+
*/
|
|
2093
2097
|
short: <ID extends string, Req extends boolean = true>(id: ID, label: string, options?: {
|
|
2094
2098
|
required?: Req;
|
|
2095
2099
|
minLength?: number;
|
|
2096
2100
|
maxLength?: number;
|
|
2097
2101
|
placeholder?: string;
|
|
2098
2102
|
value?: string;
|
|
2099
|
-
}) => ModalFieldDef<Req> & {
|
|
2103
|
+
}) => ModalFieldDef<Req, TEXT_INPUT_STYLES.SHORT> & {
|
|
2100
2104
|
id: ID;
|
|
2101
2105
|
};
|
|
2106
|
+
/**
|
|
2107
|
+
* Create a multi-line text input field for a modal
|
|
2108
|
+
* @param id Field ID used as the key inside `ctx.fields`
|
|
2109
|
+
* @param label Visible field label shown in the modal
|
|
2110
|
+
* @param options Extra validation and UX settings for the paragraph input
|
|
2111
|
+
*/
|
|
2102
2112
|
paragraph: <ID extends string, Req extends boolean = true>(id: ID, label: string, options?: {
|
|
2103
2113
|
required?: Req;
|
|
2104
2114
|
minLength?: number;
|
|
2105
2115
|
maxLength?: number;
|
|
2106
2116
|
placeholder?: string;
|
|
2107
2117
|
value?: string;
|
|
2108
|
-
}) => ModalFieldDef<Req> & {
|
|
2118
|
+
}) => ModalFieldDef<Req, TEXT_INPUT_STYLES.PARAGRAPH> & {
|
|
2119
|
+
id: ID;
|
|
2120
|
+
};
|
|
2121
|
+
/**
|
|
2122
|
+
* Create a boolean checkbox field for a modal
|
|
2123
|
+
* @param id Field ID used as the key inside `ctx.fields`
|
|
2124
|
+
* @param label Visible field label shown in the modal
|
|
2125
|
+
* @param options Checkbox settings such as `required` and default `value`
|
|
2126
|
+
*/
|
|
2127
|
+
checkbox: <ID extends string, Req extends boolean = true>(id: ID, label: string, options?: {
|
|
2128
|
+
required?: Req;
|
|
2129
|
+
value?: boolean;
|
|
2130
|
+
}) => ModalFieldDef<Req, 23> & {
|
|
2131
|
+
id: ID;
|
|
2132
|
+
};
|
|
2133
|
+
/**
|
|
2134
|
+
* Create a multi-select checkbox group field for a modal
|
|
2135
|
+
* @param id Field ID used as the key inside `ctx.fields`
|
|
2136
|
+
* @param label Visible field label shown in the modal
|
|
2137
|
+
* @param options Available choices and selection limits
|
|
2138
|
+
*/
|
|
2139
|
+
checkboxGroup: <ID extends string, Req extends boolean = true>(id: ID, label: string, options: {
|
|
2140
|
+
options: SelectOption[];
|
|
2141
|
+
required?: Req;
|
|
2142
|
+
minValues?: number;
|
|
2143
|
+
maxValues?: number;
|
|
2144
|
+
}) => ModalFieldDef<Req, 22> & {
|
|
2145
|
+
id: ID;
|
|
2146
|
+
};
|
|
2147
|
+
/**
|
|
2148
|
+
* Create a single-choice radio group field for a modal
|
|
2149
|
+
* @param id Field ID used as the key inside `ctx.fields`
|
|
2150
|
+
* @param label Visible field label shown in the modal
|
|
2151
|
+
* @param options Available choices for the radio group
|
|
2152
|
+
*/
|
|
2153
|
+
radioGroup: <ID extends string, Req extends boolean = true>(id: ID, label: string, options: {
|
|
2154
|
+
options: SelectOption[];
|
|
2155
|
+
required?: Req;
|
|
2156
|
+
}) => ModalFieldDef<Req, 21> & {
|
|
2157
|
+
id: ID;
|
|
2158
|
+
};
|
|
2159
|
+
/**
|
|
2160
|
+
* Create a file upload field for a modal
|
|
2161
|
+
* Submitted files are available in `ctx.attachments[id]`
|
|
2162
|
+
* @param id Field ID used as the key inside `ctx.fields` and `ctx.attachments`
|
|
2163
|
+
* @param label Visible field label shown in the modal
|
|
2164
|
+
* @param options Upload field settings such as `required`
|
|
2165
|
+
*/
|
|
2166
|
+
fileUpload: <ID extends string, Req extends boolean = true>(id: ID, label: string, options?: {
|
|
2167
|
+
required?: Req;
|
|
2168
|
+
}) => ModalFieldDef<Req, 19> & {
|
|
2109
2169
|
id: ID;
|
|
2110
2170
|
};
|
|
2111
2171
|
};
|
|
2112
|
-
type
|
|
2113
|
-
|
|
2172
|
+
type ResolveModalFieldType<K extends ModalFieldDef<any, any>> = K['type'] extends 23 ? boolean : K['type'] extends 19 ? string[] : K['type'] extends 22 ? string[] : string;
|
|
2173
|
+
type ResolveModalFields<F extends ReadonlyArray<ModalFieldDef<boolean, any>>> = {
|
|
2174
|
+
[K in F[number] as K['id']]: K['required'] extends false ? ResolveModalFieldType<K> | undefined : ResolveModalFieldType<K>;
|
|
2114
2175
|
};
|
|
2115
|
-
interface ModalDef<F extends ReadonlyArray<ModalFieldDef<boolean>>> {
|
|
2176
|
+
interface ModalDef<F extends ReadonlyArray<ModalFieldDef<boolean, any>>> {
|
|
2116
2177
|
customId: string;
|
|
2117
2178
|
title: string;
|
|
2118
2179
|
fields: F;
|
|
2119
|
-
execute: (ctx:
|
|
2180
|
+
execute: (ctx: ModalContext<ResolveModalFields<F>>) => void | Promise<void>;
|
|
2120
2181
|
}
|
|
2121
|
-
declare function defineModal<F extends ReadonlyArray<ModalFieldDef<boolean>>>(def: ModalDef<F>): ModalDef<F> & {
|
|
2182
|
+
declare function defineModal<F extends ReadonlyArray<ModalFieldDef<boolean, any>>>(def: ModalDef<F>): ModalDef<F> & {
|
|
2122
2183
|
type: 'modal';
|
|
2123
2184
|
};
|
|
2185
|
+
declare class ModalDefinitionBuilder<F extends ReadonlyArray<ModalFieldDef<boolean, any>> = []> {
|
|
2186
|
+
private readonly customId;
|
|
2187
|
+
private readonly title;
|
|
2188
|
+
private readonly fieldsDef;
|
|
2189
|
+
constructor(customId: string, title: string, fieldsDef?: F);
|
|
2190
|
+
/**
|
|
2191
|
+
* Append one or more fields to the modal definition
|
|
2192
|
+
* The resulting builder keeps full type information, so added field IDs become available in `ctx.fields`
|
|
2193
|
+
* @param fields Fields to add to the modal
|
|
2194
|
+
*/
|
|
2195
|
+
add<NewFields extends ReadonlyArray<ModalFieldDef<boolean, any>>>(...fields: NewFields): ModalDefinitionBuilder<[...F, ...NewFields]>;
|
|
2196
|
+
/**
|
|
2197
|
+
* Finalize the modal definition and attach its submit handler
|
|
2198
|
+
* The handler receives a strongly-typed `ctx.fields` object derived from the fields added to this builder
|
|
2199
|
+
* @param execute Modal submit handler
|
|
2200
|
+
*/
|
|
2201
|
+
execute(execute: (ctx: ModalContext<ResolveModalFields<F>>) => void | Promise<void>): ModalDef<F> & {
|
|
2202
|
+
type: "modal";
|
|
2203
|
+
};
|
|
2204
|
+
handle(execute: (ctx: ModalContext<ResolveModalFields<F>>) => void | Promise<void>): ModalDef<F> & {
|
|
2205
|
+
type: "modal";
|
|
2206
|
+
};
|
|
2207
|
+
}
|
|
2208
|
+
/**
|
|
2209
|
+
* Start a fluent modal definition
|
|
2210
|
+
* @param customId Custom ID returned when the modal is submitted
|
|
2211
|
+
* @param title Modal title shown in the Discord client
|
|
2212
|
+
*/
|
|
2213
|
+
declare function modal(customId: string, title: string): ModalDefinitionBuilder<[]>;
|
|
2214
|
+
|
|
2215
|
+
type InteractionReplyOptions = string | {
|
|
2216
|
+
content?: string;
|
|
2217
|
+
embeds?: (Embed | {
|
|
2218
|
+
toJSON(): Record<string, unknown>;
|
|
2219
|
+
} | Record<string, unknown>)[];
|
|
2220
|
+
components?: (MessageComponent | {
|
|
2221
|
+
build?(): MessageComponent;
|
|
2222
|
+
} | {
|
|
2223
|
+
toJSON(): Record<string, unknown>;
|
|
2224
|
+
} | Record<string, unknown>)[];
|
|
2225
|
+
ephemeral?: boolean;
|
|
2226
|
+
};
|
|
2227
|
+
declare class BaseInteractionContext {
|
|
2228
|
+
user: User;
|
|
2229
|
+
guild?: Guild | {
|
|
2230
|
+
id: string;
|
|
2231
|
+
} | undefined;
|
|
2232
|
+
channel?: Channel | {
|
|
2233
|
+
id: string;
|
|
2234
|
+
} | undefined;
|
|
2235
|
+
interactionId: string;
|
|
2236
|
+
interactionToken: string;
|
|
2237
|
+
protected _client: Client;
|
|
2238
|
+
protected _deferred: boolean;
|
|
2239
|
+
protected _replied: boolean;
|
|
2240
|
+
constructor(client: Client, raw: Record<string, unknown>, user: User, guild?: Guild | {
|
|
2241
|
+
id: string;
|
|
2242
|
+
}, channel?: Channel | {
|
|
2243
|
+
id: string;
|
|
2244
|
+
});
|
|
2245
|
+
get client(): Client<readonly IntentResolvable[]>;
|
|
2246
|
+
get replied(): boolean;
|
|
2247
|
+
get deferred(): boolean;
|
|
2248
|
+
protected _assertOk(result: ChameleonAPIResult<unknown>, action: string): void;
|
|
2249
|
+
protected _resolvePayload(payload: InteractionReplyOptions): Record<string, unknown>;
|
|
2250
|
+
protected _serializeModalField(field: ModalFieldDef<boolean, any>): Record<string, unknown>;
|
|
2251
|
+
reply(payload: InteractionReplyOptions): Promise<void>;
|
|
2252
|
+
defer(options?: {
|
|
2253
|
+
ephemeral?: boolean;
|
|
2254
|
+
}): Promise<void>;
|
|
2255
|
+
followUp(payload: InteractionReplyOptions): Promise<void>;
|
|
2256
|
+
showModal(modal: Record<string, unknown> | (ModalDef<ReadonlyArray<ModalFieldDef<boolean, any>>> & {
|
|
2257
|
+
type: 'modal';
|
|
2258
|
+
})): Promise<void>;
|
|
2259
|
+
}
|
|
2260
|
+
declare class CommandContext<Options = Record<string, unknown>> extends BaseInteractionContext {
|
|
2261
|
+
options: Options;
|
|
2262
|
+
constructor(client: Client, rawInteraction: Record<string, unknown>, parsedOptions: Options, user: User, guild?: Guild | {
|
|
2263
|
+
id: string;
|
|
2264
|
+
}, channel?: Channel | {
|
|
2265
|
+
id: string;
|
|
2266
|
+
});
|
|
2267
|
+
}
|
|
2268
|
+
|
|
2269
|
+
type BitFieldResolvable = string | number | bigint | BitField | BitFieldResolvable[];
|
|
2270
|
+
declare class BitField {
|
|
2271
|
+
static FLAGS: Record<string, bigint>;
|
|
2272
|
+
bitfield: bigint;
|
|
2273
|
+
constructor(bits?: BitFieldResolvable);
|
|
2274
|
+
has(bit: BitFieldResolvable): boolean;
|
|
2275
|
+
any(bit: BitFieldResolvable): boolean;
|
|
2276
|
+
add(...bits: BitFieldResolvable[]): this;
|
|
2277
|
+
remove(...bits: BitFieldResolvable[]): this;
|
|
2278
|
+
toArray(): string[];
|
|
2279
|
+
serialize(): Record<string, boolean>;
|
|
2280
|
+
equals(other: BitFieldResolvable): boolean;
|
|
2281
|
+
freeze(): Readonly<this>;
|
|
2282
|
+
toString(): string;
|
|
2283
|
+
toJSON(): string;
|
|
2284
|
+
static resolve(bit: BitFieldResolvable): bigint;
|
|
2285
|
+
}
|
|
2286
|
+
|
|
2287
|
+
type CommandOptionMap = Record<string, OptionDef<OptionType, boolean>>;
|
|
2288
|
+
type SubcommandMap = Record<string, Subcommand<CommandOptionMap>>;
|
|
2289
|
+
type SubcommandGroupMap = Record<string, SubcommandGroup<SubcommandMap>>;
|
|
2290
|
+
type ExecuteFunction<O extends Record<string, OptionDef<OptionType, boolean>>> = (ctx: CommandContext<ResolveOptions<O>>) => void | Promise<void>;
|
|
2291
|
+
interface Subcommand<O extends CommandOptionMap = Record<string, never>> {
|
|
2292
|
+
description: string;
|
|
2293
|
+
options?: O;
|
|
2294
|
+
execute: ExecuteFunction<O>;
|
|
2295
|
+
}
|
|
2296
|
+
declare function defineSubcommand<O extends CommandOptionMap>(def: Subcommand<O>): Subcommand<O>;
|
|
2297
|
+
interface SubcommandGroup<S extends SubcommandMap = Record<string, never>> {
|
|
2298
|
+
description: string;
|
|
2299
|
+
subcommands: S;
|
|
2300
|
+
}
|
|
2301
|
+
declare function defineSubcommandGroup<S extends SubcommandMap>(def: SubcommandGroup<S>): SubcommandGroup<S>;
|
|
2302
|
+
type CommandDef<O extends CommandOptionMap = Record<string, never>, S extends SubcommandMap | SubcommandGroupMap = Record<string, never>> = {
|
|
2303
|
+
name: string;
|
|
2304
|
+
description: string;
|
|
2305
|
+
options?: O;
|
|
2306
|
+
subcommands?: S;
|
|
2307
|
+
defaultMemberPermissions?: string | null;
|
|
2308
|
+
execute?: ExecuteFunction<O>;
|
|
2309
|
+
};
|
|
2310
|
+
type AnyCommandDef = CommandDef<any, any>;
|
|
2311
|
+
type AnyCommandInput = CommandDef<any, any> | CommandDefinitionBuilder<any, any>;
|
|
2312
|
+
declare function defineCommand<O extends CommandOptionMap, S extends SubcommandMap | SubcommandGroupMap>(def: CommandDef<O, S>): CommandDef<O, S>;
|
|
2313
|
+
interface CommandMetadata {
|
|
2314
|
+
defaultMemberPermissions?: string | null;
|
|
2315
|
+
}
|
|
2316
|
+
declare class SubcommandDefinitionBuilder<O extends CommandOptionMap = Record<string, never>> {
|
|
2317
|
+
private readonly description;
|
|
2318
|
+
private readonly optionsDef?;
|
|
2319
|
+
constructor(description: string, optionsDef?: O | undefined);
|
|
2320
|
+
options<NewOptions extends CommandOptionMap>(options: NewOptions): SubcommandDefinitionBuilder<NewOptions>;
|
|
2321
|
+
option<Name extends string, Def extends OptionDef<OptionType, boolean>>(name: Name, definition: Def): SubcommandDefinitionBuilder<O & Record<Name, Def>>;
|
|
2322
|
+
string<Name extends string, R extends boolean = false>(name: Name, description: string, choicesOrOptions?: readonly ChoiceDef<string>[] | {
|
|
2323
|
+
required?: R;
|
|
2324
|
+
choices?: readonly ChoiceDef<string>[];
|
|
2325
|
+
minLength?: number;
|
|
2326
|
+
maxLength?: number;
|
|
2327
|
+
}, maybeOptions?: {
|
|
2328
|
+
required?: R;
|
|
2329
|
+
minLength?: number;
|
|
2330
|
+
maxLength?: number;
|
|
2331
|
+
}): SubcommandDefinitionBuilder<O & Record<Name, OptionDef<'string', R>>>;
|
|
2332
|
+
integer<Name extends string, R extends boolean = false>(name: Name, description: string, choicesOrOptions?: readonly ChoiceDef<number>[] | {
|
|
2333
|
+
required?: R;
|
|
2334
|
+
choices?: readonly ChoiceDef<number>[];
|
|
2335
|
+
min?: number;
|
|
2336
|
+
max?: number;
|
|
2337
|
+
}, maybeOptions?: {
|
|
2338
|
+
required?: R;
|
|
2339
|
+
min?: number;
|
|
2340
|
+
max?: number;
|
|
2341
|
+
}): SubcommandDefinitionBuilder<O & Record<Name, OptionDef<'integer', R>>>;
|
|
2342
|
+
number<Name extends string, R extends boolean = false>(name: Name, description: string, choicesOrOptions?: readonly ChoiceDef<number>[] | {
|
|
2343
|
+
required?: R;
|
|
2344
|
+
choices?: readonly ChoiceDef<number>[];
|
|
2345
|
+
min?: number;
|
|
2346
|
+
max?: number;
|
|
2347
|
+
}, maybeOptions?: {
|
|
2348
|
+
required?: R;
|
|
2349
|
+
min?: number;
|
|
2350
|
+
max?: number;
|
|
2351
|
+
}): SubcommandDefinitionBuilder<O & Record<Name, OptionDef<'number', R>>>;
|
|
2352
|
+
boolean<Name extends string, R extends boolean = false>(name: Name, description: string, options?: {
|
|
2353
|
+
required?: R;
|
|
2354
|
+
}): SubcommandDefinitionBuilder<O & Record<Name, OptionDef<'boolean', R>>>;
|
|
2355
|
+
user<Name extends string, R extends boolean = false>(name: Name, description: string, options?: {
|
|
2356
|
+
required?: R;
|
|
2357
|
+
}): SubcommandDefinitionBuilder<O & Record<Name, OptionDef<'user', R>>>;
|
|
2358
|
+
channel<Name extends string, R extends boolean = false>(name: Name, description: string, options?: {
|
|
2359
|
+
required?: R;
|
|
2360
|
+
channelTypes?: number[];
|
|
2361
|
+
}): SubcommandDefinitionBuilder<O & Record<Name, OptionDef<'channel', R>>>;
|
|
2362
|
+
role<Name extends string, R extends boolean = false>(name: Name, description: string, options?: {
|
|
2363
|
+
required?: R;
|
|
2364
|
+
}): SubcommandDefinitionBuilder<O & Record<Name, OptionDef<'role', R>>>;
|
|
2365
|
+
mentionable<Name extends string, R extends boolean = false>(name: Name, description: string, options?: {
|
|
2366
|
+
required?: R;
|
|
2367
|
+
}): SubcommandDefinitionBuilder<O & Record<Name, OptionDef<'mentionable', R>>>;
|
|
2368
|
+
attachment<Name extends string, R extends boolean = false>(name: Name, description: string, options?: {
|
|
2369
|
+
required?: R;
|
|
2370
|
+
}): SubcommandDefinitionBuilder<O & Record<Name, OptionDef<'attachment', R>>>;
|
|
2371
|
+
execute(execute: ExecuteFunction<O>): Subcommand<O>;
|
|
2372
|
+
handle(execute: ExecuteFunction<O>): Subcommand<O>;
|
|
2373
|
+
}
|
|
2374
|
+
declare class SubcommandGroupDefinitionBuilder<S extends SubcommandMap = Record<string, never>> {
|
|
2375
|
+
private readonly description;
|
|
2376
|
+
private readonly subcommandsDef?;
|
|
2377
|
+
constructor(description: string, subcommandsDef?: S | undefined);
|
|
2378
|
+
subcommands<NewSubcommands extends SubcommandMap>(subcommands: NewSubcommands): SubcommandGroupDefinitionBuilder<NewSubcommands>;
|
|
2379
|
+
subcommand<Name extends string, Sub extends Subcommand<any>>(name: Name, subcommand: Sub): SubcommandGroupDefinitionBuilder<S & Record<Name, Sub>>;
|
|
2380
|
+
toGroup(): SubcommandGroup<S>;
|
|
2381
|
+
build(): SubcommandGroup<S>;
|
|
2382
|
+
}
|
|
2383
|
+
declare class CommandDefinitionBuilder<O extends CommandOptionMap = Record<string, never>, S extends SubcommandMap | SubcommandGroupMap = Record<string, never>> {
|
|
2384
|
+
private readonly name;
|
|
2385
|
+
private readonly description;
|
|
2386
|
+
private readonly optionsDef?;
|
|
2387
|
+
private readonly subcommandsDef?;
|
|
2388
|
+
private readonly metadata;
|
|
2389
|
+
constructor(name: string, description: string, optionsDef?: O | undefined, subcommandsDef?: S | undefined, metadata?: CommandMetadata);
|
|
2390
|
+
options<NewOptions extends CommandOptionMap>(options: NewOptions): CommandDefinitionBuilder<NewOptions, S>;
|
|
2391
|
+
option<Name extends string, Def extends OptionDef<OptionType, boolean>>(name: Name, definition: Def): CommandDefinitionBuilder<O & Record<Name, Def>, S>;
|
|
2392
|
+
string<Name extends string, R extends boolean = false>(name: Name, description: string, choicesOrOptions?: readonly ChoiceDef<string>[] | {
|
|
2393
|
+
required?: R;
|
|
2394
|
+
choices?: readonly ChoiceDef<string>[];
|
|
2395
|
+
minLength?: number;
|
|
2396
|
+
maxLength?: number;
|
|
2397
|
+
}, maybeOptions?: {
|
|
2398
|
+
required?: R;
|
|
2399
|
+
minLength?: number;
|
|
2400
|
+
maxLength?: number;
|
|
2401
|
+
}): CommandDefinitionBuilder<O & Record<Name, OptionDef<'string', R>>, S>;
|
|
2402
|
+
integer<Name extends string, R extends boolean = false>(name: Name, description: string, choicesOrOptions?: readonly ChoiceDef<number>[] | {
|
|
2403
|
+
required?: R;
|
|
2404
|
+
choices?: readonly ChoiceDef<number>[];
|
|
2405
|
+
min?: number;
|
|
2406
|
+
max?: number;
|
|
2407
|
+
}, maybeOptions?: {
|
|
2408
|
+
required?: R;
|
|
2409
|
+
min?: number;
|
|
2410
|
+
max?: number;
|
|
2411
|
+
}): CommandDefinitionBuilder<O & Record<Name, OptionDef<'integer', R>>, S>;
|
|
2412
|
+
number<Name extends string, R extends boolean = false>(name: Name, description: string, choicesOrOptions?: readonly ChoiceDef<number>[] | {
|
|
2413
|
+
required?: R;
|
|
2414
|
+
choices?: readonly ChoiceDef<number>[];
|
|
2415
|
+
min?: number;
|
|
2416
|
+
max?: number;
|
|
2417
|
+
}, maybeOptions?: {
|
|
2418
|
+
required?: R;
|
|
2419
|
+
min?: number;
|
|
2420
|
+
max?: number;
|
|
2421
|
+
}): CommandDefinitionBuilder<O & Record<Name, OptionDef<'number', R>>, S>;
|
|
2422
|
+
boolean<Name extends string, R extends boolean = false>(name: Name, description: string, options?: {
|
|
2423
|
+
required?: R;
|
|
2424
|
+
}): CommandDefinitionBuilder<O & Record<Name, OptionDef<'boolean', R>>, S>;
|
|
2425
|
+
user<Name extends string, R extends boolean = false>(name: Name, description: string, options?: {
|
|
2426
|
+
required?: R;
|
|
2427
|
+
}): CommandDefinitionBuilder<O & Record<Name, OptionDef<'user', R>>, S>;
|
|
2428
|
+
channel<Name extends string, R extends boolean = false>(name: Name, description: string, options?: {
|
|
2429
|
+
required?: R;
|
|
2430
|
+
channelTypes?: number[];
|
|
2431
|
+
}): CommandDefinitionBuilder<O & Record<Name, OptionDef<'channel', R>>, S>;
|
|
2432
|
+
role<Name extends string, R extends boolean = false>(name: Name, description: string, options?: {
|
|
2433
|
+
required?: R;
|
|
2434
|
+
}): CommandDefinitionBuilder<O & Record<Name, OptionDef<'role', R>>, S>;
|
|
2435
|
+
mentionable<Name extends string, R extends boolean = false>(name: Name, description: string, options?: {
|
|
2436
|
+
required?: R;
|
|
2437
|
+
}): CommandDefinitionBuilder<O & Record<Name, OptionDef<'mentionable', R>>, S>;
|
|
2438
|
+
attachment<Name extends string, R extends boolean = false>(name: Name, description: string, options?: {
|
|
2439
|
+
required?: R;
|
|
2440
|
+
}): CommandDefinitionBuilder<O & Record<Name, OptionDef<'attachment', R>>, S>;
|
|
2441
|
+
subcommands<NewSubcommands extends SubcommandMap | SubcommandGroupMap>(subcommands: NewSubcommands): CommandDefinitionBuilder<O, NewSubcommands>;
|
|
2442
|
+
subcommand<Name extends string, Sub extends Subcommand<any>>(name: Name, subcommand: Sub): CommandDefinitionBuilder<O, S & Record<Name, Sub>>;
|
|
2443
|
+
group<Name extends string, Group extends SubcommandGroup<SubcommandMap> | SubcommandGroupDefinitionBuilder<any>>(name: Name, group: Group): CommandDefinitionBuilder<O, S & Record<Name, Group extends SubcommandGroupDefinitionBuilder<infer GS> ? SubcommandGroup<GS> : Group>>;
|
|
2444
|
+
setPermissions(permissions: BitFieldResolvable | null): CommandDefinitionBuilder<O, S>;
|
|
2445
|
+
setDefaultMemberPermissions(permissions: BitFieldResolvable | null): CommandDefinitionBuilder<O, S>;
|
|
2446
|
+
execute(execute: ExecuteFunction<O>): CommandDef<O, S>;
|
|
2447
|
+
handle(execute: ExecuteFunction<O>): CommandDef<O, S>;
|
|
2448
|
+
toCommand(): CommandDef<O, S>;
|
|
2449
|
+
build(): CommandDef<O, S>;
|
|
2450
|
+
}
|
|
2451
|
+
/**
|
|
2452
|
+
* Start a fluent command definition
|
|
2453
|
+
*/
|
|
2454
|
+
declare function command(name: string, description: string): CommandDefinitionBuilder<Record<string, never>, Record<string, never>>;
|
|
2455
|
+
/**
|
|
2456
|
+
* Start a fluent subcommand definition
|
|
2457
|
+
*/
|
|
2458
|
+
declare function subcommand(description: string): SubcommandDefinitionBuilder<Record<string, never>>;
|
|
2459
|
+
/**
|
|
2460
|
+
* Start a fluent subcommand group definition
|
|
2461
|
+
*/
|
|
2462
|
+
declare function subcommandGroup(description: string): SubcommandGroupDefinitionBuilder<Record<string, never>>;
|
|
2463
|
+
|
|
2464
|
+
interface ComponentHandler {
|
|
2465
|
+
type?: string;
|
|
2466
|
+
customId?: string | RegExp;
|
|
2467
|
+
execute?: (ctx: ComponentContext) => unknown | Promise<unknown>;
|
|
2468
|
+
}
|
|
2469
|
+
interface ModalHandler<Fields = Record<string, unknown>> {
|
|
2470
|
+
customId: string | RegExp;
|
|
2471
|
+
execute: (ctx: ModalContext<Fields>) => unknown | Promise<unknown>;
|
|
2472
|
+
}
|
|
2473
|
+
declare class CommandManager {
|
|
2474
|
+
private _commands;
|
|
2475
|
+
private _components;
|
|
2476
|
+
private _modals;
|
|
2477
|
+
private _client;
|
|
2478
|
+
constructor(client: Client);
|
|
2479
|
+
register(...commands: AnyCommandInput[]): void;
|
|
2480
|
+
registerGuild(guildId: string, ...commands: AnyCommandInput[]): void;
|
|
2481
|
+
registerComponent(handler: ComponentHandler): void;
|
|
2482
|
+
registerModal<F extends ReadonlyArray<ModalFieldDef<boolean, any>>>(handler: ModalDef<F> | ModalHandler<ResolveModalFields<F>>): void;
|
|
2483
|
+
load(directory: string): Promise<void>;
|
|
2484
|
+
private _deployCommands;
|
|
2485
|
+
private _transformCommand;
|
|
2486
|
+
private _normalizeCommand;
|
|
2487
|
+
handleInteraction(raw: Record<string, unknown>): Promise<void>;
|
|
2488
|
+
private _handleComponentInteraction;
|
|
2489
|
+
private _handleModalInteraction;
|
|
2490
|
+
}
|
|
2124
2491
|
|
|
2125
2492
|
type ComponentInput = (ButtonDef & {
|
|
2126
2493
|
type: 'button';
|
|
@@ -2144,6 +2511,80 @@ declare const ActionRow: {
|
|
|
2144
2511
|
};
|
|
2145
2512
|
};
|
|
2146
2513
|
|
|
2514
|
+
type ButtonLike = ButtonDef & {
|
|
2515
|
+
type: 'button';
|
|
2516
|
+
};
|
|
2517
|
+
type JSONEncodable = {
|
|
2518
|
+
toJSON(): Record<string, unknown>;
|
|
2519
|
+
};
|
|
2520
|
+
type V2RawComponent = {
|
|
2521
|
+
type: number;
|
|
2522
|
+
[key: string]: unknown;
|
|
2523
|
+
};
|
|
2524
|
+
type V2ComponentLike = V2RawComponent | JSONEncodable | ButtonLike;
|
|
2525
|
+
declare class SectionBuilder {
|
|
2526
|
+
private readonly data;
|
|
2527
|
+
constructor(components: V2ComponentLike[], accessory?: V2ComponentLike);
|
|
2528
|
+
accessory(accessory: V2ComponentLike): this;
|
|
2529
|
+
toJSON(): {
|
|
2530
|
+
accessory?: Record<string, unknown>;
|
|
2531
|
+
components: Record<string, unknown>[];
|
|
2532
|
+
};
|
|
2533
|
+
}
|
|
2534
|
+
declare const TextDisplay: {
|
|
2535
|
+
of: (content: string) => {
|
|
2536
|
+
type: COMPONENT_TYPES;
|
|
2537
|
+
content: string;
|
|
2538
|
+
};
|
|
2539
|
+
};
|
|
2540
|
+
declare const Thumbnail: {
|
|
2541
|
+
of: (url: string, description?: string, spoiler?: boolean) => {
|
|
2542
|
+
type: COMPONENT_TYPES;
|
|
2543
|
+
media: {
|
|
2544
|
+
url: string;
|
|
2545
|
+
};
|
|
2546
|
+
description: string | undefined;
|
|
2547
|
+
spoiler: boolean | undefined;
|
|
2548
|
+
};
|
|
2549
|
+
};
|
|
2550
|
+
declare const Separator: {
|
|
2551
|
+
of: (spacing?: number, divider?: boolean) => {
|
|
2552
|
+
type: COMPONENT_TYPES;
|
|
2553
|
+
spacing: number | undefined;
|
|
2554
|
+
divider: boolean | undefined;
|
|
2555
|
+
};
|
|
2556
|
+
};
|
|
2557
|
+
declare const Section: {
|
|
2558
|
+
/**
|
|
2559
|
+
* Section builder
|
|
2560
|
+
* @param components Child components rendered inside the section body
|
|
2561
|
+
* @param accessory Optional accessory rendered on the side of the section
|
|
2562
|
+
*/
|
|
2563
|
+
of: (components: V2ComponentLike[], accessory?: V2ComponentLike) => SectionBuilder;
|
|
2564
|
+
/** @param content Text rendered as a single TextDisplay inside the section */
|
|
2565
|
+
text: (content: string) => SectionBuilder;
|
|
2566
|
+
};
|
|
2567
|
+
declare const Container: {
|
|
2568
|
+
/**
|
|
2569
|
+
* Container builder
|
|
2570
|
+
* @param components Child components rendered inside the container
|
|
2571
|
+
* @param spoiler Whether the container should be hidden behind a spoiler
|
|
2572
|
+
*/
|
|
2573
|
+
of: (components: V2ComponentLike[], spoiler?: boolean) => Record<string, unknown>;
|
|
2574
|
+
/** Helper for stacking V2 components vertically without manually creating an array */
|
|
2575
|
+
stack: (...components: V2ComponentLike[]) => Record<string, unknown>;
|
|
2576
|
+
};
|
|
2577
|
+
declare const Label: {
|
|
2578
|
+
/** Wrap a modal field component in a V2 label container */
|
|
2579
|
+
of: (field: ModalFieldDef<boolean, any>) => {
|
|
2580
|
+
type: COMPONENT_TYPES;
|
|
2581
|
+
label: string | undefined;
|
|
2582
|
+
component: {
|
|
2583
|
+
[k: string]: unknown;
|
|
2584
|
+
};
|
|
2585
|
+
};
|
|
2586
|
+
};
|
|
2587
|
+
|
|
2147
2588
|
declare class ComponentManager {
|
|
2148
2589
|
private client;
|
|
2149
2590
|
private handlers;
|
|
@@ -3211,24 +3652,6 @@ declare class Chameleon {
|
|
|
3211
3652
|
};
|
|
3212
3653
|
}
|
|
3213
3654
|
|
|
3214
|
-
type BitFieldResolvable = string | number | bigint | BitField | BitFieldResolvable[];
|
|
3215
|
-
declare class BitField {
|
|
3216
|
-
static FLAGS: Record<string, bigint>;
|
|
3217
|
-
bitfield: bigint;
|
|
3218
|
-
constructor(bits?: BitFieldResolvable);
|
|
3219
|
-
has(bit: BitFieldResolvable): boolean;
|
|
3220
|
-
any(bit: BitFieldResolvable): boolean;
|
|
3221
|
-
add(...bits: BitFieldResolvable[]): this;
|
|
3222
|
-
remove(...bits: BitFieldResolvable[]): this;
|
|
3223
|
-
toArray(): string[];
|
|
3224
|
-
serialize(): Record<string, boolean>;
|
|
3225
|
-
equals(other: BitFieldResolvable): boolean;
|
|
3226
|
-
freeze(): Readonly<this>;
|
|
3227
|
-
toString(): string;
|
|
3228
|
-
toJSON(): string;
|
|
3229
|
-
static resolve(bit: BitFieldResolvable): bigint;
|
|
3230
|
-
}
|
|
3231
|
-
|
|
3232
3655
|
declare class PermissionsBitField extends BitField {
|
|
3233
3656
|
static FLAGS: Record<string, bigint>;
|
|
3234
3657
|
static ALL: bigint;
|
|
@@ -3287,4 +3710,4 @@ declare class CShard extends EventEmitter {
|
|
|
3287
3710
|
broadcast(message: unknown): Promise<void[]>;
|
|
3288
3711
|
}
|
|
3289
3712
|
|
|
3290
|
-
export { AUDIT_LOG_EVENT_TYPES, ActionRow, ActionRowBuilder, Activity, type ActivityInstance, type ActivityLocation, ActivityLocationKind, type AnyCommandDef, type Application, type ApplicationCommand, type ApplicationCommandOption, type ApplicationCommandOptionChoice, ApplicationCommandOptionType, ApplicationCommandType, ApplicationEventWebhookStatus, ApplicationFlag, ApplicationIntegrationType, type ApplicationIntegrationTypeConfiguration, ApplicationManager, type ApplicationRoleConnection, type ApplicationRoleConnectionMetadata, ApplicationRoleConnectionMetadataType, type Attachment, AttachmentBuilder, type AttachmentData, AttachmentFlag, type AuditLog, type AuditLogChange, type AuditLogEntry, type AutoModerationAction, type AutoModerationActionMetadata, AutoModerationActionType, AutoModerationEventType, AutoModerationKeywordPresetType, AutoModerationManager, type AutoModerationRule, type AutoModerationTriggerMetadata, AutoModerationTriggerType, type AvatarDecorationData, type AwaitComponentOptions, type AwaitMessagesOptions, BaseInteractionContext, BaseManager, BitField, type BitFieldResolvable, ButtonBuilder, type ButtonDef, ButtonStyle, type ButtonStyleString, CHAMELEON_SELF_MAP, CShard, Chameleon, type ChameleonAPIResult, type ChameleonEvent, type ChameleonEventHandler, ChameleonGateway, type ChameleonGatewayOptions, ChameleonREST, type ChameleonRESTOptions, type ChameleonSelfKey, type Channel, ChannelFlag, ChannelManager, type ChannelMention, type ChannelSelectDef, ChannelType, Client, type ClientOptions, type Collectibles, Collection, CollectorManager, Colors, CommandContext, type CommandDef, CommandManager, ComponentContext, type ComponentHandler, ComponentManager, ComponentType, type Connection, DISCORD_GATEWAY_OPCODES, DISCORD_PERMISSIONS, DefaultMessageNotificationLevel, type DefaultReaction, type Embed, type EmbedAuthor, EmbedBuilder, type EmbedField, type EmbedFooter, type EmbedImage, type EmbedProvider, EmbedType, type EmbedVideo, type Emoji, type Entitlement, EntitlementManager, EntitlementType, type EventMap, type ExecuteFunction, ExplicitContentFilterLevel, ForumLayoutType, type ForumTag, type GatewayPayload, type GatewayStatus, type Guild, GuildInviteFlag, GuildManager, GuildMemberFlag, GuildNSFWLevel, type GuildScheduledEvent, type GuildScheduledEventEntityMetadata, GuildScheduledEventEntityType, GuildScheduledEventPrivacyLevel, GuildScheduledEventStatus, type GuildScheduledEventUser, type GuildTemplate, type HttpMethod, type IncidentsData, type InstallParams, type Integration, type IntegrationAccount, IntegrationExpireBehavior, IntentBits, type IntentResolvable, type IntentString, Intents, IntentsBitField, type InteractionReplyOptions, type Invite, InviteManager, type InviteMetadata, type InviteStageInstance, InviteTargetType, InviteType, type Lobby, type LobbyMember, LobbyMemberFlag, MFALevel, type Member, MemberManager, type MentionableSelectDef, type Message, type MessageActivity, MessageActivityType, type MessageCall, type MessageComponent, type MessageCreateOptions, MessageFlag, type MessageInteractionMetadata, MessageManager, type MessageReference, MessageReferenceType, type MessageSnapshot, MessageType, type MiddlewareFn, ModalBuilder, type ModalDef, type ModalFieldDef, type ModalHandler, type Nameplate, type OptionDef, type OptionType, type OptionalAuditEntryInfo, type Overwrite, type PartialChannel, type PartialGuild, type PermissionFlag, PermissionsBitField, type Poll, type PollAnswer, type PollAnswerCount, type PollCreateRequest, type PollMedia, type PollResults, PremiumTier, PremiumType, type Reaction, type ReactionCountDetails, type ResolveModalFields, type ResolveOption, type ResolveOptionType, type ResolveOptions, type Role, RoleManager, type RoleSelectDef, type RoleSubscriptionData, type RoleTags, ScheduledEventManager, SelectMenuBuilder, type SelectOption, Shard, type ShardOptions, type SharedClientTheme, type Sku, SkuFlag, SkuType, SortOrderType, type SoundboardCreateOptions, type SoundboardEditOptions, SoundboardManager, type SoundboardSound, type StageInstance, StageInstanceManager, StagePrivacyLevel, type Sticker, StickerFormatType, type StickerItem, type StickerPack, StickerType, type StoreOptions, type StringSelectDef, type Subcommand, type Subscription, SubscriptionStatus, SystemChannelFlag, type Team, type TeamMember, TemplateManager, TextInputBuilder, type ThreadMember, type ThreadMetadata, Tongue, TongueStore, type User, UserFlag, UserFlagsBitField, UserManager, type UserPrimaryGuild, type UserSelectDef, VerificationLevel, VideoQualityMode, VisibilityType, type Voice, type Webhook, WebhookManager, type WebhookMessageCreateOptions, WebhookType, type WelcomeScreen, type WelcomeScreenChannel, buildAutoModRule, buildChannel, buildEmoji, buildEntitlement, buildGuild, buildIntegration, buildInteraction, buildInvite, buildMember, buildMessage, buildRole, buildScheduledEvent, buildStageInstance, buildSticker, buildStickerItem, buildUser, buildVoiceState, buildWebhook, combinePermissions, computeBasePermissions, computeChannelPermissions, defineButton, defineChannelSelect, defineCommand, defineMentionableSelect, defineModal, defineRoleSelect, defineStringSelect, defineSubcommand, defineUserSelect, field, hasAllPermissions, hasAnyPermission, hasPermission, listPermissions, opt, resolveButtonStyle, resolveChannel, resolveGuild, resolveRole, resolveUser, serializeComponent };
|
|
3713
|
+
export { AUDIT_LOG_EVENT_TYPES, ActionRow, ActionRowBuilder, Activity, type ActivityInstance, type ActivityLocation, ActivityLocationKind, type AnyCommandDef, type AnyCommandInput, type Application, type ApplicationCommand, type ApplicationCommandOption, type ApplicationCommandOptionChoice, ApplicationCommandOptionType, ApplicationCommandType, ApplicationEventWebhookStatus, ApplicationFlag, ApplicationIntegrationType, type ApplicationIntegrationTypeConfiguration, ApplicationManager, type ApplicationRoleConnection, type ApplicationRoleConnectionMetadata, ApplicationRoleConnectionMetadataType, type Attachment, AttachmentBuilder, type AttachmentData, AttachmentFlag, type AuditLog, type AuditLogChange, type AuditLogEntry, type AutoModerationAction, type AutoModerationActionMetadata, AutoModerationActionType, AutoModerationEventType, AutoModerationKeywordPresetType, AutoModerationManager, type AutoModerationRule, type AutoModerationTriggerMetadata, AutoModerationTriggerType, type AvatarDecorationData, type AwaitComponentOptions, type AwaitMessagesOptions, BaseInteractionContext, BaseManager, BitField, type BitFieldResolvable, Button, ButtonBuilder, type ButtonDef, ButtonStyle, type ButtonStyleString, CHAMELEON_SELF_MAP, CShard, Chameleon, type ChameleonAPIResult, type ChameleonEvent, type ChameleonEventHandler, ChameleonGateway, type ChameleonGatewayOptions, ChameleonREST, type ChameleonRESTOptions, type ChameleonSelfKey, type Channel, ChannelFlag, ChannelManager, type ChannelMention, type ChannelSelectDef, ChannelType, type ChoiceDef, type ChoiceValue, Client, type ClientOptions, type Collectibles, Collection, CollectorManager, Colors, CommandContext, type CommandDef, CommandDefinitionBuilder, CommandManager, ComponentContext, type ComponentHandler, ComponentManager, ComponentType, type Connection, Container, DISCORD_GATEWAY_OPCODES, DISCORD_PERMISSIONS, DefaultMessageNotificationLevel, type DefaultReaction, type Embed, type EmbedAuthor, EmbedBuilder, type EmbedField, type EmbedFooter, type EmbedImage, type EmbedProvider, EmbedType, type EmbedVideo, type Emoji, type Entitlement, EntitlementManager, EntitlementType, type EventMap, type ExecuteFunction, ExplicitContentFilterLevel, ForumLayoutType, type ForumTag, type GatewayPayload, type GatewayStatus, type Guild, GuildInviteFlag, GuildManager, GuildMemberFlag, GuildNSFWLevel, type GuildScheduledEvent, type GuildScheduledEventEntityMetadata, GuildScheduledEventEntityType, GuildScheduledEventPrivacyLevel, GuildScheduledEventStatus, type GuildScheduledEventUser, type GuildTemplate, type HttpMethod, type IncidentsData, type InstallParams, type Integration, type IntegrationAccount, IntegrationExpireBehavior, IntentBits, type IntentResolvable, type IntentString, Intents, IntentsBitField, type InteractionReplyOptions, type Invite, InviteManager, type InviteMetadata, type InviteStageInstance, InviteTargetType, InviteType, Label, type Lobby, type LobbyMember, LobbyMemberFlag, MFALevel, type Member, MemberManager, type MentionableSelectDef, type Message, type MessageActivity, MessageActivityType, type MessageCall, type MessageComponent, type MessageCreateOptions, MessageFlag, type MessageInteractionMetadata, MessageManager, type MessageReference, MessageReferenceType, type MessageSnapshot, MessageType, type MiddlewareFn, ModalBuilder, ModalContext, type ModalDef, ModalDefinitionBuilder, type ModalFieldDef, type ModalFieldType, type ModalHandler, type Nameplate, type OptionDef, type OptionType, type OptionalAuditEntryInfo, type Overwrite, type PartialChannel, type PartialGuild, type PermissionFlag, PermissionsBitField, type Poll, type PollAnswer, type PollAnswerCount, type PollCreateRequest, type PollMedia, type PollResults, PremiumTier, PremiumType, type Reaction, type ReactionCountDetails, type ResolveModalFieldType, type ResolveModalFields, type ResolveOption, type ResolveOptionType, type ResolveOptions, type Role, RoleManager, type RoleSelectDef, type RoleSubscriptionData, type RoleTags, ScheduledEventManager, Section, SelectMenuBuilder, type SelectOption, Separator, Shard, type ShardOptions, type SharedClientTheme, type Sku, SkuFlag, SkuType, SortOrderType, type SoundboardCreateOptions, type SoundboardEditOptions, SoundboardManager, type SoundboardSound, type StageInstance, StageInstanceManager, StagePrivacyLevel, type Sticker, StickerFormatType, type StickerItem, type StickerPack, StickerType, type StoreOptions, type StringSelectDef, type Subcommand, SubcommandDefinitionBuilder, type SubcommandGroup, SubcommandGroupDefinitionBuilder, type Subscription, SubscriptionStatus, SystemChannelFlag, type Team, type TeamMember, TemplateManager, TextDisplay, TextInputBuilder, type ThreadMember, type ThreadMetadata, Thumbnail, Tongue, TongueStore, type User, UserFlag, UserFlagsBitField, UserManager, type UserPrimaryGuild, type UserSelectDef, VerificationLevel, VideoQualityMode, VisibilityType, type Voice, type Webhook, WebhookManager, type WebhookMessageCreateOptions, WebhookType, type WelcomeScreen, type WelcomeScreenChannel, buildAutoModRule, buildChannel, buildEmoji, buildEntitlement, buildGuild, buildIntegration, buildInteraction, buildInvite, buildMember, buildMessage, buildRole, buildScheduledEvent, buildStageInstance, buildSticker, buildStickerItem, buildUser, buildVoiceState, buildWebhook, choice, choices, combinePermissions, command, computeBasePermissions, computeChannelPermissions, defineButton, defineChannelSelect, defineCommand, defineMentionableSelect, defineModal, defineRoleSelect, defineStringSelect, defineSubcommand, defineSubcommandGroup, defineUserSelect, field, hasAllPermissions, hasAnyPermission, hasPermission, listPermissions, modal, opt, resolveButtonStyle, resolveChannel, resolveGuild, resolveRole, resolveUser, serializeComponent, subcommand, subcommandGroup };
|