Skip to content

Commit

Permalink
Khaaz#67 reflections
Browse files Browse the repository at this point in the history
  • Loading branch information
bsian03 committed Mar 9, 2020
1 parent 1111af4 commit 5da7cca
Show file tree
Hide file tree
Showing 4 changed files with 97 additions and 10 deletions.
1 change: 1 addition & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ declare namespace AxonCore {
export import ASelector = Types.ASelector;
export import Base = Types.Base;
export import CommandDispatcher = Types.CommandDispatcher;
export import Executor = Types.Executor;
export import Module = Types.Module;
export import Validator = Types.Validator;
export import AxonEnums = Types.AxonEnums;
Expand Down
12 changes: 2 additions & 10 deletions types/AxonClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
EventManager, GuildConfigCache, AxonConfig, ModuleLoader, CommandDispatcher, MessageManager, AxonStaffIDs, AxonOptions, Collection, AHandler, Listener, Resolver,
Webhooks, AxonTemplate, Module, Command, LOG_LEVELS, Ctx, LibMessage, GuildConfig, CommandContext, AxonCommandError, DEBUG_FLAGS, CommandEnvironment,
} from './';
import { Executor } from '..';

export declare class AxonClient extends EventEmitter {
/** Configs (webhooks, template, custom) */
Expand Down Expand Up @@ -44,6 +45,7 @@ export declare class AxonClient extends EventEmitter {
public moduleLoader: ModuleLoader;
/** Dispatch commands onMessageCreate. */
public dispatcher: CommandDispatcher;
public executor: Executor;
/** Message manager object accessible with `<AxonClient>.l` */
private _messageManager: MessageManager;

Expand Down Expand Up @@ -207,9 +209,6 @@ export declare class AxonClient extends EventEmitter {
*/
public initStatus(): void;

public _execCommand(command: Command, env: CommandEnvironment): void;
public _execHelp(command: Command, env: CommandEnvironment): void;
public _execListener(listener: Listener, guildConfig: GuildConfig, ...args: any[] ): void;

/**
* Send full help in DM.
Expand Down Expand Up @@ -246,11 +245,4 @@ export declare class AxonClient extends EventEmitter {
* @memberof AxonClient
*/
toJSON(): object;

// events
on(event: 'debug', listener: (flags: DEBUG_FLAGS, debugMessage: string) => void): this;
on(event: 'commandExecution', listener: (status: boolean, commandFullLabel: string, data: { msg: LibMessage; command: Command; guildConfig: GuildConfig; context: CommandContext;} ) => void): this;
on(event: 'commandError', listener: (commandFullLabel: string, data: { msg: LibMessage; command: Command; guildConfig: GuildConfig; error: AxonCommandError; } ) => void): this;
on(event: 'listenerExecution', listener: (status: boolean, eventName: string, listenerName: string, data: { listener: Listener; guildConfig: GuildConfig; } ) => void): this;
on(event: 'listenerError', listener: (eventName: string, listenerName: string, data: { listener: Listener; guildConfig: GuildConfig; error: Error; } ) => void): this;
}
93 changes: 93 additions & 0 deletions types/Core/Executor.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
import {
DEBUG_FLAGS, AxonClient, LibMessage, Command, GuildConfig, CommandContext, AxonCommandError, Listener, CommandEnvironment,
} from '../';

/**
* @param flags Debug flags used to have more information about the event
* @param debugMessage Debug message with information about the situation
*/
type debugListener = (flags: DEBUG_FLAGS, debugMessage: string) => void;
/**
* @param status If the command was successfully executed or not
* @param commandFullLabel The command fullLabel
* @param data.msg The message that triggered the command
* @param data.command The command that was executed
* @param data.guildConfig The GuildConfig
* @param data.context The execution context
*/
type commandExecutionListener = (status: boolean, commandFullLabel: string, data: { msg: LibMessage; command: Command; guildConfig: GuildConfig; context: CommandContext;} ) => void;
/**
* @param commandFullLabel the command fullLabel
* @param data.msg The message that triggered the command
* @param data.command The command that was executed
* @param data.guildConfig The GuildConfig
* @param data.error The error
*/
type commandErrorListener = (commandFullLabel: string, data: { msg: LibMessage; command: Command; guildConfig: GuildConfig; error: AxonCommandError; } ) => void;
/**
* @param status Whether the listener was successfully executed or not
* @param eventName The Discord event name
* @param listenerName The listener label
* @param data Additional information
* @param data.listener The listener that was executed
* @param data.guildConfig The GuildConfig object
*/
type listenerExecutionListener = (status: boolean, eventName: string, listenerName: string, data: { listener: Listener; guildConfig: GuildConfig; } ) => void;
/**
* @param eventName The Discord event name
* @param listenerName The Listener label
* @param data Additional information
* @param data.listener The listener that was executed
* @param data.guildConfig The GuildConfig object
* @param data.error The error
*/
type listenerErrorListener = (eventName: string, listenerName: string, data: { listener: Listener; guildConfig: GuildConfig; error: Error; } ) => void

/**
* Exeutor class. Execute and handle execution of listeners and commands in the framework.
* Will emit events depending on the execution
* @class Executor
*/
export declare class Executor {
private _axon: AxonClient;
/**
* Creates an instance of Executor.
* @memberof Executor
*/
constructor(axonClient: AxonClient);

/**
* Fired when a debug message needs to be sent
* @event AxonClient#debug
* @memberof Executor
*/
on(event: 'debug', listener: debugListener): this;
/**
* Fired when a command is successfully ran
* @event AxonClient#commandExecution
* @memberof Executor
*/
on(event: 'commandExecution', listener: commandExecutionListener): this;
/**
* Fired when a command fails
* @event AxonClient#commandError
* @memberof Executor
*/
on(event: 'commandError', listener: commandErrorListener): this;
/**
* Fired when a listener is executed
* @event AxonClient#listenerExecution
* @memberof Executor
*/
on(event: 'listenerExecution', listener: listenerExecutionListener): this;
/**
* Fired when a listener errors
* @event AxonClient#listenerError
* @memberof Executor
*/
on(event: 'listenerError', listener: listenerErrorListener): this;

public listener(listener: Listener, guildConfig: GuildConfig, ...args: any[] ): void;
public execCommand(command: Command, env: CommandEnvironment): void;
public help(command: Command, env: CommandEnvironment): void;
}
1 change: 1 addition & 0 deletions types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ export { ModuleRegistry } from './Core/Stores/ModuleRegistry';
export { ASelector } from './Core/ASelector';
export { Base } from './Core/Base';
export { CommandDispatcher } from './Core/CommandDispatcher';
export { Executor } from './Core/Executor';
export { Module } from './Core/Module';
export { Validator } from './Core/Validator';

Expand Down

0 comments on commit 5da7cca

Please sign in to comment.