Search Results for

    Show / Hide Table of Contents

    Class CommandsNextExtension

    This is the class which handles command registration, management, and execution.

    Inheritance
    System.Object
    BaseExtension
    CommandsNextExtension
    Inherited Members
    BaseExtension.Client
    Namespace: DisCatSharp.CommandsNext
    Assembly: DisCatSharp.CommandsNext.dll
    Syntax
    public class CommandsNextExtension : BaseExtension

    Properties

    | Improve this Doc View Source

    RegisteredCommands

    Gets a dictionary of registered top-level commands.

    Declaration
    public IReadOnlyDictionary<string, Command> RegisteredCommands { get; }
    Property Value
    Type Description
    System.Collections.Generic.IReadOnlyDictionary<System.String, Command>
    | Improve this Doc View Source

    Services

    Gets the service provider this CommandsNext module was configured with.

    Declaration
    public IServiceProvider Services { get; }
    Property Value
    Type Description
    System.IServiceProvider

    Methods

    | Improve this Doc View Source

    ConvertArgument(String, CommandContext, Type)

    Converts a string to specified type.

    Declaration
    public async 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.

    System.Type type

    Type to convert to.

    Returns
    Type Description
    System.Threading.Tasks.Task<System.Object>

    Converted object.

    | Improve this Doc View Source

    ConvertArgument<T>(String, CommandContext)

    Converts a string to specified type.

    Declaration
    public async Task<T> 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<T>

    Converted object.

    Type Parameters
    Name Description
    T

    Type to convert to.

    | Improve this Doc View Source

    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.

    | Improve this Doc View Source

    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.

    | Improve this Doc View Source

    ExecuteCommandAsync(CommandContext)

    Executes specified command from given context.

    Declaration
    public async Task ExecuteCommandAsync(CommandContext ctx)
    Parameters
    Type Name Description
    CommandContext ctx

    Context to execute command from.

    Returns
    Type Description
    System.Threading.Tasks.Task
    | Improve this Doc View Source

    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.

    | Improve this Doc View Source

    GetUserFriendlyTypeName(Type)

    Converts a type into user-friendly type name.

    Declaration
    public string GetUserFriendlyTypeName(Type t)
    Parameters
    Type Name Description
    System.Type t

    Type to convert.

    Returns
    Type Description
    System.String

    User-friendly type name.

    | Improve this Doc View Source

    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.

    | Improve this Doc View Source

    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
    System.Reflection.Assembly assembly

    Assembly to register commands from.

    | Improve this Doc View Source

    RegisterCommands(Type)

    Registers all commands from a given command class.

    Declaration
    public void RegisterCommands(Type t)
    Parameters
    Type Name Description
    System.Type t

    Type of the class which holds commands to register.

    | Improve this Doc View Source

    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.

    | Improve this Doc View Source

    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.

    | Improve this Doc View Source

    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.

    | Improve this Doc View Source

    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.

    | Improve this Doc View Source

    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
    BaseExtension.Setup(DiscordClient)
    Exceptions
    Type Condition
    System.InvalidOperationException
    | Improve this Doc View Source

    UnregisterCommands(Command[])

    Unregister specified commands from CommandsNext.

    Declaration
    public void UnregisterCommands(params Command[] cmds)
    Parameters
    Type Name Description
    Command[] cmds

    Commands to unregister.

    | Improve this Doc View Source

    UnregisterConverter<T>()

    Unregister an argument converter for specified type.

    Declaration
    public void UnregisterConverter<T>()
    Type Parameters
    Name Description
    T

    Type for which to unregister the converter.

    Events

    | Improve this Doc View Source

    CommandErrored

    Triggered whenever a command throws an exception during execution.

    Declaration
    public event AsyncEventHandler<CommandsNextExtension, CommandErrorEventArgs> CommandErrored
    Event Type
    Type Description
    AsyncEventHandler<CommandsNextExtension, CommandErrorEventArgs>
    | Improve this Doc View Source

    CommandExecuted

    Triggered whenever a command executes successfully.

    Declaration
    public event AsyncEventHandler<CommandsNextExtension, CommandExecutionEventArgs> CommandExecuted
    Event Type
    Type Description
    AsyncEventHandler<CommandsNextExtension, CommandExecutionEventArgs>

    Extension Methods

    ReflectionUtilities.ToDictionary<T>(T)
    • Improve this Doc
    • View Source
    In This Article
    Back to top © 2021-2022 Aiko IT Systems