From 86e4d6fc64ad3c47ad5bae0b3f8dbc726309d168 Mon Sep 17 00:00:00 2001 From: CGX <92705245+Cyberghxst@users.noreply.github.com> Date: Thu, 3 Oct 2024 19:41:59 -0600 Subject: [PATCH] Update createFunction types (#659) --- src/index.d.ts | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/src/index.d.ts b/src/index.d.ts index 91d2d5501..e5b94b845 100644 --- a/src/index.d.ts +++ b/src/index.d.ts @@ -386,6 +386,34 @@ export type Interpreter = ( sendMessage?: boolean ) => Promise; +/** + * Available custom function types that FunctionManager supports. + */ +export type CustomFunctionTypes = "aoi.js" | "djs"; + +/** + * Base custom function interface. + */ +export interface BaseCustomFunction { + name: `$${string}`; + type: T; +} + +/** + * Represents the structure for an aoi.js custom function type. + */ +export interface CustomAoiJSFunction extends BaseCustomFunction { + params?: string[]; + code: string; +} + +/** + * Represents the structure for a discord.js custom function type. + */ +export interface CustomDiscordJSFunction extends BaseCustomFunction { + code(d: Data): Promise> | Record +} + // FunctionManager export declare class FunctionManager { client: AoiClient; @@ -395,7 +423,7 @@ export declare class FunctionManager { interpreter: Interpreter; constructor(client: AoiClient); cacheFunctions(): void; - createFunction(data: Array>): void; + createFunction(...data: (CustomAoiJSFunction | CustomDiscordJSFunction)[]): void; findFunctions(code: string): string[]; serializeCode(code: string): string[]; }