convert property

  1. @override
FutureOr<T?> Function(StringView, ContextData) convert
override

The function called to perform the conversion.

view is a view on the current argument string. For text commands, this will contain the entire content of the message. For Slash Commands, this will contain the content provided by the user for the current argument.

This function should not throw if parsing fails, it should instead return null to indicate failure. A BadInputException will then be added to CommandsPlugin.onCommandError where it can be handled appropriately.

Implementation

@override
FutureOr<T?> Function(StringView, ContextData) get convert => (view, context) async {
      GuildChannel? channel = await _internal.convert(view, context);

      if (channel is T) {
        return channel;
      }

      return null;
    };