Lingo.Bot.Options (Lingo v0.4.2)

Copy Markdown View Source

Builders for application command options, imported by use Lingo.Bot.

command "search", "Search the catalog",
  options: [
    string(:query, "What to look for", required: true, autocomplete: true),
    integer(:limit, "How many results", min_value: 1, max_value: 25),
    channel(:where, "Channel to post in", channel_types: [:guild_text])
  ]

Names may be atoms or strings. Every builder takes these options:

  • :required - must be filled in (default false)
  • :choices - for strings and numbers, a fixed list of %{name:, value:} maps or [name:, value:] keyword lists
  • :autocomplete - suggest values from Lingo.Bot.handle_autocomplete/2
  • :min_value, :max_value - bounds for integer/3 and number/3
  • :min_length, :max_length - bounds for string/3
  • :channel_types - channel types channel/3 accepts
  • :file_types - file extensions attachment/3 accepts, like ".pdf" (Discord only checks the name)
  • :options - the nested options of subcommand/3 and subcommand_group/3
  • :name_localizations, :description_localizations - maps of locale to text

Summary

Functions

A file option. Its value is the id; Lingo.Context.get_attachment/2 resolves it.

A channel option. Its value is the id; Lingo.Context.get_channel/2 resolves it.

A user or role option. Its value is the id.

A number option; the value may be a float.

A role option. Its value is the id; Lingo.Context.get_role/2 resolves it.

A subcommand; its own options go in :options.

A group of subcommands, listed in :options.

A user option. Its value is the id; Lingo.Context.get_user/2 resolves it.

Types

name()

@type name() :: atom() | String.t()

Functions

attachment(name, description, opts \\ [])

@spec attachment(name(), String.t(), keyword()) :: Lingo.Type.CommandOption.t()

A file option. Its value is the id; Lingo.Context.get_attachment/2 resolves it.

boolean(name, description, opts \\ [])

@spec boolean(name(), String.t(), keyword()) :: Lingo.Type.CommandOption.t()

A true/false option.

channel(name, description, opts \\ [])

@spec channel(name(), String.t(), keyword()) :: Lingo.Type.CommandOption.t()

A channel option. Its value is the id; Lingo.Context.get_channel/2 resolves it.

integer(name, description, opts \\ [])

@spec integer(name(), String.t(), keyword()) :: Lingo.Type.CommandOption.t()

An integer option.

mentionable(name, description, opts \\ [])

@spec mentionable(name(), String.t(), keyword()) :: Lingo.Type.CommandOption.t()

A user or role option. Its value is the id.

number(name, description, opts \\ [])

@spec number(name(), String.t(), keyword()) :: Lingo.Type.CommandOption.t()

A number option; the value may be a float.

role(name, description, opts \\ [])

@spec role(name(), String.t(), keyword()) :: Lingo.Type.CommandOption.t()

A role option. Its value is the id; Lingo.Context.get_role/2 resolves it.

string(name, description, opts \\ [])

@spec string(name(), String.t(), keyword()) :: Lingo.Type.CommandOption.t()

A text option.

subcommand(name, description, opts \\ [])

@spec subcommand(name(), String.t(), keyword()) :: Lingo.Type.CommandOption.t()

A subcommand; its own options go in :options.

subcommand_group(name, description, opts \\ [])

@spec subcommand_group(name(), String.t(), keyword()) :: Lingo.Type.CommandOption.t()

A group of subcommands, listed in :options.

user(name, description, opts \\ [])

@spec user(name(), String.t(), keyword()) :: Lingo.Type.CommandOption.t()

A user option. Its value is the id; Lingo.Context.get_user/2 resolves it.