Class ExtensionMethods
Defines various extensions specific to CommandsNext.
Inheritance
Namespace: DisCatSharp.CommandsNext
Assembly: DisCatSharp.CommandsNext.dll
Syntax
public static class ExtensionMethods
Methods
| Improve this Doc View SourceGetCommandsNext(DiscordClient)
Gets the active CommandsNext module for this client.
Declaration
public static CommandsNextExtension GetCommandsNext(this DiscordClient client)
Parameters
Type | Name | Description |
---|---|---|
DiscordClient | client | Client to get CommandsNext module from. |
Returns
Type | Description |
---|---|
CommandsNextExtension | The module, or null if not activated. |
GetCommandsNextAsync(DiscordShardedClient)
Gets the active CommandsNext modules for all shards in this client.
Declaration
public static async Task<IReadOnlyDictionary<int, CommandsNextExtension>> GetCommandsNextAsync(this DiscordShardedClient client)
Parameters
Type | Name | Description |
---|---|---|
DiscordShardedClient | client | Client to get CommandsNext instances from. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.Collections.Generic.IReadOnlyDictionary<System.Int32, CommandsNextExtension>> | A dictionary of the modules, indexed by shard id. |
RegisterCommands(IReadOnlyDictionary<Int32, CommandsNextExtension>, CommandBuilder[])
Builds and registers all supplied commands.
Declaration
public static void RegisterCommands(this IReadOnlyDictionary<int, CommandsNextExtension> extensions, params CommandBuilder[] cmds)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IReadOnlyDictionary<System.Int32, CommandsNextExtension> | extensions | Extensions to register commands on. |
CommandBuilder[] | cmds | Commands to build and register. |
RegisterCommands(IReadOnlyDictionary<Int32, CommandsNextExtension>, Assembly)
Registers all commands from a given assembly. The command classes need to be public to be considered for registration.
Declaration
public static void RegisterCommands(this IReadOnlyDictionary<int, CommandsNextExtension> extensions, Assembly assembly)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IReadOnlyDictionary<System.Int32, CommandsNextExtension> | extensions | Extensions to register commands on. |
System.Reflection.Assembly | assembly | Assembly to register commands from. |
RegisterCommands(IReadOnlyDictionary<Int32, CommandsNextExtension>, Type)
Registers all commands from a given command class.
Declaration
public static void RegisterCommands(this IReadOnlyDictionary<int, CommandsNextExtension> extensions, Type t)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IReadOnlyDictionary<System.Int32, CommandsNextExtension> | extensions | Extensions to register commands on. |
System.Type | t | Type of the class which holds commands to register. |
RegisterCommands<T>(IReadOnlyDictionary<Int32, CommandsNextExtension>)
Registers all commands from a given command class.
Declaration
public static void RegisterCommands<T>(this IReadOnlyDictionary<int, CommandsNextExtension> extensions)
where T : BaseCommandModule
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IReadOnlyDictionary<System.Int32, CommandsNextExtension> | extensions | Extensions to register commands on. |
Type Parameters
Name | Description |
---|---|
T | Class which holds commands to register. |
RegisterConverter<T>(IReadOnlyDictionary<Int32, CommandsNextExtension>, IArgumentConverter<T>)
Registers an argument converter for specified type.
Declaration
public static void RegisterConverter<T>(this IReadOnlyDictionary<int, CommandsNextExtension> extensions, IArgumentConverter<T> converter)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IReadOnlyDictionary<System.Int32, CommandsNextExtension> | extensions | Extensions to register the converter on. |
IArgumentConverter<T> | converter | Converter to register. |
Type Parameters
Name | Description |
---|---|
T | Type for which to register the converter. |
RegisterUserFriendlyTypeName<T>(IReadOnlyDictionary<Int32, CommandsNextExtension>, String)
Registers a user-friendly type name.
Declaration
public static void RegisterUserFriendlyTypeName<T>(this IReadOnlyDictionary<int, CommandsNextExtension> extensions, string value)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IReadOnlyDictionary<System.Int32, CommandsNextExtension> | extensions | Extensions to register the name on. |
System.String | value | Name to register. |
Type Parameters
Name | Description |
---|---|
T | Type to register the name for. |
SetHelpFormatter<T>(IReadOnlyDictionary<Int32, CommandsNextExtension>)
Sets the help formatter to use with the default help command.
Declaration
public static void SetHelpFormatter<T>(this IReadOnlyDictionary<int, CommandsNextExtension> extensions)
where T : BaseHelpFormatter
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IReadOnlyDictionary<System.Int32, CommandsNextExtension> | extensions | Extensions to set the help formatter on. |
Type Parameters
Name | Description |
---|---|
T | Type of the formatter to use. |
UnregisterCommands(IReadOnlyDictionary<Int32, CommandsNextExtension>, Command[])
Unregisters specified commands from CommandsNext.
Declaration
public static void UnregisterCommands(this IReadOnlyDictionary<int, CommandsNextExtension> extensions, params Command[] cmds)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IReadOnlyDictionary<System.Int32, CommandsNextExtension> | extensions | Extensions to unregister commands on. |
Command[] | cmds | Commands to unregister. |
UnregisterConverter<T>(IReadOnlyDictionary<Int32, CommandsNextExtension>)
Unregisters an argument converter for specified type.
Declaration
public static void UnregisterConverter<T>(this IReadOnlyDictionary<int, CommandsNextExtension> extensions)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IReadOnlyDictionary<System.Int32, CommandsNextExtension> | extensions | Extensions to unregister the converter on. |
Type Parameters
Name | Description |
---|---|
T | Type for which to unregister the converter. |
UseCommandsNext(DiscordClient, CommandsNextConfiguration)
Enables CommandsNext module on this DiscordClient.
Declaration
public static CommandsNextExtension UseCommandsNext(this DiscordClient client, CommandsNextConfiguration cfg)
Parameters
Type | Name | Description |
---|---|---|
DiscordClient | client | Client to enable CommandsNext for. |
CommandsNextConfiguration | cfg | CommandsNext configuration to use. |
Returns
Type | Description |
---|---|
CommandsNextExtension | Created CommandsNextExtension. |
UseCommandsNextAsync(DiscordShardedClient, CommandsNextConfiguration)
Enables CommandsNext module on all shards in this DiscordShardedClient.
Declaration
public static async Task<IReadOnlyDictionary<int, CommandsNextExtension>> UseCommandsNextAsync(this DiscordShardedClient client, CommandsNextConfiguration cfg)
Parameters
Type | Name | Description |
---|---|---|
DiscordShardedClient | client | Client to enable CommandsNext for. |
CommandsNextConfiguration | cfg | CommandsNext configuration to use. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.Collections.Generic.IReadOnlyDictionary<System.Int32, CommandsNextExtension>> | A dictionary of created CommandsNextExtension, indexed by shard id. |