tgstation-server 6.17.0
The /tg/station 13 server suite
Loading...
Searching...
No Matches
Public Member Functions | Properties | Private Attributes | List of all members
Tgstation.Server.Host.Components.Chat.Commands.CustomCommand Class Referencesealed

Represents a command made from DM code. More...

Inheritance diagram for Tgstation.Server.Host.Components.Chat.Commands.CustomCommand:
Inheritance graph
[legend]
Collaboration diagram for Tgstation.Server.Host.Components.Chat.Commands.CustomCommand:
Collaboration graph
[legend]

Public Member Functions

 CustomCommand (string name, string helpText, bool adminOnly)
 Initializes a new instance of the CustomCommand class.
 
void SetHandler (ICustomCommandHandler handler)
 Set a new handler .
 
ValueTask< MessageContentInvoke (string arguments, ChatUser user, CancellationToken cancellationToken)
 Invoke the ICommand.
Parameters
argumentsThe text after Name with leading whitespace trimmed.
userThe ChatUser who invoked the command.
cancellationTokenThe CancellationToken for the operation.
Returns
A ValueTask<TResult> resulting in a MessageContent to send to the invoker.

 

Properties

string Name [get]
 The text to invoke the command. May not be "?" or "help" (case-insensitive).
 
string HelpText [get]
 The help text to display when queires are made about the command.
 
bool AdminOnly [get]
 If the command should only be available to ChatUsers who's ChatUser.Channel has ChannelRepresentation.IsAdminChannel set.
 
- Properties inherited from Tgstation.Server.Host.Components.Chat.Commands.ICommand

Private Attributes

ICustomCommandHandlerhandler
 The ICustomCommandHandler for the CustomCommand.
 

Detailed Description

Represents a command made from DM code.

Definition at line 12 of file CustomCommand.cs.

Constructor & Destructor Documentation

◆ CustomCommand()

Tgstation.Server.Host.Components.Chat.Commands.CustomCommand.CustomCommand ( string  name,
string  helpText,
bool  adminOnly 
)

Initializes a new instance of the CustomCommand class.

Parameters
nameThe value of Name.
helpTextThe value of HelpText.
adminOnlyThe value of AdminOnly.

Definition at line 34 of file CustomCommand.cs.

35 {
36 Name = name ?? throw new ArgumentNullException(nameof(name));
37 HelpText = helpText ?? throw new ArgumentNullException(nameof(helpText));
38 AdminOnly = adminOnly;
39 }
bool AdminOnly
If the command should only be available to ChatUsers who's ChatUser.Channel has ChannelRepresentation...
string Name
The text to invoke the command. May not be "?" or "help" (case-insensitive).
string HelpText
The help text to display when queires are made about the command.

References Tgstation.Server.Host.Components.Chat.Commands.CustomCommand.AdminOnly, Tgstation.Server.Host.Components.Chat.Commands.CustomCommand.HelpText, and Tgstation.Server.Host.Components.Chat.Commands.CustomCommand.Name.

Member Function Documentation

◆ Invoke()

ValueTask< MessageContent > Tgstation.Server.Host.Components.Chat.Commands.CustomCommand.Invoke ( string  arguments,
ChatUser  user,
CancellationToken  cancellationToken 
)

Invoke the ICommand.

Parameters
argumentsThe text after Name with leading whitespace trimmed.
userThe ChatUser who invoked the command.
cancellationTokenThe CancellationToken for the operation.
Returns
A ValueTask<TResult> resulting in a MessageContent to send to the invoker.

Implements Tgstation.Server.Host.Components.Chat.Commands.ICommand.

Definition at line 53 of file CustomCommand.cs.

54 {
55 if (handler == null)
56 throw new InvalidOperationException("SetHandler() has not been called!");
57 return handler.HandleChatCommand(Name, arguments, user, cancellationToken);
58 }
ICustomCommandHandler? handler
The ICustomCommandHandler for the CustomCommand.
ValueTask< MessageContent > HandleChatCommand(string commandName, string arguments, ChatUser sender, CancellationToken cancellationToken)
Handle a chat command.

References Tgstation.Server.Host.Components.Chat.ICustomCommandHandler.HandleChatCommand(), Tgstation.Server.Host.Components.Chat.Commands.CustomCommand.handler, and Tgstation.Server.Host.Components.Chat.Commands.CustomCommand.Name.

Here is the call graph for this function:

◆ SetHandler()

void Tgstation.Server.Host.Components.Chat.Commands.CustomCommand.SetHandler ( ICustomCommandHandler  handler)

Set a new handler .

Parameters
handlerThe value of handler.

Definition at line 45 of file CustomCommand.cs.

46 {
47 if (this.handler != null)
48 throw new InvalidOperationException("SetHandler() already called!");
49 this.handler = handler ?? throw new ArgumentNullException(nameof(handler));
50 }

References Tgstation.Server.Host.Components.Chat.Commands.CustomCommand.handler.

Member Data Documentation

◆ handler

ICustomCommandHandler? Tgstation.Server.Host.Components.Chat.Commands.CustomCommand.handler
private

Property Documentation

◆ AdminOnly

bool Tgstation.Server.Host.Components.Chat.Commands.CustomCommand.AdminOnly
get

◆ HelpText

string Tgstation.Server.Host.Components.Chat.Commands.CustomCommand.HelpText
get

The help text to display when queires are made about the command.

Implements Tgstation.Server.Host.Components.Chat.Commands.ICommand.

Definition at line 18 of file CustomCommand.cs.

18{ get; }

Referenced by Tgstation.Server.Host.Components.Chat.Commands.CustomCommand.CustomCommand().

◆ Name

string Tgstation.Server.Host.Components.Chat.Commands.CustomCommand.Name
get

The text to invoke the command. May not be "?" or "help" (case-insensitive).

Implements Tgstation.Server.Host.Components.Chat.Commands.ICommand.

Definition at line 15 of file CustomCommand.cs.

15{ get; }

Referenced by Tgstation.Server.Host.Components.Chat.Commands.CustomCommand.CustomCommand(), and Tgstation.Server.Host.Components.Chat.Commands.CustomCommand.Invoke().


The documentation for this class was generated from the following file: