SimpleConverter<T> class
abstract
A basic wrapper around a converter, providing an easy way to create custom converters.
This class allows you to create a custom converter by simply specifying a function to retrieve the available elements to convert and a function to convert elements to a String displayed to the user.
This converter provides the core converter functionality as well as autocompletion and, if SimpleConverter.fixed is used, command parameter choices.
You might also be interested in:
- Converter, the base class for creating custom converters.
- FallbackConverter and CombineConverter, two other helpers for creating custom converters.
- Implemented types
-
- Converter<
T>
- Converter<
Constructors
-
SimpleConverter({required FutureOr<
Iterable< provider(ContextData), required String stringify(T), int sensitivity, T? reviver(StringView, ContextData)})T> > -
Create a new SimpleConverter.
constfactory
-
SimpleConverter.fixed({required List<
T> elements, required String stringify(T), int sensitivity, T? reviver(StringView, ContextData)}) -
Create a new SimpleConverter which converts an unchanging number of elements.
constfactory
Properties
-
autocompleteCallback
→ (Future<
Iterable< ? Function(AutocompleteContext)?)CommandOptionChoiceBuilder> > -
A function called to provide autocompletion
for arguments of this type.
no setteroverride
-
choices
→ Iterable<
CommandOptionChoiceBuilder> ? -
The choices for this type.
no setteroverride
-
convert
→ Future<
T?> Function(StringView view, ContextData context) -
The function called to perform the conversion.
no setteroverride
- hashCode → int
-
The hash code for this object.
no setterinherited
-
output
→ RuntimeType<
T> -
The type that this converter parses.
no setteroverride
- processOptionCallback → (void Function(CommandOptionBuilder)?)
-
A callback called with the CommandOptionBuilder created for an option using this converter.
no setteroverride
-
provider
→ FutureOr<
Iterable< Function(ContextData)T> > -
A function called to retrieve the available elements to convert.
no setter
- reviver → (T? Function(StringView, ContextData)?)
-
A function called if this converter fails to convert the input.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- sensitivity → int
-
The sensitivity of this converter.
final
- stringify → String Function(T)
-
A function called to convert elements into Strings that can be displayed in the Discord
client.
no setter
-
toButton
→ (FutureOr<
ButtonBuilder> Function(T)?) -
A function called to provide ButtonBuilders that can be used to represent an element
converted by this converter.
no setteroverride
-
toSelectMenuOption
→ (FutureOr<
SelectMenuOptionBuilder> Function(T)?) -
A function called to provide SelectMenuOptionBuilders that can be used to represent an
element converted by this converter.
no setteroverride
- type → CommandOptionType
-
The Discord Slash Command Argument Type
of the type that this converter parses.
no setteroverride
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited