Table of Contents

Class CommandService<TContext>

Namespace
NetCord.Services.Commands
Assembly
NetCord.Services.dll

Provides functionality for handling text-based commands.

public class CommandService<TContext> : ICommandService, IService where TContext : ICommandContext

Type Parameters

TContext

The context the invoked commands use.

Inheritance
CommandService<TContext>
Implements
Inherited Members

Constructors

CommandService(CommandServiceConfiguration<TContext>?)

Provides functionality for handling text-based commands.

public CommandService(CommandServiceConfiguration<TContext>? configuration = null)

Parameters

configuration CommandServiceConfiguration<TContext>
The configuration for the command service.

Properties

Configuration

The configuration for the command service.

public CommandServiceConfiguration<TContext> Configuration { get; }

Property Value

CommandServiceConfiguration<TContext>

Methods

AddCommand(CommandBuilder)

Adds a command to the service.

public void AddCommand(CommandBuilder builder)

Parameters

builder CommandBuilder

The command builder.

AddCommandGroup(CommandGroupBuilder)

Adds a command group to the service.

public void AddCommandGroup(CommandGroupBuilder builder)

Parameters

builder CommandGroupBuilder

The command group builder.

AddModule(Type)

Adds a command module to the service.

public void AddModule(Type type)

Parameters

type Type

The type of the command module to add.

AddModule<T>()

Adds a command module to the service.

public void AddModule<T>()

Type Parameters

T

The type of the command module to add.

AddModules(Assembly)

Scans the specified assembly for public modules and registers them with the service.

public void AddModules(Assembly assembly)

Parameters

assembly Assembly

The assembly to scan for modules.

ExecuteAsync(int, TContext, IServiceProvider?)

Executes a command.

public ValueTask<IExecutionResult> ExecuteAsync(int prefixLength, TContext context, IServiceProvider? serviceProvider = null)

Parameters

prefixLength int

The length of the prefix that was used to invoke the command.

context TContext

The command context.

serviceProvider IServiceProvider

The service provider for dependency injection.

Returns

ValueTask<IExecutionResult>

A task representing the execution result.

GetCommands()

Gets the collection of commands registered in the service.

public IReadOnlyDictionary<ReadOnlyMemory<char>, IReadOnlyList<ICommandInfo<TContext>>> GetCommands()

Returns

IReadOnlyDictionary<ReadOnlyMemory<char>, IReadOnlyList<ICommandInfo<TContext>>>

The collection of commands registered in the service.