Options
All
  • Public
  • Public/Protected
  • All
Menu

Namespace middleware

Index

Functions

  • Logger logs requests to a stream, or stdout by default

    example
    client.use(logger({format: "tiny"}))
    client.use(logger({format: ":date - :username#:discriminator :type :command"}))
    client.use(
    logger({
    format: (tokens, req) =>
    `:username#:discriminator ${tokens.date(req, "clf")} ":requestType :command"`,
    }),
    )

    Parameters

    Returns DiscordExpressHandler

  • MessageCommandParser is a forgiving implementation of an argv parser, simillar to the command line. The parsed options are put in the body. "Positional" arguments are put in the "_" field. See example below.

    example
    const intput = "!myCommand a b c d --flag"

    // Becomes
    const output = {
    _: ["a", "b", "c", "d"],
    flag: true,
    }

    const intput = "<@BOT_ID> anotherCommand -flag a b c d --option=10"

    // Becomes
    const output = {
    flag: ["a", "b", "c", "d"],
    option: "10",
    }

    Parameters

    Returns DiscordExpressHandler

  • Recommended middleware to include with every bot

    example
    import * as middleware from "discord-express/middleware"

    client.use(...middleware.recommended())

    // E.g allow bot in DMs
    client.use(
    ...middleware.recommended({
    allowDMs: true,
    }),
    )

    Parameters

    Returns DiscordExpressHandler[]

Generated using TypeDoc