Class SlashCommandService
Holds all methods to setup, build and execute slash commands.
Inheritance
Implements
Inherited Members
Namespace: Color_Chan.Discord.Commands.Services.Implementations
Assembly: Color-Chan.Discord.Commands.dll
Syntax
public class SlashCommandService : ISlashCommandService
Constructors
| Improve this Doc View SourceSlashCommandService(ILogger<SlashCommandService>, ISlashCommandBuildService, ISlashCommandRequirementService, ISlashCommandAutoSyncService)
Initializes a new instance of SlashCommandService.
Declaration
public SlashCommandService(ILogger<SlashCommandService> logger, ISlashCommandBuildService slashCommandBuildService, ISlashCommandRequirementService requirementService, ISlashCommandAutoSyncService commandAutoSyncService)
Parameters
Type | Name | Description |
---|---|---|
Microsoft.Extensions.Logging.ILogger<SlashCommandService> | logger | The Microsoft.Extensions.Logging.ILogger for SlashCommandService. |
ISlashCommandBuildService | slashCommandBuildService | The ISlashCommandBuildService that will get and build the commands. |
ISlashCommandRequirementService | requirementService | The ISlashCommandRequirementService that will used to execute the requirements. |
ISlashCommandAutoSyncService | commandAutoSyncService | The ISlashCommandAutoSyncService that handles all the syncing of the slash commands. |
Methods
| Improve this Doc View SourceAddInteractionCommandsAsync(Assembly)
Add all interaction commands in an System.Reflection.Assembly to the ISlashCommandService.
Declaration
public async Task AddInteractionCommandsAsync(Assembly assembly)
Parameters
Type | Name | Description |
---|---|---|
System.Reflection.Assembly | assembly | The System.Reflection.Assembly where the commands are located. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task |
See Also
| Improve this Doc View SourceExecuteSlashCommandAsync(ISlashCommandContext, IEnumerable<IDiscordInteractionOption>, IServiceProvider)
Execute a specific command with their dependencies. The command will be searched for with its Name.
Declaration
public async Task<Result<IDiscordInteractionResponse>> ExecuteSlashCommandAsync(ISlashCommandContext context, IEnumerable<IDiscordInteractionOption> options = null, IServiceProvider serviceProvider = null)
Parameters
Type | Name | Description |
---|---|---|
ISlashCommandContext | context | The current ISlashCommandContext that will be passed to the command module. |
System.Collections.Generic.IEnumerable<IDiscordInteractionOption> | options | The options used with the command. |
System.IServiceProvider | serviceProvider | The System.IServiceProvider containing the necessary dependencies for the the module of the command. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<Result<IDiscordInteractionResponse>> | The Result containing the result of the command execution. |
See Also
| Improve this Doc View SourceExecuteSlashCommandAsync(ISlashCommandInfo, ISlashCommandContext, List<IDiscordInteractionOption>, IServiceProvider)
Execute a specific command with their dependencies. The command will be searched for with its Name.
Declaration
public async Task<Result<IDiscordInteractionResponse>> ExecuteSlashCommandAsync(ISlashCommandInfo commandInfo, ISlashCommandContext context, List<IDiscordInteractionOption> suppliedOptions = null, IServiceProvider serviceProvider = null)
Parameters
Type | Name | Description |
---|---|---|
ISlashCommandInfo | commandInfo | The command that will be executed. |
ISlashCommandContext | context | The current ISlashCommandContext that will be passed to the command module. |
System.Collections.Generic.List<IDiscordInteractionOption> | suppliedOptions | The options used by the user. |
System.IServiceProvider | serviceProvider | The System.IServiceProvider containing the necessary dependencies for the the module of the command. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<Result<IDiscordInteractionResponse>> | The Result containing the result of the command execution. |
See Also
| Improve this Doc View SourceExecuteSlashCommandAsync(ISlashCommandOptionInfo, ISlashCommandContext, List<IDiscordInteractionOption>, IServiceProvider)
Execute a specific command with their dependencies. The command will be searched for with its Name.
Declaration
public async Task<Result<IDiscordInteractionResponse>> ExecuteSlashCommandAsync(ISlashCommandOptionInfo commandOptionInfo, ISlashCommandContext context, List<IDiscordInteractionOption> suppliedOptions = null, IServiceProvider serviceProvider = null)
Parameters
Type | Name | Description |
---|---|---|
ISlashCommandOptionInfo | commandOptionInfo | The sub command that will be executed. |
ISlashCommandContext | context | The current ISlashCommandContext that will be passed to the command module. |
System.Collections.Generic.List<IDiscordInteractionOption> | suppliedOptions | The options used by the user. |
System.IServiceProvider | serviceProvider | The System.IServiceProvider containing the necessary dependencies for the the module of the command. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<Result<IDiscordInteractionResponse>> | The Result containing the result of the command execution. |
See Also
| Improve this Doc View SourceExecuteSlashCommandAsync(MethodInfo, IEnumerable<ISlashCommandOptionInfo>, IEnumerable<InteractionRequirementAttribute>, ISlashCommandContext, List<IDiscordInteractionOption>, IServiceProvider)
Execute a specific command with their dependencies. The command will be searched for with its Name.
Declaration
public async Task<Result<IDiscordInteractionResponse>> ExecuteSlashCommandAsync(MethodInfo commandMethod, IEnumerable<ISlashCommandOptionInfo> options, IEnumerable<InteractionRequirementAttribute> requirements, ISlashCommandContext context, List<IDiscordInteractionOption> suppliedOptions = null, IServiceProvider serviceProvider = null)
Parameters
Type | Name | Description |
---|---|---|
System.Reflection.MethodInfo | commandMethod | The command method that will be executed. |
System.Collections.Generic.IEnumerable<ISlashCommandOptionInfo> | options | The command options of the command. |
System.Collections.Generic.IEnumerable<InteractionRequirementAttribute> | requirements | The requirements before the command can be executed. |
ISlashCommandContext | context | The current ISlashCommandContext that will be passed to the command module. |
System.Collections.Generic.List<IDiscordInteractionOption> | suppliedOptions | The options used by the user. |
System.IServiceProvider | serviceProvider | The System.IServiceProvider containing the necessary dependencies for the the module of the command. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<Result<IDiscordInteractionResponse>> | The Result containing the result of the command execution. |
See Also
| Improve this Doc View SourceSearchSlashCommand(String)
Search for a command by its Name.
Declaration
public ISlashCommandInfo SearchSlashCommand(string name)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | The name of the command. |
Returns
Type | Description |
---|---|
ISlashCommandInfo | The SlashCommandInfo containing the command. |
SearchSlashCommand(String, String)
Declaration
public ISlashCommandOptionInfo SearchSlashCommand(string groupName, string subCommandName)
Parameters
Type | Name | Description |
---|---|---|
System.String | groupName | The command group name. |
System.String | subCommandName | The name of the command. |
Returns
Type | Description |
---|---|
ISlashCommandOptionInfo | The ISlashCommandOptionInfo containing the sub command. |
SearchSlashCommand(String, String, String)
Search for a sub command by its Name of the command module. And the Name of the sub command group. And the Name of the sub slash command.
Declaration
public ISlashCommandOptionInfo SearchSlashCommand(string groupName, string subCommandGroupName, string subCommandName)
Parameters
Type | Name | Description |
---|---|---|
System.String | groupName | The command group name. |
System.String | subCommandGroupName | The name of the sub command group. |
System.String | subCommandName | The name of the command. |
Returns
Type | Description |
---|---|
ISlashCommandOptionInfo | The ISlashCommandOptionInfo containing the sub command. |