Options
All
  • Public
  • Public/Protected
  • All
Menu

Class HaSeul<Message>

Type parameters

  • Message

Hierarchy

  • HaSeul

Index

Constructors

constructor

  • Returns HaSeul

Methods

command

  • command(...middleware: (HaSeul<Message> | ((__namedParameters: { content: string; done: (err?: Error) => void; err: undefined | Error; message: undefined | Message; next: (err?: Error) => void; prefix: string; req: HaSeulRequest; route: null | string; userInput: string }) => void))[]): HaSeul<Message>
  • command(url: string, ...middleware: (HaSeul<Message> | ((__namedParameters: { content: string; done: (err?: Error) => void; err: undefined | Error; message: undefined | Message; next: (err?: Error) => void; prefix: string; req: HaSeulRequest; route: null | string; userInput: string }) => void))[]): HaSeul<Message>
  • Create a handler which matches all commands

    Parameters

    • Rest ...middleware: (HaSeul<Message> | ((__namedParameters: { content: string; done: (err?: Error) => void; err: undefined | Error; message: undefined | Message; next: (err?: Error) => void; prefix: string; req: HaSeulRequest; route: null | string; userInput: string }) => void))[]

      Middleware that will be executed in order whenever the route is executed

    Returns HaSeul<Message>

  • Create a handler which matches a command

    Parameters

    • url: string

      The command that must be matched in order for this route to be executed

    • Rest ...middleware: (HaSeul<Message> | ((__namedParameters: { content: string; done: (err?: Error) => void; err: undefined | Error; message: undefined | Message; next: (err?: Error) => void; prefix: string; req: HaSeulRequest; route: null | string; userInput: string }) => void))[]

      Middleware that will be executed in order whenever the route is executed

    Returns HaSeul<Message>

error

  • error(...middleware: (HaSeul<Message> | ((__namedParameters: { content: string; done: (err?: Error) => void; err: undefined | Error; message: undefined | Message; next: (err?: Error) => void; prefix: string; req: HaSeulRequest; route: null | string; userInput: string }) => void))[]): HaSeul<Message>
  • error(url: string, ...middleware: (HaSeul<Message> | ((__namedParameters: { content: string; done: (err?: Error) => void; err: undefined | Error; message: undefined | Message; next: (err?: Error) => void; prefix: string; req: HaSeulRequest; route: null | string; userInput: string }) => void))[]): HaSeul<Message>
  • Create an error handler which matches all commands

    You can set up the handler by placing it at the bottom to catch all errors which are created by routers.

    const router = new HaSeul<Message>();
    
    router
     .command('help', ({ next }) => {
       next(new Error('An error occured while processing the HELP command!'))
     })
     .error(({ err, message }) => {
       console.log(err)
       message.channel.createMessage('An error occurred: ' + err)
     })

    Parameters

    • Rest ...middleware: (HaSeul<Message> | ((__namedParameters: { content: string; done: (err?: Error) => void; err: undefined | Error; message: undefined | Message; next: (err?: Error) => void; prefix: string; req: HaSeulRequest; route: null | string; userInput: string }) => void))[]

      Middleware that will be executed in order whenever an error is caught by the router

    Returns HaSeul<Message>

  • Create an error handler which matches a command

    Parameters

    • url: string

      The command that must be matched in order for this route to be executed

    • Rest ...middleware: (HaSeul<Message> | ((__namedParameters: { content: string; done: (err?: Error) => void; err: undefined | Error; message: undefined | Message; next: (err?: Error) => void; prefix: string; req: HaSeulRequest; route: null | string; userInput: string }) => void))[]

      Middleware that will be executed in order whenever an error is caught by the router

    Returns HaSeul<Message>

get

  • get(option: "prefix"): string[]
  • get(option: "case sensitive routing"): boolean
  • get(option: "json spaces"): string | number
  • Obtain the current prefix of the router.

    Parameters

    • option: "prefix"

      The name of the option

    Returns string[]

  • Obtain whether or not the router is case sensitive or not.

    Parameters

    • option: "case sensitive routing"

      The name of the option

    Returns boolean

  • Obtain the delimiter used to generate JSON objects.

    Parameters

    • option: "json spaces"

      The name of the option

    Returns string | number

getContentIfMatched

  • Returns the content of a message, if the prefix (and optional route) matches the user's message.

    Parameters

    • content: string

      The message content that the user has provided

    • route: string | null

      The route name that needs to be removed from the resulting content

    Returns HaSeulSearchResults | null

route

  • route(userInput: string, message?: Message): Promise<any>
  • Pass a message into the router

    Parameters

    • userInput: string

      The content of a message from a user

    • Optional message: Message

      The object from your client API

    Returns Promise<any>

set

  • set(option: "prefix", value: string[]): HaSeul<Message>
  • set(option: "prefix", value: string): HaSeul<Message>
  • set(option: "case sensitive routing", value: boolean): HaSeul<Message>
  • set(option: "json spaces", value: string | number): HaSeul<Message>
  • Set the prefixes the router will respond to.

    Parameters

    • option: "prefix"

      The name of the option

    • value: string[]

      The value that will be assigned to this option

    Returns HaSeul<Message>

  • Set the prefix of the router.

    deprecated

    Please use an array of strings instead.

    Parameters

    • option: "prefix"

      The name of the option

    • value: string

      The value that will be assigned to this option

    Returns HaSeul<Message>

  • Set the case sensitivity of routing.

    Parameters

    • option: "case sensitive routing"

      The name of the option

    • value: boolean

      The value that will be assigned to this option

    Returns HaSeul<Message>

  • Set the white space that is used when converting an object to JSON.

    beta

    Parameters

    • option: "json spaces"

      The name of the option

    • value: string | number

      The value that will be assigned to this option

    Returns HaSeul<Message>

Generated using TypeDoc