Results

Namespace

Type

The built-in Pylon command handler. Provides utilities for building a bot that handles commands.

You can of course roll your own if you want, using the discord.Event.MESSAGE_CREATE event handler.

Index

Type aliases

ArgumentOptions

ArgumentOptions<T>: IArgumentOptions | IOptionalArgumentOptions<T> | undefined

A type union containing possible options passed to an argument.

Type parameters

  • T

ArgumentType

ArgumentType: "string" | "stringOptional" | "integer" | "integerOptional" | "number" | "numberOptional" | "text" | "textOptional" | "stringList" | "stringListOptional" | "user" | "userOptional" | "guildMember" | "guildMemberOptional" | "guildChannel" | "guildChannelOptional" | "guildTextChannel" | "guildTextChannelOptional" | "guildVoiceChannel" | "guildVoiceChannelOptional"

A type union of the string representations available as an argument type.

ArgumentTypeTypes

ArgumentTypeTypes: string | number | string[] | User | GuildMember | GuildChannel | GuildTextChannel | GuildVoiceChannel

A type union containing possible resolved argument types.

ArgumentsParser

ArgumentsParser<T>: function

A type alias for a function called by the command handler to construct the argument requirements for a command.

param

A class containing possible command arguments, use return value from functions in this class as values for properties of T.

Type parameters

Type declaration

CommandArgumentTypes

CommandArgumentTypes: string | string[] | number | Promise<User> | Promise<User | null> | Promise<GuildMember> | Promise<GuildMember | null> | Promise<GuildChannel> | Promise<GuildChannel | null> | Promise<GuildTextChannel> | Promise<GuildTextChannel | null> | Promise<GuildVoiceChannel> | Promise<GuildVoiceChannel | null> | null

A type alias containing a union of possible command argument types.

CommandArgumentsContainer

CommandArgumentsContainer: object | null

A type alias describing the way to define arguments for a command. To be returned by discord.command.ArgumentsParser.

CommandHandler

CommandHandler<T>: function

A function called when a command is executed.

param

A reference to the discord.GuildMemberMessage that triggered this command.

param

An object containing entries for the command arguments parsed for this command.

param

An object containing additional command context information.

Type parameters

  • T

Type declaration

CommandHandlerDeprecated

CommandHandlerDeprecated<T>: function

Type parameters

  • T

Type declaration

Named

Named<T>: object & T

Type parameters

  • T

ResolvedArgs

ResolvedArgs<T>: object

An object containing parsed arguments for a command.

Type parameters

Type declaration

Functions

handler

  • handler<T>(parser: ArgumentsParser<T>, handler: CommandHandler<ResolvedArgs<T>>, options?: Omit<ICommandOptions, "name">): ICommandExecutor
  • Creates an un-attached command handler that can be attached to a CommandGroup using the attach method.

    If you have no need to split your handlers across modules, it's generally more preferred to use CommandGroup.on!

    Example:

    const commandGroup = new discord.command.CommandGroup();
    const hello = discord.command.handler(
     ctx => ({name: ctx.text()}),
     (msg, {name}) => msg.reply(`Hello ${name}`)
    );
    
    commandGroup.attach({hello});

    This allows you to export commands directly from modules.

    In main.ts:

    import * as EconomyCommands from './economy-commands';
    const commandGroup = new discord.command.CommandGroup();
    commandGroup.attach(EconomyCommands);

    In economy-commands.ts:

    export const balance = discord.command.rawHandler((m) =>
      m.reply('your balance is $50')
    );
    export const buy = discord.command.handler(
      (ctx) => ({ item: ctx.string() }),
      (m, { item }) => m.reply(`You bought **${item}**, your balance is now $0`)
    );

    Type parameters

    Parameters

    • parser: ArgumentsParser<T>

      A function that collects the argument types this command expects.

    • handler: CommandHandler<ResolvedArgs<T>>

      A function to be ran when command validation succeeds and the command should be executed.

    • Optional options: Omit<ICommandOptions, "name">

      A object containing the command options (filters, description, etc). It is not possible to specify a name here.

    Returns ICommandExecutor

rawHandler

Legend

  • Module
  • Object literal
  • Variable
  • Function
  • Function with type parameter
  • Index signature
  • Type alias
  • Type alias with type parameter
  • Enumeration
  • Enumeration member
  • Property
  • Method
  • Interface
  • Interface with type parameter
  • Constructor
  • Property
  • Method
  • Index signature
  • Class
  • Class with type parameter
  • Constructor
  • Property
  • Method
  • Accessor
  • Index signature
  • Inherited constructor
  • Inherited property
  • Inherited method
  • Inherited accessor
  • Protected property
  • Protected method
  • Protected accessor
  • Private property
  • Private method
  • Private accessor
  • Static property
  • Static method

Generated using TypeDoc