@tanzanite/discord-akairo
    Preparing search index...

    Class CommandHandler

    Loads commands and handles messages.

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    "[brandSymbol]": CommandHandlerEvents

    This field doesn't actually exist, it's just a way to make TS properly infer the events from classes that extend AsyncEventEmitter

    aliases: Collection<string, string>

    Collection of command aliases.

    aliasReplacement?: RegExp

    Regular expression to automatically make command aliases for.

    allowMention:
        | boolean
        | ((...args: [message: TextCommandMessage]) => SyncOrAsync)

    Whether or not mentions are allowed for prefixing.

    argumentDefaults: ArgumentDefaults

    Default argument options.

    autoDefer: boolean

    Automatically defer messages "BotName is thinking".

    automateCategories: boolean

    Whether or not to automate category names.

    autoRegisterSlashCommands: boolean

    Specify whether to register all slash commands when starting the client

    blockBots: boolean

    Whether or not to block bots.

    blockClient: boolean

    Whether or not to block self.

    categories: Collection<string, Category<string, Command>>

    Categories, mapped by ID to Category.

    classToHandle: Class<Command>

    Class to handle.

    client: AkairoClient

    The Akairo client.

    commandUtil: boolean

    Whether or not message.util is assigned.

    commandUtilLifetime: number

    Milliseconds a message should exist for before its command util instance is marked for removal.

    commandUtils: Collection<string, CommandUtil<MessageUnion>>

    Collection of CommandUtils.

    commandUtilSweepInterval: number

    Time interval in milliseconds for sweeping command util instances.

    cooldowns: Collection<string, { [id: string]: CooldownData }>

    Collection of cooldowns. The elements in the collection are objects with user IDs as keys and CooldownData objects as values

    defaultCooldown: number

    Default cooldown for commands.

    directory: string

    The main directory to modules.

    execSlash: boolean

    Whether or not to require the use of execSlash for slash commands.

    extensions: Set<string>

    File extensions to load.

    fetchMembers: boolean

    Whether or not members are fetched on each message author from a guild.

    handleEdits: boolean

    Whether or not edits are handled.

    ignoreCooldown:
        | string
        | string[]
        | ((...args: [message: MessageUnion, command: Command]) => boolean)

    ID of user(s) to ignore cooldown or a function to ignore.

    ignorePermissions:
        | string
        | string[]
        | ((...args: [message: MessageUnion, command: Command]) => boolean)

    ID of user(s) to ignore userPermissions checks or a function to ignore.

    inhibitorHandler: null | InhibitorHandler

    Inhibitor handler to use.

    loadFilter: LoadPredicate

    Function that filters files when loading.

    modules: Collection<string, Command>

    Modules loaded, mapped by ID to AkairoModule.

    prefix:
        | string
        | string[]
        | ((...args: [message: TextCommandMessage]) => SyncOrAsync)

    The prefix(es) for command parsing.

    prefixes: Collection<
        string
        | ((...args: [message: TextCommandMessage]) => SyncOrAsync),
        Set<string>,
    >

    Collection of prefix overwrites to commands.

    prompts: Collection<string, Set<string>>

    Collection of sets of ongoing argument prompts.

    resolver: TypeResolver

    The type resolver.

    skipBuiltInPostInhibitors: boolean

    Whether or not to skip built in reasons post type inhibitors so you can make custom ones.

    storeMessages: boolean

    Whether or not to store messages in CommandUtil.

    typing: boolean

    Show "BotName is typing" information message on the text channels when a command is running.

    Methods

    • Type Parameters

      • K extends
            | "error"
            | "remove"
            | "load"
            | "removeListener"
            | "newListener"
            | "commandBlocked"
            | "commandBreakout"
            | "commandCancelled"
            | "commandTimeout"
            | "commandFinished"
            | "commandInvalid"
            | "commandLocked"
            | "commandStarted"
            | "cooldown"
            | "inPrompt"
            | "messageBlocked"
            | "messageInvalid"
            | "missingPermissions"
            | "slashBlocked"
            | "slashError"
            | "slashFinished"
            | "slashMissingPermissions"
            | "slashNotFound"
            | "slashStarted"
            | "slashOnly"

      Parameters

      • eventName: K
      • listener: Exclude<
            InternalAsyncEventEmitterInternalListenerForEvent<
                AsyncEventEmitter<CommandHandlerEvents>,
                K,
                CommandHandlerEvents,
            >["listener"],
            undefined,
        >

      Returns this

    • Type Parameters

      • K extends string | symbol

      Parameters

      • eventName: K
      • listener: Exclude<
            InternalAsyncEventEmitterInternalListenerForEvent<
                AsyncEventEmitter<CommandHandlerEvents>,
                K,
                CommandHandlerEvents,
            >["listener"],
            undefined,
        >

      Returns this

    • Adds an ongoing prompt in order to prevent command usage in the channel.

      Parameters

      • channel: TextBasedChannel

        Channel to add to.

      • user: User

        User to add.

      Returns void

    • Type Parameters

      • K extends
            | "error"
            | "remove"
            | "load"
            | "removeListener"
            | "newListener"
            | "commandBlocked"
            | "commandBreakout"
            | "commandCancelled"
            | "commandTimeout"
            | "commandFinished"
            | "commandInvalid"
            | "commandLocked"
            | "commandStarted"
            | "cooldown"
            | "inPrompt"
            | "messageBlocked"
            | "messageInvalid"
            | "missingPermissions"
            | "slashBlocked"
            | "slashError"
            | "slashFinished"
            | "slashMissingPermissions"
            | "slashNotFound"
            | "slashStarted"
            | "slashOnly"

      Parameters

      • eventName: K
      • ...args: InternalGetAsyncEventEmitterEventParameters<
            AsyncEventEmitter<CommandHandlerEvents>,
            K,
        >

      Returns boolean

    • Type Parameters

      • K extends string | symbol

      Parameters

      • eventName: K
      • ...args: InternalGetAsyncEventEmitterEventParameters<
            AsyncEventEmitter<CommandHandlerEvents>,
            K,
        >

      Returns boolean

    • Returns (string | symbol)[] & (keyof AsyncEventEmitterPredefinedEvents)[] & (
          keyof CommandHandlerEvents
      )[]

    • Returns number

    • Handles autocomplete interactions.

      Parameters

      • interaction: AutocompleteInteraction

        The interaction to handle.

      Returns void

    • Handles normal commands.

      Parameters

      • message: TextCommandMessage

        Message to handle.

      • content: string

        Content of message without command.

      • command: Command

        Command instance.

      • ignore: boolean = false

        Ignore inhibitors and other checks.

      Returns Promise<null | boolean>

    • Handles a slash command.

      Parameters

      • interaction: ChatInputCommandInteraction

        Interaction to handle.

      Returns Promise<null | boolean>

    • Checks if there is an ongoing prompt.

      Parameters

      • channel: TextBasedChannel

        Channel to check.

      • user: User

        User to check.

      Returns boolean

    • Type Parameters

      • K extends
            | "error"
            | "remove"
            | "load"
            | "removeListener"
            | "newListener"
            | "commandBlocked"
            | "commandBreakout"
            | "commandCancelled"
            | "commandTimeout"
            | "commandFinished"
            | "commandInvalid"
            | "commandLocked"
            | "commandStarted"
            | "cooldown"
            | "inPrompt"
            | "messageBlocked"
            | "messageInvalid"
            | "missingPermissions"
            | "slashBlocked"
            | "slashError"
            | "slashFinished"
            | "slashMissingPermissions"
            | "slashNotFound"
            | "slashStarted"
            | "slashOnly"

      Parameters

      • eventName: K

      Returns number

    • Parameters

      • eventName: string | symbol

      Returns number

    • Type Parameters

      • K extends
            | "error"
            | "remove"
            | "load"
            | "removeListener"
            | "newListener"
            | "commandBlocked"
            | "commandBreakout"
            | "commandCancelled"
            | "commandTimeout"
            | "commandFinished"
            | "commandInvalid"
            | "commandLocked"
            | "commandStarted"
            | "cooldown"
            | "inPrompt"
            | "messageBlocked"
            | "messageInvalid"
            | "missingPermissions"
            | "slashBlocked"
            | "slashError"
            | "slashFinished"
            | "slashMissingPermissions"
            | "slashNotFound"
            | "slashStarted"
            | "slashOnly"

      Parameters

      • eventName: K

      Returns Exclude<
          InternalAsyncEventEmitterInternalListenerForEvent<
              AsyncEventEmitter<CommandHandlerEvents>,
              K,
              CommandHandlerEvents,
          >["listener"],
          undefined,
      >[]

    • Type Parameters

      • K extends string | symbol

      Parameters

      • eventName: K

      Returns Exclude<
          InternalAsyncEventEmitterInternalListenerForEvent<
              AsyncEventEmitter<CommandHandlerEvents>,
              K,
              CommandHandlerEvents,
          >["listener"],
          undefined,
      >[]

    • Type Parameters

      • K extends
            | "error"
            | "remove"
            | "load"
            | "removeListener"
            | "newListener"
            | "commandBlocked"
            | "commandBreakout"
            | "commandCancelled"
            | "commandTimeout"
            | "commandFinished"
            | "commandInvalid"
            | "commandLocked"
            | "commandStarted"
            | "cooldown"
            | "inPrompt"
            | "messageBlocked"
            | "messageInvalid"
            | "missingPermissions"
            | "slashBlocked"
            | "slashError"
            | "slashFinished"
            | "slashMissingPermissions"
            | "slashNotFound"
            | "slashStarted"
            | "slashOnly"

      Parameters

      • eventName: K
      • listener: Exclude<
            InternalAsyncEventEmitterInternalListenerForEvent<
                AsyncEventEmitter<CommandHandlerEvents>,
                K,
                CommandHandlerEvents,
            >["listener"],
            undefined,
        >

      Returns this

    • Type Parameters

      • K extends string | symbol

      Parameters

      • eventName: K
      • listener: Exclude<
            InternalAsyncEventEmitterInternalListenerForEvent<
                AsyncEventEmitter<CommandHandlerEvents>,
                K,
                CommandHandlerEvents,
            >["listener"],
            undefined,
        >

      Returns this

    • Type Parameters

      • K extends
            | "error"
            | "remove"
            | "load"
            | "removeListener"
            | "newListener"
            | "commandBlocked"
            | "commandBreakout"
            | "commandCancelled"
            | "commandTimeout"
            | "commandFinished"
            | "commandInvalid"
            | "commandLocked"
            | "commandStarted"
            | "cooldown"
            | "inPrompt"
            | "messageBlocked"
            | "messageInvalid"
            | "missingPermissions"
            | "slashBlocked"
            | "slashError"
            | "slashFinished"
            | "slashMissingPermissions"
            | "slashNotFound"
            | "slashStarted"
            | "slashOnly"

      Parameters

      • eventName: K
      • listener: Exclude<
            InternalAsyncEventEmitterInternalListenerForEvent<
                AsyncEventEmitter<CommandHandlerEvents>,
                K,
                CommandHandlerEvents,
            >["listener"],
            undefined,
        >

      Returns this

    • Type Parameters

      • K extends string | symbol

      Parameters

      • eventName: K
      • listener: Exclude<
            InternalAsyncEventEmitterInternalListenerForEvent<
                AsyncEventEmitter<CommandHandlerEvents>,
                K,
                CommandHandlerEvents,
            >["listener"],
            undefined,
        >

      Returns this

    • Type Parameters

      • K extends
            | "error"
            | "remove"
            | "load"
            | "removeListener"
            | "newListener"
            | "commandBlocked"
            | "commandBreakout"
            | "commandCancelled"
            | "commandTimeout"
            | "commandFinished"
            | "commandInvalid"
            | "commandLocked"
            | "commandStarted"
            | "cooldown"
            | "inPrompt"
            | "messageBlocked"
            | "messageInvalid"
            | "missingPermissions"
            | "slashBlocked"
            | "slashError"
            | "slashFinished"
            | "slashMissingPermissions"
            | "slashNotFound"
            | "slashStarted"
            | "slashOnly"

      Parameters

      • eventName: K
      • listener: Exclude<
            InternalAsyncEventEmitterInternalListenerForEvent<
                AsyncEventEmitter<CommandHandlerEvents>,
                K,
                CommandHandlerEvents,
            >["listener"],
            undefined,
        >

      Returns this

    • Type Parameters

      • K extends string | symbol

      Parameters

      • eventName: K
      • listener: Exclude<
            InternalAsyncEventEmitterInternalListenerForEvent<
                AsyncEventEmitter<CommandHandlerEvents>,
                K,
                CommandHandlerEvents,
            >["listener"],
            undefined,
        >

      Returns this

    • Type Parameters

      • K extends
            | "error"
            | "remove"
            | "load"
            | "removeListener"
            | "newListener"
            | "commandBlocked"
            | "commandBreakout"
            | "commandCancelled"
            | "commandTimeout"
            | "commandFinished"
            | "commandInvalid"
            | "commandLocked"
            | "commandStarted"
            | "cooldown"
            | "inPrompt"
            | "messageBlocked"
            | "messageInvalid"
            | "missingPermissions"
            | "slashBlocked"
            | "slashError"
            | "slashFinished"
            | "slashMissingPermissions"
            | "slashNotFound"
            | "slashStarted"
            | "slashOnly"

      Parameters

      • eventName: K
      • listener: Exclude<
            InternalAsyncEventEmitterInternalListenerForEvent<
                AsyncEventEmitter<CommandHandlerEvents>,
                K,
                CommandHandlerEvents,
            >["listener"],
            undefined,
        >

      Returns this

    • Type Parameters

      • K extends string | symbol

      Parameters

      • eventName: K
      • listener: Exclude<
            InternalAsyncEventEmitterInternalListenerForEvent<
                AsyncEventEmitter<CommandHandlerEvents>,
                K,
                CommandHandlerEvents,
            >["listener"],
            undefined,
        >

      Returns this

    • Type Parameters

      • K extends
            | "error"
            | "remove"
            | "load"
            | "removeListener"
            | "newListener"
            | "commandBlocked"
            | "commandBreakout"
            | "commandCancelled"
            | "commandTimeout"
            | "commandFinished"
            | "commandInvalid"
            | "commandLocked"
            | "commandStarted"
            | "cooldown"
            | "inPrompt"
            | "messageBlocked"
            | "messageInvalid"
            | "missingPermissions"
            | "slashBlocked"
            | "slashError"
            | "slashFinished"
            | "slashMissingPermissions"
            | "slashNotFound"
            | "slashStarted"
            | "slashOnly"

      Parameters

      • eventName: K
      • listener: Exclude<
            InternalAsyncEventEmitterInternalListenerForEvent<
                AsyncEventEmitter<CommandHandlerEvents>,
                K,
                CommandHandlerEvents,
            >["listener"],
            undefined,
        >

      Returns this

    • Type Parameters

      • K extends string | symbol

      Parameters

      • eventName: K
      • listener: Exclude<
            InternalAsyncEventEmitterInternalListenerForEvent<
                AsyncEventEmitter<CommandHandlerEvents>,
                K,
                CommandHandlerEvents,
            >["listener"],
            undefined,
        >

      Returns this

    • Type Parameters

      • K extends
            | "error"
            | "remove"
            | "load"
            | "removeListener"
            | "newListener"
            | "commandBlocked"
            | "commandBreakout"
            | "commandCancelled"
            | "commandTimeout"
            | "commandFinished"
            | "commandInvalid"
            | "commandLocked"
            | "commandStarted"
            | "cooldown"
            | "inPrompt"
            | "messageBlocked"
            | "messageInvalid"
            | "missingPermissions"
            | "slashBlocked"
            | "slashError"
            | "slashFinished"
            | "slashMissingPermissions"
            | "slashNotFound"
            | "slashStarted"
            | "slashOnly"

      Parameters

      • eventName: K

      Returns InternalAsyncEventEmitterInternalListenerForEvent<
          AsyncEventEmitter<CommandHandlerEvents>,
          K,
          CommandHandlerEvents,
      >[]

    • Type Parameters

      • K extends string | symbol

      Parameters

      • eventName: K

      Returns InternalAsyncEventEmitterInternalListenerForEvent<
          AsyncEventEmitter<CommandHandlerEvents>,
          K,
          CommandHandlerEvents,
      >[]

    • Type Parameters

      • K extends
            | "error"
            | "remove"
            | "load"
            | "removeListener"
            | "newListener"
            | "commandBlocked"
            | "commandBreakout"
            | "commandCancelled"
            | "commandTimeout"
            | "commandFinished"
            | "commandInvalid"
            | "commandLocked"
            | "commandStarted"
            | "cooldown"
            | "inPrompt"
            | "messageBlocked"
            | "messageInvalid"
            | "missingPermissions"
            | "slashBlocked"
            | "slashError"
            | "slashFinished"
            | "slashMissingPermissions"
            | "slashNotFound"
            | "slashStarted"
            | "slashOnly"

      Parameters

      • event: K

      Returns this

    • Type Parameters

      • K extends
            | "error"
            | "remove"
            | "load"
            | "removeListener"
            | "newListener"
            | "commandBlocked"
            | "commandBreakout"
            | "commandCancelled"
            | "commandTimeout"
            | "commandFinished"
            | "commandInvalid"
            | "commandLocked"
            | "commandStarted"
            | "cooldown"
            | "inPrompt"
            | "messageBlocked"
            | "messageInvalid"
            | "missingPermissions"
            | "slashBlocked"
            | "slashError"
            | "slashFinished"
            | "slashMissingPermissions"
            | "slashNotFound"
            | "slashStarted"
            | "slashOnly"

      Parameters

      • Optionalevent: K

      Returns this

    • Parameters

      • event: string | symbol

      Returns this

    • Parameters

      • Optionalevent: string | symbol

      Returns this

    • Type Parameters

      • K extends
            | "error"
            | "remove"
            | "load"
            | "removeListener"
            | "newListener"
            | "commandBlocked"
            | "commandBreakout"
            | "commandCancelled"
            | "commandTimeout"
            | "commandFinished"
            | "commandInvalid"
            | "commandLocked"
            | "commandStarted"
            | "cooldown"
            | "inPrompt"
            | "messageBlocked"
            | "messageInvalid"
            | "missingPermissions"
            | "slashBlocked"
            | "slashError"
            | "slashFinished"
            | "slashMissingPermissions"
            | "slashNotFound"
            | "slashStarted"
            | "slashOnly"

      Parameters

      • eventName: K
      • listener: Exclude<
            InternalAsyncEventEmitterInternalListenerForEvent<
                AsyncEventEmitter<CommandHandlerEvents>,
                K,
                CommandHandlerEvents,
            >["listener"],
            undefined,
        >

      Returns this

    • Type Parameters

      • K extends string | symbol

      Parameters

      • eventName: K
      • listener: Exclude<
            InternalAsyncEventEmitterInternalListenerForEvent<
                AsyncEventEmitter<CommandHandlerEvents>,
                K,
                CommandHandlerEvents,
            >["listener"],
            undefined,
        >

      Returns this

    • Removes an ongoing prompt.

      Parameters

      • channel: TextBasedChannel

        Channel to remove from.

      • user: User

        User to remove.

      Returns void

    • Parameters

      • n: number

      Returns this

    • Sweep command util instances from cache and returns amount sweeped.

      Parameters

      • lifetime: number = ...

        Messages older than this will have their command util instance sweeped. This is in milliseconds and defaults to the commandUtilLifetime option.

      Returns number

    • Type Parameters

      • EventMap extends {}
      • EventName extends PropertyKey = (keyof AsyncEventEmitterPredefinedEvents) | keyof EventMap

      Parameters

      • emitter: AsyncEventEmitter<EventMap>
      • eventName: (keyof AsyncEventEmitterPredefinedEvents) | EventName

      Returns number

    • Parameters

      • emitter: AsyncEventEmitter<any>
      • eventName: string | symbol

      Returns number

    • Type Parameters

      • EventMap extends {}
      • EventName extends PropertyKey = (keyof AsyncEventEmitterPredefinedEvents) | keyof EventMap

      Parameters

      • emitter: AsyncEventEmitter<EventMap>
      • eventName: EventName
      • Optionaloptions: AbortableMethods

      Returns AsyncGenerator<
          InternalGetAsyncEventEmitterEventParameters<
              AsyncEventEmitter<EventMap>,
              EventName,
              EventMap,
          >,
          void,
      >

    • Parameters

      • emitter: AsyncEventEmitter<any>
      • eventName: string | symbol
      • Optionaloptions: AbortableMethods

      Returns AsyncGenerator<any[], void>

    • Type Parameters

      • EventMap extends {}
      • EventName extends PropertyKey = (keyof AsyncEventEmitterPredefinedEvents) | keyof EventMap

      Parameters

      • emitter: AsyncEventEmitter<EventMap>
      • eventName: EventName
      • Optionaloptions: AbortableMethods

      Returns Promise<
          InternalGetAsyncEventEmitterEventParameters<
              AsyncEventEmitter<EventMap>,
              EventName,
              EventMap,
          >,
      >

    • Parameters

      • emitter: AsyncEventEmitter<any>
      • eventName: string | symbol
      • Optionaloptions: AbortableMethods

      Returns Promise<any[]>