swiftlys2/docs/api/ai/
API Reference Commands

ICommandService

Interface
Namespace: SwiftlyS2.Shared.Commands · Assembly: SwiftlyS2.CS2.dll
public interface ICommandService
View source

Methods

GetAllCommands()

Gets all registered commands by plugins.

List<string> GetAllCommands()
Returns

GetAllCommandsByPlugin()

Gets all plugins that have registered commands.

Dictionary<string, List<CommandInfo>> GetAllCommandsByPlugin()
Returns
Dictionary mapping plugin names to their registered command information.

GetAllCommandsInfo()

Gets all commands info for the commands registered by plugins.

List<CommandInfo> GetAllCommandsInfo()
Returns
List of command information registered by the plugin.

GetCommandsByPlugin(string)

Gets all commands registered by a specific plugin.

List<CommandInfo> GetCommandsByPlugin(string pluginName)
Parameters
  • pluginNamestringThe name of the plugin.
Returns
List of command information registered by the plugin.

HookClientChat(ClientChatHandler)

Hooks client chat, will be fired when a player sends any chat message.

Guid HookClientChat(ICommandService.ClientChatHandler handler)
Parameters
Returns

HookClientCommand(ClientCommandHandler)

Hooks client commands, will be fired when a player sends any command.

Guid HookClientCommand(ICommandService.ClientCommandHandler handler)
Parameters
Returns

IsCommandRegistered(string)

Checks if a command is registered.

bool IsCommandRegistered(string commandName)
Parameters
  • commandNamestringThe command name.
Returns
Whether the command is registered.

RegisterCommand(string, CommandListener, bool, string)

Registers a command (backward compatibility overload).

Guid RegisterCommand(string commandName, ICommandService.CommandListener handler, bool registerRaw, string permission)
Parameters
  • commandNamestringThe command name.
  • handlerICommandService.CommandListenerThe handler callback for the command.
  • registerRawboolIf set to true, the command will not starts with a `sw_` prefix.
  • permissionstringThe permission required to use the command.
Returns
The guid of the command.

RegisterCommand(string, CommandListener, bool, string, string)

Registers a command.

Guid RegisterCommand(string commandName, ICommandService.CommandListener handler, bool registerRaw = false, string permission = "", string helpText = "SwiftlyS2 registered command")
Parameters
  • commandNamestringThe command name.
  • handlerICommandService.CommandListenerThe handler callback for the command.
  • registerRawbooloptionalIf set to true, the command will not starts with a `sw_` prefix.
  • permissionstringoptionalThe permission required to use the command.
  • helpTextstringoptionalThe help text of the command.
Returns
The guid of the command.

RegisterCommandAlias(string, string, bool)

Registers a command alias.

void RegisterCommandAlias(string commandName, string alias, bool registerRaw = false)
Parameters
  • commandNamestringThe command name.
  • aliasstringThe alias.
  • registerRawbooloptionalIf set to true, the alias will not starts with a `sw_` prefix.

UnhookClientChat(Guid)

Unhooks a client chat.

void UnhookClientChat(Guid guid)
Parameters
  • guidGuidThe guid of the client chat.

UnhookClientCommand(Guid)

Unhooks a client command.

void UnhookClientCommand(Guid guid)
Parameters
  • guidGuidThe guid of the client command.

UnregisterCommand(Guid)

Unregisters a command.

void UnregisterCommand(Guid guid)
Parameters
  • guidGuidThe guid of the command.

UnregisterCommand(string)

Unregisters all command listeners with the specified command name.

void UnregisterCommand(string commandName)
Parameters
  • commandNamestringThe command name.