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
TContextThe 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
configurationApplicationCommandServiceConfiguration<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
builderEntryPointCommandBuilderThe entry point command builder.
AddMessageCommand(MessageCommandBuilder)
Adds a message command to the service.
public void AddMessageCommand(MessageCommandBuilder builder)
Parameters
builderMessageCommandBuilderThe message command builder.
AddModule(Type)
Adds a module to the service.
public void AddModule(Type type)
Parameters
typeTypeThe type of the module to add.
AddModule<T>()
Adds a module to the service.
public void AddModule<T>()
Type Parameters
TThe 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
assemblyAssemblyThe assembly to scan for modules.
AddSlashCommand(SlashCommandBuilder)
Adds a slash command to the service.
public void AddSlashCommand(SlashCommandBuilder builder)
Parameters
builderSlashCommandBuilderThe slash command builder.
AddSlashCommandGroup(SlashCommandGroupBuilder)
Adds a slash command group to the service.
public void AddSlashCommandGroup(SlashCommandGroupBuilder builder)
Parameters
builderSlashCommandGroupBuilderThe slash command group builder.
AddUserCommand(UserCommandBuilder)
Adds a user command to the service.
public void AddUserCommand(UserCommandBuilder builder)
Parameters
builderUserCommandBuilderThe user command builder.
ExecuteAsync(TContext, IServiceProvider?)
Executes an application command.
public ValueTask<IExecutionResult> ExecuteAsync(TContext context, IServiceProvider? serviceProvider = null)
Parameters
contextTContextThe application command context.
serviceProviderIServiceProviderThe 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
clientRestClientThe RestClient to use for registration.
applicationIdulongThe application ID.
guildIdulong?The guild ID for guild-specific commands, or null for global commands.
propertiesRestRequestPropertiesThe RestClient's request properties to use for registration.
cancellationTokenCancellationTokenThe cancellation token to cancel the operation.
Returns
- Task<IReadOnlyList<ApplicationCommand>>
A task representing the registered application commands.