Table of Contents

Class ApplicationCommandService<TContext>

Namespace
NetCord.Services.ApplicationCommands
Assembly
NetCord.Services.dll

Provides functionality for managing and executing application commands.

public class ApplicationCommandService<TContext> : IApplicationCommandService, IService where TContext : IApplicationCommandContext

Type Parameters

TContext

The context the invoked application commands use.

Inheritance
ApplicationCommandService<TContext>
Implements
Derived
Inherited Members

Constructors

ApplicationCommandService(ApplicationCommandServiceConfiguration<TContext>?)

Provides functionality for managing and executing application commands.

public ApplicationCommandService(ApplicationCommandServiceConfiguration<TContext>? configuration = null)

Parameters

configuration ApplicationCommandServiceConfiguration<TContext>
The configuration for the application command service.

Properties

Configuration

The configuration for the application command service.

public ApplicationCommandServiceConfiguration<TContext> Configuration { get; }

Property Value

ApplicationCommandServiceConfiguration<TContext>

Methods

AddEntryPointCommand(EntryPointCommandBuilder)

Adds an entry point command to the service.

public void AddEntryPointCommand(EntryPointCommandBuilder builder)

Parameters

builder EntryPointCommandBuilder

The entry point command builder.

AddMessageCommand(MessageCommandBuilder)

Adds a message command to the service.

public void AddMessageCommand(MessageCommandBuilder builder)

Parameters

builder MessageCommandBuilder

The message command builder.

AddModule(Type)

Adds a module to the service.

public void AddModule(Type type)

Parameters

type Type

The type of the module to add.

AddModule<T>()

Adds a module to the service.

public void AddModule<T>()

Type Parameters

T

The type of the 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.

AddSlashCommand(SlashCommandBuilder)

Adds a slash command to the service.

public void AddSlashCommand(SlashCommandBuilder builder)

Parameters

builder SlashCommandBuilder

The slash command builder.

AddSlashCommandGroup(SlashCommandGroupBuilder)

Adds a slash command group to the service.

public void AddSlashCommandGroup(SlashCommandGroupBuilder builder)

Parameters

builder SlashCommandGroupBuilder

The slash command group builder.

AddUserCommand(UserCommandBuilder)

Adds a user command to the service.

public void AddUserCommand(UserCommandBuilder builder)

Parameters

builder UserCommandBuilder

The user command builder.

ExecuteAsync(TContext, IServiceProvider?)

Executes an application command.

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

Parameters

context TContext

The application command context.

serviceProvider IServiceProvider

The service provider for dependency injection.

Returns

ValueTask<IExecutionResult>

A task representing the execution result.

GetCommands()

Gets the list of application commands registered in the service.

public IReadOnlyList<ApplicationCommandInfo<TContext>> GetCommands()

Returns

IReadOnlyList<ApplicationCommandInfo<TContext>>

The list of application commands registered in the service.

RegisterCommandsAsync(RestClient, ulong, ulong?, RestRequestProperties?, CancellationToken)

Registers the application commands to Discord.

public Task<IReadOnlyList<ApplicationCommand>> RegisterCommandsAsync(RestClient client, ulong applicationId, ulong? guildId = null, RestRequestProperties? properties = null, CancellationToken cancellationToken = default)

Parameters

client RestClient

The RestClient to use for registration.

applicationId ulong

The application ID.

guildId ulong?

The guild ID for guild-specific commands, or null for global commands.

properties RestRequestProperties

The RestClient's request properties to use for registration.

cancellationToken CancellationToken

The cancellation token to cancel the operation.

Returns

Task<IReadOnlyList<ApplicationCommand>>

A task representing the registered application commands.