Skip to content

Commit

Permalink
Update createFunction types (#659)
Browse files Browse the repository at this point in the history
  • Loading branch information
Cyberghxst authored Oct 4, 2024
1 parent cb2f694 commit 86e4d6f
Showing 1 changed file with 29 additions and 1 deletion.
30 changes: 29 additions & 1 deletion src/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,34 @@ export type Interpreter = (
sendMessage?: boolean
) => Promise<InterpreterReturn>;

/**
* Available custom function types that FunctionManager supports.
*/
export type CustomFunctionTypes = "aoi.js" | "djs";

/**
* Base custom function interface.
*/
export interface BaseCustomFunction<T extends CustomFunctionTypes> {
name: `$${string}`;
type: T;
}

/**
* Represents the structure for an aoi.js custom function type.
*/
export interface CustomAoiJSFunction<Type = "aoi.js"> extends BaseCustomFunction<Type> {
params?: string[];
code: string;
}

/**
* Represents the structure for a discord.js custom function type.
*/
export interface CustomDiscordJSFunction<Type = "djs"> extends BaseCustomFunction<Type> {
code(d: Data): Promise<Record<string, any>> | Record<string, any>
}

// FunctionManager
export declare class FunctionManager {
client: AoiClient;
Expand All @@ -395,7 +423,7 @@ export declare class FunctionManager {
interpreter: Interpreter;
constructor(client: AoiClient);
cacheFunctions(): void;
createFunction(data: Array<Record<string, any>>): void;
createFunction(...data: (CustomAoiJSFunction | CustomDiscordJSFunction)[]): void;
findFunctions(code: string): string[];
serializeCode(code: string): string[];
}
Expand Down

0 comments on commit 86e4d6f

Please sign in to comment.