Builder for command option objects.
Provides type-specific constructors that produce validated option structs.
Options are added to commands via EDA.Command.option/2.
Example
import EDA.Command.Option
string("query", "Search query", required: true, min_length: 1, max_length: 100)
integer("count", "How many", min_value: 1, max_value: 25)
user("target", "The user to mention")
channel("channel", "Where to post", channel_types: [:guild_text])
string("color", "Pick a color",
required: true,
choices: [
{"Red", "red"},
{"Blue", "blue"},
{"Green", "green"}
]
)
sub_command("add", "Add something", [
string("name", "The name", required: true),
integer("amount", "How many")
])
Summary
Functions
Creates an ATTACHMENT option (type 11).
Creates a BOOLEAN option (type 5).
Creates a CHANNEL option (type 7).
Creates an INTEGER option (type 4).
Adds localized name and/or description for a given locale.
Creates a MENTIONABLE option (type 9) — accepts users or roles.
Creates a NUMBER option (type 10) — double-precision float.
Creates a ROLE option (type 8).
Creates a STRING option (type 3).
Creates a SUB_COMMAND option (type 1) with nested options.
Creates a SUB_COMMAND_GROUP option (type 2) containing sub_commands.
Converts the option struct to a plain map for the Discord API.
Creates a USER option (type 6).
Types
@type t() :: %EDA.Command.Option{ autocomplete: boolean() | nil, channel_types: [non_neg_integer()] | nil, choices: [map()] | nil, description: String.t(), description_localizations: term(), max_length: pos_integer() | nil, max_value: number() | nil, min_length: non_neg_integer() | nil, min_value: number() | nil, name: String.t(), name_localizations: term(), options: [t()] | nil, required: boolean() | nil, type: 1..11 }
Functions
Creates an ATTACHMENT option (type 11).
Creates a BOOLEAN option (type 5).
Creates a CHANNEL option (type 7).
Options
:channel_types- list of channel type atoms to restrict selection. Valid types::guild_text,:dm,:guild_voice,:group_dm,:guild_category,:guild_announcement,:announcement_thread,:public_thread,:private_thread,:guild_stage_voice,:guild_forum,:guild_media
Creates an INTEGER option (type 4).
Adds localized name and/or description for a given locale.
Examples
string("query", "Search query")
|> localize("fr", name: "requête", description: "Requête de recherche")
Creates a MENTIONABLE option (type 9) — accepts users or roles.
Creates a NUMBER option (type 10) — double-precision float.
Creates a ROLE option (type 8).
Creates a STRING option (type 3).
Creates a SUB_COMMAND option (type 1) with nested options.
Creates a SUB_COMMAND_GROUP option (type 2) containing sub_commands.
Converts the option struct to a plain map for the Discord API.
Creates a USER option (type 6).