Difference between revisions of "CommandDocs object"
(→Parameters property) |
m (1 revision imported) |
(No difference)
|
Latest revision as of 08:20, 1 December 2017
The CommandDocs object allows you to access a command's documentation. This is not generally needed as most access checks are handled before calling Event_command() with a Command object. This object is returned by the CreateCommand function and OpenCommand function allowing scripts to provide the documentation for script commands during load. You must call .Save() after completing changes so that they get saved to the Commands.xml file.
History
This object was added in StealthBot version 2.7 by Eric to create an object-oriented experience in scripting.
How to use
Example: Get the current numeric rank required by the command.
Value = CommandDocsObj.Rank
Example: Store a response to the command.
CommandDocObj.Description = "Description for example command." ' more documentation / syntax changes CommandDocObj.Save
Properties
List of properties
- .Name
- .Owner
- .Aliases
- .IsEnabled
- .RequiredRank
- .RequiredFlags
- .Description
- .AliasString
- .RequirementsString
- .RequirementsStringShort
- .SpecialNotes
- .Parameters
Name property
Returns or sets the name of the command, as a string. This is the name of the command as defined by the XML, not the alias.
Owner property
Returns or sets the name of the script which created the command with CreateCommand(). If this is an internal script, vbNullString will be returned.
Aliases property
Returns a collection of strings representing the aliases that can be used to execute the command. Changes to this collection can be saved. Do not include the command's name as one of its aliases.
IsEnabled property
Returns or sets whether a command is currently enabled. Disabled commands will not fire any Event_Command() subroutine.
RequiredRank property
Returns or sets the numeric rank a user requires in order to use a command. Commands attempted by a user without access will not fire any Event_Command() subroutine.
Description property
Returns or sets the description of a command, viewable with the help command or from the command manager.
AliasString property
Returns a string containing the aliases formatted as a comma-delimited list for display. Does not include the command name.
RequirementsString property
Returns a string containing the required rank and flags formatted like "Requires rank #[ or one of the following flags: ...]." for display.
RequirementsString property
Returns a string containing the required rank and flags formatted like "Requires rank #[ or one of the following flags: ...]." for display.
SpecialNotes property
Returns or sets a description string only visible in the command manager.
Parameters property
Returns a collection of CommandParams objects specifying the syntax the command can require for use with the CommandObj.Argument property. If the command's syntax is not valid, Event_Command will still fire. You will have to use CommandObj.IsValid to determine whether the command follows this documentation object.
Functions
List of functions
- .NewParameter(argName, argIsOptional, optional argDataType)
- .NewRestriction(argName, optional argRequiredRank, optional argRequiredFlags)
- .Save()
- .Delete()
- .SyntaxString(optional IsLocal)
- .GetParameterByName(sParamName)
NewParameter function
Returns a CommandParams object containing the information you provide. You must add this parameter to the collection from the Parameters property before saving this CommandDocs object.
NewRestriction function
Returns a CommandRestriction object containing the information you provide. You must add this restriction to the collection from a CommandParamsObj.Restrictions property before saving this CommandDocs object.
Save function
Saves the current command to the commands.xml file. Returns True on success and False on failure.
Deletes function
Deletes the current command from the commands.xml file.
SyntaxString function
Returns a string showing how to use the current command for display, such as ".add <username> [rank] [attributes]". If you pass True to its only parameter, you will receive the same string but with your currently set bot trigger replaced by a "/", to indicate how to use this command from inside the bot.
GetParameterByName function
Returns a CommandParams object for the specified parameter name.