Converter<T> class

Contains metadata and parsing capabilities for a given type.

A Converter will convert textual user input received from the Discord API to the type requested by the current command. It also contains metadata about the type it converts.

nyxx_commands provides a set of converters for common argument types, a list of which can be found below. These converters are automatically added to CommandsPlugin instances and do not need to be added manually.

The list of default converters is as follows:

You can override these default implementations with your own by calling CommandsPlugin.addConverter with your own converter for one of the types mentioned above.

You might also be interested in:

Implementers

Constructors

Converter(FutureOr<T?> convert(StringView view, ContextData context), {Iterable<CommandOptionChoiceBuilder>? choices, void processOptionCallback(CommandOptionBuilder)?, FutureOr<Iterable<CommandOptionChoiceBuilder>?> autocompleteCallback(AutocompleteContext)?, CommandOptionType type = CommandOptionType.string, FutureOr<SelectMenuOptionBuilder> toSelectMenuOption(T)?, FutureOr<ButtonBuilder> toButton(T)?})
Create a new converter.
const

Properties

autocompleteCallback → (FutureOr<Iterable<CommandOptionChoiceBuilder>?> Function(AutocompleteContext)?)
A function called to provide autocompletion for arguments of this type.
final
choices Iterable<CommandOptionChoiceBuilder>?
The choices for this type.
final
convert FutureOr<T?> Function(StringView view, ContextData context)
The function called to perform the conversion.
final
hashCode int
The hash code for this object.
no setterinherited
output RuntimeType<T>
The type that this converter parses.
no setter
processOptionCallback → (void Function(CommandOptionBuilder)?)
A callback called with the CommandOptionBuilder created for an option using this converter.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
toButton → (FutureOr<ButtonBuilder> Function(T)?)
A function called to provide ButtonBuilders that can be used to represent an element converted by this converter.
final
toSelectMenuOption → (FutureOr<SelectMenuOptionBuilder> Function(T)?)
A function called to provide SelectMenuOptionBuilders that can be used to represent an element converted by this converter.
final
type CommandOptionType
The Discord Slash Command Argument Type of the type that this converter parses.
final

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
override

Operators

operator ==(Object other) bool
The equality operator.
inherited