Class CommandsNextExtension
This is the class which handles command registration, management, and execution.
Inherited Members
Namespace: DSharpPlus.CommandsNext
Assembly: cs.temp.dll.dll
Syntax
public class CommandsNextExtension : BaseExtension
Properties
RegisteredCommands
Gets a dictionary of registered top-level commands.
Declaration
public IReadOnlyDictionary<string, Command> RegisteredCommands { get; }
Property Value
Type | Description |
---|---|
IReadOnlyDictionary<System.String, Command> |
Services
Gets the service provider this CommandsNext module was configured with.
Declaration
public IServiceProvider Services { get; }
Property Value
Type | Description |
---|---|
IServiceProvider |
Methods
ConvertArgument(String, CommandContext, Type)
Converts a string to specified type.
Declaration
public Task<object> ConvertArgument(string value, CommandContext ctx, Type type)
Parameters
Type | Name | Description |
---|---|---|
System.String | value | Value to convert. |
CommandContext | ctx | Context in which to convert to. |
Type | type | Type to convert to. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.Object> | Converted object. |
ConvertArgument<T>(String, CommandContext)
Converts a string to specified type.
Declaration
public Task<object> ConvertArgument<T>(string value, CommandContext ctx)
Parameters
Type | Name | Description |
---|---|---|
System.String | value | Value to convert. |
CommandContext | ctx | Context in which to convert to. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.Object> | Converted object. |
Type Parameters
Name | Description |
---|---|
T | Type to convert to. |
CreateContext(DiscordMessage, String, Command, String)
Creates a command execution context from specified arguments.
Declaration
public CommandContext CreateContext(DiscordMessage msg, string prefix, Command cmd, string rawArguments = null)
Parameters
Type | Name | Description |
---|---|---|
DiscordMessage | msg | Message to use for context. |
System.String | prefix | Command prefix, used to execute commands. |
Command | cmd | Command to execute. |
System.String | rawArguments | Raw arguments to pass to command. |
Returns
Type | Description |
---|---|
CommandContext | Created command execution context. |
CreateFakeContext(DiscordUser, DiscordChannel, String, String, Command, String)
Creates a fake command context to execute commands with.
Declaration
public CommandContext CreateFakeContext(DiscordUser actor, DiscordChannel channel, string messageContents, string prefix, Command cmd, string rawArguments = null)
Parameters
Type | Name | Description |
---|---|---|
DiscordUser | actor | The user or member to use as message author. |
DiscordChannel | channel | The channel the message is supposed to appear from. |
System.String | messageContents | Contents of the message. |
System.String | prefix | Command prefix, used to execute commands. |
Command | cmd | Command to execute. |
System.String | rawArguments | Raw arguments to pass to command. |
Returns
Type | Description |
---|---|
CommandContext | Created fake context. |
ExecuteCommandAsync(CommandContext)
Executes specified command from given context.
Declaration
public Task ExecuteCommandAsync(CommandContext ctx)
Parameters
Type | Name | Description |
---|---|---|
CommandContext | ctx | Context to execute command from. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task |
FindCommand(String, out String)
Finds a specified command by its qualified name, then separates arguments.
Declaration
public Command FindCommand(string commandString, out string rawArguments)
Parameters
Type | Name | Description |
---|---|---|
System.String | commandString | Qualified name of the command, optionally with arguments. |
System.String | rawArguments | Separated arguments. |
Returns
Type | Description |
---|---|
Command | Found command or null if none was found. |
GetUserFriendlyTypeName(Type)
Converts a type into user-friendly type name.
Declaration
public string GetUserFriendlyTypeName(Type t)
Parameters
Type | Name | Description |
---|---|---|
Type | t | Type to convert. |
Returns
Type | Description |
---|---|
System.String | User-friendly type name. |
RegisterCommands(Assembly)
Registers all commands from a given assembly. The command classes need to be public to be considered for registration.
Declaration
public void RegisterCommands(Assembly assembly)
Parameters
Type | Name | Description |
---|---|---|
Assembly | assembly | Assembly to register commands from. |
RegisterCommands(CommandBuilder[])
Builds and registers all supplied commands.
Declaration
public void RegisterCommands(params CommandBuilder[] cmds)
Parameters
Type | Name | Description |
---|---|---|
CommandBuilder[] | cmds | Commands to build and register. |
RegisterCommands(Type)
Registers all commands from a given command class.
Declaration
public void RegisterCommands(Type t)
Parameters
Type | Name | Description |
---|---|---|
Type | t | Type of the class which holds commands to register. |
RegisterCommands<T>()
Registers all commands from a given command class.
Declaration
public void RegisterCommands<T>()
where T : BaseCommandModule
Type Parameters
Name | Description |
---|---|
T | Class which holds commands to register. |
RegisterConverter<T>(IArgumentConverter<T>)
Registers an argument converter for specified type.
Declaration
public void RegisterConverter<T>(IArgumentConverter<T> converter)
Parameters
Type | Name | Description |
---|---|---|
IArgumentConverter<T> | converter | Converter to register. |
Type Parameters
Name | Description |
---|---|
T | Type for which to register the converter. |
RegisterUserFriendlyTypeName<T>(String)
Registers a user-friendly type name.
Declaration
public void RegisterUserFriendlyTypeName<T>(string value)
Parameters
Type | Name | Description |
---|---|---|
System.String | value | Name to register. |
Type Parameters
Name | Description |
---|---|
T | Type to register the name for. |
SetHelpFormatter<T>()
Sets the help formatter to use with the default help command.
Declaration
public void SetHelpFormatter<T>()
where T : BaseHelpFormatter
Type Parameters
Name | Description |
---|---|
T | Type of the formatter to use. |
Setup(DiscordClient)
DO NOT USE THIS MANUALLY.
Declaration
protected override void Setup(DiscordClient client)
Parameters
Type | Name | Description |
---|---|---|
DiscordClient | client | DO NOT USE THIS MANUALLY. |
Overrides
UnregisterCommands(Command[])
Unregisters specified commands from CommandsNext.
Declaration
public void UnregisterCommands(params Command[] cmds)
Parameters
Type | Name | Description |
---|---|---|
Command[] | cmds | Commands to unregister. |
UnregisterConverter<T>()
Unregisters an argument converter for specified type.
Declaration
public void UnregisterConverter<T>()
Type Parameters
Name | Description |
---|---|
T | Type for which to unregister the converter. |
Events
CommandErrored
Triggered whenever a command throws an exception during execution.
Declaration
public event AsyncEventHandler<CommandsNextExtension, CommandErrorEventArgs> CommandErrored
Event Type
Type | Description |
---|---|
AsyncEventHandler<CommandsNextExtension, CommandErrorEventArgs> |
CommandExecuted
Triggered whenever a command executes successfully.
Declaration
public event AsyncEventHandler<CommandsNextExtension, CommandExecutionEventArgs> CommandExecuted
Event Type
Type | Description |
---|---|
AsyncEventHandler<CommandsNextExtension, CommandExecutionEventArgs> |