/// import EventEmitter = require('events'); import BaseError from '../errors/BaseError'; import Command from '../structures/Command'; import Response from '../structures/Response'; import CommandHandler from './CommandHandler'; import CommandRegistry from './CommandRegistry'; import { IConfig } from '../interfaces/Config'; import { Client, Message } from 'discord.js'; /** * The starting point for using handles. * * ```js * const discord = require('discord.js'); * const handles = require('discord-handles'); * * const client = new discord.Client(); * const handler = new handles.Client(); * * client.on('message', handler.handle); * client.login('token'); * ``` */ export default class HandlesClient extends EventEmitter { readonly registry: CommandRegistry; readonly handler: CommandHandler; Response: typeof Response; argsSuffix?: string; readonly prefixes: Set; constructor(client: Client, config?: IConfig); /** * Handle a message as a command. * * ```js * const client = new discord.Client(); * const handler = new handles.Client(); * * client.on('message', handler.handle); * * // or * * const client = new discord.Client(); * const handler = new handles.Client(); * * client.on('message', message => { * // do other stuff * handler.handle(message); * }); * ``` */ handle(msg: Message): Promise; on(event: 'commandStarted' | 'commandUnknown', listener: (cmd: Command) => void): this; on(event: 'commandError', listener: ({command, error}: { command: Command; error: Error | BaseError; }) => void): this; on(event: 'commandFinished', listener: ({command, result}: { command: Command; result: any; }) => void): this; on(event: 'commandFailed', listener: ({command, error}: { command: Command; error: BaseError; }) => void): this; on(event: 'commandsLoaded', listener: ({commands, failed, time}: { commands: Map; failed: string[]; time: number; }) => void): this; }