choices property
override
The choices for this type.
Choices will be the only options selectable in Slash Commands, however text commands might still pass any content to this converter.
Implementation
@override
Iterable<CommandOptionChoiceBuilder<dynamic>>? get choices {
if (_choices != null) {
return _choices;
}
List<CommandOptionChoiceBuilder<dynamic>> allChoices = [];
for (final converter in converters) {
Iterable<CommandOptionChoiceBuilder<dynamic>>? converterChoices = converter.choices;
if (converterChoices == null) {
return null;
}
for (final choice in converterChoices) {
CommandOptionChoiceBuilder<dynamic> existing =
allChoices.singleWhere((element) => element.name == choice.name, orElse: () => choice);
if (existing.value != choice.value) {
return null;
} else if (identical(choice, existing)) {
allChoices.add(choice);
}
}
}
if (allChoices.isEmpty || allChoices.length > 25) {
return null;
}
return allChoices;
}