Table of Contents

Class BaseCommandProcessor<TConverter, TConverterContext, TCommandContext>

Namespace
DSharpPlus.Commands.Processors
Assembly
DSharpPlus.Commands.dll

A command processor containing command logic that's shared between all command processors.

public abstract class BaseCommandProcessor<TConverter, TConverterContext, TCommandContext> : ICommandProcessor where TConverter : class, IArgumentConverter where TConverterContext : ConverterContext where TCommandContext : CommandContext

Type Parameters

TConverter

The converter type that's associated with this command processor. May have extra metadata related to this processor specifically.

TConverterContext

The context type that's used for argument converters.

TCommandContext

The context type that's used for command execution.

Inheritance
BaseCommandProcessor<TConverter, TConverterContext, TCommandContext>
Implements
Derived

Remarks

When implementing a new command processor, it's recommended to inherit from this class. You can however implement ICommandProcessor directly instead, if desired.

Fields

converterFactories

A dictionary of argument converter factories indexed by the output type they convert to. These factories populate the Converters and ConverterDelegates dictionaries.

extension

The extension this processor belongs to.

logger

The logger for this processor.

Properties

Commands

List of commands which are registered to this processor

ContextType

Processor specific context type. Context type which is provided on command invokation

ConverterDelegates

A dictionary of argument converter delegates indexed by the output type they convert to.

Converters

A dictionary of argument converters indexed by the type they convert to.

Methods

AddConverter(ConverterDelegateFactory)

Registers a new argument converter factory with the processor.

AddConverter(Type, TConverter)

Registers a new argument converter with the processor.

AddConverter<T>()

Registers a new argument converter with the processor.

AddConverter<T>(TConverter)

Registers a new argument converter with the processor.

AddConverters(IEnumerable<Type>)

Adds multiple argument converters to the processor.

AddConverters(Assembly)

Scans the specified assembly for argument converters and registers them with the processor. The argument converters will be created through the IServiceProvider provided to the CommandsExtension.

AddEnumConverters(Type?)

Finds all parameters that are enums and creates a generic enum converter for them.

ConfigureAsync(CommandsExtension)

This method is called on initial setup and when the extension is refreshed. Register your needed event handlers here but use a mechanism to track if the inital setup was already done and if this call is only a refresh

CreateCommandContext(TConverterContext, IReadOnlyDictionary<CommandParameter, object?>)

Constructs a command context from the parsed arguments and the current state of the ConverterContext.

ExecuteConverterAsync<T>(TConverter, TConverterContext)

Executes an argument converter on the specified context.

ParseParameterAsync(TConverterContext)

Parses a single parameter from the command context. This method will handle VariadicArgumentAttribute annotated parameters.

ParseParametersAsync(TConverterContext)

Parses the arguments provided to the command and returns a prepared command context.