@impulsedev/chameleon 3.5.0 → 3.7.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/dist/{builders-WHD6LQWX.js → builders-S6W5F64D.js} +1 -1
- package/dist/{chunk-G4SUOXGV.js → chunk-CGH3AKKX.js} +174 -8
- package/dist/index.d.ts +603 -151
- package/dist/index.js +962 -364
- 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: {
|
|
@@ -914,6 +935,33 @@ interface PollCreateRequest {
|
|
|
914
935
|
interface MessageSnapshot {
|
|
915
936
|
message: Partial<Message>;
|
|
916
937
|
}
|
|
938
|
+
interface MessageSystemPresence {
|
|
939
|
+
any: boolean;
|
|
940
|
+
booster: boolean;
|
|
941
|
+
call: boolean;
|
|
942
|
+
pinned: boolean;
|
|
943
|
+
thread: boolean;
|
|
944
|
+
welcome: boolean;
|
|
945
|
+
}
|
|
946
|
+
interface MessagePresence {
|
|
947
|
+
attachments: boolean;
|
|
948
|
+
components: boolean;
|
|
949
|
+
edited: boolean;
|
|
950
|
+
embeds: boolean;
|
|
951
|
+
forwarded: boolean;
|
|
952
|
+
interaction: boolean;
|
|
953
|
+
mentionHere: boolean;
|
|
954
|
+
mentionEveryone: boolean;
|
|
955
|
+
pinned: boolean;
|
|
956
|
+
poll: boolean;
|
|
957
|
+
reply: boolean;
|
|
958
|
+
stickers: boolean;
|
|
959
|
+
system: MessageSystemPresence;
|
|
960
|
+
thread: boolean;
|
|
961
|
+
tts: boolean;
|
|
962
|
+
voiceMessage: boolean;
|
|
963
|
+
webhook: boolean;
|
|
964
|
+
}
|
|
917
965
|
interface Message {
|
|
918
966
|
id: string;
|
|
919
967
|
channelId: string;
|
|
@@ -955,6 +1003,7 @@ interface Message {
|
|
|
955
1003
|
poll?: Poll;
|
|
956
1004
|
call?: MessageCall;
|
|
957
1005
|
sharedClientTheme?: SharedClientTheme;
|
|
1006
|
+
has: MessagePresence;
|
|
958
1007
|
}
|
|
959
1008
|
type MessageCreateOptions = string | {
|
|
960
1009
|
content?: string;
|
|
@@ -1669,6 +1718,7 @@ type ChameleonAPIResult<T> = {
|
|
|
1669
1718
|
ok: false;
|
|
1670
1719
|
status: number;
|
|
1671
1720
|
code?: number;
|
|
1721
|
+
error: string;
|
|
1672
1722
|
message: string;
|
|
1673
1723
|
raw?: unknown;
|
|
1674
1724
|
};
|
|
@@ -1814,48 +1864,46 @@ declare class ChameleonGateway {
|
|
|
1814
1864
|
private clearReconnectTimer;
|
|
1815
1865
|
}
|
|
1816
1866
|
|
|
1817
|
-
type OptionType = 'string' | 'integer' | 'boolean' | 'user' | 'channel' | 'role' | 'number';
|
|
1867
|
+
type OptionType = 'string' | 'integer' | 'boolean' | 'user' | 'channel' | 'role' | 'mentionable' | 'number' | 'attachment';
|
|
1868
|
+
type ChoiceValue = string | number;
|
|
1869
|
+
interface ChoiceDef<V extends ChoiceValue = ChoiceValue> {
|
|
1870
|
+
name: string;
|
|
1871
|
+
value: V;
|
|
1872
|
+
}
|
|
1818
1873
|
interface OptionDef<T extends OptionType, R extends boolean> {
|
|
1819
1874
|
type: T;
|
|
1820
1875
|
description: string;
|
|
1821
1876
|
required: R;
|
|
1822
1877
|
min?: number;
|
|
1823
1878
|
max?: number;
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1879
|
+
minLength?: number;
|
|
1880
|
+
maxLength?: number;
|
|
1881
|
+
choices?: readonly ChoiceDef[];
|
|
1882
|
+
channelTypes?: number[];
|
|
1828
1883
|
}
|
|
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;
|
|
1884
|
+
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
1885
|
type ResolveOption<O extends OptionDef<OptionType, boolean>> = O['required'] extends true ? ResolveOptionType<O['type']> : ResolveOptionType<O['type']> | undefined;
|
|
1831
1886
|
type ResolveOptions<O extends Record<string, OptionDef<OptionType, boolean>>> = {
|
|
1832
1887
|
[K in keyof O]: ResolveOption<O[K]>;
|
|
1833
1888
|
};
|
|
1889
|
+
declare function choice<V extends ChoiceValue>(name: string, value: V): ChoiceDef<V>;
|
|
1890
|
+
declare function choices<const T extends readonly ChoiceDef[]>(...items: T): T;
|
|
1834
1891
|
declare const opt: {
|
|
1835
1892
|
string: <R extends boolean = false>(description: string, options?: {
|
|
1836
1893
|
required?: R;
|
|
1837
|
-
choices?:
|
|
1838
|
-
name: string;
|
|
1839
|
-
value: string;
|
|
1840
|
-
}[];
|
|
1894
|
+
choices?: readonly ChoiceDef<string>[];
|
|
1841
1895
|
minLength?: number;
|
|
1842
1896
|
maxLength?: number;
|
|
1843
1897
|
}) => OptionDef<"string", R>;
|
|
1844
1898
|
integer: <R extends boolean = false>(description: string, options?: {
|
|
1845
1899
|
required?: R;
|
|
1846
|
-
choices?:
|
|
1847
|
-
name: string;
|
|
1848
|
-
value: number;
|
|
1849
|
-
}[];
|
|
1900
|
+
choices?: readonly ChoiceDef<number>[];
|
|
1850
1901
|
min?: number;
|
|
1851
1902
|
max?: number;
|
|
1852
1903
|
}) => OptionDef<"integer", R>;
|
|
1853
1904
|
number: <R extends boolean = false>(description: string, options?: {
|
|
1854
1905
|
required?: R;
|
|
1855
|
-
choices?:
|
|
1856
|
-
name: string;
|
|
1857
|
-
value: number;
|
|
1858
|
-
}[];
|
|
1906
|
+
choices?: readonly ChoiceDef<number>[];
|
|
1859
1907
|
min?: number;
|
|
1860
1908
|
max?: number;
|
|
1861
1909
|
}) => OptionDef<"number", R>;
|
|
@@ -1867,80 +1915,36 @@ declare const opt: {
|
|
|
1867
1915
|
}) => OptionDef<"user", R>;
|
|
1868
1916
|
channel: <R extends boolean = false>(description: string, options?: {
|
|
1869
1917
|
required?: R;
|
|
1918
|
+
channelTypes?: number[];
|
|
1870
1919
|
}) => OptionDef<"channel", R>;
|
|
1871
1920
|
role: <R extends boolean = false>(description: string, options?: {
|
|
1872
1921
|
required?: R;
|
|
1873
1922
|
}) => OptionDef<"role", R>;
|
|
1923
|
+
mentionable: <R extends boolean = false>(description: string, options?: {
|
|
1924
|
+
required?: R;
|
|
1925
|
+
}) => OptionDef<"mentionable", R>;
|
|
1926
|
+
attachment: <R extends boolean = false>(description: string, options?: {
|
|
1927
|
+
required?: R;
|
|
1928
|
+
}) => OptionDef<"attachment", R>;
|
|
1874
1929
|
};
|
|
1875
1930
|
|
|
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;
|
|
1931
|
+
declare class ComponentContext<Values = unknown, Fields = unknown> extends BaseInteractionContext {
|
|
1932
|
+
customId: string;
|
|
1933
|
+
message?: Record<string, unknown>;
|
|
1934
|
+
values: Values;
|
|
1935
|
+
fields: Fields;
|
|
1901
1936
|
constructor(client: Client, raw: Record<string, unknown>, user: User, guild?: Guild | {
|
|
1902
1937
|
id: string;
|
|
1903
1938
|
}, channel?: Channel | {
|
|
1904
1939
|
id: string;
|
|
1905
1940
|
});
|
|
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>;
|
|
1941
|
+
deferUpdate(): Promise<void>;
|
|
1942
|
+
update(payload: InteractionReplyOptions): Promise<void>;
|
|
1930
1943
|
}
|
|
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
1944
|
|
|
1942
|
-
declare class ModalContext extends BaseInteractionContext {
|
|
1945
|
+
declare class ModalContext<Fields = Record<string, unknown>> extends BaseInteractionContext {
|
|
1943
1946
|
customId: string;
|
|
1947
|
+
attachments: Record<string, Attachment[]>;
|
|
1944
1948
|
private _fields;
|
|
1945
1949
|
constructor(client: Client, raw: Record<string, unknown>, user: User, guild?: Guild | {
|
|
1946
1950
|
id: string;
|
|
@@ -1948,48 +1952,7 @@ declare class ModalContext extends BaseInteractionContext {
|
|
|
1948
1952
|
id: string;
|
|
1949
1953
|
});
|
|
1950
1954
|
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;
|
|
1955
|
+
get fields(): Fields;
|
|
1993
1956
|
}
|
|
1994
1957
|
|
|
1995
1958
|
declare enum COMPONENT_TYPES {
|
|
@@ -2000,7 +1963,19 @@ declare enum COMPONENT_TYPES {
|
|
|
2000
1963
|
USER_SELECT = 5,
|
|
2001
1964
|
ROLE_SELECT = 6,
|
|
2002
1965
|
MENTIONABLE_SELECT = 7,
|
|
2003
|
-
CHANNEL_SELECT = 8
|
|
1966
|
+
CHANNEL_SELECT = 8,
|
|
1967
|
+
SECTION = 9,
|
|
1968
|
+
TEXT_DISPLAY = 10,
|
|
1969
|
+
THUMBNAIL = 11,
|
|
1970
|
+
MEDIA_GALLERY = 12,
|
|
1971
|
+
FILE = 13,
|
|
1972
|
+
SEPARATOR = 14,
|
|
1973
|
+
CONTAINER = 17,
|
|
1974
|
+
LABEL = 18,
|
|
1975
|
+
FILE_UPLOAD = 19,
|
|
1976
|
+
RADIO_GROUP = 21,
|
|
1977
|
+
CHECKBOX_GROUP = 22,
|
|
1978
|
+
CHECKBOX = 23
|
|
2004
1979
|
}
|
|
2005
1980
|
declare enum TEXT_INPUT_STYLES {
|
|
2006
1981
|
SHORT = 1,
|
|
@@ -2009,19 +1984,67 @@ declare enum TEXT_INPUT_STYLES {
|
|
|
2009
1984
|
|
|
2010
1985
|
type ButtonStyleString = 'primary' | 'secondary' | 'success' | 'danger' | 'link' | 'premium';
|
|
2011
1986
|
interface ButtonDef {
|
|
1987
|
+
/** Custom ID returned in the interaction payload for non-link buttons */
|
|
2012
1988
|
customId?: string;
|
|
1989
|
+
/** External URL opened by a link button */
|
|
2013
1990
|
url?: string;
|
|
1991
|
+
/** Visible text rendered on the button */
|
|
2014
1992
|
label?: string;
|
|
1993
|
+
/** Discord button style as either a readable string or raw numeric value */
|
|
2015
1994
|
style: ButtonStyleString | number;
|
|
1995
|
+
/** Whether the button should be rendered as disabled */
|
|
2016
1996
|
disabled?: boolean;
|
|
1997
|
+
/** Optional emoji rendered next to the label */
|
|
2017
1998
|
emoji?: Partial<Emoji>;
|
|
1999
|
+
/** Premium SKU ID used by Discord premium buttons */
|
|
2018
2000
|
skuId?: string;
|
|
2001
|
+
/** Optional handler executed when the component interaction is received */
|
|
2019
2002
|
execute?: (ctx: ComponentContext) => void | Promise<void>;
|
|
2020
2003
|
}
|
|
2004
|
+
/**
|
|
2005
|
+
* Normalize a human-readable button style into the numeric Discord API value
|
|
2006
|
+
* Accepts either a style name such as `'primary'` or a raw numeric style
|
|
2007
|
+
*/
|
|
2021
2008
|
declare function resolveButtonStyle(style: string | number): number;
|
|
2009
|
+
/**
|
|
2010
|
+
* Define a reusable button component handler
|
|
2011
|
+
* The returned object can be used in `ActionRow.of(...)` or in higher-level builders that accept button definitions
|
|
2012
|
+
*
|
|
2013
|
+
* @param def Button configuration including label, style, IDs and optional execute handler
|
|
2014
|
+
*/
|
|
2022
2015
|
declare function defineButton(def: ButtonDef): ButtonDef & {
|
|
2023
2016
|
type: 'button';
|
|
2024
2017
|
};
|
|
2018
|
+
declare const Button: {
|
|
2019
|
+
/** Build a reusable button definition that can be used in both V1 action rows and V2 accessories */
|
|
2020
|
+
of: (def: ButtonDef) => ButtonDef & {
|
|
2021
|
+
type: "button";
|
|
2022
|
+
};
|
|
2023
|
+
/** @param customId Component custom ID sent back in the interaction payload @param label Visible button text */
|
|
2024
|
+
primary: (customId: string, label: string) => ButtonDef & {
|
|
2025
|
+
type: "button";
|
|
2026
|
+
};
|
|
2027
|
+
/** @param customId Component custom ID sent back in the interaction payload @param label Visible button text */
|
|
2028
|
+
secondary: (customId: string, label: string) => ButtonDef & {
|
|
2029
|
+
type: "button";
|
|
2030
|
+
};
|
|
2031
|
+
/** @param customId Component custom ID sent back in the interaction payload @param label Visible button text */
|
|
2032
|
+
success: (customId: string, label: string) => ButtonDef & {
|
|
2033
|
+
type: "button";
|
|
2034
|
+
};
|
|
2035
|
+
/** @param customId Component custom ID sent back in the interaction payload @param label Visible button text */
|
|
2036
|
+
danger: (customId: string, label: string) => ButtonDef & {
|
|
2037
|
+
type: "button";
|
|
2038
|
+
};
|
|
2039
|
+
/** @param url Destination URL opened by the button @param label Visible button text */
|
|
2040
|
+
link: (url: string, label: string) => ButtonDef & {
|
|
2041
|
+
type: "button";
|
|
2042
|
+
};
|
|
2043
|
+
/** @param skuId Premium SKU ID used by Discord premium buttons @param label Visible button text */
|
|
2044
|
+
premium: (skuId: string, label: string) => ButtonDef & {
|
|
2045
|
+
type: "button";
|
|
2046
|
+
};
|
|
2047
|
+
};
|
|
2025
2048
|
interface StringSelectDef {
|
|
2026
2049
|
customId: string;
|
|
2027
2050
|
options: SelectOption[];
|
|
@@ -2079,48 +2102,421 @@ interface MentionableSelectDef {
|
|
|
2079
2102
|
declare function defineMentionableSelect(def: MentionableSelectDef): MentionableSelectDef & {
|
|
2080
2103
|
type: 'mentionable_select';
|
|
2081
2104
|
};
|
|
2082
|
-
|
|
2105
|
+
type ModalFieldType = TEXT_INPUT_STYLES | 19 | 21 | 22 | 23;
|
|
2106
|
+
interface ModalFieldDef<Required extends boolean = true, T extends ModalFieldType = ModalFieldType> {
|
|
2083
2107
|
id: string;
|
|
2084
|
-
type:
|
|
2085
|
-
label
|
|
2108
|
+
type: T;
|
|
2109
|
+
label?: string;
|
|
2086
2110
|
required?: Required;
|
|
2087
2111
|
minLength?: number;
|
|
2088
2112
|
maxLength?: number;
|
|
2089
2113
|
placeholder?: string;
|
|
2090
|
-
value?: string;
|
|
2114
|
+
value?: string | boolean | string[];
|
|
2115
|
+
options?: SelectOption[];
|
|
2116
|
+
[key: string]: any;
|
|
2091
2117
|
}
|
|
2092
2118
|
declare const field: {
|
|
2119
|
+
/**
|
|
2120
|
+
* Create a single-line text input field for a modal
|
|
2121
|
+
* @param id Field ID used as the key inside `ctx.fields`
|
|
2122
|
+
* @param label Visible field label shown in the modal
|
|
2123
|
+
* @param options Extra validation and UX settings for the text input
|
|
2124
|
+
*/
|
|
2093
2125
|
short: <ID extends string, Req extends boolean = true>(id: ID, label: string, options?: {
|
|
2094
2126
|
required?: Req;
|
|
2095
2127
|
minLength?: number;
|
|
2096
2128
|
maxLength?: number;
|
|
2097
2129
|
placeholder?: string;
|
|
2098
2130
|
value?: string;
|
|
2099
|
-
}) => ModalFieldDef<Req> & {
|
|
2131
|
+
}) => ModalFieldDef<Req, TEXT_INPUT_STYLES.SHORT> & {
|
|
2100
2132
|
id: ID;
|
|
2101
2133
|
};
|
|
2134
|
+
/**
|
|
2135
|
+
* Create a multi-line text input field for a modal
|
|
2136
|
+
* @param id Field ID used as the key inside `ctx.fields`
|
|
2137
|
+
* @param label Visible field label shown in the modal
|
|
2138
|
+
* @param options Extra validation and UX settings for the paragraph input
|
|
2139
|
+
*/
|
|
2102
2140
|
paragraph: <ID extends string, Req extends boolean = true>(id: ID, label: string, options?: {
|
|
2103
2141
|
required?: Req;
|
|
2104
2142
|
minLength?: number;
|
|
2105
2143
|
maxLength?: number;
|
|
2106
2144
|
placeholder?: string;
|
|
2107
2145
|
value?: string;
|
|
2108
|
-
}) => ModalFieldDef<Req> & {
|
|
2146
|
+
}) => ModalFieldDef<Req, TEXT_INPUT_STYLES.PARAGRAPH> & {
|
|
2147
|
+
id: ID;
|
|
2148
|
+
};
|
|
2149
|
+
/**
|
|
2150
|
+
* Create a boolean checkbox field for a modal
|
|
2151
|
+
* @param id Field ID used as the key inside `ctx.fields`
|
|
2152
|
+
* @param label Visible field label shown in the modal
|
|
2153
|
+
* @param options Checkbox settings such as `required` and default `value`
|
|
2154
|
+
*/
|
|
2155
|
+
checkbox: <ID extends string, Req extends boolean = true>(id: ID, label: string, options?: {
|
|
2156
|
+
required?: Req;
|
|
2157
|
+
value?: boolean;
|
|
2158
|
+
}) => ModalFieldDef<Req, 23> & {
|
|
2159
|
+
id: ID;
|
|
2160
|
+
};
|
|
2161
|
+
/**
|
|
2162
|
+
* Create a multi-select checkbox group field for a modal
|
|
2163
|
+
* @param id Field ID used as the key inside `ctx.fields`
|
|
2164
|
+
* @param label Visible field label shown in the modal
|
|
2165
|
+
* @param options Available choices and selection limits
|
|
2166
|
+
*/
|
|
2167
|
+
checkboxGroup: <ID extends string, Req extends boolean = true>(id: ID, label: string, options: {
|
|
2168
|
+
options: SelectOption[];
|
|
2169
|
+
required?: Req;
|
|
2170
|
+
minValues?: number;
|
|
2171
|
+
maxValues?: number;
|
|
2172
|
+
}) => ModalFieldDef<Req, 22> & {
|
|
2173
|
+
id: ID;
|
|
2174
|
+
};
|
|
2175
|
+
/**
|
|
2176
|
+
* Create a single-choice radio group field for a modal
|
|
2177
|
+
* @param id Field ID used as the key inside `ctx.fields`
|
|
2178
|
+
* @param label Visible field label shown in the modal
|
|
2179
|
+
* @param options Available choices for the radio group
|
|
2180
|
+
*/
|
|
2181
|
+
radioGroup: <ID extends string, Req extends boolean = true>(id: ID, label: string, options: {
|
|
2182
|
+
options: SelectOption[];
|
|
2183
|
+
required?: Req;
|
|
2184
|
+
}) => ModalFieldDef<Req, 21> & {
|
|
2185
|
+
id: ID;
|
|
2186
|
+
};
|
|
2187
|
+
/**
|
|
2188
|
+
* Create a file upload field for a modal
|
|
2189
|
+
* Submitted files are available in `ctx.attachments[id]`
|
|
2190
|
+
* @param id Field ID used as the key inside `ctx.fields` and `ctx.attachments`
|
|
2191
|
+
* @param label Visible field label shown in the modal
|
|
2192
|
+
* @param options Upload field settings such as `required`
|
|
2193
|
+
*/
|
|
2194
|
+
fileUpload: <ID extends string, Req extends boolean = true>(id: ID, label: string, options?: {
|
|
2195
|
+
required?: Req;
|
|
2196
|
+
}) => ModalFieldDef<Req, 19> & {
|
|
2109
2197
|
id: ID;
|
|
2110
2198
|
};
|
|
2111
2199
|
};
|
|
2112
|
-
type
|
|
2113
|
-
|
|
2200
|
+
type ResolveModalFieldType<K extends ModalFieldDef<any, any>> = K['type'] extends 23 ? boolean : K['type'] extends 19 ? string[] : K['type'] extends 22 ? string[] : string;
|
|
2201
|
+
type ResolveModalFields<F extends ReadonlyArray<ModalFieldDef<boolean, any>>> = {
|
|
2202
|
+
[K in F[number] as K['id']]: K['required'] extends false ? ResolveModalFieldType<K> | undefined : ResolveModalFieldType<K>;
|
|
2114
2203
|
};
|
|
2115
|
-
interface ModalDef<F extends ReadonlyArray<ModalFieldDef<boolean>>> {
|
|
2204
|
+
interface ModalDef<F extends ReadonlyArray<ModalFieldDef<boolean, any>>> {
|
|
2116
2205
|
customId: string;
|
|
2117
2206
|
title: string;
|
|
2118
2207
|
fields: F;
|
|
2119
|
-
execute: (ctx:
|
|
2208
|
+
execute: (ctx: ModalContext<ResolveModalFields<F>>) => void | Promise<void>;
|
|
2120
2209
|
}
|
|
2121
|
-
declare function defineModal<F extends ReadonlyArray<ModalFieldDef<boolean>>>(def: ModalDef<F>): ModalDef<F> & {
|
|
2210
|
+
declare function defineModal<F extends ReadonlyArray<ModalFieldDef<boolean, any>>>(def: ModalDef<F>): ModalDef<F> & {
|
|
2122
2211
|
type: 'modal';
|
|
2123
2212
|
};
|
|
2213
|
+
declare class ModalDefinitionBuilder<F extends ReadonlyArray<ModalFieldDef<boolean, any>> = []> {
|
|
2214
|
+
private readonly customId;
|
|
2215
|
+
private readonly title;
|
|
2216
|
+
private readonly fieldsDef;
|
|
2217
|
+
constructor(customId: string, title: string, fieldsDef?: F);
|
|
2218
|
+
/**
|
|
2219
|
+
* Append one or more fields to the modal definition
|
|
2220
|
+
* The resulting builder keeps full type information, so added field IDs become available in `ctx.fields`
|
|
2221
|
+
* @param fields Fields to add to the modal
|
|
2222
|
+
*/
|
|
2223
|
+
add<NewFields extends ReadonlyArray<ModalFieldDef<boolean, any>>>(...fields: NewFields): ModalDefinitionBuilder<[...F, ...NewFields]>;
|
|
2224
|
+
/**
|
|
2225
|
+
* Finalize the modal definition and attach its submit handler
|
|
2226
|
+
* The handler receives a strongly-typed `ctx.fields` object derived from the fields added to this builder
|
|
2227
|
+
* @param execute Modal submit handler
|
|
2228
|
+
*/
|
|
2229
|
+
execute(execute: (ctx: ModalContext<ResolveModalFields<F>>) => void | Promise<void>): ModalDef<F> & {
|
|
2230
|
+
type: "modal";
|
|
2231
|
+
};
|
|
2232
|
+
handle(execute: (ctx: ModalContext<ResolveModalFields<F>>) => void | Promise<void>): ModalDef<F> & {
|
|
2233
|
+
type: "modal";
|
|
2234
|
+
};
|
|
2235
|
+
}
|
|
2236
|
+
/**
|
|
2237
|
+
* Start a fluent modal definition
|
|
2238
|
+
* @param customId Custom ID returned when the modal is submitted
|
|
2239
|
+
* @param title Modal title shown in the Discord client
|
|
2240
|
+
*/
|
|
2241
|
+
declare function modal(customId: string, title: string): ModalDefinitionBuilder<[]>;
|
|
2242
|
+
|
|
2243
|
+
type InteractionReplyOptions = string | {
|
|
2244
|
+
content?: string;
|
|
2245
|
+
embeds?: (Embed | {
|
|
2246
|
+
toJSON(): Record<string, unknown>;
|
|
2247
|
+
} | Record<string, unknown>)[];
|
|
2248
|
+
components?: (MessageComponent | {
|
|
2249
|
+
build?(): MessageComponent;
|
|
2250
|
+
} | {
|
|
2251
|
+
toJSON(): Record<string, unknown>;
|
|
2252
|
+
} | Record<string, unknown>)[];
|
|
2253
|
+
ephemeral?: boolean;
|
|
2254
|
+
flags?: number;
|
|
2255
|
+
};
|
|
2256
|
+
declare class BaseInteractionContext {
|
|
2257
|
+
user: User;
|
|
2258
|
+
guild?: Guild | {
|
|
2259
|
+
id: string;
|
|
2260
|
+
} | undefined;
|
|
2261
|
+
channel?: Channel | {
|
|
2262
|
+
id: string;
|
|
2263
|
+
} | undefined;
|
|
2264
|
+
interactionId: string;
|
|
2265
|
+
interactionToken: string;
|
|
2266
|
+
protected _client: Client;
|
|
2267
|
+
protected _deferred: boolean;
|
|
2268
|
+
protected _replied: boolean;
|
|
2269
|
+
constructor(client: Client, raw: Record<string, unknown>, user: User, guild?: Guild | {
|
|
2270
|
+
id: string;
|
|
2271
|
+
}, channel?: Channel | {
|
|
2272
|
+
id: string;
|
|
2273
|
+
});
|
|
2274
|
+
get client(): Client<readonly IntentResolvable[]>;
|
|
2275
|
+
get replied(): boolean;
|
|
2276
|
+
get deferred(): boolean;
|
|
2277
|
+
protected _assertOk(result: ChameleonAPIResult<unknown>, action: string): void;
|
|
2278
|
+
protected _resolvePayload(payload: InteractionReplyOptions): Record<string, unknown>;
|
|
2279
|
+
protected _serializeModalField(field: ModalFieldDef<boolean, any>): Record<string, unknown>;
|
|
2280
|
+
reply(payload: InteractionReplyOptions): Promise<void>;
|
|
2281
|
+
defer(options?: {
|
|
2282
|
+
ephemeral?: boolean;
|
|
2283
|
+
}): Promise<void>;
|
|
2284
|
+
followUp(payload: InteractionReplyOptions): Promise<void>;
|
|
2285
|
+
showModal(modal: Record<string, unknown> | (ModalDef<ReadonlyArray<ModalFieldDef<boolean, any>>> & {
|
|
2286
|
+
type: 'modal';
|
|
2287
|
+
})): Promise<void>;
|
|
2288
|
+
}
|
|
2289
|
+
declare class CommandContext<Options = Record<string, unknown>> extends BaseInteractionContext {
|
|
2290
|
+
options: Options;
|
|
2291
|
+
constructor(client: Client, rawInteraction: Record<string, unknown>, parsedOptions: Options, user: User, guild?: Guild | {
|
|
2292
|
+
id: string;
|
|
2293
|
+
}, channel?: Channel | {
|
|
2294
|
+
id: string;
|
|
2295
|
+
});
|
|
2296
|
+
}
|
|
2297
|
+
|
|
2298
|
+
type BitFieldResolvable = string | number | bigint | BitField | BitFieldResolvable[];
|
|
2299
|
+
declare class BitField {
|
|
2300
|
+
static FLAGS: Record<string, bigint>;
|
|
2301
|
+
bitfield: bigint;
|
|
2302
|
+
constructor(bits?: BitFieldResolvable);
|
|
2303
|
+
has(bit: BitFieldResolvable): boolean;
|
|
2304
|
+
any(bit: BitFieldResolvable): boolean;
|
|
2305
|
+
add(...bits: BitFieldResolvable[]): this;
|
|
2306
|
+
remove(...bits: BitFieldResolvable[]): this;
|
|
2307
|
+
toArray(): string[];
|
|
2308
|
+
serialize(): Record<string, boolean>;
|
|
2309
|
+
equals(other: BitFieldResolvable): boolean;
|
|
2310
|
+
freeze(): Readonly<this>;
|
|
2311
|
+
toString(): string;
|
|
2312
|
+
toJSON(): string;
|
|
2313
|
+
static resolve(bit: BitFieldResolvable): bigint;
|
|
2314
|
+
}
|
|
2315
|
+
|
|
2316
|
+
type CommandOptionMap = Record<string, OptionDef<OptionType, boolean>>;
|
|
2317
|
+
type SubcommandMap = Record<string, Subcommand<CommandOptionMap>>;
|
|
2318
|
+
type SubcommandGroupMap = Record<string, SubcommandGroup<SubcommandMap>>;
|
|
2319
|
+
type ExecuteFunction<O extends Record<string, OptionDef<OptionType, boolean>>> = (ctx: CommandContext<ResolveOptions<O>>) => void | Promise<void>;
|
|
2320
|
+
interface Subcommand<O extends CommandOptionMap = Record<string, never>> {
|
|
2321
|
+
description: string;
|
|
2322
|
+
options?: O;
|
|
2323
|
+
execute: ExecuteFunction<O>;
|
|
2324
|
+
}
|
|
2325
|
+
declare function defineSubcommand<O extends CommandOptionMap>(def: Subcommand<O>): Subcommand<O>;
|
|
2326
|
+
interface SubcommandGroup<S extends SubcommandMap = Record<string, never>> {
|
|
2327
|
+
description: string;
|
|
2328
|
+
subcommands: S;
|
|
2329
|
+
}
|
|
2330
|
+
declare function defineSubcommandGroup<S extends SubcommandMap>(def: SubcommandGroup<S>): SubcommandGroup<S>;
|
|
2331
|
+
type CommandDef<O extends CommandOptionMap = Record<string, never>, S extends SubcommandMap | SubcommandGroupMap = Record<string, never>> = {
|
|
2332
|
+
name: string;
|
|
2333
|
+
description: string;
|
|
2334
|
+
options?: O;
|
|
2335
|
+
subcommands?: S;
|
|
2336
|
+
defaultMemberPermissions?: string | null;
|
|
2337
|
+
execute?: ExecuteFunction<O>;
|
|
2338
|
+
};
|
|
2339
|
+
type AnyCommandDef = CommandDef<any, any>;
|
|
2340
|
+
type AnyCommandInput = CommandDef<any, any> | CommandDefinitionBuilder<any, any>;
|
|
2341
|
+
declare function defineCommand<O extends CommandOptionMap, S extends SubcommandMap | SubcommandGroupMap>(def: CommandDef<O, S>): CommandDef<O, S>;
|
|
2342
|
+
interface CommandMetadata {
|
|
2343
|
+
defaultMemberPermissions?: string | null;
|
|
2344
|
+
}
|
|
2345
|
+
declare class SubcommandDefinitionBuilder<O extends CommandOptionMap = Record<string, never>> {
|
|
2346
|
+
private readonly description;
|
|
2347
|
+
private readonly optionsDef?;
|
|
2348
|
+
constructor(description: string, optionsDef?: O | undefined);
|
|
2349
|
+
options<NewOptions extends CommandOptionMap>(options: NewOptions): SubcommandDefinitionBuilder<NewOptions>;
|
|
2350
|
+
option<Name extends string, Def extends OptionDef<OptionType, boolean>>(name: Name, definition: Def): SubcommandDefinitionBuilder<O & Record<Name, Def>>;
|
|
2351
|
+
string<Name extends string, R extends boolean = false>(name: Name, description: string, choicesOrOptions?: readonly ChoiceDef<string>[] | {
|
|
2352
|
+
required?: R;
|
|
2353
|
+
choices?: readonly ChoiceDef<string>[];
|
|
2354
|
+
minLength?: number;
|
|
2355
|
+
maxLength?: number;
|
|
2356
|
+
}, maybeOptions?: {
|
|
2357
|
+
required?: R;
|
|
2358
|
+
minLength?: number;
|
|
2359
|
+
maxLength?: number;
|
|
2360
|
+
}): SubcommandDefinitionBuilder<O & Record<Name, OptionDef<'string', R>>>;
|
|
2361
|
+
integer<Name extends string, R extends boolean = false>(name: Name, description: string, choicesOrOptions?: readonly ChoiceDef<number>[] | {
|
|
2362
|
+
required?: R;
|
|
2363
|
+
choices?: readonly ChoiceDef<number>[];
|
|
2364
|
+
min?: number;
|
|
2365
|
+
max?: number;
|
|
2366
|
+
}, maybeOptions?: {
|
|
2367
|
+
required?: R;
|
|
2368
|
+
min?: number;
|
|
2369
|
+
max?: number;
|
|
2370
|
+
}): SubcommandDefinitionBuilder<O & Record<Name, OptionDef<'integer', R>>>;
|
|
2371
|
+
number<Name extends string, R extends boolean = false>(name: Name, description: string, choicesOrOptions?: readonly ChoiceDef<number>[] | {
|
|
2372
|
+
required?: R;
|
|
2373
|
+
choices?: readonly ChoiceDef<number>[];
|
|
2374
|
+
min?: number;
|
|
2375
|
+
max?: number;
|
|
2376
|
+
}, maybeOptions?: {
|
|
2377
|
+
required?: R;
|
|
2378
|
+
min?: number;
|
|
2379
|
+
max?: number;
|
|
2380
|
+
}): SubcommandDefinitionBuilder<O & Record<Name, OptionDef<'number', R>>>;
|
|
2381
|
+
boolean<Name extends string, R extends boolean = false>(name: Name, description: string, options?: {
|
|
2382
|
+
required?: R;
|
|
2383
|
+
}): SubcommandDefinitionBuilder<O & Record<Name, OptionDef<'boolean', R>>>;
|
|
2384
|
+
user<Name extends string, R extends boolean = false>(name: Name, description: string, options?: {
|
|
2385
|
+
required?: R;
|
|
2386
|
+
}): SubcommandDefinitionBuilder<O & Record<Name, OptionDef<'user', R>>>;
|
|
2387
|
+
channel<Name extends string, R extends boolean = false>(name: Name, description: string, options?: {
|
|
2388
|
+
required?: R;
|
|
2389
|
+
channelTypes?: number[];
|
|
2390
|
+
}): SubcommandDefinitionBuilder<O & Record<Name, OptionDef<'channel', R>>>;
|
|
2391
|
+
role<Name extends string, R extends boolean = false>(name: Name, description: string, options?: {
|
|
2392
|
+
required?: R;
|
|
2393
|
+
}): SubcommandDefinitionBuilder<O & Record<Name, OptionDef<'role', R>>>;
|
|
2394
|
+
mentionable<Name extends string, R extends boolean = false>(name: Name, description: string, options?: {
|
|
2395
|
+
required?: R;
|
|
2396
|
+
}): SubcommandDefinitionBuilder<O & Record<Name, OptionDef<'mentionable', R>>>;
|
|
2397
|
+
attachment<Name extends string, R extends boolean = false>(name: Name, description: string, options?: {
|
|
2398
|
+
required?: R;
|
|
2399
|
+
}): SubcommandDefinitionBuilder<O & Record<Name, OptionDef<'attachment', R>>>;
|
|
2400
|
+
execute(execute: ExecuteFunction<O>): Subcommand<O>;
|
|
2401
|
+
handle(execute: ExecuteFunction<O>): Subcommand<O>;
|
|
2402
|
+
}
|
|
2403
|
+
declare class SubcommandGroupDefinitionBuilder<S extends SubcommandMap = Record<string, never>> {
|
|
2404
|
+
private readonly description;
|
|
2405
|
+
private readonly subcommandsDef?;
|
|
2406
|
+
constructor(description: string, subcommandsDef?: S | undefined);
|
|
2407
|
+
subcommands<NewSubcommands extends SubcommandMap>(subcommands: NewSubcommands): SubcommandGroupDefinitionBuilder<NewSubcommands>;
|
|
2408
|
+
subcommand<Name extends string, Sub extends Subcommand<any>>(name: Name, subcommand: Sub): SubcommandGroupDefinitionBuilder<S & Record<Name, Sub>>;
|
|
2409
|
+
toGroup(): SubcommandGroup<S>;
|
|
2410
|
+
build(): SubcommandGroup<S>;
|
|
2411
|
+
}
|
|
2412
|
+
declare class CommandDefinitionBuilder<O extends CommandOptionMap = Record<string, never>, S extends SubcommandMap | SubcommandGroupMap = Record<string, never>> {
|
|
2413
|
+
private readonly name;
|
|
2414
|
+
private readonly description;
|
|
2415
|
+
private readonly optionsDef?;
|
|
2416
|
+
private readonly subcommandsDef?;
|
|
2417
|
+
private readonly metadata;
|
|
2418
|
+
constructor(name: string, description: string, optionsDef?: O | undefined, subcommandsDef?: S | undefined, metadata?: CommandMetadata);
|
|
2419
|
+
options<NewOptions extends CommandOptionMap>(options: NewOptions): CommandDefinitionBuilder<NewOptions, S>;
|
|
2420
|
+
option<Name extends string, Def extends OptionDef<OptionType, boolean>>(name: Name, definition: Def): CommandDefinitionBuilder<O & Record<Name, Def>, S>;
|
|
2421
|
+
string<Name extends string, R extends boolean = false>(name: Name, description: string, choicesOrOptions?: readonly ChoiceDef<string>[] | {
|
|
2422
|
+
required?: R;
|
|
2423
|
+
choices?: readonly ChoiceDef<string>[];
|
|
2424
|
+
minLength?: number;
|
|
2425
|
+
maxLength?: number;
|
|
2426
|
+
}, maybeOptions?: {
|
|
2427
|
+
required?: R;
|
|
2428
|
+
minLength?: number;
|
|
2429
|
+
maxLength?: number;
|
|
2430
|
+
}): CommandDefinitionBuilder<O & Record<Name, OptionDef<'string', R>>, S>;
|
|
2431
|
+
integer<Name extends string, R extends boolean = false>(name: Name, description: string, choicesOrOptions?: readonly ChoiceDef<number>[] | {
|
|
2432
|
+
required?: R;
|
|
2433
|
+
choices?: readonly ChoiceDef<number>[];
|
|
2434
|
+
min?: number;
|
|
2435
|
+
max?: number;
|
|
2436
|
+
}, maybeOptions?: {
|
|
2437
|
+
required?: R;
|
|
2438
|
+
min?: number;
|
|
2439
|
+
max?: number;
|
|
2440
|
+
}): CommandDefinitionBuilder<O & Record<Name, OptionDef<'integer', R>>, S>;
|
|
2441
|
+
number<Name extends string, R extends boolean = false>(name: Name, description: string, choicesOrOptions?: readonly ChoiceDef<number>[] | {
|
|
2442
|
+
required?: R;
|
|
2443
|
+
choices?: readonly ChoiceDef<number>[];
|
|
2444
|
+
min?: number;
|
|
2445
|
+
max?: number;
|
|
2446
|
+
}, maybeOptions?: {
|
|
2447
|
+
required?: R;
|
|
2448
|
+
min?: number;
|
|
2449
|
+
max?: number;
|
|
2450
|
+
}): CommandDefinitionBuilder<O & Record<Name, OptionDef<'number', R>>, S>;
|
|
2451
|
+
boolean<Name extends string, R extends boolean = false>(name: Name, description: string, options?: {
|
|
2452
|
+
required?: R;
|
|
2453
|
+
}): CommandDefinitionBuilder<O & Record<Name, OptionDef<'boolean', R>>, S>;
|
|
2454
|
+
user<Name extends string, R extends boolean = false>(name: Name, description: string, options?: {
|
|
2455
|
+
required?: R;
|
|
2456
|
+
}): CommandDefinitionBuilder<O & Record<Name, OptionDef<'user', R>>, S>;
|
|
2457
|
+
channel<Name extends string, R extends boolean = false>(name: Name, description: string, options?: {
|
|
2458
|
+
required?: R;
|
|
2459
|
+
channelTypes?: number[];
|
|
2460
|
+
}): CommandDefinitionBuilder<O & Record<Name, OptionDef<'channel', R>>, S>;
|
|
2461
|
+
role<Name extends string, R extends boolean = false>(name: Name, description: string, options?: {
|
|
2462
|
+
required?: R;
|
|
2463
|
+
}): CommandDefinitionBuilder<O & Record<Name, OptionDef<'role', R>>, S>;
|
|
2464
|
+
mentionable<Name extends string, R extends boolean = false>(name: Name, description: string, options?: {
|
|
2465
|
+
required?: R;
|
|
2466
|
+
}): CommandDefinitionBuilder<O & Record<Name, OptionDef<'mentionable', R>>, S>;
|
|
2467
|
+
attachment<Name extends string, R extends boolean = false>(name: Name, description: string, options?: {
|
|
2468
|
+
required?: R;
|
|
2469
|
+
}): CommandDefinitionBuilder<O & Record<Name, OptionDef<'attachment', R>>, S>;
|
|
2470
|
+
subcommands<NewSubcommands extends SubcommandMap | SubcommandGroupMap>(subcommands: NewSubcommands): CommandDefinitionBuilder<O, NewSubcommands>;
|
|
2471
|
+
subcommand<Name extends string, Sub extends Subcommand<any>>(name: Name, subcommand: Sub): CommandDefinitionBuilder<O, S & Record<Name, Sub>>;
|
|
2472
|
+
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>>;
|
|
2473
|
+
setPermissions(permissions: BitFieldResolvable | null): CommandDefinitionBuilder<O, S>;
|
|
2474
|
+
setDefaultMemberPermissions(permissions: BitFieldResolvable | null): CommandDefinitionBuilder<O, S>;
|
|
2475
|
+
execute(execute: ExecuteFunction<O>): CommandDef<O, S>;
|
|
2476
|
+
handle(execute: ExecuteFunction<O>): CommandDef<O, S>;
|
|
2477
|
+
toCommand(): CommandDef<O, S>;
|
|
2478
|
+
build(): CommandDef<O, S>;
|
|
2479
|
+
}
|
|
2480
|
+
/**
|
|
2481
|
+
* Start a fluent command definition
|
|
2482
|
+
*/
|
|
2483
|
+
declare function command(name: string, description: string): CommandDefinitionBuilder<Record<string, never>, Record<string, never>>;
|
|
2484
|
+
/**
|
|
2485
|
+
* Start a fluent subcommand definition
|
|
2486
|
+
*/
|
|
2487
|
+
declare function subcommand(description: string): SubcommandDefinitionBuilder<Record<string, never>>;
|
|
2488
|
+
/**
|
|
2489
|
+
* Start a fluent subcommand group definition
|
|
2490
|
+
*/
|
|
2491
|
+
declare function subcommandGroup(description: string): SubcommandGroupDefinitionBuilder<Record<string, never>>;
|
|
2492
|
+
|
|
2493
|
+
interface ComponentHandler {
|
|
2494
|
+
type?: string;
|
|
2495
|
+
customId?: string | RegExp;
|
|
2496
|
+
execute?: (ctx: ComponentContext) => unknown | Promise<unknown>;
|
|
2497
|
+
}
|
|
2498
|
+
interface ModalHandler<Fields = Record<string, unknown>> {
|
|
2499
|
+
customId: string | RegExp;
|
|
2500
|
+
execute: (ctx: ModalContext<Fields>) => unknown | Promise<unknown>;
|
|
2501
|
+
}
|
|
2502
|
+
declare class CommandManager {
|
|
2503
|
+
private _commands;
|
|
2504
|
+
private _components;
|
|
2505
|
+
private _modals;
|
|
2506
|
+
private _client;
|
|
2507
|
+
constructor(client: Client);
|
|
2508
|
+
register(...commands: AnyCommandInput[]): void;
|
|
2509
|
+
registerGuild(guildId: string, ...commands: AnyCommandInput[]): void;
|
|
2510
|
+
registerComponent(handler: ComponentHandler): void;
|
|
2511
|
+
registerModal<F extends ReadonlyArray<ModalFieldDef<boolean, any>>>(handler: ModalDef<F> | ModalHandler<ResolveModalFields<F>>): void;
|
|
2512
|
+
load(directory: string): Promise<void>;
|
|
2513
|
+
private _deployCommands;
|
|
2514
|
+
private _transformCommand;
|
|
2515
|
+
private _normalizeCommand;
|
|
2516
|
+
handleInteraction(raw: Record<string, unknown>): Promise<void>;
|
|
2517
|
+
private _handleComponentInteraction;
|
|
2518
|
+
private _handleModalInteraction;
|
|
2519
|
+
}
|
|
2124
2520
|
|
|
2125
2521
|
type ComponentInput = (ButtonDef & {
|
|
2126
2522
|
type: 'button';
|
|
@@ -2144,6 +2540,80 @@ declare const ActionRow: {
|
|
|
2144
2540
|
};
|
|
2145
2541
|
};
|
|
2146
2542
|
|
|
2543
|
+
type ButtonLike = ButtonDef & {
|
|
2544
|
+
type: 'button';
|
|
2545
|
+
};
|
|
2546
|
+
type JSONEncodable = {
|
|
2547
|
+
toJSON(): Record<string, unknown>;
|
|
2548
|
+
};
|
|
2549
|
+
type V2RawComponent = {
|
|
2550
|
+
type: number;
|
|
2551
|
+
[key: string]: unknown;
|
|
2552
|
+
};
|
|
2553
|
+
type V2ComponentLike = V2RawComponent | JSONEncodable | ButtonLike;
|
|
2554
|
+
declare class SectionBuilder {
|
|
2555
|
+
private readonly data;
|
|
2556
|
+
constructor(components: V2ComponentLike[], accessory?: V2ComponentLike);
|
|
2557
|
+
accessory(accessory: V2ComponentLike): this;
|
|
2558
|
+
toJSON(): {
|
|
2559
|
+
accessory?: Record<string, unknown>;
|
|
2560
|
+
components: Record<string, unknown>[];
|
|
2561
|
+
};
|
|
2562
|
+
}
|
|
2563
|
+
declare const TextDisplay: {
|
|
2564
|
+
of: (content: string) => {
|
|
2565
|
+
type: COMPONENT_TYPES;
|
|
2566
|
+
content: string;
|
|
2567
|
+
};
|
|
2568
|
+
};
|
|
2569
|
+
declare const Thumbnail: {
|
|
2570
|
+
of: (url: string, description?: string, spoiler?: boolean) => {
|
|
2571
|
+
type: COMPONENT_TYPES;
|
|
2572
|
+
media: {
|
|
2573
|
+
url: string;
|
|
2574
|
+
};
|
|
2575
|
+
description: string | undefined;
|
|
2576
|
+
spoiler: boolean | undefined;
|
|
2577
|
+
};
|
|
2578
|
+
};
|
|
2579
|
+
declare const Separator: {
|
|
2580
|
+
of: (spacing?: number, divider?: boolean) => {
|
|
2581
|
+
type: COMPONENT_TYPES;
|
|
2582
|
+
spacing: number | undefined;
|
|
2583
|
+
divider: boolean | undefined;
|
|
2584
|
+
};
|
|
2585
|
+
};
|
|
2586
|
+
declare const Section: {
|
|
2587
|
+
/**
|
|
2588
|
+
* Section builder
|
|
2589
|
+
* @param components Child components rendered inside the section body
|
|
2590
|
+
* @param accessory Optional accessory rendered on the side of the section
|
|
2591
|
+
*/
|
|
2592
|
+
of: (components: V2ComponentLike[], accessory?: V2ComponentLike) => SectionBuilder;
|
|
2593
|
+
/** @param content Text rendered as a single TextDisplay inside the section */
|
|
2594
|
+
text: (content: string) => SectionBuilder;
|
|
2595
|
+
};
|
|
2596
|
+
declare const Container: {
|
|
2597
|
+
/**
|
|
2598
|
+
* Container builder
|
|
2599
|
+
* @param components Child components rendered inside the container
|
|
2600
|
+
* @param spoiler Whether the container should be hidden behind a spoiler
|
|
2601
|
+
*/
|
|
2602
|
+
of: (components: V2ComponentLike[], spoiler?: boolean) => Record<string, unknown>;
|
|
2603
|
+
/** Helper for stacking V2 components vertically without manually creating an array */
|
|
2604
|
+
stack: (...components: V2ComponentLike[]) => Record<string, unknown>;
|
|
2605
|
+
};
|
|
2606
|
+
declare const Label: {
|
|
2607
|
+
/** Wrap a modal field component in a V2 label container */
|
|
2608
|
+
of: (field: ModalFieldDef<boolean, any>) => {
|
|
2609
|
+
type: COMPONENT_TYPES;
|
|
2610
|
+
label: string | undefined;
|
|
2611
|
+
component: {
|
|
2612
|
+
[k: string]: unknown;
|
|
2613
|
+
};
|
|
2614
|
+
};
|
|
2615
|
+
};
|
|
2616
|
+
|
|
2147
2617
|
declare class ComponentManager {
|
|
2148
2618
|
private client;
|
|
2149
2619
|
private handlers;
|
|
@@ -3211,24 +3681,6 @@ declare class Chameleon {
|
|
|
3211
3681
|
};
|
|
3212
3682
|
}
|
|
3213
3683
|
|
|
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
3684
|
declare class PermissionsBitField extends BitField {
|
|
3233
3685
|
static FLAGS: Record<string, bigint>;
|
|
3234
3686
|
static ALL: bigint;
|
|
@@ -3287,4 +3739,4 @@ declare class CShard extends EventEmitter {
|
|
|
3287
3739
|
broadcast(message: unknown): Promise<void[]>;
|
|
3288
3740
|
}
|
|
3289
3741
|
|
|
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 };
|
|
3742
|
+
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 MessagePresence, type MessageReference, MessageReferenceType, type MessageSnapshot, type MessageSystemPresence, 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 };
|